aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/api.php39
-rw-r--r--include/help.php150
-rwxr-xr-xinclude/importdoc.php2
-rw-r--r--include/nav.php2
-rw-r--r--include/photos.php40
5 files changed, 212 insertions, 21 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/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/nav.php b/include/nav.php
index 541ab3aed..027ce4a6c 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -150,7 +150,7 @@ EOT;
$help_url = z_root() . '/help?f=&cmd=' . App::$cmd;
if(! get_config('system','hide_help')) {
- require_once('mod/help.php');
+ require_once('include/help.php');
$context_help = load_context_help();
$nav['help'] = array($help_url, t('Help'), "", t('Help and documentation'),'help_nav_btn',$context_help);
}
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;
+ }