From 213f6ae1a14cb646a0a0fcf0d115a65d3693525f Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Wed, 17 Jan 2018 12:03:10 -0500 Subject: [PATCH 01/11] Create Addon and Theme classes Create Addon and Theme classes and functions from plugin.php to appropriate class. --- src/Core/Addon.php | 300 +++++++++++++++++++++++++++++++++++++++++++++ src/Core/Theme.php | 187 ++++++++++++++++++++++++++++ 2 files changed, 487 insertions(+) create mode 100644 src/Core/Addon.php create mode 100644 src/Core/Theme.php diff --git a/src/Core/Addon.php b/src/Core/Addon.php new file mode 100644 index 000000000..f9a21d429 --- /dev/null +++ b/src/Core/Addon.php @@ -0,0 +1,300 @@ + $plugin]); + + @include_once('addon/' . $plugin . '/' . $plugin . '.php'); + if (function_exists($plugin . '_uninstall')) { + $func = $plugin . '_uninstall'; + $func(); + } + } + + /** + * @brief installs an addon. + * + * @param string $plugin name of the addon + * @return bool + */ + function install_plugin($plugin) { + // silently fail if plugin was removed + + if (!file_exists('addon/' . $plugin . '/' . $plugin . '.php')) { + return false; + } + logger("Addons: installing " . $plugin); + $t = @filemtime('addon/' . $plugin . '/' . $plugin . '.php'); + @include_once('addon/' . $plugin . '/' . $plugin . '.php'); + if (function_exists($plugin . '_install')) { + $func = $plugin . '_install'; + $func(); + + $plugin_admin = (function_exists($plugin."_plugin_admin") ? 1 : 0); + + dba::insert('addon', ['name' => $plugin, 'installed' => true, + 'timestamp' => $t, 'plugin_admin' => $plugin_admin]); + + // we can add the following with the previous SQL + // once most site tables have been updated. + // This way the system won't fall over dead during the update. + + if (file_exists('addon/' . $plugin . '/.hidden')) { + dba::update('addon', ['hidden' => true], ['name' => $plugin]); + } + return true; + } else { + logger("Addons: FAILED installing " . $plugin); + return false; + } + } + + // reload all updated plugins + + function reload_plugins() { + $plugins = Config::get('system', 'addon'); + if (strlen($plugins)) { + + $r = q("SELECT * FROM `addon` WHERE `installed` = 1"); + if (DBM::is_result($r)) { + $installed = $r; + } else { + $installed = []; + } + + $parr = explode(',',$plugins); + + if (count($parr)) { + foreach ($parr as $pl) { + + $pl = trim($pl); + + $fname = 'addon/' . $pl . '/' . $pl . '.php'; + + if (file_exists($fname)) { + $t = @filemtime($fname); + foreach ($installed as $i) { + if (($i['name'] == $pl) && ($i['timestamp'] != $t)) { + logger('Reloading plugin: ' . $i['name']); + @include_once($fname); + + if (function_exists($pl . '_uninstall')) { + $func = $pl . '_uninstall'; + $func(); + } + if (function_exists($pl . '_install')) { + $func = $pl . '_install'; + $func(); + } + dba::update('addon', ['timestamp' => $t], ['id' => $i['id']]); + } + } + } + } + } + } + + } + + /** + * @brief check if addon is enabled + * + * @param string $plugin + * @return boolean + */ + function plugin_enabled($plugin) { + return dba::exists('addon', ['installed' => true, 'name' => $plugin]); + } + + + /** + * @brief registers a hook. + * + * @param string $hook the name of the hook + * @param string $file the name of the file that hooks into + * @param string $function the name of the function that the hook will call + * @param int $priority A priority (defaults to 0) + * @return mixed|bool + */ + function register_hook($hook, $file, $function, $priority=0) { + $condition = ['hook' => $hook, 'file' => $file, 'function' => $function]; + $exists = dba::exists('hook', $condition); + if ($exists) { + return true; + } + + $r = dba::insert('hook', ['hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority]); + + return $r; + } + + /** + * @brief unregisters a hook. + * + * @param string $hook the name of the hook + * @param string $file the name of the file that hooks into + * @param string $function the name of the function that the hook called + * @return array + */ + function unregister_hook($hook, $file, $function) { + $condition = ['hook' => $hook, 'file' => $file, 'function' => $function]; + $r = dba::delete('hook', $condition); + return $r; + } + + + function load_hooks() { + $a = get_app(); + $a->hooks = []; + $r = dba::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]); + + while ($rr = dba::fetch($r)) { + if (! array_key_exists($rr['hook'],$a->hooks)) { + $a->hooks[$rr['hook']] = []; + } + $a->hooks[$rr['hook']][] = [$rr['file'],$rr['function']]; + } + dba::close($r); + } + + /** + * @brief Calls a hook. + * + * Use this function when you want to be able to allow a hook to manipulate + * the provided data. + * + * @param string $name of the hook to call + * @param string|array &$data to transmit to the callback handler + */ + function call_hooks($name, &$data = null) + { + $a = get_app(); + + if (is_array($a->hooks) && array_key_exists($name, $a->hooks)) { + foreach ($a->hooks[$name] as $hook) { + call_single_hook($a, $name, $hook, $data); + } + } + } + + /** + * @brief Calls a single hook. + * + * @param string $name of the hook to call + * @param array $hook Hook data + * @param string|array &$data to transmit to the callback handler + */ + function call_single_hook($a, $name, $hook, &$data = null) { + // Don't run a theme's hook if the user isn't using the theme + if (strpos($hook[0], 'view/theme/') !== false && strpos($hook[0], 'view/theme/'.current_theme()) === false) + return; + + @include_once($hook[0]); + if (function_exists($hook[1])) { + $func = $hook[1]; + $func($a, $data); + } else { + // remove orphan hooks + $condition = ['hook' => $name, 'file' => $hook[0], 'function' => $hook[1]]; + dba::delete('hook', $condition); + } + } + + //check if an app_menu hook exist for plugin $name. + //Return true if the plugin is an app + function plugin_is_app($name) { + $a = get_app(); + + if (is_array($a->hooks) && (array_key_exists('app_menu',$a->hooks))) { + foreach ($a->hooks['app_menu'] as $hook) { + if ($hook[0] == 'addon/'.$name.'/'.$name.'.php') + return true; + } + } + + return false; + } + + /** + * @brief Parse plugin comment in search of plugin infos. + * + * like + * \code + *...* Name: Plugin + * * Description: A plugin which plugs in + * . * Version: 1.2.3 + * * Author: John + * * Author: Jane + * * + * *\endcode + * @param string $plugin the name of the plugin + * @return array with the plugin information + */ + + function get_plugin_info($plugin) { + + $a = get_app(); + + $info=[ + 'name' => $plugin, + 'description' => "", + 'author' => [], + 'version' => "", + 'status' => "" + ]; + + if (!is_file("addon/$plugin/$plugin.php")) return $info; + + $stamp1 = microtime(true); + $f = file_get_contents("addon/$plugin/$plugin.php"); + $a->save_timestamp($stamp1, "file"); + + $r = preg_match("|/\*.*\*/|msU", $f, $m); + + if ($r) { + $ll = explode("\n", $m[0]); + foreach ( $ll as $l ) { + $l = trim($l,"\t\n\r */"); + if ($l != "") { + list($k,$v) = array_map("trim", explode(":",$l,2)); + $k= strtolower($k); + if ($k == "author") { + $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); + if ($r) { + $info['author'][] = ['name'=>$m[1], 'link'=>$m[2]]; + } else { + $info['author'][] = ['name'=>$v]; + } + } else { + if (array_key_exists($k,$info)) { + $info[$k]=$v; + } + } + + } + } + + } + return $info; + } +} diff --git a/src/Core/Theme.php b/src/Core/Theme.php new file mode 100644 index 000000000..f08d48efb --- /dev/null +++ b/src/Core/Theme.php @@ -0,0 +1,187 @@ + + * * Maintainer: Jane + * * + * \endcode + * @param string $theme the name of the theme + * @return array + */ + + function get_theme_info($theme) { + $info=[ + 'name' => $theme, + 'description' => "", + 'author' => [], + 'maintainer' => [], + 'version' => "", + 'credits' => "", + 'experimental' => false, + 'unsupported' => false + ]; + + if (file_exists("view/theme/$theme/experimental")) + $info['experimental'] = true; + if (file_exists("view/theme/$theme/unsupported")) + $info['unsupported'] = true; + + if (!is_file("view/theme/$theme/theme.php")) return $info; + + $a = get_app(); + $stamp1 = microtime(true); + $f = file_get_contents("view/theme/$theme/theme.php"); + $a->save_timestamp($stamp1, "file"); + + $r = preg_match("|/\*.*\*/|msU", $f, $m); + + if ($r) { + $ll = explode("\n", $m[0]); + foreach ( $ll as $l ) { + $l = trim($l,"\t\n\r */"); + if ($l != "") { + list($k,$v) = array_map("trim", explode(":",$l,2)); + $k= strtolower($k); + if ($k == "author") { + + $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); + if ($r) { + $info['author'][] = ['name'=>$m[1], 'link'=>$m[2]]; + } else { + $info['author'][] = ['name'=>$v]; + } + } elseif ($k == "maintainer") { + $r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); + if ($r) { + $info['maintainer'][] = ['name'=>$m[1], 'link'=>$m[2]]; + } else { + $info['maintainer'][] = ['name'=>$v]; + } + } else { + if (array_key_exists($k,$info)) { + $info[$k]=$v; + } + } + + } + } + + } + return $info; + } + + /** + * @brief Returns the theme's screenshot. + * + * The screenshot is expected as view/theme/$theme/screenshot.[png|jpg]. + * + * @param sring $theme The name of the theme + * @return string + */ + function get_theme_screenshot($theme) { + $exts = ['.png','.jpg']; + foreach ($exts as $ext) { + if (file_exists('view/theme/' . $theme . '/screenshot' . $ext)) { + return(System::baseUrl() . '/view/theme/' . $theme . '/screenshot' . $ext); + } + } + return(System::baseUrl() . '/images/blank.png'); + } + + // install and uninstall theme + function uninstall_theme($theme) { + logger("Addons: uninstalling theme " . $theme); + + include_once("view/theme/$theme/theme.php"); + if (function_exists("{$theme}_uninstall")) { + $func = "{$theme}_uninstall"; + $func(); + } + } + + function install_theme($theme) { + // silently fail if theme was removed + + if (! file_exists("view/theme/$theme/theme.php")) { + return false; + } + + logger("Addons: installing theme $theme"); + + include_once("view/theme/$theme/theme.php"); + + if (function_exists("{$theme}_install")) { + $func = "{$theme}_install"; + $func(); + return true; + } else { + logger("Addons: FAILED installing theme $theme"); + return false; + } + + } + + /** + * @brief Get the full path to relevant theme files by filename + * + * This function search in the theme directory (and if not present in global theme directory) + * if there is a directory with the file extension and for a file with the given + * filename. + * + * @param string $file Filename + * @param string $root Full root path + * @return string Path to the file or empty string if the file isn't found + */ + function theme_include($file, $root = '') { + $file = basename($file); + + // Make sure $root ends with a slash / if it's not blank + if ($root !== '' && $root[strlen($root)-1] !== '/') { + $root = $root . '/'; + } + $theme_info = get_app()->theme_info; + if (is_array($theme_info) && array_key_exists('extends',$theme_info)) { + $parent = $theme_info['extends']; + } else { + $parent = 'NOPATH'; + } + $theme = current_theme(); + $thname = $theme; + $ext = substr($file,strrpos($file,'.')+1); + $paths = [ + "{$root}view/theme/$thname/$ext/$file", + "{$root}view/theme/$parent/$ext/$file", + "{$root}view/$ext/$file", + ]; + foreach ($paths as $p) { + // strpos() is faster than strstr when checking if one string is in another (http://php.net/manual/en/function.strstr.php) + if (strpos($p,'NOPATH') !== false) { + continue; + } elseif (file_exists($p)) { + return $p; + } + } + return ''; + } +} From 11cf36105ccd359c9d21a006e13b3767712196b6 Mon Sep 17 00:00:00 2001 From: Adam Magness Date: Wed, 17 Jan 2018 13:42:40 -0500 Subject: [PATCH 02/11] Update Addon functions and calls Update function names and calls for Addon class. --- boot.php | 8 +- doc/Plugins.md | 180 ++++++++++++++++---------------- doc/de/Plugins.md | 178 +++++++++++++++---------------- include/acl_selectors.php | 19 ++-- include/api.php | 7 +- include/bb2diaspora.php | 3 +- include/bbcode.php | 3 +- include/conversation.php | 13 +-- include/enotify.php | 9 +- include/event.php | 5 +- include/friendica_smarty.php | 3 +- include/html2bbcode.php | 3 +- include/items.php | 13 +-- include/like.php | 3 +- include/network.php | 3 +- include/security.php | 3 +- include/text.php | 11 +- index.php | 25 ++--- mod/admin.php | 11 +- mod/contacts.php | 5 +- mod/directory.php | 3 +- mod/editpost.php | 5 +- mod/friendica.php | 3 +- mod/home.php | 5 +- mod/item.php | 7 +- mod/lockview.php | 3 +- mod/manage.php | 3 +- mod/network.php | 5 +- mod/nodeinfo.php | 43 ++++---- mod/parse_url.php | 3 +- mod/photos.php | 17 +-- mod/ping.php | 3 +- mod/poke.php | 3 +- mod/profile.php | 3 +- mod/profiles.php | 5 +- mod/register.php | 5 +- mod/settings.php | 17 +-- mod/statistics_json.php | 27 ++--- mod/subthread.php | 3 +- mod/tagger.php | 3 +- mod/uexport.php | 3 +- mod/xrd.php | 3 +- scripts/worker.php | 3 +- src/Content/ContactSelector.php | 9 +- src/Content/Feature.php | 5 +- src/Content/Nav.php | 5 +- src/Content/OEmbed.php | 3 +- src/Content/Smilies.php | 3 +- src/Content/Widget.php | 13 +-- src/Core/Addon.php | 138 +++++++++++++----------- src/Core/Worker.php | 3 +- src/Model/Contact.php | 5 +- src/Model/Profile.php | 9 +- src/Model/User.php | 5 +- src/Module/Login.php | 5 +- src/Module/Logout.php | 4 +- src/Network/FKOAuth1.php | 3 +- src/Object/Post.php | 5 +- src/Protocol/DFRN.php | 7 +- src/Util/Emailer.php | 5 +- src/Util/Map.php | 6 +- src/Util/ParseUrl.php | 3 +- src/Worker/Cron.php | 3 +- src/Worker/CronHooks.php | 3 +- src/Worker/Directory.php | 3 +- src/Worker/Expire.php | 5 +- src/Worker/Notifier.php | 5 +- src/Worker/Queue.php | 5 +- update.php | 5 +- view/theme/frio/php/schema.php | 2 +- view/theme/frio/theme.php | 25 ++--- view/theme/frost/theme.php | 5 +- view/theme/vier/theme.php | 31 +++--- 73 files changed, 544 insertions(+), 464 deletions(-) diff --git a/boot.php b/boot.php index 0692e8475..2c4a6fa0a 100644 --- a/boot.php +++ b/boot.php @@ -21,6 +21,7 @@ require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; use Friendica\App; +use Friendica\Core\Addon; use Friendica\Core\System; use Friendica\Core\Cache; use Friendica\Core\Config; @@ -32,7 +33,6 @@ use Friendica\Database\DBStructure; use Friendica\Module\Login; require_once 'include/network.php'; -require_once 'include/plugin.php'; require_once 'include/text.php'; require_once 'include/datetime.php'; require_once 'include/pgettext.php'; @@ -833,7 +833,7 @@ function check_plugins(App $a) if (count($installed)) { foreach ($installed as $i) { if (!in_array($i['name'], $plugins_arr)) { - uninstall_plugin($i['name']); + Addon::uninstall($i['name']); } else { $installed_arr[] = $i['name']; } @@ -843,12 +843,12 @@ function check_plugins(App $a) if (count($plugins_arr)) { foreach ($plugins_arr as $p) { if (!in_array($p, $installed_arr)) { - install_plugin($p); + Addon::install($p); } } } - load_hooks(); + Addon::loadHooks(); return; } diff --git a/doc/Plugins.md b/doc/Plugins.md index ab8c58eb8..995e9184c 100644 --- a/doc/Plugins.md +++ b/doc/Plugins.md @@ -27,7 +27,7 @@ Plugins should contain a comment block with the four following parameters: Register your plugin hooks during installation. - register_hook($hookname, $file, $function); + Addon::registerHook($hookname, $file, $function); $hookname is a string and corresponds to a known Friendica hook. @@ -296,182 +296,182 @@ Complete list of hook callbacks Here is a complete list of all hook callbacks with file locations (as of 14-Feb-2012). Please see the source for details of any hooks not documented above. -boot.php: call_hooks('login_hook',$o); +boot.php: Addon::callHooks('login_hook',$o); -boot.php: call_hooks('profile_sidebar_enter', $profile); +boot.php: Addon::callHooks('profile_sidebar_enter', $profile); -boot.php: call_hooks('profile_sidebar', $arr); +boot.php: Addon::callHooks('profile_sidebar', $arr); -boot.php: call_hooks("proc_run", $arr); +boot.php: Addon::callHooks("proc_run", $arr); -include/contact_selectors.php: call_hooks('network_to_name', $nets); +include/contact_selectors.php: Addon::callHooks('network_to_name', $nets); -include/api.php: call_hooks('logged_in', $a->user); +include/api.php: Addon::callHooks('logged_in', $a->user); -include/api.php: call_hooks('logged_in', $a->user); +include/api.php: Addon::callHooks('logged_in', $a->user); -include/queue.php: call_hooks('queue_predeliver', $a, $r); +include/queue.php: Addon::callHooks('queue_predeliver', $a, $r); -include/queue.php: call_hooks('queue_deliver', $a, $params); +include/queue.php: Addon::callHooks('queue_deliver', $a, $params); -include/text.php: call_hooks('contact_block_end', $arr); +include/text.php: Addon::callHooks('contact_block_end', $arr); -include/text.php: call_hooks('smilie', $s); +include/text.php: Addon::callHooks('smilie', $s); -include/text.php: call_hooks('prepare_body_init', $item); +include/text.php: Addon::callHooks('prepare_body_init', $item); -include/text.php: call_hooks('prepare_body', $prep_arr); +include/text.php: Addon::callHooks('prepare_body', $prep_arr); -include/text.php: call_hooks('prepare_body_final', $prep_arr); +include/text.php: Addon::callHooks('prepare_body_final', $prep_arr); -include/nav.php: call_hooks('page_header', $a->page['nav']); +include/nav.php: Addon::callHooks('page_header', $a->page['nav']); -include/auth.php: call_hooks('authenticate', $addon_auth); +include/auth.php: Addon::callHooks('authenticate', $addon_auth); -include/bbcode.php: call_hooks('bbcode',$Text); +include/bbcode.php: Addon::callHooks('bbcode',$Text); -include/oauth.php: call_hooks('logged_in', $a->user); +include/oauth.php: Addon::callHooks('logged_in', $a->user); -include/acl_selectors.php: call_hooks($a->module . '_pre_' . $selname, $arr); +include/acl_selectors.php: Addon::callHooks($a->module . '_pre_' . $selname, $arr); -include/acl_selectors.php: call_hooks($a->module . '_post_' . $selname, $o); +include/acl_selectors.php: Addon::callHooks($a->module . '_post_' . $selname, $o); -include/acl_selectors.php: call_hooks('contact_select_options', $x); +include/acl_selectors.php: Addon::callHooks('contact_select_options', $x); -include/acl_selectors.php: call_hooks($a->module . '_pre_' . $selname, $arr); +include/acl_selectors.php: Addon::callHooks($a->module . '_pre_' . $selname, $arr); -include/acl_selectors.php: call_hooks($a->module . '_post_' . $selname, $o); +include/acl_selectors.php: Addon::callHooks($a->module . '_post_' . $selname, $o); -include/acl_selectors.php: call_hooks($a->module . '_pre_' . $selname, $arr); +include/acl_selectors.php: Addon::callHooks($a->module . '_pre_' . $selname, $arr); -include/acl_selectors.php: call_hooks($a->module . '_post_' . $selname, $o); +include/acl_selectors.php: Addon::callHooks($a->module . '_post_' . $selname, $o); -include/acl_selectors.php call_hooks('acl_lookup_end', $results); +include/acl_selectors.php Addon::callHooks('acl_lookup_end', $results); -include/notifier.php: call_hooks('notifier_normal',$target_item); +include/notifier.php: Addon::callHooks('notifier_normal',$target_item); -include/notifier.php: call_hooks('notifier_end',$target_item); +include/notifier.php: Addon::callHooks('notifier_end',$target_item); -include/items.php: call_hooks('atom_feed', $atom); +include/items.php: Addon::callHooks('atom_feed', $atom); -include/items.php: call_hooks('atom_feed_end', $atom); +include/items.php: Addon::callHooks('atom_feed_end', $atom); -include/items.php: call_hooks('atom_feed_end', $atom); +include/items.php: Addon::callHooks('atom_feed_end', $atom); -include/items.php: call_hooks('parse_atom', $arr); +include/items.php: Addon::callHooks('parse_atom', $arr); -include/items.php: call_hooks('post_remote',$arr); +include/items.php: Addon::callHooks('post_remote',$arr); -include/items.php: call_hooks('atom_author', $o); +include/items.php: Addon::callHooks('atom_author', $o); -include/items.php: call_hooks('atom_entry', $o); +include/items.php: Addon::callHooks('atom_entry', $o); -include/bb2diaspora.php: call_hooks('bb2diaspora',$Text); +include/bb2diaspora.php: Addon::callHooks('bb2diaspora',$Text); -include/cronhooks.php: call_hooks('cron', $d); +include/cronhooks.php: Addon::callHooks('cron', $d); -include/security.php: call_hooks('logged_in', $a->user); +include/security.php: Addon::callHooks('logged_in', $a->user); -include/html2bbcode.php: call_hooks('html2bbcode', $text); +include/html2bbcode.php: Addon::callHooks('html2bbcode', $text); -include/Contact.php: call_hooks('remove_user',$r[0]); +include/Contact.php: Addon::callHooks('remove_user',$r[0]); -include/Contact.php: call_hooks('contact_photo_menu', $args); +include/Contact.php: Addon::callHooks('contact_photo_menu', $args); -include/conversation.php: call_hooks('conversation_start',$cb); +include/conversation.php: Addon::callHooks('conversation_start',$cb); -include/conversation.php: call_hooks('render_location',$locate); +include/conversation.php: Addon::callHooks('render_location',$locate); -include/conversation.php: call_hooks('display_item', $arr); +include/conversation.php: Addon::callHooks('display_item', $arr); -include/conversation.php: call_hooks('render_location',$locate); +include/conversation.php: Addon::callHooks('render_location',$locate); -include/conversation.php: call_hooks('display_item', $arr); +include/conversation.php: Addon::callHooks('display_item', $arr); -include/conversation.php: call_hooks('item_photo_menu', $args); +include/conversation.php: Addon::callHooks('item_photo_menu', $args); -include/conversation.php: call_hooks('jot_tool', $jotplugins); +include/conversation.php: Addon::callHooks('jot_tool', $jotplugins); -include/conversation.php: call_hooks('jot_networks', $jotnets); +include/conversation.php: Addon::callHooks('jot_networks', $jotnets); include/plugin.php:if(! function_exists('call_hooks')) { -include/plugin.php:function call_hooks($name, &$data = null) { +include/plugin.php:function Addon::callHooks($name, &$data = null) { -index.php: call_hooks('init_1'); +index.php: Addon::callHooks('init_1'); -index.php:call_hooks('app_menu', $arr); +index.php:Addon::callHooks('app_menu', $arr); -index.php:call_hooks('page_end', $a->page['content']); +index.php:Addon::callHooks('page_end', $a->page['content']); -mod/photos.php: call_hooks('photo_post_init', $_POST); +mod/photos.php: Addon::callHooks('photo_post_init', $_POST); -mod/photos.php: call_hooks('photo_post_file',$ret); +mod/photos.php: Addon::callHooks('photo_post_file',$ret); -mod/photos.php: call_hooks('photo_post_end',$foo); +mod/photos.php: Addon::callHooks('photo_post_end',$foo); -mod/photos.php: call_hooks('photo_post_end',$foo); +mod/photos.php: Addon::callHooks('photo_post_end',$foo); -mod/photos.php: call_hooks('photo_post_end',$foo); +mod/photos.php: Addon::callHooks('photo_post_end',$foo); -mod/photos.php: call_hooks('photo_post_end',intval($item_id)); +mod/photos.php: Addon::callHooks('photo_post_end',intval($item_id)); -mod/photos.php: call_hooks('photo_upload_form',$ret); +mod/photos.php: Addon::callHooks('photo_upload_form',$ret); -mod/friendica.php: call_hooks('about_hook', $o); +mod/friendica.php: Addon::callHooks('about_hook', $o); -mod/editpost.php: call_hooks('jot_tool', $jotplugins); +mod/editpost.php: Addon::callHooks('jot_tool', $jotplugins); -mod/editpost.php: call_hooks('jot_networks', $jotnets); +mod/editpost.php: Addon::callHooks('jot_networks', $jotnets); -mod/parse_url.php: call_hooks('parse_link', $arr); +mod/parse_url.php: Addon::callHooks('parse_link', $arr); -mod/home.php: call_hooks('home_init',$ret); +mod/home.php: Addon::callHooks('home_init',$ret); -mod/home.php: call_hooks("home_content",$o); +mod/home.php: Addon::callHooks("home_content",$o); -mod/contacts.php: call_hooks('contact_edit_post', $_POST); +mod/contacts.php: Addon::callHooks('contact_edit_post', $_POST); -mod/contacts.php: call_hooks('contact_edit', $arr); +mod/contacts.php: Addon::callHooks('contact_edit', $arr); -mod/settings.php: call_hooks('plugin_settings_post', $_POST); +mod/settings.php: Addon::callHooks('plugin_settings_post', $_POST); -mod/settings.php: call_hooks('connector_settings_post', $_POST); +mod/settings.php: Addon::callHooks('connector_settings_post', $_POST); -mod/settings.php: call_hooks('settings_post', $_POST); +mod/settings.php: Addon::callHooks('settings_post', $_POST); -mod/settings.php: call_hooks('plugin_settings', $settings_addons); +mod/settings.php: Addon::callHooks('plugin_settings', $settings_addons); -mod/settings.php: call_hooks('connector_settings', $settings_connectors); +mod/settings.php: Addon::callHooks('connector_settings', $settings_connectors); -mod/settings.php: call_hooks('settings_form',$o); +mod/settings.php: Addon::callHooks('settings_form',$o); -mod/register.php: call_hooks('register_account', $newuid); +mod/register.php: Addon::callHooks('register_account', $newuid); -mod/like.php: call_hooks('post_local_end', $arr); +mod/like.php: Addon::callHooks('post_local_end', $arr); -mod/xrd.php: call_hooks('personal_xrd', $arr); +mod/xrd.php: Addon::callHooks('personal_xrd', $arr); -mod/item.php: call_hooks('post_local_start', $_REQUEST); +mod/item.php: Addon::callHooks('post_local_start', $_REQUEST); -mod/item.php: call_hooks('post_local',$datarray); +mod/item.php: Addon::callHooks('post_local',$datarray); -mod/item.php: call_hooks('post_local_end', $datarray); +mod/item.php: Addon::callHooks('post_local_end', $datarray); -mod/profile.php: call_hooks('profile_advanced',$o); +mod/profile.php: Addon::callHooks('profile_advanced',$o); -mod/profiles.php: call_hooks('profile_post', $_POST); +mod/profiles.php: Addon::callHooks('profile_post', $_POST); -mod/profiles.php: call_hooks('profile_edit', $arr); +mod/profiles.php: Addon::callHooks('profile_edit', $arr); -mod/tagger.php: call_hooks('post_local_end', $arr); +mod/tagger.php: Addon::callHooks('post_local_end', $arr); -mod/cb.php: call_hooks('cb_init'); +mod/cb.php: Addon::callHooks('cb_init'); -mod/cb.php: call_hooks('cb_post', $_POST); +mod/cb.php: Addon::callHooks('cb_post', $_POST); -mod/cb.php: call_hooks('cb_afterpost'); +mod/cb.php: Addon::callHooks('cb_afterpost'); -mod/cb.php: call_hooks('cb_content', $o); +mod/cb.php: Addon::callHooks('cb_content', $o); -mod/directory.php: call_hooks('directory_item', $arr); +mod/directory.php: Addon::callHooks('directory_item', $arr); diff --git a/doc/de/Plugins.md b/doc/de/Plugins.md index 8b1c71177..6ad3ac8f7 100644 --- a/doc/de/Plugins.md +++ b/doc/de/Plugins.md @@ -26,7 +26,7 @@ Plugins sollten einen Kommentarblock mit den folgenden vier Parametern enthalten Registriere deine Plugin-Hooks während der Installation. - register_hook($hookname, $file, $function); + Addon::registerHook($hookname, $file, $function); $hookname ist ein String und entspricht einem bekannten Friendica-Hook. @@ -191,180 +191,180 @@ Komplette Liste der Hook-Callbacks Eine komplette Liste aller Hook-Callbacks mit den zugehörigen Dateien (am 14-Feb-2012 generiert): Bitte schau in die Quellcodes für Details zu Hooks, die oben nicht dokumentiert sind. -boot.php: call_hooks('login_hook',$o); +boot.php: Addon::callHooks('login_hook',$o); -boot.php: call_hooks('profile_sidebar_enter', $profile); +boot.php: Addon::callHooks('profile_sidebar_enter', $profile); -boot.php: call_hooks('profile_sidebar', $arr); +boot.php: Addon::callHooks('profile_sidebar', $arr); -boot.php: call_hooks("proc_run", $arr); +boot.php: Addon::callHooks("proc_run", $arr); -include/contact_selectors.php: call_hooks('network_to_name', $nets); +include/contact_selectors.php: Addon::callHooks('network_to_name', $nets); -include/api.php: call_hooks('logged_in', $a->user); +include/api.php: Addon::callHooks('logged_in', $a->user); -include/api.php: call_hooks('logged_in', $a->user); +include/api.php: Addon::callHooks('logged_in', $a->user); -include/queue.php: call_hooks('queue_predeliver', $a, $r); +include/queue.php: Addon::callHooks('queue_predeliver', $a, $r); -include/queue.php: call_hooks('queue_deliver', $a, $params); +include/queue.php: Addon::callHooks('queue_deliver', $a, $params); -include/text.php: call_hooks('contact_block_end', $arr); +include/text.php: Addon::callHooks('contact_block_end', $arr); -include/text.php: call_hooks('smilie', $s); +include/text.php: Addon::callHooks('smilie', $s); -include/text.php: call_hooks('prepare_body_init', $item); +include/text.php: Addon::callHooks('prepare_body_init', $item); -include/text.php: call_hooks('prepare_body', $prep_arr); +include/text.php: Addon::callHooks('prepare_body', $prep_arr); -include/text.php: call_hooks('prepare_body_final', $prep_arr); +include/text.php: Addon::callHooks('prepare_body_final', $prep_arr); -include/nav.php: call_hooks('page_header', $a->page['nav']); +include/nav.php: Addon::callHooks('page_header', $a->page['nav']); -include/auth.php: call_hooks('authenticate', $addon_auth); +include/auth.php: Addon::callHooks('authenticate', $addon_auth); -include/bbcode.php: call_hooks('bbcode',$Text); +include/bbcode.php: Addon::callHooks('bbcode',$Text); -include/oauth.php: call_hooks('logged_in', $a->user); +include/oauth.php: Addon::callHooks('logged_in', $a->user); -include/acl_selectors.php: call_hooks($a->module . '_pre_' . $selname, $arr); +include/acl_selectors.php: Addon::callHooks($a->module . '_pre_' . $selname, $arr); -include/acl_selectors.php: call_hooks($a->module . '_post_' . $selname, $o); +include/acl_selectors.php: Addon::callHooks($a->module . '_post_' . $selname, $o); -include/acl_selectors.php: call_hooks('contact_select_options', $x); +include/acl_selectors.php: Addon::callHooks('contact_select_options', $x); -include/acl_selectors.php: call_hooks($a->module . '_pre_' . $selname, $arr); +include/acl_selectors.php: Addon::callHooks($a->module . '_pre_' . $selname, $arr); -include/acl_selectors.php: call_hooks($a->module . '_post_' . $selname, $o); +include/acl_selectors.php: Addon::callHooks($a->module . '_post_' . $selname, $o); -include/acl_selectors.php: call_hooks($a->module . '_pre_' . $selname, $arr); +include/acl_selectors.php: Addon::callHooks($a->module . '_pre_' . $selname, $arr); -include/acl_selectors.php: call_hooks($a->module . '_post_' . $selname, $o); +include/acl_selectors.php: Addon::callHooks($a->module . '_post_' . $selname, $o); -include/notifier.php: call_hooks('notifier_normal',$target_item); +include/notifier.php: Addon::callHooks('notifier_normal',$target_item); -include/notifier.php: call_hooks('notifier_end',$target_item); +include/notifier.php: Addon::callHooks('notifier_end',$target_item); -include/items.php: call_hooks('atom_feed', $atom); +include/items.php: Addon::callHooks('atom_feed', $atom); -include/items.php: call_hooks('atom_feed_end', $atom); +include/items.php: Addon::callHooks('atom_feed_end', $atom); -include/items.php: call_hooks('atom_feed_end', $atom); +include/items.php: Addon::callHooks('atom_feed_end', $atom); -include/items.php: call_hooks('parse_atom', $arr); +include/items.php: Addon::callHooks('parse_atom', $arr); -include/items.php: call_hooks('post_remote',$arr); +include/items.php: Addon::callHooks('post_remote',$arr); -include/items.php: call_hooks('atom_author', $o); +include/items.php: Addon::callHooks('atom_author', $o); -include/items.php: call_hooks('atom_entry', $o); +include/items.php: Addon::callHooks('atom_entry', $o); -include/bb2diaspora.php: call_hooks('bb2diaspora',$Text); +include/bb2diaspora.php: Addon::callHooks('bb2diaspora',$Text); -include/cronhooks.php: call_hooks('cron', $d); +include/cronhooks.php: Addon::callHooks('cron', $d); -include/security.php: call_hooks('logged_in', $a->user); +include/security.php: Addon::callHooks('logged_in', $a->user); -include/html2bbcode.php: call_hooks('html2bbcode', $text); +include/html2bbcode.php: Addon::callHooks('html2bbcode', $text); -include/Contact.php: call_hooks('remove_user',$r[0]); +include/Contact.php: Addon::callHooks('remove_user',$r[0]); -include/Contact.php: call_hooks('contact_photo_menu', $args); +include/Contact.php: Addon::callHooks('contact_photo_menu', $args); -include/conversation.php: call_hooks('conversation_start',$cb); +include/conversation.php: Addon::callHooks('conversation_start',$cb); -include/conversation.php: call_hooks('render_location',$locate); +include/conversation.php: Addon::callHooks('render_location',$locate); -include/conversation.php: call_hooks('display_item', $arr); +include/conversation.php: Addon::callHooks('display_item', $arr); -include/conversation.php: call_hooks('render_location',$locate); +include/conversation.php: Addon::callHooks('render_location',$locate); -include/conversation.php: call_hooks('display_item', $arr); +include/conversation.php: Addon::callHooks('display_item', $arr); -include/conversation.php: call_hooks('item_photo_menu', $args); +include/conversation.php: Addon::callHooks('item_photo_menu', $args); -include/conversation.php: call_hooks('jot_tool', $jotplugins); +include/conversation.php: Addon::callHooks('jot_tool', $jotplugins); -include/conversation.php: call_hooks('jot_networks', $jotnets); +include/conversation.php: Addon::callHooks('jot_networks', $jotnets); include/plugin.php: if(! function_exists('call_hooks')) { -include/plugin.php:function call_hooks($name, &$data = null) { +include/plugin.php:function Addon::callHooks($name, &$data = null) { -index.php: call_hooks('init_1'); +index.php: Addon::callHooks('init_1'); -index.php: call_hooks('app_menu', $arr); +index.php: Addon::callHooks('app_menu', $arr); -index.php: call_hooks('page_end', $a->page['content']); +index.php: Addon::callHooks('page_end', $a->page['content']); -mod/photos.php: call_hooks('photo_post_init', $_POST); +mod/photos.php: Addon::callHooks('photo_post_init', $_POST); -mod/photos.php: call_hooks('photo_post_file',$ret); +mod/photos.php: Addon::callHooks('photo_post_file',$ret); -mod/photos.php: call_hooks('photo_post_end',$foo); +mod/photos.php: Addon::callHooks('photo_post_end',$foo); -mod/photos.php: call_hooks('photo_post_end',$foo); +mod/photos.php: Addon::callHooks('photo_post_end',$foo); -mod/photos.php: call_hooks('photo_post_end',$foo); +mod/photos.php: Addon::callHooks('photo_post_end',$foo); -mod/photos.php: call_hooks('photo_post_end',intval($item_id)); +mod/photos.php: Addon::callHooks('photo_post_end',intval($item_id)); -mod/photos.php: call_hooks('photo_upload_form',$ret); +mod/photos.php: Addon::callHooks('photo_upload_form',$ret); -mod/friendica.php: call_hooks('about_hook', $o); +mod/friendica.php: Addon::callHooks('about_hook', $o); -mod/editpost.php: call_hooks('jot_tool', $jotplugins); +mod/editpost.php: Addon::callHooks('jot_tool', $jotplugins); -mod/editpost.php: call_hooks('jot_networks', $jotnets); +mod/editpost.php: Addon::callHooks('jot_networks', $jotnets); -mod/parse_url.php: call_hooks('parse_link', $arr); +mod/parse_url.php: Addon::callHooks('parse_link', $arr); -mod/home.php: call_hooks('home_init',$ret); +mod/home.php: Addon::callHooks('home_init',$ret); -mod/home.php: call_hooks("home_content",$o); +mod/home.php: Addon::callHooks("home_content",$o); -mod/contacts.php: call_hooks('contact_edit_post', $_POST); +mod/contacts.php: Addon::callHooks('contact_edit_post', $_POST); -mod/contacts.php: call_hooks('contact_edit', $arr); +mod/contacts.php: Addon::callHooks('contact_edit', $arr); -mod/settings.php: call_hooks('plugin_settings_post', $_POST); +mod/settings.php: Addon::callHooks('plugin_settings_post', $_POST); -mod/settings.php: call_hooks('connector_settings_post', $_POST); +mod/settings.php: Addon::callHooks('connector_settings_post', $_POST); -mod/settings.php: call_hooks('settings_post', $_POST); +mod/settings.php: Addon::callHooks('settings_post', $_POST); -mod/settings.php: call_hooks('plugin_settings', $settings_addons); +mod/settings.php: Addon::callHooks('plugin_settings', $settings_addons); -mod/settings.php: call_hooks('connector_settings', $settings_connectors); +mod/settings.php: Addon::callHooks('connector_settings', $settings_connectors); -mod/settings.php: call_hooks('settings_form',$o); +mod/settings.php: Addon::callHooks('settings_form',$o); -mod/register.php: call_hooks('register_account', $newuid); +mod/register.php: Addon::callHooks('register_account', $newuid); -mod/like.php: call_hooks('post_local_end', $arr); +mod/like.php: Addon::callHooks('post_local_end', $arr); -mod/xrd.php: call_hooks('personal_xrd', $arr); +mod/xrd.php: Addon::callHooks('personal_xrd', $arr); -mod/item.php: call_hooks('post_local_start', $_REQUEST); +mod/item.php: Addon::callHooks('post_local_start', $_REQUEST); -mod/item.php: call_hooks('post_local',$datarray); +mod/item.php: Addon::callHooks('post_local',$datarray); -mod/item.php: call_hooks('post_local_end', $datarray); +mod/item.php: Addon::callHooks('post_local_end', $datarray); -mod/profile.php: call_hooks('profile_advanced',$o); +mod/profile.php: Addon::callHooks('profile_advanced',$o); -mod/profiles.php: call_hooks('profile_post', $_POST); +mod/profiles.php: Addon::callHooks('profile_post', $_POST); -mod/profiles.php: call_hooks('profile_edit', $arr); +mod/profiles.php: Addon::callHooks('profile_edit', $arr); -mod/tagger.php: call_hooks('post_local_end', $arr); +mod/tagger.php: Addon::callHooks('post_local_end', $arr); -mod/cb.php: call_hooks('cb_init'); +mod/cb.php: Addon::callHooks('cb_init'); -mod/cb.php: call_hooks('cb_post', $_POST); +mod/cb.php: Addon::callHooks('cb_post', $_POST); -mod/cb.php: call_hooks('cb_afterpost'); +mod/cb.php: Addon::callHooks('cb_afterpost'); -mod/cb.php: call_hooks('cb_content', $o); +mod/cb.php: Addon::callHooks('cb_content', $o); -mod/directory.php: call_hooks('directory_item', $arr); +mod/directory.php: Addon::callHooks('directory_item', $arr); diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 5be3fd1f3..caa3e98c2 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -5,6 +5,7 @@ use Friendica\App; use Friendica\Content\Feature; use Friendica\Content\Widget; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Database\DBM; use Friendica\Model\Contact; @@ -32,7 +33,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { // e.g. 'network_pre_group_deny', 'profile_pre_group_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + Addon::callHooks($a->module . '_pre_' . $selname, $arr); if (DBM::is_result($r)) { foreach ($r as $rr) { @@ -50,7 +51,7 @@ function group_select($selname,$selclass,$preselected = false,$size = 4) { } $o .= "\r\n"; - call_hooks($a->module . '_post_' . $selname, $o); + Addon::callHooks($a->module . '_post_' . $selname, $o); return $o; @@ -111,7 +112,7 @@ function contact_selector($selname, $selclass, $options, $preselected = false) $x = ['options' => $options, 'size' => $size, 'single' => $single, 'mutual' => $mutual, 'exclude' => $exclude, 'networks' => $networks]; - call_hooks('contact_select_options', $x); + Addon::callHooks('contact_select_options', $x); $o = ''; @@ -154,7 +155,7 @@ function contact_selector($selname, $selclass, $options, $preselected = false) // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + Addon::callHooks($a->module . '_pre_' . $selname, $arr); if (DBM::is_result($r)) { foreach ($r as $rr) { @@ -173,7 +174,7 @@ function contact_selector($selname, $selclass, $options, $preselected = false) $o .= "\r\n"; - call_hooks($a->module . '_post_' . $selname, $o); + Addon::callHooks($a->module . '_post_' . $selname, $o); return $o; } @@ -232,7 +233,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p // e.g. 'network_pre_contact_deny', 'profile_pre_contact_allow' - call_hooks($a->module . '_pre_' . $selname, $arr); + Addon::callHooks($a->module . '_pre_' . $selname, $arr); $receiverlist = []; @@ -263,7 +264,7 @@ function contact_select($selname, $selclass, $preselected = false, $size = 4, $p $o .= implode(", ", $receiverlist); } - call_hooks($a->module . '_post_' . $selname, $o); + Addon::callHooks($a->module . '_post_' . $selname, $o); return $o; } @@ -353,7 +354,7 @@ function populate_acl($user = null, $show_jotnets = false) { $jotnets .= '
' . t("Post to Email") . '
'; } - call_hooks('jot_networks', $jotnets); + Addon::callHooks('jot_networks', $jotnets); } else { $jotnets .= sprintf(t('Connectors disabled, since "%s" is enabled.'), t('Hide your profile details from unknown viewers?')); @@ -671,7 +672,7 @@ function acl_lookup(App $a, $out_type = 'json') 'search' => $search, ]; - call_hooks('acl_lookup_end', $results); + Addon::callHooks('acl_lookup_end', $results); if ($out_type === 'html') { $o = [ diff --git a/include/api.php b/include/api.php index b4fdb646f..7011f613d 100644 --- a/include/api.php +++ b/include/api.php @@ -8,6 +8,7 @@ use Friendica\App; use Friendica\Content\ContactSelector; use Friendica\Content\Feature; +use Friendica\Core\Addon; use Friendica\Core\System; use Friendica\Core\Config; use Friendica\Core\NotificationsManager; @@ -166,7 +167,7 @@ function api_login(App $a) list($consumer, $token) = $oauth1->verify_request(OAuthRequest::from_request()); if (!is_null($token)) { $oauth1->loginUser($token->uid); - call_hooks('logged_in', $a->user); + Addon::callHooks('logged_in', $a->user); return; } echo __FILE__.__LINE__.__FUNCTION__ . "
";
@@ -216,7 +217,7 @@ function api_login(App $a)
 		* Plugins should never set 'authenticated' except to indicate success - as hooks may be chained
 		* and later plugins should not interfere with an earlier one that succeeded.
 		*/
-	call_hooks('authenticate', $addon_auth);
+	Addon::callHooks('authenticate', $addon_auth);
 
 	if ($addon_auth['authenticated'] && count($addon_auth['user_record'])) {
 		$record = $addon_auth['user_record'];
@@ -239,7 +240,7 @@ function api_login(App $a)
 
 	$_SESSION["allow_api"] = true;
 
-	call_hooks('logged_in', $a->user);
+	Addon::callHooks('logged_in', $a->user);
 }
 
 /**
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index fc25a584a..4856d18ab 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -1,6 +1,7 @@
 
  • ', '
  • ', $Text); //$Text = str_replace('
    $items, 'mode' => $mode, 'update' => $update, 'preview' => $preview]; - call_hooks('conversation_start',$cb); + Addon::callHooks('conversation_start',$cb); $items = $cb['items']; @@ -731,7 +732,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { } $locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => '']; - call_hooks('render_location',$locate); + Addon::callHooks('render_location',$locate); $location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate)); @@ -820,7 +821,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { ]; $arr = ['item' => $item, 'output' => $tmp_item]; - call_hooks('display_item', $arr); + Addon::callHooks('display_item', $arr); $threads[$threadsid]['id'] = $item['item_id']; $threads[$threadsid]['network'] = $item['item_network']; @@ -864,7 +865,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false) { continue; } - call_hooks('display_item', $arr); + Addon::callHooks('display_item', $arr); $item['pagedrop'] = $page_dropping; @@ -1075,7 +1076,7 @@ function item_photo_menu($item) { $args = ['item' => $item, 'menu' => $menu]; - call_hooks('item_photo_menu', $args); + Addon::callHooks('item_photo_menu', $args); $menu = $args['menu']; @@ -1297,7 +1298,7 @@ function status_editor(App $a, $x, $notes_cid = 0, $popup = false) ]); $jotplugins = ''; - call_hooks('jot_tool', $jotplugins); + Addon::callHooks('jot_tool', $jotplugins); // Private/public post links for the non-JS ACL form $private_post = 1; diff --git a/include/enotify.php b/include/enotify.php index 286a372e9..ab4bbc6db 100644 --- a/include/enotify.php +++ b/include/enotify.php @@ -3,6 +3,7 @@ * @file include/enotify.php */ use Friendica\App; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\System; use Friendica\Database\DBM; @@ -398,7 +399,7 @@ function notification($params) 'itemlink' => $itemlink ]; - call_hooks('enotify', $h); + Addon::callHooks('enotify', $h); $subject = $h['subject']; @@ -440,7 +441,7 @@ function notification($params) $datarray['otype'] = $params['otype']; $datarray['abort'] = false; - call_hooks('enotify_store', $datarray); + Addon::callHooks('enotify_store', $datarray); if ($datarray['abort']) { pop_lang(); @@ -576,7 +577,7 @@ function notification($params) $datarray['subject'] = $subject; $datarray['headers'] = $additional_mail_header; - call_hooks('enotify_mail', $datarray); + Addon::callHooks('enotify_mail', $datarray); // check whether sending post content in email notifications is allowed // always true for SYSTEM_EMAIL @@ -667,7 +668,7 @@ function check_user_notification($itemid) { */ function check_item_notification($itemid, $uid, $defaulttype = "") { $notification_data = ["uid" => $uid, "profiles" => []]; - call_hooks('check_item_notification', $notification_data); + Addon::callHooks('check_item_notification', $notification_data); $profiles = $notification_data["profiles"]; diff --git a/include/event.php b/include/event.php index d4c97c750..64ccf3f53 100644 --- a/include/event.php +++ b/include/event.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\Content\Feature; +use Friendica\Core\Addon; use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBM; @@ -328,7 +329,7 @@ function event_store($arr) { $item_id = 0; } - call_hooks("event_updated", $arr['id']); + Addon::callHooks("event_updated", $arr['id']); return $item_id; } else { @@ -406,7 +407,7 @@ function event_store($arr) { ); } - call_hooks("event_created", $event['id']); + Addon::callHooks("event_created", $event['id']); return $item_id; } diff --git a/include/friendica_smarty.php b/include/friendica_smarty.php index 1992a3716..f0d819d62 100644 --- a/include/friendica_smarty.php +++ b/include/friendica_smarty.php @@ -1,5 +1,6 @@ basename($s->filename), "vars" => $r ]; - call_hooks("template_vars", $arr); + Addon::callHooks("template_vars", $arr); $r = $arr['vars']; foreach ($r as $key => $value) { diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 75f05f453..2404e42f6 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -8,6 +8,7 @@ * https://github.com/annando/Syncom */ +use Friendica\Core\Addon; use Friendica\Util\XML; function node2bbcode(&$doc, $oldnode, $attributes, $startbb, $endbb) @@ -261,7 +262,7 @@ function html2bbcode($message, $basepath = '') $message = preg_replace('=\r *\r=i', "\n", $message); $message = str_replace("\r", "\n", $message); - call_hooks('html2bbcode', $message); + Addon::callHooks('html2bbcode', $message); $message = strip_tags($message); diff --git a/include/items.php b/include/items.php index e99799ad6..be370b3d1 100644 --- a/include/items.php +++ b/include/items.php @@ -4,6 +4,7 @@ */ use Friendica\App; use Friendica\Content\Feature; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Core\Worker; @@ -157,7 +158,7 @@ function title_is_body($title, $body) { } function add_page_info_data($data) { - call_hooks('page_info_data', $data); + Addon::callHooks('page_info_data', $data); // It maybe is a rich content, but if it does have everything that a link has, // then treat it that way @@ -943,9 +944,9 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f put_item_in_cache($arr); if ($notify) { - call_hooks('post_local', $arr); + Addon::callHooks('post_local', $arr); } else { - call_hooks('post_remote', $arr); + Addon::callHooks('post_remote', $arr); } // This array field is used to trigger some automatic reactions @@ -1086,9 +1087,9 @@ function item_store($arr, $force_parent = false, $notify = false, $dontcache = f $r = q('SELECT * FROM `item` WHERE `id` = %d', intval($current_post)); if ((DBM::is_result($r)) && (count($r) == 1)) { if ($notify) { - call_hooks('post_local_end', $r[0]); + Addon::callHooks('post_local_end', $r[0]); } else { - call_hooks('post_remote_end', $r[0]); + Addon::callHooks('post_remote_end', $r[0]); } } else { logger('item_store: new item not found in DB, id ' . $current_post); @@ -1364,7 +1365,7 @@ function tag_deliver($uid, $item_id) $arr = ['item' => $item, 'user' => $u[0], 'contact' => $r[0]]; - call_hooks('tagged', $arr); + Addon::callHooks('tagged', $arr); if ((! $community_page) && (! $prvgroup)) { return; diff --git a/include/like.php b/include/like.php index f89b7a82e..1dbdcc936 100644 --- a/include/like.php +++ b/include/like.php @@ -1,6 +1,7 @@ user); + Addon::callHooks('logged_in', $a->user); if (($a->module !== 'home') && isset($_SESSION['return_url'])) { goaway(System::baseUrl() . '/' . $_SESSION['return_url']); diff --git a/include/text.php b/include/text.php index 5ce0b850e..6856d28aa 100644 --- a/include/text.php +++ b/include/text.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\Content\ContactSelector; use Friendica\Content\Feature; use Friendica\Content\Smilies; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Core\System; @@ -969,7 +970,7 @@ function contact_block() { $arr = ['contacts' => $r, 'output' => $o]; - call_hooks('contact_block_end', $arr); + Addon::callHooks('contact_block_end', $arr); return $o; } @@ -1123,7 +1124,7 @@ function get_poke_verbs() { 'finger' => ['fingered', t('finger'), t('fingered')], 'rebuff' => ['rebuffed', t('rebuff'), t('rebuffed')], ]; - call_hooks('poke_verbs', $arr); + Addon::callHooks('poke_verbs', $arr); return $arr; } @@ -1255,7 +1256,7 @@ function put_item_in_cache(&$item, $update = false) function prepare_body(&$item, $attach = false, $preview = false) { $a = get_app(); - call_hooks('prepare_body_init', $item); + Addon::callHooks('prepare_body_init', $item); $searchpath = System::baseUrl() . "/search?tag="; @@ -1314,7 +1315,7 @@ function prepare_body(&$item, $attach = false, $preview = false) { $s = $item["rendered-html"]; $prep_arr = ['item' => $item, 'html' => $s, 'preview' => $preview]; - call_hooks('prepare_body', $prep_arr); + Addon::callHooks('prepare_body', $prep_arr); $s = $prep_arr['html']; if (! $attach) { @@ -1432,7 +1433,7 @@ function prepare_body(&$item, $attach = false, $preview = false) { } $prep_arr = ['item' => $item, 'html' => $s]; - call_hooks('prepare_body_final', $prep_arr); + Addon::callHooks('prepare_body_final', $prep_arr); return $prep_arr['html']; } diff --git a/index.php b/index.php index dcb25cc3a..c4ccc9ef2 100644 --- a/index.php +++ b/index.php @@ -11,6 +11,7 @@ use Friendica\App; use Friendica\BaseObject; use Friendica\Content\Nav; +use Friendica\Core\Addon; use Friendica\Core\System; use Friendica\Core\Config; use Friendica\Core\Worker; @@ -75,8 +76,8 @@ if (!$install) { } require_once 'include/session.php'; - load_hooks(); - call_hooks('init_1'); + Addon::loadHooks(); + Addon::callHooks('init_1'); $maintenance = Config::get('system', 'maintenance'); } @@ -200,7 +201,7 @@ $privateapps = Config::get('config', 'private_addons'); if ((local_user()) || (! $privateapps === "1")) { $arr = ['app_menu' => $a->apps]; - call_hooks('app_menu', $arr); + Addon::callHooks('app_menu', $arr); $a->apps = $arr['app_menu']; } @@ -243,7 +244,7 @@ if (strlen($a->module)) { if (is_array($a->plugins) && in_array($a->module, $a->plugins) && file_exists("addon/{$a->module}/{$a->module}.php")) { //Check if module is an app and if public access to apps is allowed or not - if ((!local_user()) && plugin_is_app($a->module) && $privateapps === "1") { + if ((!local_user()) && Addon::isApp($a->module) && $privateapps === "1") { info(t("You must be logged in to use addons. ")); } else { include_once "addon/{$a->module}/{$a->module}.php"; @@ -317,7 +318,7 @@ if (! x($a->page, 'content')) { } if (!$install && !$maintenance) { - call_hooks('page_content_top', $a->page['content']); + Addon::callHooks('page_content_top', $a->page['content']); } /** @@ -329,10 +330,10 @@ if ($a->module_loaded) { $placeholder = ''; if ($a->module_class) { - call_hooks($a->module . '_mod_init', $placeholder); + Addon::callHooks($a->module . '_mod_init', $placeholder); call_user_func([$a->module_class, 'init']); } else if (function_exists($a->module . '_init')) { - call_hooks($a->module . '_mod_init', $placeholder); + Addon::callHooks($a->module . '_mod_init', $placeholder); $func = $a->module . '_init'; $func($a); } @@ -343,7 +344,7 @@ if ($a->module_loaded) { } if (! $a->error && $_SERVER['REQUEST_METHOD'] === 'POST') { - call_hooks($a->module . '_mod_post', $_POST); + Addon::callHooks($a->module . '_mod_post', $_POST); if ($a->module_class) { call_user_func([$a->module_class, 'post']); } else if (function_exists($a->module . '_post')) { @@ -353,7 +354,7 @@ if ($a->module_loaded) { } if (! $a->error) { - call_hooks($a->module . '_mod_afterpost', $placeholder); + Addon::callHooks($a->module . '_mod_afterpost', $placeholder); if ($a->module_class) { call_user_func([$a->module_class, 'afterpost']); } else if (function_exists($a->module . '_afterpost')) { @@ -364,7 +365,7 @@ if ($a->module_loaded) { if (! $a->error) { $arr = ['content' => $a->page['content']]; - call_hooks($a->module . '_mod_content', $arr); + Addon::callHooks($a->module . '_mod_content', $arr); $a->page['content'] = $arr['content']; if ($a->module_class) { $arr = ['content' => call_user_func([$a->module_class, 'content'])]; @@ -372,7 +373,7 @@ if ($a->module_loaded) { $func = $a->module . '_content'; $arr = ['content' => $func($a)]; } - call_hooks($a->module . '_mod_aftercontent', $arr); + Addon::callHooks($a->module . '_mod_aftercontent', $arr); $a->page['content'] .= $arr['content']; } @@ -421,7 +422,7 @@ if (stristr(implode("", $_SESSION['sysmsg']), t('Permission denied'))) { /* * Report anything which needs to be communicated in the notification area (before the main body) */ -call_hooks('page_end', $a->page['content']); +Addon::callHooks('page_end', $a->page['content']); /* * Add the navigation (menu) template diff --git a/mod/admin.php b/mod/admin.php index 9c286c11d..fd8a61cb2 100644 --- a/mod/admin.php +++ b/mod/admin.php @@ -8,6 +8,7 @@ use Friendica\App; use Friendica\Content\Feature; use Friendica\Content\Text\Markdown; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\System; use Friendica\Core\Worker; @@ -1757,11 +1758,11 @@ function admin_page_plugins(App $a) $idx = array_search($plugin, $a->plugins); if ($idx !== false) { unset($a->plugins[$idx]); - uninstall_plugin($plugin); + Addon::uninstall($plugin); info(t("Plugin %s disabled.", $plugin)); } else { $a->plugins[] = $plugin; - install_plugin($plugin); + Addon::install($plugin); info(t("Plugin %s enabled.", $plugin)); } Config::set("system", "addon", implode(", ", $a->plugins)); @@ -1804,7 +1805,7 @@ function admin_page_plugins(App $a) '$plugin' => $plugin, '$status' => $status, '$action' => $action, - '$info' => get_plugin_info($plugin), + '$info' => Addon::getInfo($plugin), '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), @@ -1822,7 +1823,7 @@ function admin_page_plugins(App $a) */ if (x($_GET, "a") && $_GET['a'] == "r") { check_form_security_token_redirectOnErr(System::baseUrl() . '/admin/plugins', 'admin_themes', 't'); - reload_plugins(); + Addon::reload(); info("Plugins reloaded"); goaway(System::baseUrl() . '/admin/plugins'); } @@ -1833,7 +1834,7 @@ function admin_page_plugins(App $a) foreach ($files as $file) { if (is_dir($file)) { list($tmp, $id) = array_map("trim", explode("/", $file)); - $info = get_plugin_info($id); + $info = Addon::getInfo($id); $show_plugin = true; // If the addon is unsupported, then only show it, when it is enabled diff --git a/mod/contacts.php b/mod/contacts.php index 682d427c6..dfda3a336 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\Content\ContactSelector; use Friendica\Content\Nav; use Friendica\Content\Widget; +use Friendica\Core\Addon; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBM; @@ -173,7 +174,7 @@ function contacts_post(App $a) return; // NOTREACHED } - call_hooks('contact_edit_post', $_POST); + Addon::callHooks('contact_edit_post', $_POST); $profile_id = intval($_POST['profile-assign']); if ($profile_id) { @@ -662,7 +663,7 @@ function contacts_content(App $a) $arr = ['contact' => $contact, 'output' => $o]; - call_hooks('contact_edit', $arr); + Addon::callHooks('contact_edit', $arr); return $arr['output']; } diff --git a/mod/directory.php b/mod/directory.php index 6398127cf..5afaa08c6 100644 --- a/mod/directory.php +++ b/mod/directory.php @@ -5,6 +5,7 @@ use Friendica\App; use Friendica\Content\Nav; use Friendica\Content\Widget; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Database\DBM; use Friendica\Model\Contact; @@ -174,7 +175,7 @@ function directory_content(App $a) { $arr = ['contact' => $rr, 'entry' => $entry]; - call_hooks('directory_item', $arr); + Addon::callHooks('directory_item', $arr); unset($profile); unset($location); diff --git a/mod/editpost.php b/mod/editpost.php index 117cb3fb1..9e3401e95 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -4,6 +4,7 @@ */ use Friendica\App; use Friendica\Content\Feature; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\System; use Friendica\Database\DBM; @@ -94,8 +95,8 @@ function editpost_content(App $a) { - call_hooks('jot_tool', $jotplugins); - //call_hooks('jot_networks', $jotnets); + Addon::callHooks('jot_tool', $jotplugins); + //Addon::callHooks('jot_networks', $jotnets); //$tpl = replace_macros($tpl,array('$jotplugins' => $jotplugins)); diff --git a/mod/friendica.php b/mod/friendica.php index 7f48ae3d4..7a9f6c6f6 100644 --- a/mod/friendica.php +++ b/mod/friendica.php @@ -1,6 +1,7 @@ ' . PHP_EOL; } - call_hooks('about_hook', $o); + Addon::callHooks('about_hook', $o); return $o; } diff --git a/mod/home.php b/mod/home.php index 614fd0e3e..dc571aaab 100644 --- a/mod/home.php +++ b/mod/home.php @@ -1,6 +1,7 @@ user['nickname'])) { goaway(System::baseUrl()."/network"); @@ -46,7 +47,7 @@ function home_content(App $a) { $login = Login::form($a->query_string, $a->config['register_policy'] == REGISTER_CLOSED ? 0 : 1); $content = ''; - call_hooks("home_content",$content); + Addon::callHooks("home_content",$content); $tpl = get_markup_template('home.tpl'); diff --git a/mod/item.php b/mod/item.php index 4b284568a..ef4bf8dbc 100644 --- a/mod/item.php +++ b/mod/item.php @@ -15,6 +15,7 @@ * information. */ use Friendica\App; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\System; use Friendica\Core\Worker; @@ -50,7 +51,7 @@ function item_post(App $a) { killme(); } - call_hooks('post_local_start', $_REQUEST); + Addon::callHooks('post_local_start', $_REQUEST); // logger('postinput ' . file_get_contents('php://input')); logger('postvars ' . print_r($_REQUEST,true), LOGGER_DATA); @@ -772,7 +773,7 @@ function item_post(App $a) { killme(); } - call_hooks('post_local',$datarray); + Addon::callHooks('post_local',$datarray); if (x($datarray, 'cancel')) { logger('mod_item: post cancelled by plugin.'); @@ -885,7 +886,7 @@ function item_post(App $a) { } } - call_hooks('post_local_end', $datarray); + Addon::callHooks('post_local_end', $datarray); if (strlen($emailcc) && $profile_uid == local_user()) { $erecips = explode(',', $emailcc); diff --git a/mod/lockview.php b/mod/lockview.php index ced03d1b5..ead2269c7 100644 --- a/mod/lockview.php +++ b/mod/lockview.php @@ -1,6 +1,7 @@ '; diff --git a/mod/manage.php b/mod/manage.php index f2781f108..dde08d3fa 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -1,6 +1,7 @@ user['nickname'] ); // NOTREACHED diff --git a/mod/network.php b/mod/network.php index c08d8e68d..6bb1cf387 100644 --- a/mod/network.php +++ b/mod/network.php @@ -7,6 +7,7 @@ use Friendica\Content\Feature; use Friendica\Content\ForumManager; use Friendica\Content\Nav; use Friendica\Content\Widget; +use Friendica\Core\Addon; use Friendica\Core\System; use Friendica\Core\Config; use Friendica\Core\PConfig; @@ -388,7 +389,7 @@ function network_content(App $a, $update = 0) { /// @TODO Is this really necessary? $a is already available to hooks $arr = ['query' => $a->query_string]; - call_hooks('network_content_init', $arr); + Addon::callHooks('network_content_init', $arr); $nouveau = false; @@ -1006,7 +1007,7 @@ function network_tabs(App $a) } $arr = ['tabs' => $tabs]; - call_hooks('network_tabs', $arr); + Addon::callHooks('network_tabs', $arr); $tpl = get_markup_template('common_tabs.tpl'); diff --git a/mod/nodeinfo.php b/mod/nodeinfo.php index d92335ad1..e5388154f 100644 --- a/mod/nodeinfo.php +++ b/mod/nodeinfo.php @@ -6,11 +6,10 @@ */ use Friendica\App; +use Friendica\Core\Addon; use Friendica\Core\System; use Friendica\Core\Config; -require_once 'include/plugin.php'; - function nodeinfo_wellknown(App $a) { $nodeinfo = ['links' => [['rel' => 'http://nodeinfo.diaspora.software/ns/schema/1.0', 'href' => System::baseUrl().'/nodeinfo/1.0']]]; @@ -72,48 +71,48 @@ function nodeinfo_init(App $a) { $nodeinfo['usage']['localPosts'] = (int)Config::get('nodeinfo', 'local_posts'); $nodeinfo['usage']['localComments'] = (int)Config::get('nodeinfo', 'local_comments'); - if (plugin_enabled('appnet')) { + if (Addon::isEnabled('appnet')) { $nodeinfo['services']['inbound'][] = 'appnet'; } - if (plugin_enabled('appnet') || plugin_enabled('buffer')) { + if (Addon::isEnabled('appnet') || Addon::isEnabled('buffer')) { $nodeinfo['services']['outbound'][] = 'appnet'; } - if (plugin_enabled('blogger')) { + if (Addon::isEnabled('blogger')) { $nodeinfo['services']['outbound'][] = 'blogger'; } - if (plugin_enabled('dwpost')) { + if (Addon::isEnabled('dwpost')) { $nodeinfo['services']['outbound'][] = 'dreamwidth'; } - if (plugin_enabled('fbpost') || plugin_enabled('buffer')) { + if (Addon::isEnabled('fbpost') || Addon::isEnabled('buffer')) { $nodeinfo['services']['outbound'][] = 'facebook'; } - if (plugin_enabled('statusnet')) { + if (Addon::isEnabled('statusnet')) { $nodeinfo['services']['inbound'][] = 'gnusocial'; $nodeinfo['services']['outbound'][] = 'gnusocial'; } - if (plugin_enabled('gpluspost') || plugin_enabled('buffer')) { + if (Addon::isEnabled('gpluspost') || Addon::isEnabled('buffer')) { $nodeinfo['services']['outbound'][] = 'google'; } - if (plugin_enabled('ijpost')) { + if (Addon::isEnabled('ijpost')) { $nodeinfo['services']['outbound'][] = 'insanejournal'; } - if (plugin_enabled('libertree')) { + if (Addon::isEnabled('libertree')) { $nodeinfo['services']['outbound'][] = 'libertree'; } - if (plugin_enabled('buffer')) { + if (Addon::isEnabled('buffer')) { $nodeinfo['services']['outbound'][] = 'linkedin'; } - if (plugin_enabled('ljpost')) { + if (Addon::isEnabled('ljpost')) { $nodeinfo['services']['outbound'][] = 'livejournal'; } - if (plugin_enabled('buffer')) { + if (Addon::isEnabled('buffer')) { $nodeinfo['services']['outbound'][] = 'pinterest'; } - if (plugin_enabled('posterous')) { + if (Addon::isEnabled('posterous')) { $nodeinfo['services']['outbound'][] = 'posterous'; } - if (plugin_enabled('pumpio')) { + if (Addon::isEnabled('pumpio')) { $nodeinfo['services']['inbound'][] = 'pumpio'; $nodeinfo['services']['outbound'][] = 'pumpio'; } @@ -121,13 +120,13 @@ function nodeinfo_init(App $a) { if ($smtp) { $nodeinfo['services']['outbound'][] = 'smtp'; } - if (plugin_enabled('tumblr')) { + if (Addon::isEnabled('tumblr')) { $nodeinfo['services']['outbound'][] = 'tumblr'; } - if (plugin_enabled('twitter') || plugin_enabled('buffer')) { + if (Addon::isEnabled('twitter') || Addon::isEnabled('buffer')) { $nodeinfo['services']['outbound'][] = 'twitter'; } - if (plugin_enabled('wppost')) { + if (Addon::isEnabled('wppost')) { $nodeinfo['services']['outbound'][] = 'wordpress'; } $nodeinfo['metadata']['protocols'] = $nodeinfo['protocols']; @@ -137,7 +136,7 @@ function nodeinfo_init(App $a) { $nodeinfo['metadata']['services'] = $nodeinfo['services']; - if (plugin_enabled('twitter')) { + if (Addon::isEnabled('twitter')) { $nodeinfo['metadata']['services']['inbound'][] = 'twitter'; } } @@ -154,7 +153,7 @@ function nodeinfo_cron() { $a = get_app(); // If the plugin 'statistics_json' is enabled then disable it and actrivate nodeinfo. - if (plugin_enabled('statistics_json')) { + if (Addon::isEnabled('statistics_json')) { Config::set('system', 'nodeinfo', true); $plugin = 'statistics_json'; @@ -167,7 +166,7 @@ function nodeinfo_cron() { $idx = array_search($plugin, $plugins_arr); if ($idx !== false) { unset($plugins_arr[$idx]); - uninstall_plugin($plugin); + Addon::uninstall($plugin); Config::set('system', 'addon', implode(', ',$plugins_arr)); } } diff --git a/mod/parse_url.php b/mod/parse_url.php index dbe45aba1..6fb404f1b 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -11,6 +11,7 @@ */ use Friendica\App; +use Friendica\Core\Addon; use Friendica\Util\ParseUrl; require_once("include/items.php"); @@ -91,7 +92,7 @@ function parse_url_content(App $a) { $arr = ["url" => $url, "text" => ""]; - call_hooks("parse_link", $arr); + Addon::callHooks("parse_link", $arr); if (strlen($arr["text"])) { echo $arr["text"]; diff --git a/mod/photos.php b/mod/photos.php index 6183ed60b..3cb75e539 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -5,6 +5,7 @@ use Friendica\App; use Friendica\Content\Feature; use Friendica\Content\Nav; +use Friendica\Core\Addon; use Friendica\Core\System; use Friendica\Core\Config; use Friendica\Core\Worker; @@ -720,7 +721,7 @@ function photos_post(App $a) // default post action - upload a photo - call_hooks('photo_post_init', $_POST); + Addon::callHooks('photo_post_init', $_POST); // Determine the album to use $album = x($_REQUEST, 'album') ? notags(trim($_REQUEST['album'])) : ''; @@ -770,7 +771,7 @@ function photos_post(App $a) $ret = ['src' => '', 'filename' => '', 'filesize' => 0, 'type' => '']; - call_hooks('photo_post_file', $ret); + Addon::callHooks('photo_post_file', $ret); if (x($ret, 'src') && x($ret, 'filesize')) { $src = $ret['src']; @@ -808,7 +809,7 @@ function photos_post(App $a) } @unlink($src); $foo = 0; - call_hooks('photo_post_end', $foo); + Addon::callHooks('photo_post_end', $foo); return; } @@ -824,7 +825,7 @@ function photos_post(App $a) notice(t('Image exceeds size limit of %s', formatBytes($maximagesize)) . EOL); @unlink($src); $foo = 0; - call_hooks('photo_post_end', $foo); + Addon::callHooks('photo_post_end', $foo); return; } @@ -832,7 +833,7 @@ function photos_post(App $a) notice(t('Image file is empty.') . EOL); @unlink($src); $foo = 0; - call_hooks('photo_post_end', $foo); + Addon::callHooks('photo_post_end', $foo); return; } @@ -847,7 +848,7 @@ function photos_post(App $a) notice(t('Unable to process image.') . EOL); @unlink($src); $foo = 0; - call_hooks('photo_post_end',$foo); + Addon::callHooks('photo_post_end',$foo); killme(); } @@ -937,7 +938,7 @@ function photos_post(App $a) Worker::add(PRIORITY_HIGH, "Notifier", 'wall-new', $item_id); } - call_hooks('photo_post_end', intval($item_id)); + Addon::callHooks('photo_post_end', intval($item_id)); // addon uploaders should call "killme()" [e.g. exit] within the photo_post_end hook // if they do not wish to be redirected @@ -1103,7 +1104,7 @@ function photos_content(App $a) 'addon_text' => $uploader, 'default_upload' => true]; - call_hooks('photo_upload_form',$ret); + Addon::callHooks('photo_upload_form',$ret); $default_upload_box = replace_macros(get_markup_template('photos_default_uploader_box.tpl'), []); $default_upload_submit = replace_macros(get_markup_template('photos_default_uploader_submit.tpl'), [ diff --git a/mod/ping.php b/mod/ping.php index 9dd6780d0..6e11e18cd 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -5,6 +5,7 @@ use Friendica\App; use Friendica\Content\Feature; use Friendica\Content\ForumManager; +use Friendica\Core\Addon; use Friendica\Core\Cache; use Friendica\Core\System; use Friendica\Core\PConfig; @@ -138,7 +139,7 @@ function ping_init(App $a) if (DBM::is_result($items_unseen)) { $arr = ['items' => $items_unseen]; - call_hooks('network_ping', $arr); + Addon::callHooks('network_ping', $arr); foreach ($items_unseen as $item) { if ($item['wall']) { diff --git a/mod/poke.php b/mod/poke.php index a8410b17d..74348f84a 100644 --- a/mod/poke.php +++ b/mod/poke.php @@ -15,6 +15,7 @@ */ use Friendica\App; +use Friendica\Core\Addon; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Database\DBM; @@ -142,7 +143,7 @@ function poke_init(App $a) { } - call_hooks('post_local_end', $arr); + Addon::callHooks('post_local_end', $arr); Worker::add(PRIORITY_HIGH, "Notifier", "like", $post_id); diff --git a/mod/profile.php b/mod/profile.php index 4b1d4d2a0..081b5e3a8 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -5,6 +5,7 @@ use Friendica\App; use Friendica\Content\Widget; use Friendica\Content\Nav; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Core\System; @@ -180,7 +181,7 @@ function profile_content(App $a, $update = 0) if ($tab === 'profile') { $o .= Profile::getAdvanced($a); - call_hooks('profile_advanced', $o); + Addon::callHooks('profile_advanced', $o); return $o; } diff --git a/mod/profiles.php b/mod/profiles.php index 32ed24346..4cb953309 100644 --- a/mod/profiles.php +++ b/mod/profiles.php @@ -6,6 +6,7 @@ use Friendica\App; use Friendica\Content\ContactSelector; use Friendica\Content\Feature; use Friendica\Content\Nav; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\PConfig; use Friendica\Core\System; @@ -178,7 +179,7 @@ function profiles_post(App $a) { $namechanged = false; - call_hooks('profile_post', $_POST); + Addon::callHooks('profile_post', $_POST); if (($a->argc > 1) && ($a->argv[1] !== "new") && intval($a->argv[1])) { $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -743,7 +744,7 @@ function profiles_content(App $a) { ]); $arr = ['profile' => $r[0], 'entry' => $o]; - call_hooks('profile_edit', $arr); + Addon::callHooks('profile_edit', $arr); return $o; } else { diff --git a/mod/register.php b/mod/register.php index 56d4e5936..2bd09aca9 100644 --- a/mod/register.php +++ b/mod/register.php @@ -1,6 +1,7 @@ $_POST]; - call_hooks('register_post', $arr); + Addon::callHooks('register_post', $arr); $max_dailies = intval(Config::get('system', 'max_daily_registrations')); if ($max_dailies) { @@ -241,7 +242,7 @@ function register_content(App $a) $arr = ['template' => $tpl]; - call_hooks('register_form', $arr); + Addon::callHooks('register_form', $arr); $tpl = $arr['template']; diff --git a/mod/settings.php b/mod/settings.php index 572857a48..dd863cc19 100644 --- a/mod/settings.php +++ b/mod/settings.php @@ -5,6 +5,7 @@ use Friendica\App; use Friendica\Content\Feature; use Friendica\Content\Nav; +use Friendica\Core\Addon; use Friendica\Core\System; use Friendica\Core\Worker; use Friendica\Core\Config; @@ -195,7 +196,7 @@ function settings_post(App $a) if (($a->argc > 1) && ($a->argv[1] == 'addon')) { check_form_security_token_redirectOnErr('/settings/addon', 'settings_addon'); - call_hooks('plugin_settings_post', $_POST); + Addon::callHooks('plugin_settings_post', $_POST); return; } @@ -277,7 +278,7 @@ function settings_post(App $a) } } - call_hooks('connector_settings_post', $_POST); + Addon::callHooks('connector_settings_post', $_POST); return; } @@ -351,7 +352,7 @@ function settings_post(App $a) intval(local_user()) ); - call_hooks('display_settings_post', $_POST); + Addon::callHooks('display_settings_post', $_POST); goaway('settings/display'); return; // NOTREACHED } @@ -364,7 +365,7 @@ function settings_post(App $a) goaway('settings'); } - call_hooks('settings_post', $_POST); + Addon::callHooks('settings_post', $_POST); if (x($_POST, 'password') || x($_POST, 'confirm')) { $newpass = $_POST['password']; @@ -753,7 +754,7 @@ function settings_content(App $a) $settings_addons = t('No Plugin settings configured'); } - call_hooks('plugin_settings', $settings_addons); + Addon::callHooks('plugin_settings', $settings_addons); $tpl = get_markup_template('settings/addons.tpl'); @@ -799,7 +800,7 @@ function settings_content(App $a) } $settings_connectors = ''; - call_hooks('connector_settings', $settings_connectors); + Addon::callHooks('connector_settings', $settings_connectors); if (is_site_admin()) { $diasp_enabled = t('Built-in support for %s connectivity is %s', t('Diaspora'), ((Config::get('system', 'diaspora_enabled')) ? t('enabled') : t('disabled'))); @@ -871,7 +872,7 @@ function settings_content(App $a) '$submit' => t('Save Settings'), ]); - call_hooks('display_settings', $o); + Addon::callHooks('display_settings', $o); return $o; } @@ -1284,7 +1285,7 @@ function settings_content(App $a) ]); - call_hooks('settings_form', $o); + Addon::callHooks('settings_form', $o); $o .= '' . "\r\n"; diff --git a/mod/statistics_json.php b/mod/statistics_json.php index 21eb10ab4..94a7fc9e1 100644 --- a/mod/statistics_json.php +++ b/mod/statistics_json.php @@ -5,6 +5,7 @@ */ use Friendica\App; +use Friendica\Core\Addon; use Friendica\Core\Config; require_once("include/plugin.php"); @@ -28,19 +29,19 @@ function statistics_json_init(App $a) { ]; $statistics["services"] = []; - $statistics["services"]["appnet"] = plugin_enabled("appnet"); - $statistics["services"]["blogger"] = plugin_enabled("blogger"); - $statistics["services"]["buffer"] = plugin_enabled("buffer"); - $statistics["services"]["dreamwidth"] = plugin_enabled("dwpost"); - $statistics["services"]["facebook"] = plugin_enabled("fbpost"); - $statistics["services"]["gnusocial"] = plugin_enabled("statusnet"); - $statistics["services"]["googleplus"] = plugin_enabled("gpluspost"); - $statistics["services"]["libertree"] = plugin_enabled("libertree"); - $statistics["services"]["livejournal"] = plugin_enabled("ljpost"); - $statistics["services"]["pumpio"] = plugin_enabled("pumpio"); - $statistics["services"]["twitter"] = plugin_enabled("twitter"); - $statistics["services"]["tumblr"] = plugin_enabled("tumblr"); - $statistics["services"]["wordpress"] = plugin_enabled("wppost"); + $statistics["services"]["appnet"] = Addon::isEnabled("appnet"); + $statistics["services"]["blogger"] = Addon::isEnabled("blogger"); + $statistics["services"]["buffer"] = Addon::isEnabled("buffer"); + $statistics["services"]["dreamwidth"] = Addon::isEnabled("dwpost"); + $statistics["services"]["facebook"] = Addon::isEnabled("fbpost"); + $statistics["services"]["gnusocial"] = Addon::isEnabled("statusnet"); + $statistics["services"]["googleplus"] = Addon::isEnabled("gpluspost"); + $statistics["services"]["libertree"] = Addon::isEnabled("libertree"); + $statistics["services"]["livejournal"] = Addon::isEnabled("ljpost"); + $statistics["services"]["pumpio"] = Addon::isEnabled("pumpio"); + $statistics["services"]["twitter"] = Addon::isEnabled("twitter"); + $statistics["services"]["tumblr"] = Addon::isEnabled("tumblr"); + $statistics["services"]["wordpress"] = Addon::isEnabled("wppost"); $statistics["appnet"] = $statistics["services"]["appnet"]; $statistics["blogger"] = $statistics["services"]["blogger"]; diff --git a/mod/subthread.php b/mod/subthread.php index 037e2982e..af7f0b492 100644 --- a/mod/subthread.php +++ b/mod/subthread.php @@ -1,6 +1,7 @@ $r, 'xml' => $o]; - call_hooks('personal_xrd', $arr); + Addon::callHooks('personal_xrd', $arr); echo $arr['xml']; killme(); diff --git a/scripts/worker.php b/scripts/worker.php index ccf24b7b4..a821fc1ab 100755 --- a/scripts/worker.php +++ b/scripts/worker.php @@ -6,6 +6,7 @@ */ use Friendica\App; +use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\Worker; @@ -42,7 +43,7 @@ if (Config::get('system', 'maintenance', true)) { $a->set_baseurl(Config::get('system', 'url')); -load_hooks(); +Addon::loadHooks(); $spawn = (($_SERVER["argc"] == 2) && ($_SERVER["argv"][1] == "spawn")); diff --git a/src/Content/ContactSelector.php b/src/Content/ContactSelector.php index 4eb2e74aa..fcaafb898 100644 --- a/src/Content/ContactSelector.php +++ b/src/Content/ContactSelector.php @@ -4,6 +4,7 @@ */ namespace Friendica\Content; +use Friendica\Core\Addon; use Friendica\Database\DBM; use Friendica\Protocol\Diaspora; use dba; @@ -93,7 +94,7 @@ class ContactSelector NETWORK_APPNET => t('App.net') ]; - call_hooks('network_to_name', $nets); + Addon::callHooks('network_to_name', $nets); $search = array_keys($nets); $replace = array_values($nets); @@ -122,7 +123,7 @@ class ContactSelector $o = ''; $select = ['', t('Male'), t('Female'), t('Currently Male'), t('Currently Female'), t('Mostly Male'), t('Mostly Female'), t('Transgender'), t('Intersex'), t('Transsexual'), t('Hermaphrodite'), t('Neuter'), t('Non-specific'), t('Other'), t('Undecided')]; - call_hooks('gender_selector', $select); + Addon::callHooks('gender_selector', $select); $o .= ""; foreach ($select as $selection) { @@ -166,7 +167,7 @@ class ContactSelector $o = ''; $select = ['', t('Single'), t('Lonely'), t('Available'), t('Unavailable'), t('Has crush'), t('Infatuated'), t('Dating'), t('Unfaithful'), t('Sex Addict'), t('Friends'), t('Friends/Benefits'), t('Casual'), t('Engaged'), t('Married'), t('Imaginarily married'), t('Partners'), t('Cohabiting'), t('Common law'), t('Happy'), t('Not looking'), t('Swinger'), t('Betrayed'), t('Separated'), t('Unstable'), t('Divorced'), t('Imaginarily divorced'), t('Widowed'), t('Uncertain'), t('It\'s complicated'), t('Don\'t care'), t('Ask me')]; - call_hooks('marital_selector', $select); + Addon::callHooks('marital_selector', $select); $o .= '