mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-12 01:54:26 +02:00
Update Addon functions and calls
Update function names and calls for Addon class.
This commit is contained in:
parent
213f6ae1a1
commit
11cf36105c
73 changed files with 544 additions and 464 deletions
|
@ -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 .= "<select name=\"gender$suffix\" id=\"gender-select$suffix\" size=\"1\" >";
|
||||
foreach ($select as $selection) {
|
||||
|
@ -145,7 +146,7 @@ class ContactSelector
|
|||
$select = ['', t('Males'), t('Females'), t('Gay'), t('Lesbian'), t('No Preference'), t('Bisexual'), t('Autosexual'), t('Abstinent'), t('Virgin'), t('Deviant'), t('Fetish'), t('Oodles'), t('Nonsexual')];
|
||||
|
||||
|
||||
call_hooks('sexpref_selector', $select);
|
||||
Addon::callHooks('sexpref_selector', $select);
|
||||
|
||||
$o .= "<select name=\"sexual$suffix\" id=\"sexual-select$suffix\" size=\"1\" >";
|
||||
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 .= '<select name="marital" id="marital-select" size="1" >';
|
||||
foreach ($select as $selection) {
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
namespace Friendica\Content;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
|
||||
|
@ -36,7 +37,7 @@ class Feature
|
|||
}
|
||||
|
||||
$arr = ['uid' => $uid, 'feature' => $feature, 'enabled' => $x];
|
||||
call_hooks('isEnabled', $arr);
|
||||
Addon::callHooks('isEnabled', $arr);
|
||||
return($arr['enabled']);
|
||||
}
|
||||
|
||||
|
@ -150,7 +151,7 @@ class Feature
|
|||
}
|
||||
}
|
||||
|
||||
call_hooks('get', $arr);
|
||||
Addon::callHooks('get', $arr);
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Friendica\Content;
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
|
@ -57,7 +58,7 @@ class Nav
|
|||
'$search_hint' => t('@name, !forum, #tags, content')
|
||||
]);
|
||||
|
||||
call_hooks('page_header', $a->page['nav']);
|
||||
Addon::callHooks('page_header', $a->page['nav']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -224,7 +225,7 @@ class Nav
|
|||
$banner = '<a href="https://friendi.ca"><img id="logo-img" src="images/friendica-32.png" alt="logo" /></a><span id="logo-text"><a href="https://friendi.ca">Friendica</a></span>';
|
||||
}
|
||||
|
||||
call_hooks('nav_info', $nav);
|
||||
Addon::callHooks('nav_info', $nav);
|
||||
|
||||
return [
|
||||
'sitelocation' => $sitelocation,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace Friendica\Content;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Config;
|
||||
|
@ -154,7 +155,7 @@ class OEmbed
|
|||
}
|
||||
}
|
||||
|
||||
call_hooks('oembed_fetch_url', $embedurl, $j);
|
||||
Addon::callHooks('oembed_fetch_url', $embedurl, $j);
|
||||
|
||||
return $j;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
namespace Friendica\Content;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
|
@ -139,7 +140,7 @@ class Smilies
|
|||
];
|
||||
|
||||
$params = ['texts' => $texts, 'icons' => $icons];
|
||||
call_hooks('smilie', $params);
|
||||
Addon::callHooks('smilie', $params);
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Friendica\Content;
|
|||
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
|
@ -74,23 +75,23 @@ class Widget
|
|||
{
|
||||
$networks = array();
|
||||
|
||||
if (!plugin_enabled("appnet")) {
|
||||
if (!Addon::isEnabled("appnet")) {
|
||||
$networks[] = NETWORK_APPNET;
|
||||
}
|
||||
|
||||
if (!plugin_enabled("fbpost") && !plugin_enabled("facebook")) {
|
||||
if (!Addon::isEnabled("fbpost") && !Addon::isEnabled("facebook")) {
|
||||
$networks[] = NETWORK_FACEBOOK;
|
||||
}
|
||||
|
||||
if (!plugin_enabled("statusnet")) {
|
||||
if (!Addon::isEnabled("statusnet")) {
|
||||
$networks[] = NETWORK_STATUSNET;
|
||||
}
|
||||
|
||||
if (!plugin_enabled("pumpio")) {
|
||||
if (!Addon::isEnabled("pumpio")) {
|
||||
$networks[] = NETWORK_PUMPIO;
|
||||
}
|
||||
|
||||
if (!plugin_enabled("twitter")) {
|
||||
if (!Addon::isEnabled("twitter")) {
|
||||
$networks[] = NETWORK_TWITTER;
|
||||
}
|
||||
|
||||
|
@ -102,7 +103,7 @@ class Widget
|
|||
$networks[] = NETWORK_DIASPORA;
|
||||
}
|
||||
|
||||
if (!plugin_enabled("pnut")) {
|
||||
if (!Addon::isEnabled("pnut")) {
|
||||
$networks[] = NETWORK_PNUT;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,9 @@ use Friendica\App;
|
|||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
use dba;
|
||||
|
||||
require_once 'include/dba.php';
|
||||
|
||||
/**
|
||||
* Some functions to handle addons
|
||||
|
@ -17,16 +20,17 @@ class Addon
|
|||
/**
|
||||
* @brief uninstalls an addon.
|
||||
*
|
||||
* @param string $plugin name of the addon
|
||||
* @param string $addon name of the addon
|
||||
* @return boolean
|
||||
*/
|
||||
function uninstall_plugin($plugin) {
|
||||
logger("Addons: uninstalling " . $plugin);
|
||||
dba::delete('addon', ['name' => $plugin]);
|
||||
public static function uninstall($addon)
|
||||
{
|
||||
logger("Addons: uninstalling " . $addon);
|
||||
dba::delete('addon', ['name' => $addon]);
|
||||
|
||||
@include_once('addon/' . $plugin . '/' . $plugin . '.php');
|
||||
if (function_exists($plugin . '_uninstall')) {
|
||||
$func = $plugin . '_uninstall';
|
||||
@include_once('addon/' . $addon . '/' . $addon . '.php');
|
||||
if (function_exists($addon . '_uninstall')) {
|
||||
$func = $addon . '_uninstall';
|
||||
$func();
|
||||
}
|
||||
}
|
||||
|
@ -34,76 +38,79 @@ class Addon
|
|||
/**
|
||||
* @brief installs an addon.
|
||||
*
|
||||
* @param string $plugin name of the addon
|
||||
* @param string $addon name of the addon
|
||||
* @return bool
|
||||
*/
|
||||
function install_plugin($plugin) {
|
||||
// silently fail if plugin was removed
|
||||
public static function install($addon)
|
||||
{
|
||||
// silently fail if addon was removed
|
||||
|
||||
if (!file_exists('addon/' . $plugin . '/' . $plugin . '.php')) {
|
||||
if (!file_exists('addon/' . $addon . '/' . $addon . '.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';
|
||||
logger("Addons: installing " . $addon);
|
||||
$t = @filemtime('addon/' . $addon . '/' . $addon . '.php');
|
||||
@include_once('addon/' . $addon . '/' . $addon . '.php');
|
||||
if (function_exists($addon . '_install')) {
|
||||
$func = $addon . '_install';
|
||||
$func();
|
||||
|
||||
$plugin_admin = (function_exists($plugin."_plugin_admin") ? 1 : 0);
|
||||
$addon_admin = (function_exists($addon."_plugin_admin") ? 1 : 0);
|
||||
|
||||
dba::insert('addon', ['name' => $plugin, 'installed' => true,
|
||||
'timestamp' => $t, 'plugin_admin' => $plugin_admin]);
|
||||
dba::insert('addon', ['name' => $addon, 'installed' => true,
|
||||
'timestamp' => $t, 'plugin_admin' => $addon_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]);
|
||||
if (file_exists('addon/' . $addon . '/.hidden')) {
|
||||
dba::update('addon', ['hidden' => true], ['name' => $addon]);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
logger("Addons: FAILED installing " . $plugin);
|
||||
logger("Addons: FAILED installing " . $addon);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// reload all updated plugins
|
||||
/**
|
||||
* reload all updated addons
|
||||
*/
|
||||
public static function reload()
|
||||
{
|
||||
$addons = Config::get('system', 'addon');
|
||||
if (strlen($addons)) {
|
||||
|
||||
function reload_plugins() {
|
||||
$plugins = Config::get('system', 'addon');
|
||||
if (strlen($plugins)) {
|
||||
|
||||
$r = q("SELECT * FROM `addon` WHERE `installed` = 1");
|
||||
$r = dba::select('addon', [], ['installed' => 1]);
|
||||
if (DBM::is_result($r)) {
|
||||
$installed = $r;
|
||||
} else {
|
||||
$installed = [];
|
||||
}
|
||||
|
||||
$parr = explode(',',$plugins);
|
||||
$addon_list = explode(',', $addons);
|
||||
|
||||
if (count($parr)) {
|
||||
foreach ($parr as $pl) {
|
||||
if (count($addon_list)) {
|
||||
foreach ($addon_list as $addon) {
|
||||
|
||||
$pl = trim($pl);
|
||||
$addon = trim($addon);
|
||||
|
||||
$fname = 'addon/' . $pl . '/' . $pl . '.php';
|
||||
$fname = 'addon/' . $addon . '/' . $addon . '.php';
|
||||
|
||||
if (file_exists($fname)) {
|
||||
$t = @filemtime($fname);
|
||||
foreach ($installed as $i) {
|
||||
if (($i['name'] == $pl) && ($i['timestamp'] != $t)) {
|
||||
logger('Reloading plugin: ' . $i['name']);
|
||||
if (($i['name'] == $addon) && ($i['timestamp'] != $t)) {
|
||||
logger('Reloading addon: ' . $i['name']);
|
||||
@include_once($fname);
|
||||
|
||||
if (function_exists($pl . '_uninstall')) {
|
||||
$func = $pl . '_uninstall';
|
||||
if (function_exists($addon . '_uninstall')) {
|
||||
$func = $addon . '_uninstall';
|
||||
$func();
|
||||
}
|
||||
if (function_exists($pl . '_install')) {
|
||||
$func = $pl . '_install';
|
||||
if (function_exists($addon . '_install')) {
|
||||
$func = $addon . '_install';
|
||||
$func();
|
||||
}
|
||||
dba::update('addon', ['timestamp' => $t], ['id' => $i['id']]);
|
||||
|
@ -113,17 +120,17 @@ class Addon
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief check if addon is enabled
|
||||
*
|
||||
* @param string $plugin
|
||||
* @param string $addon
|
||||
* @return boolean
|
||||
*/
|
||||
function plugin_enabled($plugin) {
|
||||
return dba::exists('addon', ['installed' => true, 'name' => $plugin]);
|
||||
public static function isEnabled($addon)
|
||||
{
|
||||
return dba::exists('addon', ['installed' => true, 'name' => $addon]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,7 +143,8 @@ class Addon
|
|||
* @param int $priority A priority (defaults to 0)
|
||||
* @return mixed|bool
|
||||
*/
|
||||
function register_hook($hook, $file, $function, $priority=0) {
|
||||
public static function registerHook($hook, $file, $function, $priority = 0)
|
||||
{
|
||||
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
|
||||
$exists = dba::exists('hook', $condition);
|
||||
if ($exists) {
|
||||
|
@ -156,14 +164,15 @@ class Addon
|
|||
* @param string $function the name of the function that the hook called
|
||||
* @return array
|
||||
*/
|
||||
function unregister_hook($hook, $file, $function) {
|
||||
public static function unregisterHook($hook, $file, $function)
|
||||
{
|
||||
$condition = ['hook' => $hook, 'file' => $file, 'function' => $function];
|
||||
$r = dba::delete('hook', $condition);
|
||||
return $r;
|
||||
}
|
||||
|
||||
|
||||
function load_hooks() {
|
||||
public static function loadHooks() {
|
||||
$a = get_app();
|
||||
$a->hooks = [];
|
||||
$r = dba::select('hook', ['hook', 'file', 'function'], [], ['order' => ['priority' => 'desc', 'file']]);
|
||||
|
@ -186,13 +195,13 @@ class Addon
|
|||
* @param string $name of the hook to call
|
||||
* @param string|array &$data to transmit to the callback handler
|
||||
*/
|
||||
function call_hooks($name, &$data = null)
|
||||
public static function callHooks($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);
|
||||
self::callSingleHook($a, $name, $hook, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +213,8 @@ class Addon
|
|||
* @param array $hook Hook data
|
||||
* @param string|array &$data to transmit to the callback handler
|
||||
*/
|
||||
function call_single_hook($a, $name, $hook, &$data = null) {
|
||||
public static function callSingleHook($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;
|
||||
|
@ -220,9 +230,12 @@ class Addon
|
|||
}
|
||||
}
|
||||
|
||||
//check if an app_menu hook exist for plugin $name.
|
||||
//Return true if the plugin is an app
|
||||
function plugin_is_app($name) {
|
||||
/**
|
||||
* check if an app_menu hook exist for addon $name.
|
||||
* Return true if the addon is an app
|
||||
*/
|
||||
function isApp($name)
|
||||
{
|
||||
$a = get_app();
|
||||
|
||||
if (is_array($a->hooks) && (array_key_exists('app_menu',$a->hooks))) {
|
||||
|
@ -236,37 +249,39 @@ class Addon
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief Parse plugin comment in search of plugin infos.
|
||||
* @brief Parse addon comment in search of addon infos.
|
||||
*
|
||||
* like
|
||||
* \code
|
||||
*...* Name: Plugin
|
||||
* * Description: A plugin which plugs in
|
||||
*...* Name: addon
|
||||
* * Description: An addon which plugs in
|
||||
* . * Version: 1.2.3
|
||||
* * Author: John <profile url>
|
||||
* * Author: Jane <email>
|
||||
* *
|
||||
* *\endcode
|
||||
* @param string $plugin the name of the plugin
|
||||
* @return array with the plugin information
|
||||
* @param string $addon the name of the addon
|
||||
* @return array with the addon information
|
||||
*/
|
||||
|
||||
function get_plugin_info($plugin) {
|
||||
public static function getInfo($addon) {
|
||||
|
||||
$a = get_app();
|
||||
|
||||
$info=[
|
||||
'name' => $plugin,
|
||||
'name' => $addon,
|
||||
'description' => "",
|
||||
'author' => [],
|
||||
'version' => "",
|
||||
'status' => ""
|
||||
];
|
||||
|
||||
if (!is_file("addon/$plugin/$plugin.php")) return $info;
|
||||
if (!is_file("addon/$addon/$addon.php")) {
|
||||
return $info;
|
||||
}
|
||||
|
||||
$stamp1 = microtime(true);
|
||||
$f = file_get_contents("addon/$plugin/$plugin.php");
|
||||
$f = file_get_contents("addon/$addon/$addon.php");
|
||||
$a->save_timestamp($stamp1, "file");
|
||||
|
||||
$r = preg_match("|/\*.*\*/|msU", $f, $m);
|
||||
|
@ -293,7 +308,6 @@ class Addon
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
namespace Friendica\Core;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
|
@ -1030,7 +1031,7 @@ class Worker
|
|||
|
||||
$arr = ['args' => $args, 'run_cmd' => true];
|
||||
|
||||
call_hooks("proc_run", $arr);
|
||||
Addon::callHooks("proc_run", $arr);
|
||||
if (!$arr['run_cmd'] || !count($args)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\BaseObject;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
|
@ -559,7 +560,7 @@ class Contact extends BaseObject
|
|||
|
||||
$args = ['contact' => $contact, 'menu' => &$menu];
|
||||
|
||||
call_hooks('contact_photo_menu', $args);
|
||||
Addon::callHooks('contact_photo_menu', $args);
|
||||
|
||||
$menucondensed = [];
|
||||
|
||||
|
@ -1146,7 +1147,7 @@ class Contact extends BaseObject
|
|||
|
||||
$arr = ['url' => $url, 'contact' => []];
|
||||
|
||||
call_hooks('follow', $arr);
|
||||
Addon::callHooks('follow', $arr);
|
||||
|
||||
if (x($arr['contact'], 'name')) {
|
||||
$ret = $arr['contact'];
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Friendica\Model;
|
|||
use Friendica\App;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Content\ForumManager;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
|
@ -286,7 +287,7 @@ class Profile
|
|||
$profile['network_name'] = '';
|
||||
}
|
||||
|
||||
call_hooks('profile_sidebar_enter', $profile);
|
||||
Addon::callHooks('profile_sidebar_enter', $profile);
|
||||
|
||||
|
||||
// don't show connect link to yourself
|
||||
|
@ -520,7 +521,7 @@ class Profile
|
|||
|
||||
$arr = ['profile' => &$profile, 'entry' => &$o];
|
||||
|
||||
call_hooks('profile_sidebar', $arr);
|
||||
Addon::callHooks('profile_sidebar', $arr);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
@ -939,7 +940,7 @@ class Profile
|
|||
}
|
||||
|
||||
$arr = ['is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => $tab, 'tabs' => $tabs];
|
||||
call_hooks('profile_tabs', $arr);
|
||||
Addon::callHooks('profile_tabs', $arr);
|
||||
|
||||
$tpl = get_markup_template('common_tabs.tpl');
|
||||
|
||||
|
@ -976,7 +977,7 @@ class Profile
|
|||
|
||||
Worker::add(PRIORITY_LOW, 'GProbe', $my_url);
|
||||
$arr = ['zrl' => $my_url, 'url' => $a->cmd];
|
||||
call_hooks('zrl_init', $arr);
|
||||
Addon::callHooks('zrl_init', $arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Friendica\Model;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
|
@ -433,7 +434,7 @@ class User
|
|||
}
|
||||
}
|
||||
|
||||
call_hooks('register_account', $uid);
|
||||
Addon::callHooks('register_account', $uid);
|
||||
|
||||
$return['user'] = $user;
|
||||
return $return;
|
||||
|
@ -532,7 +533,7 @@ class User
|
|||
|
||||
$user = dba::selectFirst('user', [], ['uid' => $uid]);
|
||||
|
||||
call_hooks('remove_user', $user);
|
||||
Addon::callHooks('remove_user', $user);
|
||||
|
||||
// save username (actually the nickname as it is guaranteed
|
||||
// unique), so it cannot be re-registered in the future.
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\User;
|
||||
|
@ -92,7 +93,7 @@ class Login extends BaseModule
|
|||
* 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'];
|
||||
|
@ -299,7 +300,7 @@ class Login extends BaseModule
|
|||
]
|
||||
);
|
||||
|
||||
call_hooks('login_hook', $o);
|
||||
Addon::callHooks('login_hook', $o);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
namespace Friendica\Module;
|
||||
|
||||
use Friendica\BaseModule;
|
||||
use Friendica\Core\Addon;
|
||||
|
||||
require_once 'boot.php';
|
||||
require_once 'include/pgettext.php';
|
||||
require_once 'include/plugin.php';
|
||||
require_once 'include/security.php';
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@ class Logout extends BaseModule
|
|||
*/
|
||||
public static function init()
|
||||
{
|
||||
call_hooks("logging_out");
|
||||
Addon::callHooks("logging_out");
|
||||
nuke_session();
|
||||
info(t('Logged out.') . EOL);
|
||||
goaway(self::getApp()->get_baseurl());
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
namespace Friendica\Network;
|
||||
|
||||
use Friendica\App;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Database\DBM;
|
||||
|
@ -72,6 +73,6 @@ class FKOAuth1 extends OAuthServer
|
|||
|
||||
dba::update('user', ['login_date' => datetime_convert()], ['uid' => $_SESSION['uid']]);
|
||||
|
||||
call_hooks('logged_in', $a->user);
|
||||
Addon::callHooks('logged_in', $a->user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ namespace Friendica\Object;
|
|||
use Friendica\BaseObject;
|
||||
use Friendica\Content\ContactSelector;
|
||||
use Friendica\Content\Feature;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Database\DBM;
|
||||
use Friendica\Model\Contact;
|
||||
|
@ -214,7 +215,7 @@ class Post extends BaseObject
|
|||
}
|
||||
|
||||
$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));
|
||||
|
||||
// process action responses - e.g. like/dislike/attend/agree/whatever
|
||||
|
@ -405,7 +406,7 @@ class Post extends BaseObject
|
|||
];
|
||||
|
||||
$arr = ['item' => $item, 'output' => $tmp_item];
|
||||
call_hooks('display_item', $arr);
|
||||
Addon::callHooks('display_item', $arr);
|
||||
|
||||
$result = $arr['output'];
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ namespace Friendica\Protocol;
|
|||
|
||||
use Friendica\App;
|
||||
use Friendica\Content\OEmbed;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\System;
|
||||
use Friendica\Core\Worker;
|
||||
|
@ -269,12 +270,12 @@ class DFRN
|
|||
$root = self::addHeader($doc, $owner, $author, $alternatelink, true);
|
||||
|
||||
/// @TODO This hook can't work anymore
|
||||
// call_hooks('atom_feed', $atom);
|
||||
// Addon::callHooks('atom_feed', $atom);
|
||||
|
||||
if (!DBM::is_result($items) || $onlyheader) {
|
||||
$atom = trim($doc->saveXML());
|
||||
|
||||
call_hooks('atom_feed_end', $atom);
|
||||
Addon::callHooks('atom_feed_end', $atom);
|
||||
|
||||
return $atom;
|
||||
}
|
||||
|
@ -303,7 +304,7 @@ class DFRN
|
|||
|
||||
$atom = trim($doc->saveXML());
|
||||
|
||||
call_hooks('atom_feed_end', $atom);
|
||||
Addon::callHooks('atom_feed_end', $atom);
|
||||
|
||||
return $atom;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
namespace Friendica\Util;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\PConfig;
|
||||
use Friendica\Protocol\Email;
|
||||
|
||||
|
@ -30,7 +31,7 @@ class Emailer
|
|||
*/
|
||||
public static function send($params)
|
||||
{
|
||||
call_hooks('emailer_send_prepare', $params);
|
||||
Addon::callHooks('emailer_send_prepare', $params);
|
||||
|
||||
$email_textonly = false;
|
||||
if (x($params, "uid")) {
|
||||
|
@ -79,7 +80,7 @@ class Emailer
|
|||
'headers' => $messageHeader
|
||||
];
|
||||
//echo "<pre>"; var_dump($hookdata); killme();
|
||||
call_hooks("emailer_send", $hookdata);
|
||||
Addon::callHooks("emailer_send", $hookdata);
|
||||
$res = mail(
|
||||
$hookdata['to'], // send to address
|
||||
$hookdata['subject'], // subject
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
*/
|
||||
namespace Friendica\Util;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
|
||||
/**
|
||||
* Leaflet Map related functions
|
||||
*/
|
||||
|
@ -12,13 +14,13 @@ class Map {
|
|||
$coord = trim($coord);
|
||||
$coord = str_replace([',','/',' '],[' ',' ',' '],$coord);
|
||||
$arr = ['lat' => trim(substr($coord,0,strpos($coord,' '))), 'lon' => trim(substr($coord,strpos($coord,' ')+1)), 'html' => ''];
|
||||
call_hooks('generate_map',$arr);
|
||||
Addon::callHooks('generate_map',$arr);
|
||||
return ($arr['html']) ? $arr['html'] : $coord;
|
||||
}
|
||||
|
||||
public static function byLocation($location) {
|
||||
$arr = ['location' => $location, 'html' => ''];
|
||||
call_hooks('generate_named_map',$arr);
|
||||
Addon::callHooks('generate_named_map',$arr);
|
||||
return ($arr['html']) ? $arr['html'] : $location;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
namespace Friendica\Util;
|
||||
|
||||
use Friendica\Content\OEmbed;
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Object\Image;
|
||||
use Friendica\Util\XML;
|
||||
|
||||
|
@ -425,7 +426,7 @@ class ParseUrl
|
|||
|
||||
logger("parseurl_getsiteinfo: Siteinfo for ".$url." ".print_r($siteinfo, true), LOGGER_DEBUG);
|
||||
|
||||
call_hooks("getsiteinfo", $siteinfo);
|
||||
Addon::callHooks("getsiteinfo", $siteinfo);
|
||||
|
||||
return($siteinfo);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
|
@ -138,7 +139,7 @@ Class Cron {
|
|||
|
||||
$sql_extra = (($manual_id) ? " AND `id` = $manual_id " : "");
|
||||
|
||||
reload_plugins();
|
||||
Addon::reload();
|
||||
|
||||
$d = datetime_convert();
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
|
||||
|
@ -18,7 +19,7 @@ Class CronHooks {
|
|||
foreach ($a->hooks["cron"] as $single_hook) {
|
||||
if ($single_hook[1] == $hook) {
|
||||
logger("Calling cron hook '" . $hook . "'", LOGGER_DEBUG);
|
||||
call_single_hook($a, $hook, $single_hook);
|
||||
Addon::callSingleHook($a, $hook, $single_hook);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
|
@ -27,7 +28,7 @@ class Directory {
|
|||
|
||||
$arr = ['url' => $url];
|
||||
|
||||
call_hooks('globaldir_update', $arr);
|
||||
Addon::callHooks('globaldir_update', $arr);
|
||||
|
||||
logger('Updating directory: ' . $arr['url'], LOGGER_DEBUG);
|
||||
if (strlen($arr['url'])) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
|
@ -20,7 +21,7 @@ class Expire {
|
|||
require_once 'include/datetime.php';
|
||||
require_once 'include/items.php';
|
||||
|
||||
load_hooks();
|
||||
Addon::loadHooks();
|
||||
|
||||
if ($param == 'delete') {
|
||||
logger('Delete expired items', LOGGER_DEBUG);
|
||||
|
@ -50,7 +51,7 @@ class Expire {
|
|||
foreach ($a->hooks["expire"] as $hook) {
|
||||
if ($hook[1] == $hook_name) {
|
||||
logger("Calling expire hook '" . $hook[1] . "'", LOGGER_DEBUG);
|
||||
call_single_hook($a, $hook_name, $hook, $data);
|
||||
Addon::callSingleHook($a, $hook_name, $hook, $data);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
use Friendica\Database\DBM;
|
||||
|
@ -553,10 +554,10 @@ class Notifier {
|
|||
logger('notifier: calling hooks', LOGGER_DEBUG);
|
||||
|
||||
if ($normal_mode) {
|
||||
call_hooks('notifier_normal',$target_item);
|
||||
Addon::callHooks('notifier_normal',$target_item);
|
||||
}
|
||||
|
||||
call_hooks('notifier_end',$target_item);
|
||||
Addon::callHooks('notifier_end',$target_item);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
*/
|
||||
namespace Friendica\Worker;
|
||||
|
||||
use Friendica\Core\Addon;
|
||||
use Friendica\Core\Cache;
|
||||
use Friendica\Core\Config;
|
||||
use Friendica\Core\Worker;
|
||||
|
@ -55,7 +56,7 @@ class Queue
|
|||
*/
|
||||
$r = q("SELECT `id` FROM `queue` WHERE ((`created` > UTC_TIMESTAMP() - INTERVAL 12 HOUR AND `last` < UTC_TIMESTAMP() - INTERVAL 15 MINUTE) OR (`last` < UTC_TIMESTAMP() - INTERVAL 1 HOUR)) ORDER BY `cid`, `created`");
|
||||
|
||||
call_hooks('queue_predeliver', $r);
|
||||
Addon::callHooks('queue_predeliver', $r);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
foreach ($r as $q_item) {
|
||||
|
@ -159,7 +160,7 @@ class Queue
|
|||
|
||||
default:
|
||||
$params = ['owner' => $owner, 'contact' => $contact, 'queue' => $q_item, 'result' => false];
|
||||
call_hooks('queue_deliver', $params);
|
||||
Addon::callHooks('queue_deliver', $params);
|
||||
|
||||
if ($params['result']) {
|
||||
QueueModel::removeItem($q_item['id']);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue