aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2019-01-18 22:17:10 +0100
committerKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2019-01-23 22:25:47 +0100
commit13e0151cd2569832588cc9a973bcf40d850edd53 (patch)
tree1d2054ca8b9edd9435d1ffa4c2584afea9121102 /include
parent51a7be29f50c4c62a2afb0ed155df43af9351fad (diff)
downloadvolse-hubzilla-13e0151cd2569832588cc9a973bcf40d850edd53.tar.gz
volse-hubzilla-13e0151cd2569832588cc9a973bcf40d850edd53.tar.bz2
volse-hubzilla-13e0151cd2569832588cc9a973bcf40d850edd53.zip
Correct and extend Doxygen comments.
Correct some documentation errors for Doxygen and add more comments. Document some undefined variables with @FIXME.
Diffstat (limited to 'include')
-rw-r--r--include/attach.php60
-rw-r--r--include/feedutils.php20
-rw-r--r--include/help.php30
-rw-r--r--include/import.php9
-rwxr-xr-xinclude/items.php30
-rwxr-xr-xinclude/plugin.php17
-rw-r--r--include/text.php147
-rw-r--r--include/zot.php22
8 files changed, 205 insertions, 130 deletions
diff --git a/include/attach.php b/include/attach.php
index dd718aa14..17a47d9ac 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -137,7 +137,7 @@ function z_mime_content_type($filename) {
* @param string $hash (optional)
* @param string $filename (optional)
* @param string $filetype (optional)
- * @return associative array with:
+ * @return array Associative array with:
* * \e boolean \b success
* * \e int|boolean \b results amount of found results, or false
* * \e string \b message with error messages if any
@@ -176,15 +176,17 @@ function attach_count_files($channel_id, $observer, $hash = '', $filename = '',
/**
* @brief Returns a list of files/attachments.
*
- * @param $channel_id
- * @param $observer
- * @param $hash (optional)
- * @param $filename (optional)
- * @param $filetype (optional)
- * @param $orderby
- * @param $start
- * @param $entries
- * @return associative array with:
+ * @param int $channel_id
+ * @param string $observer
+ * @param string $hash (optional)
+ * @param string $filename (optional)
+ * @param string $filetype (optional)
+ * @param string $orderby (optional)
+ * @param int $start (optional)
+ * @param int $entries (optional)
+ * @param string $since (optional)
+ * @param string $until (optional)
+ * @return array an associative array with:
* * \e boolean \b success
* * \e array|boolean \b results array with results, or false
* * \e string \b message with error messages if any
@@ -1428,8 +1430,17 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
if(! $r) {
attach_drop_photo($channel_id,$resource);
- $arr = ['channel_id' => $channel_id, 'resource' => $resource, 'is_photo'=>$is_photo];
- call_hooks("attach_delete",$arr);
+ $arr = ['channel_id' => $channel_id, 'resource' => $resource, 'is_photo' => $is_photo];
+
+ /**
+ * @hooks attach_delete
+ * Called when deleting an attachment from channel.
+ * * \e int \b channel_id - the channel_id
+ * * \e string \b resource
+ * * \e int \b is_photo
+ */
+ call_hooks('attach_delete', $arr);
+
return;
}
@@ -1488,8 +1499,15 @@ function attach_delete($channel_id, $resource, $is_photo = 0) {
intval($channel_id)
);
- $arr = ['channel_id' => $channel_id, 'resource' => $resource, 'is_photo'=>$is_photo];
- call_hooks("attach_delete",$arr);
+ $arr = ['channel_id' => $channel_id, 'resource' => $resource, 'is_photo' => $is_photo];
+ /**
+ * @hooks attach_delete
+ * Called when deleting an attachment from channel.
+ * * \e int \b channel_id - the channel_id
+ * * \e string \b resource
+ * * \e int \b is_photo
+ */
+ call_hooks('attach_delete', $arr);
file_activity($channel_id, $object, $object['allow_cid'], $object['allow_gid'], $object['deny_cid'], $object['deny_gid'], 'update', true);
@@ -1868,7 +1886,7 @@ function file_activity($channel_id, $object, $allow_cid, $allow_gid, $deny_cid,
* @param int $channel_id
* @param string $hash
* @param string $url
- * @return array An associative array for the specified file.
+ * @return array Associative array for the specified file.
*/
function get_file_activity_object($channel_id, $hash, $url) {
@@ -2110,7 +2128,7 @@ function attach_export_data($channel, $resource_id, $deleted = false) {
if($attach_ptr['is_photo']) {
- // This query could potentially result in a few megabytes of data use.
+ // This query could potentially result in a few megabytes of data use.
$r = q("select * from photo where resource_id = '%s' and uid = %d order by imgscale asc",
dbesc($resource_id),
@@ -2352,7 +2370,7 @@ function attach_move($channel_id, $resource_id, $new_folder_hash) {
$filename = $r[0]['filename'];
- // don't do duplicate check unless our parent folder has changed.
+ // don't do duplicate check unless our parent folder has changed.
if($r[0]['folder'] !== $new_folder_hash) {
@@ -2468,7 +2486,7 @@ function attach_move($channel_id, $resource_id, $new_folder_hash) {
/**
- * Used to generate a select input box of all your folders
+ * Used to generate a select input box of all your folders
*/
@@ -2551,10 +2569,10 @@ function attach_syspaths($channel_id,$attach_hash) {
/**
* in earlier releases we did not fill in os_path and display_path in the attach DB structure.
- * (It was not needed or used). Going forward we intend to make use of these fields.
+ * (It was not needed or used). Going forward we intend to make use of these fields.
* A cron task checks for empty values (as older attachments may have arrived at our site
- * in a clone operation) and executes attach_syspaths() to generate these field values and correct
- * the attach table entry. The operation is limited to 100 DB entries at a time so as not to
+ * in a clone operation) and executes attach_syspaths() to generate these field values and correct
+ * the attach table entry. The operation is limited to 100 DB entries at a time so as not to
* overload the system in any cron run. Eventually it will catch up with old attach structures
* and switch into maintenance mode to correct any that might arrive in clone packets from older
* sites.
diff --git a/include/feedutils.php b/include/feedutils.php
index afbe4229e..5e52828c3 100644
--- a/include/feedutils.php
+++ b/include/feedutils.php
@@ -261,13 +261,13 @@ function construct_activity_target($item) {
* @param SimplePie $item
* @return array $author
*/
-
function get_atom_author($feed, $item) {
$author = [];
$found_author = $item->get_author();
if($found_author) {
+ /// @FIXME $rawauthor is undefined here
if($rawauthor) {
if($rawauthor[0]['child'][NAMESPACE_POCO]['displayName'][0]['data'])
$author['full_name'] = unxmlify($rawauthor[0]['child'][NAMESPACE_POCO]['displayName'][0]['data']);
@@ -398,10 +398,10 @@ function get_atom_author($feed, $item) {
'author' => $author
];
/**
- * @hooks parse_atom
+ * @hooks parse_atom_author
* * \e SimplePie \b feed - The original SimplePie feed
* * \e SimplePie \b item
- * * \e array \b result - the result array that will also get returned
+ * * \e array \b author - the result array that will also get returned
*/
call_hooks('parse_atom_author', $arr);
@@ -416,10 +416,8 @@ function get_atom_author($feed, $item) {
*
* @param SimplePie $feed
* @param SimplePie $item
- * @param[out] array $author
* @return array Associative array with the parsed item data
*/
-
function get_atom_elements($feed, $item) {
require_once('include/html2bbcode.php');
@@ -669,10 +667,10 @@ function get_atom_elements($feed, $item) {
$termterm = notags(trim(unxmlify($term)));
// Mastodon auto generates an nsfw category tag for any 'content-warning' message.
- // Most people use CW and use both summary/content as a spoiler and we honour that
- // construct so the post will already be collapsed. The generated tag is almost
+ // Most people use CW and use both summary/content as a spoiler and we honour that
+ // construct so the post will already be collapsed. The generated tag is almost
// always wrong and even if it isn't we would already be doing the right thing.
-
+
if($mastodon && $termterm === 'nsfw' && $summary && $res['body'])
continue;
@@ -1336,7 +1334,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
if( ! \Zotlabs\Lib\MessageFilter::evaluate($datarray,get_config('system','pubstream_incl'),get_config('system','pubstream_excl'))) {
continue;
}
- }
+ }
if(! post_is_importable($datarray, $contact))
continue;
@@ -1492,7 +1490,7 @@ function consume_feed($xml, $importer, &$contact, $pass = 0) {
if( ! \Zotlabs\Lib\MessageFilter::evaluate($datarray,get_config('system','pubstream_incl'),get_config('system','pubstream_excl'))) {
continue;
}
- }
+ }
if(! post_is_importable($datarray, $contact))
continue;
@@ -1900,7 +1898,7 @@ function atom_entry($item, $type, $author, $owner, $comment = false, $cid = 0, $
$body = $item['body'];
- if($summary)
+ if($summary)
$body = preg_replace('|^(.*?)\[summary\](.*?)\[/summary\](.*?)$|ism','$1$3',$item['body']);
if($compat)
diff --git a/include/help.php b/include/help.php
index 61dbc7bb3..e82fa96da 100644
--- a/include/help.php
+++ b/include/help.php
@@ -7,9 +7,10 @@ use \Michelf\MarkdownExtra;
* @brief
*
* @param string $path
- * @return string|unknown
+ * @param string $suffix (optional) default null
+ * @return string
*/
-function get_help_fullpath($path,$suffix=null) {
+function get_help_fullpath($path, $suffix = null) {
$docroot = (\App::$override_helproot) ? \App::$override_helproot : 'doc/';
$docroot = (substr($docroot,-1)!='/') ? $docroot .= '/' : $docroot;
@@ -49,8 +50,8 @@ function get_help_fullpath($path,$suffix=null) {
/**
* @brief
*
- * @param string $tocpath
- * @return string|unknown
+ * @param string $tocpath (optional) default false
+ * @return string
*/
function get_help_content($tocpath = false) {
@@ -171,16 +172,20 @@ function preg_callback_help_include($matches) {
}
/**
- * @brief
+ * @brief Determines help language.
+ *
+ * If the language was specified in the URL, override the language preference
+ * of the browser. Default to English if both of these are absent.
*
- * @return boolean|array
+ * @return array Associative array with:
+ * * \e string \b language - 2-letter ISO 639-1 code ("en")
+ * * \e boolean \b from_url - true if language from URL overrides browser default
*/
function determine_help_language() {
$lang_detect = new Text_LanguageDetect();
// Set this mode to recognize language by the short code like "en", "ru", etc.
$lang_detect->setNameMode(2);
- // If the language was specified in the URL, override the language preference
- // of the browser. Default to English if both of these are absent.
+
if($lang_detect->languageExists(argv(1))) {
$lang = argv(1);
$from_url = true;
@@ -211,10 +216,10 @@ function find_doc_file($s) {
}
/**
- * @brief
+ * @brief Search in doc files.
*
- * @param string $s
- * @return number|mixed|unknown|boolean
+ * @param string $s The search string to search for
+ * @return array
*/
function search_doc_files($s) {
@@ -275,7 +280,6 @@ function doc_rank_sort($s1, $s2) {
*
* @return string
*/
-
function load_context_help() {
$path = App::$cmd;
@@ -305,7 +309,7 @@ function load_context_help() {
* @brief
*
* @param string $s
- * @return void|boolean[]|number[]|string[]|unknown[]
+ * @return void|array
*/
function store_doc_file($s) {
diff --git a/include/import.php b/include/import.php
index 3bd8b4105..f391400bd 100644
--- a/include/import.php
+++ b/include/import.php
@@ -12,6 +12,7 @@ require_once('include/perm_upgrade.php');
* @param array $channel
* @param int $account_id
* @param int $seize
+ * @param string $newname (optional)
* @return boolean|array
*/
function import_channel($channel, $account_id, $seize, $newname = '') {
@@ -650,7 +651,7 @@ function import_items($channel, $items, $sync = false, $relocate = null) {
// preserve conversations you've been involved in from being expired
$stored = $item_result['item'];
- if((is_array($stored)) && ($stored['id'] != $stored['parent'])
+ if((is_array($stored)) && ($stored['id'] != $stored['parent'])
&& ($stored['author_xchan'] === $channel['channel_hash'])) {
retain_item($stored['item']['parent']);
}
@@ -672,7 +673,7 @@ function import_items($channel, $items, $sync = false, $relocate = null) {
/**
* @brief Sync items to channel.
*
- * @see import_items
+ * @see import_items()
*
* @param array $channel where to import to
* @param array $items
@@ -1049,7 +1050,7 @@ function import_mail($channel, $mails, $sync = false) {
/**
* @brief Synchronise mails.
*
- * @see import_mail
+ * @see import_mail()
* @param array $channel
* @param array $mails
*/
@@ -1337,7 +1338,7 @@ function sync_files($channel, $files) {
if($str)
$str .= ",";
-
+
$str .= " " . TQUOT . $k . TQUOT . " = '" . (($k === 'content') ? dbescbin($v) : dbesc($v)) . "' ";
}
$r = dbq("update photo set " . $str . " where id = " . intval($exists[0]['id']) );
diff --git a/include/items.php b/include/items.php
index e5f2be003..ed6fee597 100755
--- a/include/items.php
+++ b/include/items.php
@@ -25,7 +25,7 @@ require_once('include/permissions.php');
*
* @param array $item
* @param[out] boolean $private_envelope
- * @param boolean $include_groups
+ * @param boolean $include_groups
* @return array containing the recipients
*/
function collect_recipients($item, &$private_envelope,$include_groups = true) {
@@ -97,9 +97,9 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) {
if(array_key_exists('public_policy',$item) && $item['public_policy'] !== 'self') {
$hookinfo = [
- 'recipients' => [],
- 'item' => $item,
- 'private_envelope' => $private_envelope,
+ 'recipients' => [],
+ 'item' => $item,
+ 'private_envelope' => $private_envelope,
'include_groups' => $include_groups
];
@@ -410,7 +410,7 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) {
if(! $arr['mid']) {
- $arr['uuid'] = ((x($arr,'uuid')) ? $arr['uuid'] : item_message_id());
+ $arr['uuid'] = ((x($arr,'uuid')) ? $arr['uuid'] : item_message_id());
}
$arr['mid'] = ((x($arr,'mid')) ? $arr['mid'] : z_root() . '/item/' . $arr['uuid']);
$arr['parent_mid'] = ((x($arr,'parent_mid')) ? $arr['parent_mid'] : $arr['mid']);
@@ -2400,15 +2400,15 @@ function item_update_parent_commented($item) {
$update_parent = true;
- // update the commented timestamp on the parent
+ // update the commented timestamp on the parent
// - unless this is a moderated comment or a potential clone of an older item
- // which we don't wish to bring to the surface. As the queue only holds deliveries
- // for 3 days, it's suspected of being an older cloned item if the creation time
+ // which we don't wish to bring to the surface. As the queue only holds deliveries
+ // for 3 days, it's suspected of being an older cloned item if the creation time
//is older than that.
if(intval($item['item_blocked']) === ITEM_MODERATED)
$update_parent = false;
-
+
if($item['created'] < datetime_convert('','','now - 4 days'))
$update_parent = false;
@@ -3004,7 +3004,9 @@ function tgroup_check($uid, $item) {
* @param array $channel
* @param array $item
* @param int $item_id
- * @param boolean $parent
+ * @param array $parent
+ * @param boolean $edit (optional) default false
+ * @return void
*/
function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false) {
@@ -3039,7 +3041,7 @@ function start_delivery_chain($channel, $item, $item_id, $parent, $edit = false)
}
// This will change the author to the post owner. Useful for RSS feeds which are to be syndicated
- // to federated platforms which can't verify the identity of the author.
+ // to federated platforms which can't verify the identity of the author.
// This MAY cause you to run afoul of copyright law.
$rewrite_author = intval(get_abconfig($channel['channel_id'],$item['owner_xchan'],'system','rself'));
@@ -3552,7 +3554,7 @@ function item_expire($uid,$days,$comment_days = 7) {
if(! $comment_days)
$comment_days = 7;
-
+
// $expire_network_only = save your own wall posts
// and just expire conversations started by others
// do not enable this until we can pass bulk delete messages through zot
@@ -4892,7 +4894,7 @@ function copy_of_pubitem($channel,$mid) {
dbesc($mid),
intval($syschan['channel_id'])
);
-
+
if($r) {
$items = fetch_post_tags($r,true);
foreach($items as $rv) {
@@ -4918,5 +4920,5 @@ function copy_of_pubitem($channel,$mid) {
}
}
- return $result;
+ return $result;
}
diff --git a/include/plugin.php b/include/plugin.php
index ec14fd945..c789ad522 100755
--- a/include/plugin.php
+++ b/include/plugin.php
@@ -7,13 +7,15 @@
/**
- * @brief Handle errors in plugin calls
+ * @brief Handle errors in plugin calls.
*
* @param string $plugin name of the addon
- * @param string $error_text text of error
- * @param bool $uninstall uninstall plugin
+ * @param string $notice UI visible text of error
+ * @param string $log technical error message for logging
+ * @param bool $uninstall (optional) default false
+ * uninstall plugin on error
*/
-function handleerrors_plugin($plugin,$notice,$log,$uninstall=false){
+function handleerrors_plugin($plugin, $notice, $log, $uninstall = false){
logger("Addons: [" . $plugin . "] Error: ".$log, LOGGER_ERROR);
if ($notice != '') {
notice("[" . $plugin . "] Error: ".$notice, LOGGER_ERROR);
@@ -23,7 +25,7 @@ function handleerrors_plugin($plugin,$notice,$log,$uninstall=false){
$idx = array_search($plugin, \App::$plugins);
unset(\App::$plugins[$idx]);
uninstall_plugin($plugin);
- set_config("system","addon", implode(", ",\App::$plugins));
+ set_config("system", "addon", implode(", ", \App::$plugins));
}
}
@@ -381,8 +383,6 @@ function unregister_hook($hook, $file, $function) {
* array in their theme_init() and use this to customise the app behaviour.
* use insert_hook($hookname,$function_name) to do this.
*/
-
-
function load_hooks() {
App::$hooks = [];
@@ -1085,10 +1085,11 @@ function get_markup_template($s, $root = '') {
}
/**
- * @brief
+ * @brief Test if a folder exists.
*
* @param string $folder
* @return boolean|string
+ * False if folder does not exist, or canonicalized absolute pathname
*/
function folder_exists($folder) {
// Get canonicalized absolute pathname
diff --git a/include/text.php b/include/text.php
index 6ac04f435..925c8e997 100644
--- a/include/text.php
+++ b/include/text.php
@@ -41,12 +41,12 @@ function replace_macros($s, $r) {
$t = App::template_engine();
- try {
- $output = $t->replace_macros($arr['template'], $arr['params']);
- } catch (Exception $e) {
- logger("Unable to render template: ".$e->getMessage());
- $output = "<h3>ERROR: there was an error creating the output.</h3>";
- }
+ try {
+ $output = $t->replace_macros($arr['template'], $arr['params']);
+ } catch (Exception $e) {
+ logger('Unable to render template: ' . $e->getMessage());
+ $output = '<h3>ERROR: there was an error creating the output.</h3>';
+ }
return $output;
}
@@ -539,7 +539,14 @@ function paginate(&$a) {
return $o;
}
-
+/**
+ * @brief
+ *
+ * @param int $i
+ * @param string $more
+ * @param string $less
+ * @return string Parsed HTML from template 'alt_pager.tpl'
+ */
function alt_pager($i, $more = '', $less = '') {
if(! $more)
@@ -810,7 +817,7 @@ function activity_match($haystack,$needle) {
* and strip the period from any tags which end with one.
*
* @param string $s
- * @return Returns array of tags found, or empty array.
+ * @return array Returns an array of tags found, or empty array.
*/
function get_tags($s) {
$ret = array();
@@ -825,7 +832,7 @@ function get_tags($s) {
// ignore anything in [color= ], because it may contain color codes which are mistaken for tags
$s = preg_replace('/\[color=(.*?)\]/sm','',$s);
-
+
// skip anchors in URL
$s = preg_replace('/\[url=(.*?)\]/sm','',$s);
@@ -900,6 +907,7 @@ function tag_sort_length($a,$b) {
function total_sort($a,$b) {
if($a['total'] == $b['total'])
return 0;
+
return(($b['total'] > $a['total']) ? 1 : (-1));
}
@@ -1004,9 +1012,15 @@ function contact_block() {
'$micropro' => $micropro,
));
- $arr = array('contacts' => $r, 'output' => $o);
-
+ $arr = ['contacts' => $r, 'output' => $o];
+ /**
+ * @hooks contact_block_end
+ * Called at the end of contact_block(), but can not manipulate the output.
+ * * \e array \b contacts - Result array from database
+ * * \e string \b output - the generated output
+ */
call_hooks('contact_block_end', $arr);
+
return $o;
}
@@ -1108,16 +1122,20 @@ function linkify($s, $me = false) {
* to a local redirector which uses https and which redirects to the selected content
*
* @param string $s
- * @param int $uid
* @returns string
*/
function sslify($s) {
// Local photo cache
- $str = array(
+ $str = [
'body' => $s,
'uid' => local_channel()
- );
+ ];
+ /**
+ * @hooks cache_body_hook
+ * * \e string \b body The content to parse and also the return value
+ * * \e int|bool \b uid
+ */
call_hooks('cache_body_hook', $str);
$s = $str['body'];
@@ -1222,7 +1240,11 @@ function get_mood_verbs() {
/**
* @brief Function to list all smilies, both internal and from addons.
*
- * @return Returns array with keys 'texts' and 'icons'
+ * @param boolean $default_only (optional) default false
+ * true will prevent that plugins can add smilies
+ * @return array Returns an associative array with:
+ * * \e array \b texts
+ * * \e array \b icons
*/
function list_smilies($default_only = false) {
@@ -1300,6 +1322,11 @@ function list_smilies($default_only = false) {
if($default_only)
return $params;
+ /**
+ * @hooks smile
+ * * \e array \b texts - default values and also return value
+ * * \e array \b icons - default values and also return value
+ */
call_hooks('smilie', $params);
return $params;
@@ -1625,6 +1652,10 @@ function generate_named_map($location) {
function prepare_body(&$item,$attach = false,$opts = false) {
+ /**
+ * @hooks prepare_body_init
+ * * \e array \b item
+ */
call_hooks('prepare_body_init', $item);
$s = '';
@@ -1656,13 +1687,19 @@ function prepare_body(&$item,$attach = false,$opts = false) {
$event = (($item['obj_type'] === ACTIVITY_OBJ_EVENT) ? format_event_obj($item['obj']) : false);
- $prep_arr = array(
+ $prep_arr = [
'item' => $item,
'html' => $event ? $event['content'] : $s,
'event' => $event['header'],
'photo' => $photo
- );
-
+ ];
+ /**
+ * @hooks prepare_body
+ * * \e array \b item
+ * * \e string \b html - the parsed HTML to return
+ * * \e string \b event - the event header to return
+ * * \e string \b photo - the photo to return
+ */
call_hooks('prepare_body', $prep_arr);
$s = $prep_arr['html'];
@@ -2249,19 +2286,24 @@ function ids_to_querystr($arr,$idx = 'id',$quote = false) {
}
/**
- * @brief array_elm_to_str($arr,$elm,$delim = ',') extract unique individual elements from an array of arrays and return them as a string separated by a delimiter
- * similar to ids_to_querystr, but allows a different delimiter instead of a db-quote option
- * empty elements (evaluated after trim()) are ignored.
- * @param $arr array
- * @param $elm array key to extract from sub-array
- * @param $delim string default ','
- * @param $each filter function to apply to each element before evaluation, default is 'trim'.
+ * @brief Extract unique individual elements from an array of arrays and return
+ * them as a string separated by a delimiter.
+ *
+ * Similar to ids_to_querystr, but allows a different delimiter instead of a
+ * db-quote option empty elements (evaluated after trim()) are ignored.
+ *
+ * @see ids_to_querystr()
+ *
+ * @param array $arr
+ * @param string $elm key to extract from sub-array
+ * @param string $delim (optional) default ','
+ * @param string $each (optional) default is 'trim'
+ * Filter function to apply to each element before evaluation.
* @returns string
*/
-
-function array_elm_to_str($arr,$elm,$delim = ',',$each = 'trim') {
-
+function array_elm_to_str($arr, $elm, $delim = ',', $each = 'trim') {
$tmp = [];
+
if($arr && is_array($arr)) {
foreach($arr as $x) {
if(is_array($x) && array_key_exists($elm,$x)) {
@@ -2272,7 +2314,8 @@ function array_elm_to_str($arr,$elm,$delim = ',',$each = 'trim') {
}
}
}
- return implode($delim,$tmp);
+
+ return implode($delim, $tmp);
}
function trim_and_unpunify($s) {
@@ -2496,9 +2539,9 @@ function design_tools() {
}
/**
- * @brief Creates website portation tools menu
+ * @brief Creates website portation tools menu.
*
- * @return string
+ * @return string Parsed HTML code from template 'website_portation_tools.tpl'
*/
function website_portation_tools() {
@@ -2511,7 +2554,7 @@ function website_portation_tools() {
$sys = true;
}
- return replace_macros(get_markup_template('website_portation_tools.tpl'), array(
+ return replace_macros(get_markup_template('website_portation_tools.tpl'), [
'$title' => t('Import'),
'$import_label' => t('Import website...'),
'$import_placeholder' => t('Select folder to import'),
@@ -2528,7 +2571,7 @@ function website_portation_tools() {
'$cloud_export_desc' => t('/path/to/export/folder'),
'$cloud_export_hint' => t('Enter a path to a cloud files destination.'),
'$cloud_export_select' => t('Specify folder'),
- ));
+ ]);
}
/**
@@ -2991,9 +3034,9 @@ function item_url_replace($channel,&$item,$old,$new,$oldnick = '') {
json_url_replace('/' . $oldnick . '/' ,'/' . $channel['channel_address'] . '/' ,$item['target']);
}
- $x = preg_replace("/".preg_quote($old,'/')."\/(search|\w+\/".$channel['channel_address'].")/", $new.'/${1}', $item['body']);
- if($x) {
- $item['body'] = $x;
+ $x = preg_replace("/".preg_quote($old,'/')."\/(search|\w+\/".$channel['channel_address'].")/", $new.'/${1}', $item['body']);
+ if($x) {
+ $item['body'] = $x;
$item['sig'] = base64url_encode(rsa_sign($item['body'],$channel['channel_prvkey']));
$item['item_verified'] = 1;
}
@@ -3103,7 +3146,13 @@ function pdl_selector($uid, $current='') {
intval($uid)
);
- $arr = array('channel_id' => $uid, 'current' => $current, 'entries' => $r);
+ $arr = ['channel_id' => $uid, 'current' => $current, 'entries' => $r];
+ /**
+ * @hooks pdl_selector
+ * * \e int \b channel_id
+ * * \e string \b current
+ * * \e array \b entries - Result from database query
+ */
call_hooks('pdl_selector', $arr);
$entries = $arr['entries'];
@@ -3178,7 +3227,6 @@ function text_highlight($s, $lang) {
'language' => $lang,
'success' => false
];
-
/**
* @hooks text_highlight
* * \e string \b text
@@ -3379,13 +3427,17 @@ function punify($s) {
}
-// Be aware that unpunify will only convert domain names and not pathnames
-
+/**
+ * Be aware that unpunify() will only convert domain names and not pathnames.
+ *
+ * @param string $s
+ * @return string
+ */
function unpunify($s) {
require_once('vendor/simplepie/simplepie/idn/idna_convert.class.php');
$x = new idna_convert(['encoding' => 'utf8']);
- return $x->decode($s);
+ return $x->decode($s);
}
@@ -3521,12 +3573,11 @@ function array_path_exists($str,$arr) {
*/
function new_uuid() {
- try {
- $hash = Uuid::uuid4()->toString();
- } catch (UnsatisfiedDependencyException $e) {
- $hash = random_string(48);
- }
+ try {
+ $hash = Uuid::uuid4()->toString();
+ } catch (UnsatisfiedDependencyException $e) {
+ $hash = random_string(48);
+ }
- return $hash;
+ return $hash;
}
-
diff --git a/include/zot.php b/include/zot.php
index bc2187f91..3b089831b 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -174,7 +174,7 @@ function zot_build_packet($channel, $type = 'notify', $recipients = null, $remot
* packet type: one of 'ping', 'pickup', 'purge', 'refresh', 'keychange', 'force_refresh', 'notify', 'auth_check'
* @param array $recipients
* envelope information, array ( 'guid' => string, 'guid_sig' => string ); empty for public posts
- * @param string msg
+ * @param string $msg
* optional message
* @param string $remote_key
* optional public site key of target hub used to encrypt entire packet
@@ -1829,7 +1829,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
else {
$arr['item_wall'] = 0;
}
-
+
if ((! $tag_delivery) && (! $local_public)) {
$allowed = (perm_is_allowed($channel['channel_id'],$sender['hash'],$perm));
@@ -1843,7 +1843,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
$allowed = can_comment_on_post($d['hash'],$parent[0]);
}
}
-
+
if (! $allowed) {
logger("permission denied for delivery to channel {$channel['channel_id']} {$channel['channel_address']}");
$DR->update('permission denied');
@@ -2330,7 +2330,7 @@ function process_mail_delivery($sender, $arr, $deliveries) {
if(! perm_is_allowed($channel['channel_id'],$sender['hash'],'post_mail')) {
- /*
+ /*
* Always allow somebody to reply if you initiated the conversation. It's anti-social
* and a bit rude to send a private message to somebody and block their ability to respond.
* If you are being harrassed and want to put an end to it, delete the conversation.
@@ -2358,7 +2358,7 @@ function process_mail_delivery($sender, $arr, $deliveries) {
);
if($r) {
if(intval($arr['mail_recalled'])) {
- msg_drop($r[0]['id'], $channel['channel_id'], $r[0]['conv_guid']);
+ msg_drop($r[0]['id'], $channel['channel_id'], $r[0]['conv_guid']);
$DR->update('mail recalled');
$result[] = $DR->get();
logger('mail_recalled');
@@ -3247,7 +3247,7 @@ function build_sync_packet($uid = 0, $packet = null, $groups_changed = false) {
$channel = $r[0];
- // don't provide these in the export
+ // don't provide these in the export
unset($channel['channel_active']);
unset($channel['channel_password']);
@@ -3616,7 +3616,7 @@ function process_channel_sync_delivery($sender, $arr, $deliveries) {
if(array_key_exists('channel_pageflags',$arr['channel']) && intval($arr['channel']['channel_pageflags'])) {
// Several pageflags are site-specific and cannot be sync'd.
- // Only allow those bits which are shareable from the remote and then
+ // Only allow those bits which are shareable from the remote and then
// logically OR with the local flags
$arr['channel']['channel_pageflags'] = $arr['channel']['channel_pageflags'] & (PAGE_HIDDEN|PAGE_AUTOCONNECT|PAGE_APPLICATION|PAGE_PREMIUM|PAGE_ADULT);
@@ -4974,9 +4974,9 @@ function zot_reply_pickup($data) {
// It's possible that we have more than 100 messages waiting to be sent.
// See if there are any more messages in the queue.
- $x = q("select * from outq where outq_posturl = '%s' order by outq_created limit 1",
- dbesc($data['callback'])
- );
+ $x = q("select * from outq where outq_posturl = '%s' order by outq_created limit 1",
+ dbesc($data['callback'])
+ );
// If so, kick off a new delivery notification for the next batch
if ($x) {
@@ -5057,7 +5057,7 @@ function zot_reply_auth_check($data,$encrypted_packet) {
}
// There should be exactly one recipient, the original auth requestor
-
+ /// @FIXME $recipients is undefined here.
$ret['message'] .= 'recipients ' . print_r($recipients,true) . EOL;
if ($data['recipients']) {