aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/api.php39
-rw-r--r--include/bb2diaspora.php34
-rw-r--r--include/help.php150
-rwxr-xr-xinclude/importdoc.php2
-rwxr-xr-xinclude/items.php8
-rw-r--r--include/nav.php20
-rw-r--r--include/notifier.php2
-rw-r--r--include/photos.php40
-rwxr-xr-xinclude/plugin.php42
-rw-r--r--include/zot.php11
10 files changed, 294 insertions, 54 deletions
diff --git a/include/api.php b/include/api.php
index fd644947c..e64c86695 100644
--- a/include/api.php
+++ b/include/api.php
@@ -772,13 +772,15 @@ require_once('include/api_auth.php');
$_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo
$_FILES['userfile'] = $_FILES['media'];
- require_once('mod/wall_attach.php');
- $posted = wall_attach_post($a);
-
- //now that we have the img url in bbcode we can add it to the status and insert the wall item.
+
+ $mod = new Zotlabs\Module\Wall_attach();
+ $mod->post();
+
+
$_REQUEST['body']=$txt."\n\n".$posted;
- require_once('mod/item.php');
- item_post($a);
+
+ $mod = new Zotlabs\Module\Item();
+ $mod->post();
// this should output the last post (the one we just posted).
return api_status_show($a,$type);
@@ -871,9 +873,9 @@ require_once('include/api_auth.php');
// upload each image if we have any
$_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo
- require_once('mod/wall_attach.php');
+ $mod = new Zotlabs\Module\Wall_attach();
App::$data['api_info'] = $user_info;
- $media = wall_attach_post($a);
+ $media = $mod->post();
if(strlen($media)>0)
$_REQUEST['body'] .= "\n\n" . $media;
@@ -884,9 +886,9 @@ require_once('include/api_auth.php');
$_FILES['userfile'] = $_FILES['media'];
// upload each image if we have any
$_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo
- require_once('mod/wall_attach.php');
+ $mod = new Zotlabs\Module\Wall_attach();
App::$data['api_info'] = $user_info;
- $media = wall_attach_post($a);
+ $media = $mod->post();
if(strlen($media)>0)
$_REQUEST['body'] .= "\n\n" . $media;
@@ -896,8 +898,8 @@ require_once('include/api_auth.php');
// call out normal post function
- require_once('mod/item.php');
- item_post($a);
+ $mod = new Zotlabs\Module\Item();
+ $mod->post();
// this should output the last post (the one we just posted).
return api_status_show($a,$type);
@@ -926,14 +928,14 @@ require_once('include/api_auth.php');
$_FILES['userfile'] = $_FILES['media'];
// upload the image if we have one
$_REQUEST['silent']='1'; //tell wall_upload function to return img info instead of echo
- require_once('mod/wall_upload.php');
- $media = wall_upload_post($a);
+ $mod = new Zotlabs\Module\Wall_upload();
+ $media = $mod->post();
if(strlen($media)>0)
$_REQUEST['body'] .= "\n\n".$media;
}
- require_once('mod/item.php');
- $x = item_post($a);
+ $mod = new Zotlabs\Module\Item();
+ $x = $mod->post();
json_return_and_die($x);
}
@@ -1423,9 +1425,8 @@ require_once('include/api_auth.php');
$_REQUEST['profile_uid'] = api_user();
$_REQUEST['type'] = 'wall';
$_REQUEST['api_source'] = true;
-
- require_once('mod/item.php');
- item_post($a);
+ $mod = new Zotlabs\Module\Item();
+ $mod->post();
}
}
else
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 1ed57bfd4..9167cb5ad 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -270,7 +270,14 @@ function bb2dmention_callback($match) {
function bb2diaspora_itemwallwall(&$item) {
+ // We will provide wallwall (embedded author on the Diaspora side) if
+ // 1. It is a wall-to-wall post
+ // 2. A comment arrived which has no Diaspora signature info
+
+
+ $wallwall = false;
$author_exists = true;
+
if(! array_key_exists('author',$item)) {
$author_exists = false;
logger('bb2diaspora_itemwallwall: no author');
@@ -281,11 +288,21 @@ function bb2diaspora_itemwallwall(&$item) {
$item['author'] = $r[0];
}
- if(($item['mid'] == $item['parent_mid']) && ($item['author_xchan'] != $item['owner_xchan']) && (is_array($item['author']))) {
- logger('bb2diaspora_itemwallwall: author: ' . print_r($item['author'],true), LOGGER_DATA);
+ $has_meta = false;
+ if($item['diaspora_meta'] || get_iconfig($item,'diaspora','fields'))
+ $has_meta = true;
+
+ if($item['author_xchan'] != $item['owner_xchan']) {
+ if($item['mid'] == $item['parent_mid'])
+ $wallwall = true;
+ else {
+ if(! $has_meta) {
+ $wallwall = true;
+ }
+ }
}
- if(($item['mid'] == $item['parent_mid']) && ($item['author_xchan'] != $item['owner_xchan']) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_m']) {
+ if(($wallwall) && (is_array($item['author'])) && $item['author']['xchan_url'] && $item['author']['xchan_name'] && $item['author']['xchan_photo_m']) {
logger('bb2diaspora_itemwallwall: wall to wall post',LOGGER_DEBUG);
// post will come across with the owner's identity. Throw a preamble onto the post to indicate the true author.
$item['body'] = "\n\n"
@@ -301,7 +318,12 @@ function bb2diaspora_itemwallwall(&$item) {
}
-function bb2diaspora_itembody($item, $force_update = false) {
+function bb2diaspora_itembody($item, $force_update = false, $have_channel = false) {
+
+
+ if(! get_iconfig($item,'diaspora','fields')) {
+ $force_update = true;
+ }
$matches = array();
@@ -339,8 +361,8 @@ function bb2diaspora_itembody($item, $force_update = false) {
}
}
-
- bb2diaspora_itemwallwall($newitem);
+ if(! $have_channel)
+ bb2diaspora_itemwallwall($newitem);
$title = $newitem['title'];
$body = preg_replace('/\#\^http/i', 'http', $newitem['body']);
diff --git a/include/help.php b/include/help.php
new file mode 100644
index 000000000..13473164d
--- /dev/null
+++ b/include/help.php
@@ -0,0 +1,150 @@
+<?php
+
+function load_doc_file($s) {
+ $lang = \App::$language;
+ if(! isset($lang))
+ $lang = 'en';
+ $b = basename($s);
+ $d = dirname($s);
+
+ $c = find_doc_file("$d/$lang/$b");
+ if($c)
+ return $c;
+ $c = find_doc_file($s);
+ if($c)
+ return $c;
+ return '';
+}
+
+function find_doc_file($s) {
+ if(file_exists($s))
+ return file_get_contents($s);
+ return '';
+}
+
+function search_doc_files($s) {
+
+ $a = get_app();
+
+ $itemspage = get_pconfig(local_channel(),'system','itemspage');
+ \App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 20));
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
+
+ $regexop = db_getfunc('REGEXP');
+
+ $r = q("select item_id.sid, item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and
+ body $regexop '%s' and item_type = %d $pager_sql",
+ dbesc($s),
+ intval(ITEM_TYPE_DOC)
+ );
+
+ $r = fetch_post_tags($r,true);
+
+ for($x = 0; $x < count($r); $x ++) {
+
+ $r[$x]['text'] = $r[$x]['body'];
+
+ $r[$x]['rank'] = 0;
+ if($r[$x]['term']) {
+ foreach($r[$x]['term'] as $t) {
+ if(stristr($t['term'],$s)) {
+ $r[$x]['rank'] ++;
+ }
+ }
+ }
+ if(stristr($r[$x]['sid'],$s))
+ $r[$x]['rank'] ++;
+ $r[$x]['rank'] += substr_count(strtolower($r[$x]['text']),strtolower($s));
+ // bias the results to the observer's native language
+ if($r[$x]['lang'] === \App::$language)
+ $r[$x]['rank'] = $r[$x]['rank'] + 10;
+
+ }
+ usort($r,'doc_rank_sort');
+ return $r;
+}
+
+
+function doc_rank_sort($s1,$s2) {
+ if($s1['rank'] == $s2['rank'])
+ return 0;
+ return (($s1['rank'] < $s2['rank']) ? 1 : (-1));
+}
+
+
+function load_context_help() {
+
+ $path = App::$cmd;
+ $args = App::$argv;
+ $lang = App::$language;
+
+ if(! isset($lang) || !is_dir('doc/context/' . $lang . '/')) {
+ $lang = 'en';
+ }
+ while($path) {
+ $context_help = load_doc_file('doc/context/' . $lang . '/' . $path . '/help.html');
+ if(!$context_help) {
+ // Fallback to English if the translation is absent
+ $context_help = load_doc_file('doc/context/en/' . $path . '/help.html');
+ }
+ if($context_help)
+ break;
+ array_pop($args);
+ $path = implode($args,'/');
+ }
+
+ return $context_help;
+}
+
+
+function store_doc_file($s) {
+
+ if(is_dir($s))
+ return;
+
+ $item = array();
+ $sys = get_sys_channel();
+
+ $item['aid'] = 0;
+ $item['uid'] = $sys['channel_id'];
+
+
+ if(strpos($s,'.md'))
+ $mimetype = 'text/markdown';
+ elseif(strpos($s,'.html'))
+ $mimetype = 'text/html';
+ else
+ $mimetype = 'text/bbcode';
+
+ require_once('include/html2plain.php');
+
+ $item['body'] = html2plain(prepare_text(file_get_contents($s),$mimetype, true));
+ $item['mimetype'] = 'text/plain';
+
+ $item['plink'] = z_root() . '/' . str_replace('doc','help',$s);
+ $item['owner_xchan'] = $item['author_xchan'] = $sys['channel_hash'];
+ $item['item_type'] = ITEM_TYPE_DOC;
+
+ $r = q("select item.* from item left join item_id on item.id = item_id.iid where service = 'docfile' and
+ sid = '%s' and item_type = %d limit 1",
+ dbesc($s),
+ intval(ITEM_TYPE_DOC)
+ );
+
+ if($r) {
+ $item['id'] = $r[0]['id'];
+ $item['mid'] = $item['parent_mid'] = $r[0]['mid'];
+ $x = item_store_update($item);
+ }
+ else {
+ $item['mid'] = $item['parent_mid'] = item_message_id();
+ $x = item_store($item);
+ }
+
+ if($x['success']) {
+ update_remote_id($sys,$x['item_id'],ITEM_TYPE_DOC,$s,'docfile',0,$item['mid']);
+ }
+
+
+}
+
diff --git a/include/importdoc.php b/include/importdoc.php
index 10f868697..90dfb2fc4 100755
--- a/include/importdoc.php
+++ b/include/importdoc.php
@@ -9,7 +9,7 @@ function importdoc_run($argv, $argc){
cli_startup();
- require_once('mod/help.php');
+ require_once('include/help.php');
update_docs_dir('doc/*');
diff --git a/include/items.php b/include/items.php
index 95822c0ba..014e626b6 100755
--- a/include/items.php
+++ b/include/items.php
@@ -555,8 +555,8 @@ function get_public_feed($channel, $params) {
// put a sane lower limit on feed requests if not specified
- if($params['begin'] === NULL_DATE)
- $params['begin'] = datetime_convert('UTC','UTC','now - 1 month');
+// if($params['begin'] === NULL_DATE)
+// $params['begin'] = datetime_convert('UTC','UTC','now - 1 month');
switch($params['type']) {
case 'json':
@@ -4235,10 +4235,10 @@ function atom_entry($item,$type,$author,$owner,$comment = false,$cid = 0) {
$obj = ((is_array($item['obj'])) ? $item['object'] : json_decode($item['object'],true));
$o .= '<title>' . xmlify($item['title']) . '</title>' . "\r\n";
- $o .= '<summary>' . xmlify(bbcode($obj['title'])) . '</summary>' . "\r\n";
+ $o .= '<summary xmlns="urn:ietf:params:xml:ns:xcal">' . xmlify(bbcode($obj['title'])) . '</summary>' . "\r\n";
$o .= '<dtstart xmlns="urn:ietf:params:xml:ns:xcal">' . datetime_convert('UTC','UTC', $obj['start'],'Ymd\\THis' . (($obj['adjust']) ? '\\Z' : '')) . '</dtstart>' . "\r\n";
$o .= '<dtend xmlns="urn:ietf:params:xml:ns:xcal">' . datetime_convert('UTC','UTC', $obj['finish'],'Ymd\\THis' . (($obj['adjust']) ? '\\Z' : '')) . '</dtend>' . "\r\n";
- $o .= '<location>' . bbcode($obj['location']) . '</location>' . "\r\n";
+ $o .= '<location xmlns="urn:ietf:params:xml:ns:xcal">' . xmlify(bbcode($obj['location'])) . '</location>' . "\r\n";
$o .= '<content type="' . $type . '" >' . xmlify(bbcode($obj['description'])) . '</content>' . "\r\n";
}
else {
diff --git a/include/nav.php b/include/nav.php
index 541ab3aed..c59aaae37 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -150,9 +150,15 @@ EOT;
$help_url = z_root() . '/help?f=&cmd=' . App::$cmd;
if(! get_config('system','hide_help')) {
- require_once('mod/help.php');
- $context_help = load_context_help();
- $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'),'help_nav_btn',$context_help);
+ $context_help = '';
+ $enable_context_help = ((intval(get_config('system','enable_context_help')) === 1 || get_config('system','enable_context_help') === false) ? true : false);
+ if($enable_context_help === true) {
+ require_once('include/help.php');
+ $context_help = load_context_help();
+ //direct directly to /help if $context_help is empty - this can be removed once we have context help for all modules
+ $enable_context_help = (($context_help) ? true : false);
+ }
+ $nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'), 'help_nav_btn', $context_help, $enable_context_help);
}
if(! UNO)
@@ -234,6 +240,12 @@ $powered_by = '';
// $powered_by = '<strong>red<img class="smiley" src="' . z_root() . '/images/rm-16.png" alt="r#" />matrix</strong>';
+ $tpl = get_markup_template('nav_header.tpl');
+
+ App::$page['htmlhead'] .= replace_macros($tpl, array(
+ '$enable_context_help' => $enable_context_help
+ ));
+
$tpl = get_markup_template('nav.tpl');
App::$page['nav'] .= replace_macros($tpl, array(
@@ -248,7 +260,7 @@ $powered_by = '';
'$powered_by' => $powered_by,
'$help' => t('@name, #tag, ?doc, content'),
'$pleasewait' => t('Please wait...')
- ));
+ ));
call_hooks('page_header', App::$page['nav']);
}
diff --git a/include/notifier.php b/include/notifier.php
index 628847d54..4435c7497 100644
--- a/include/notifier.php
+++ b/include/notifier.php
@@ -450,7 +450,6 @@ function notifier_run($argv, $argc){
'target_item' => $target_item,
'top_level_post' => $top_level_post,
'private' => $private,
- 'followup' => $followup,
'relay_to_owner' => $relay_to_owner,
'uplink' => $uplink,
'cmd' => $cmd,
@@ -547,7 +546,6 @@ function notifier_run($argv, $argc){
'hub' => $hub,
'top_level_post' => $top_level_post,
'private' => $private,
- 'followup' => $followup,
'relay_to_owner' => $relay_to_owner,
'uplink' => $uplink,
'cmd' => $cmd,
diff --git a/include/photos.php b/include/photos.php
index 943d7d503..24e872890 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -706,3 +706,43 @@ function gps2Num($coordPart) {
return floatval($parts[0]) / floatval($parts[1]);
}
+
+function profile_photo_set_profile_perms($profileid = '') {
+
+ $allowcid = '';
+ if (x($profileid)) {
+
+ $r = q("SELECT photo, profile_guid, id, is_default, uid FROM profile WHERE profile.id = %d OR profile.profile_guid = '%s' LIMIT 1", intval($profileid), dbesc($profileid));
+
+ } else {
+
+ logger('Resetting permissions on default-profile-photo for user'.local_channel());
+ $r = q("SELECT photo, profile_guid, id, is_default, uid FROM profile WHERE profile.uid = %d AND is_default = 1 LIMIT 1", intval(local_channel()) ); //If no profile is given, we update the default profile
+ }
+
+ $profile = $r[0];
+ if(x($profile['id']) && x($profile['photo'])) {
+ preg_match("@\w*(?=-\d*$)@i", $profile['photo'], $resource_id);
+ $resource_id = $resource_id[0];
+
+ if (intval($profile['is_default']) != 1) {
+ $r0 = q("SELECT channel_hash FROM channel WHERE channel_id = %d LIMIT 1", intval(local_channel()) );
+ $r1 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%d' ", intval($profile['id'])); //Should not be needed in future. Catches old int-profile-ids.
+ $r2 = q("SELECT abook.abook_xchan FROM abook WHERE abook_profile = '%s'", dbesc($profile['profile_guid']));
+ $allowcid = "<" . $r0[0]['channel_hash'] . ">";
+ foreach ($r1 as $entry) {
+ $allowcid .= "<" . $entry['abook_xchan'] . ">";
+ }
+ foreach ($r2 as $entry) {
+ $allowcid .= "<" . $entry['abook_xchan'] . ">";
+ }
+
+ q("UPDATE `photo` SET allow_cid = '%s' WHERE resource_id = '%s' AND uid = %d",dbesc($allowcid),dbesc($resource_id),intval($profile['uid']));
+
+ } else {
+ q("UPDATE `photo` SET allow_cid = '' WHERE profile = 1 AND uid = %d",intval($profile['uid'])); //Reset permissions on default profile picture to public
+ }
+ }
+
+ return;
+ }
diff --git a/include/plugin.php b/include/plugin.php
index 8dceb8fb1..80e3ae20e 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -185,7 +185,7 @@ function register_hook($hook, $file, $function, $priority = 0) {
dbesc($file),
dbesc($function)
);
- if(count($r))
+ if($r)
return true;
$r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`) VALUES ( '%s', '%s', '%s', '%s' )",
@@ -226,9 +226,8 @@ function unregister_hook($hook, $file, $function) {
function load_hooks() {
- $a = get_app();
-// if(! is_array(App::$hooks))
- App::$hooks = array();
+
+ App::$hooks = array();
$r = q("SELECT * FROM hook WHERE true ORDER BY priority DESC");
if($r) {
@@ -236,10 +235,10 @@ function load_hooks() {
if(! array_key_exists($rr['hook'],App::$hooks))
App::$hooks[$rr['hook']] = array();
- App::$hooks[$rr['hook']][] = array($rr['file'],$rr['function']);
+ App::$hooks[$rr['hook']][] = array($rr['file'],$rr['function'],$rr['priority'],$rr['hook_version']);
}
}
-//logger('hooks: ' . print_r(App::$hooks,true));
+ //logger('hooks: ' . print_r(App::$hooks,true));
}
/**
@@ -259,15 +258,15 @@ function load_hooks() {
* @param string $fn
* function name of callback handler
*/
-function insert_hook($hook, $fn) {
- $a = get_app();
+function insert_hook($hook, $fn, $version = 0, $priority = 0) {
+
if(! is_array(App::$hooks))
App::$hooks = array();
if(! array_key_exists($hook, App::$hooks))
App::$hooks[$hook] = array();
- App::$hooks[$hook][] = array('', $fn);
+ App::$hooks[$hook][] = array('', $fn, $priority, $version);
}
/**
@@ -280,8 +279,7 @@ function insert_hook($hook, $fn) {
* @param string|array &$data to transmit to the callback handler
*/
function call_hooks($name, &$data = null) {
- $a = get_app();
-
+ $a = 0;
if((is_array(App::$hooks)) && (array_key_exists($name, App::$hooks))) {
foreach(App::$hooks[$name] as $hook) {
if($hook[0])
@@ -289,9 +287,11 @@ function call_hooks($name, &$data = null) {
if(function_exists($hook[1])) {
$func = $hook[1];
- $func($a, $data);
+ if($hook[3])
+ $func($data);
+ else
+ $func($a, $data);
} else {
-
q("DELETE FROM hook WHERE hook = '%s' AND file = '%s' AND function = '%s'",
dbesc($name),
dbesc($hook[0]),
@@ -535,8 +535,11 @@ function format_css_if_exists($source) {
else
$path = theme_include($source[0]);
- if($path)
- return '<link rel="stylesheet" href="' . script_path() . '/' . $path . '" type="text/css" media="' . $source[1] . '">' . "\r\n";
+ if($path) {
+ $path = script_path() . '/' . $path;
+ $qstring = ((parse_url($path, PHP_URL_QUERY)) ? '&' : '?') . 'v=' . STD_VERSION;
+ return '<link rel="stylesheet" href="' . $path . $qstring . '" type="text/css" media="' . $source[1] . '">' . "\r\n";
+ }
}
/*
@@ -612,8 +615,11 @@ function format_js_if_exists($source) {
$path = $source;
else
$path = theme_include($source);
- if($path)
- return '<script src="' . script_path() . '/' . $path . '" ></script>' . "\r\n" ;
+ if($path) {
+ $path = script_path() . '/' . $path;
+ $qstring = ((parse_url($path, PHP_URL_QUERY)) ? '&' : '?') . 'v=' . STD_VERSION;
+ return '<script src="' . $path . $qstring . '" ></script>' . "\r\n" ;
+ }
}
@@ -678,4 +684,4 @@ function folder_exists($folder)
// If it exist, check if it's a directory
return (($path !== false) && is_dir($path)) ? $path : false;
-} \ No newline at end of file
+}
diff --git a/include/zot.php b/include/zot.php
index 0cdf7fc87..9d9f9ab5f 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -4048,6 +4048,17 @@ function delivery_report_is_storable($dr) {
if(($dr['location'] !== z_root()) && ($dr['sender'] === $rxchan) && ($dr['status'] === 'recipient_not_found'))
return false;
+ // If you have a private post with a recipient list, every single site is going to report
+ // back a failed delivery for anybody on that list that isn't local to them. We're only
+ // concerned about this if we have a local hubloc record which says we expected them to
+ // have a channel on that site.
+
+ $r = q("select hubloc_id from hubloc where hubloc_hash = '%s' and hubloc_url = '%s'",
+ dbesc($rxchan),
+ dbesc($dr['location'])
+ );
+ if((! $r) && ($dr['status'] === 'recipient_not_found'))
+ return false;
$r = q("select abook_id from abook where abook_xchan = '%s' and abook_channel = %d limit 1",
dbesc($rxchan),