mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 01:35:12 +00:00
This checkin is surely broken, but I need to commit it because it represents a fair bit of work.
This commit is contained in:
parent
b7a9b0b677
commit
4dd986a2db
125 changed files with 1213 additions and 399 deletions
|
@ -4,6 +4,7 @@ namespace Zotlabs\Access;
|
|||
|
||||
use App;
|
||||
use Zotlabs\Lib\PConfig;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
/**
|
||||
* @brief Permission limits.
|
||||
|
@ -92,7 +93,7 @@ class PermissionLimits
|
|||
$x = PConfig::Get($channel_id, 'perm_limits', $perm);
|
||||
if ($x === false) {
|
||||
$a = [ 'channel_id' => $channel_id, 'permission' => $perm, 'value' => $x ];
|
||||
call_hooks('permission_limits_get', $a);
|
||||
Hook::call('permission_limits_get', $a);
|
||||
return intval($a['value']);
|
||||
}
|
||||
return intval($x);
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
|
||||
namespace Zotlabs\Access;
|
||||
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
|
||||
/**
|
||||
* @brief PermissionRoles class.
|
||||
*
|
||||
|
@ -115,7 +118,7 @@ class PermissionRoles
|
|||
*/
|
||||
$x = ['role' => $role, 'result' => $ret];
|
||||
|
||||
call_hooks('get_role_perms', $x);
|
||||
Hook::call('get_role_perms', $x);
|
||||
|
||||
return $x['result'];
|
||||
}
|
||||
|
@ -144,7 +147,7 @@ class PermissionRoles
|
|||
],
|
||||
];
|
||||
|
||||
call_hooks('list_permission_roles', $roles);
|
||||
Hook::call('list_permission_roles', $roles);
|
||||
|
||||
return $roles;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Zotlabs\Access;
|
|||
|
||||
use Zotlabs\Lib as Zlib;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
/**
|
||||
* @brief Extensible permissions.
|
||||
|
@ -80,7 +81,7 @@ class Permissions
|
|||
* * \e array \b permissions
|
||||
* * \e string \b filter
|
||||
*/
|
||||
call_hooks('permissions_list', $x);
|
||||
Hook::call('permissions_list', $x);
|
||||
|
||||
return($x['permissions']);
|
||||
}
|
||||
|
@ -108,7 +109,7 @@ class Permissions
|
|||
* @hooks write_perms
|
||||
* * \e array \b permissions
|
||||
*/
|
||||
call_hooks('write_perms', $x);
|
||||
Hook::call('write_perms', $x);
|
||||
|
||||
return($x['permissions']);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
namespace Zotlabs\Daemon;
|
||||
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Addon
|
||||
{
|
||||
|
||||
public static function run($argc, $argv)
|
||||
{
|
||||
|
||||
call_hooks('daemon_addon', $argv);
|
||||
Hook::call('daemon_addon', $argv);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use Zotlabs\Lib\ServiceClass;
|
|||
use Zotlabs\Lib\Libzotdir;
|
||||
use Zotlabs\Lib\Libzot;
|
||||
use Zotlabs\Lib\Statistics;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Cron_daily
|
||||
{
|
||||
|
@ -105,7 +106,7 @@ class Cron_daily
|
|||
|
||||
remove_obsolete_hublocs();
|
||||
|
||||
call_hooks('cron_daily', datetime_convert());
|
||||
Hook::call('cron_daily', datetime_convert());
|
||||
|
||||
set_config('system', 'last_expire_day', intval(datetime_convert('UTC', 'UTC', 'now', 'd')));
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Zotlabs\Daemon;
|
||||
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Cron_weekly
|
||||
{
|
||||
|
@ -17,7 +18,7 @@ class Cron_weekly
|
|||
*
|
||||
*/
|
||||
|
||||
call_hooks('cron_weekly', datetime_convert());
|
||||
Hook::call('cron_weekly', datetime_convert());
|
||||
|
||||
z_check_cert();
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
/** @file */
|
||||
|
||||
namespace Zotlabs\Daemon;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Cronhooks
|
||||
{
|
||||
|
@ -14,7 +15,7 @@ class Cronhooks
|
|||
|
||||
$d = datetime_convert();
|
||||
|
||||
call_hooks('cron', $d);
|
||||
Hook::call('cron', $d);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Zotlabs\Daemon;
|
||||
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Deliver_hooks
|
||||
{
|
||||
|
||||
|
@ -18,7 +20,7 @@ class Deliver_hooks
|
|||
intval($argv[1])
|
||||
);
|
||||
if ($r) {
|
||||
call_hooks('notifier_normal', $r[0]);
|
||||
Hook::call('notifier_normal', $r[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ use Zotlabs\Lib\ActivityStreams;
|
|||
use Zotlabs\Lib\ActivityPub;
|
||||
use Zotlabs\Lib\LDSignatures;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/html2plain.php');
|
||||
require_once('include/conversation.php');
|
||||
|
@ -178,7 +179,7 @@ class Notifier
|
|||
break;
|
||||
}
|
||||
if (! $perm_update['success']) {
|
||||
call_hooks($cmd, $perm_update);
|
||||
Hook::call($cmd, $perm_update);
|
||||
}
|
||||
|
||||
if ($perm_update['success']) {
|
||||
|
@ -278,7 +279,7 @@ class Notifier
|
|||
'deliver' => false
|
||||
];
|
||||
|
||||
call_hooks('customitem_deliver', $hookinfo);
|
||||
Hook::call('customitem_deliver', $hookinfo);
|
||||
}
|
||||
|
||||
if (! $hookinfo['deliver']) {
|
||||
|
@ -552,7 +553,7 @@ class Notifier
|
|||
'queued' => []
|
||||
];
|
||||
|
||||
call_hooks('notifier_process', $narr);
|
||||
Hook::call('notifier_process', $narr);
|
||||
if ($narr['queued']) {
|
||||
foreach ($narr['queued'] as $pq) {
|
||||
self::$deliveries[] = $pq;
|
||||
|
@ -690,7 +691,7 @@ class Notifier
|
|||
|
||||
ActivityPub::notifier_process($narr);
|
||||
|
||||
call_hooks('notifier_hub', $narr);
|
||||
Hook::call('notifier_hub', $narr);
|
||||
if ($narr['queued']) {
|
||||
foreach ($narr['queued'] as $pq) {
|
||||
self::$deliveries[] = $pq;
|
||||
|
@ -807,7 +808,7 @@ class Notifier
|
|||
}
|
||||
}
|
||||
|
||||
call_hooks('notifier_end', $target_item);
|
||||
Hook::call('notifier_end', $target_item);
|
||||
|
||||
logger('notifer: complete.');
|
||||
return;
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Zotlabs\Daemon;
|
||||
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
if (array_search(__file__, get_included_files()) === 0) {
|
||||
require_once('include/cli_startup.php');
|
||||
array_shift($argv);
|
||||
|
@ -38,7 +40,7 @@ class Run
|
|||
'long_running' => self::$long_running
|
||||
];
|
||||
|
||||
call_hooks('daemon_summon', $hookinfo);
|
||||
Hook::call('daemon_summon', $hookinfo);
|
||||
|
||||
$arr = $hookinfo['argv'];
|
||||
$argc = count($arr);
|
||||
|
@ -60,7 +62,7 @@ class Run
|
|||
'long_running' => self::$long_running
|
||||
];
|
||||
|
||||
call_hooks('daemon_release', $hookinfo);
|
||||
Hook::call('daemon_release', $hookinfo);
|
||||
|
||||
$argv = $hookinfo['argv'];
|
||||
$argc = count($argv);
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
namespace Zotlabs\Daemon;
|
||||
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Thumbnail
|
||||
{
|
||||
|
||||
|
@ -46,7 +48,7 @@ class Thumbnail
|
|||
* * \e string \b thumbnail
|
||||
*/
|
||||
|
||||
call_hooks('thumbnail', $p);
|
||||
Hook::call('thumbnail', $p);
|
||||
if ($p['thumbnail']) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -133,4 +133,104 @@ class Hook
|
|||
|
||||
App::$hooks[$hook][] = [ '', $fn, $priority, $version ];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief loads all active hooks into memory
|
||||
* alters: App::$hooks
|
||||
* Called during initialisation
|
||||
* Duplicated hooks are removed and the duplicates ignored
|
||||
*
|
||||
* It might not be obvious but themes can manually add hooks to the App::$hooks
|
||||
* array in their theme_init() and use this to customise the app behaviour.
|
||||
* use insert_hook($hookname,$function_name) to do this.
|
||||
*/
|
||||
|
||||
|
||||
public static function load()
|
||||
{
|
||||
|
||||
App::$hooks = [];
|
||||
|
||||
$r = q("SELECT * FROM hook WHERE true ORDER BY priority DESC");
|
||||
if ($r) {
|
||||
foreach ($r as $rv) {
|
||||
$duplicated = false;
|
||||
if (! array_key_exists($rv['hook'], App::$hooks)) {
|
||||
App::$hooks[$rv['hook']] = [];
|
||||
} else {
|
||||
foreach (App::$hooks[$rv['hook']] as $h) {
|
||||
if ($h[0] === $rv['file'] && $h[1] === $rv['fn']) {
|
||||
$duplicated = true;
|
||||
q(
|
||||
"delete from hook where id = %d",
|
||||
intval($rv['id'])
|
||||
);
|
||||
logger('duplicate hook ' . $h[1] . ' removed');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (! $duplicated) {
|
||||
App::$hooks[$rv['hook']][] = [ $rv['file'], $rv['fn'], $rv['priority'], $rv['hook_version']];
|
||||
}
|
||||
}
|
||||
}
|
||||
// logger('hooks: ' . print_r(App::$hooks,true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @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[in,out] string|array &$data to transmit to the callback handler
|
||||
*/
|
||||
static public function call($name, &$data = null)
|
||||
{
|
||||
$a = 0;
|
||||
|
||||
if (isset(App::$hooks[$name])) {
|
||||
foreach (App::$hooks[$name] as $hook) {
|
||||
$origfn = $hook[1];
|
||||
if ($hook[0]) {
|
||||
@include_once($hook[0]);
|
||||
}
|
||||
if (preg_match('|^a:[0-9]+:{.*}$|s', $hook[1])) {
|
||||
$hook[1] = unserialize($hook[1]);
|
||||
} elseif (strpos($hook[1], '::')) {
|
||||
// We shouldn't need to do this, but it appears that PHP
|
||||
// isn't able to directly execute a string variable with a class
|
||||
// method in the manner we are attempting it, so we'll
|
||||
// turn it into an array.
|
||||
$hook[1] = explode('::', $hook[1]);
|
||||
}
|
||||
|
||||
if (is_callable($hook[1])) {
|
||||
$func = $hook[1];
|
||||
if ($hook[3]) {
|
||||
$func($data);
|
||||
} else {
|
||||
$func($a, $data);
|
||||
}
|
||||
} else {
|
||||
// Don't do any DB write calls if we're currently logging a possibly failed DB call.
|
||||
if (! DBA::$logging) {
|
||||
// The hook should be removed so we don't process it.
|
||||
q(
|
||||
"DELETE FROM hook WHERE hook = '%s' AND file = '%s' AND fn = '%s'",
|
||||
dbesc($name),
|
||||
dbesc($hook[0]),
|
||||
dbesc($origfn)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ use Zotlabs\Access\PermissionLimits;
|
|||
use Zotlabs\Access\PermissionRoles;
|
||||
use Zotlabs\Access\Permissions;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Friendica
|
||||
{
|
||||
|
@ -295,7 +296,7 @@ class Friendica
|
|||
}
|
||||
}
|
||||
|
||||
call_hooks('create_identity', $newuid);
|
||||
Hook::call('create_identity', $newuid);
|
||||
}
|
||||
|
||||
$this->groups = ((isset($this->data['group'])) ? $this->data['group'] : null);
|
||||
|
|
|
@ -11,6 +11,7 @@ use App;
|
|||
use Zotlabs\Lib\Crypto;
|
||||
use Zotlabs\Lib\System;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Account {
|
||||
|
||||
|
@ -45,7 +46,7 @@ class Account {
|
|||
}
|
||||
|
||||
$arr = array('email' => $email, 'result' => $result);
|
||||
call_hooks('check_account_email', $arr);
|
||||
Hook::call('check_account_email', $arr);
|
||||
|
||||
return $arr['result'];
|
||||
}
|
||||
|
@ -59,7 +60,7 @@ class Account {
|
|||
// Use hooked functions to perform complexity requirement checks.
|
||||
|
||||
$arr = [ 'password' => $password, 'result' => $result ];
|
||||
call_hooks('check_account_password', $arr);
|
||||
Hook::call('check_account_password', $arr);
|
||||
|
||||
return $arr['result'];
|
||||
}
|
||||
|
@ -84,7 +85,7 @@ class Account {
|
|||
}
|
||||
|
||||
$arr = [ 'invite_code' => $invite_code, 'result' => $result ];
|
||||
call_hooks('check_account_invite', $arr);
|
||||
Hook::call('check_account_invite', $arr);
|
||||
|
||||
return $arr['result'];
|
||||
}
|
||||
|
@ -255,7 +256,7 @@ class Account {
|
|||
$result['email'] = $email;
|
||||
$result['password'] = $password;
|
||||
|
||||
call_hooks('register_account', $result);
|
||||
Hook::call('register_account', $result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ use Zotlabs\Lib\Libzot;
|
|||
use Zotlabs\Lib\Nodeinfo;
|
||||
use Zotlabs\Lib\System;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
use Emoji;
|
||||
|
||||
require_once('include/html2bbcode.php');
|
||||
|
@ -68,7 +69,7 @@ class Activity
|
|||
return self::fetch_thing($x);
|
||||
}
|
||||
|
||||
call_hooks('encode_object', $x);
|
||||
Hook::call('encode_object', $x);
|
||||
|
||||
return $x;
|
||||
}
|
||||
|
@ -1732,7 +1733,7 @@ class Activity
|
|||
}
|
||||
|
||||
$arr = ['xchan' => $p, 'encoded' => $ret, 'activitypub' => $activitypub];
|
||||
call_hooks('encode_person', $arr);
|
||||
Hook::call('encode_person', $arr);
|
||||
$ret = $arr['encoded'];
|
||||
|
||||
|
||||
|
@ -1813,7 +1814,7 @@ class Activity
|
|||
'http://activitystrea.ms/schema/1.0/unfollow' => 'Ignore',
|
||||
];
|
||||
|
||||
call_hooks('activity_mapper', $acts);
|
||||
Hook::call('activity_mapper', $acts);
|
||||
|
||||
if (array_key_exists($verb, $acts) && $acts[$verb]) {
|
||||
return $acts[$verb];
|
||||
|
@ -1863,7 +1864,7 @@ class Activity
|
|||
|
||||
];
|
||||
|
||||
call_hooks('activity_obj_mapper', $objs);
|
||||
Hook::call('activity_obj_mapper', $objs);
|
||||
|
||||
if ($obj === 'Answer') {
|
||||
return 'Note';
|
||||
|
@ -3358,7 +3359,7 @@ class Activity
|
|||
's' => $s
|
||||
];
|
||||
|
||||
call_hooks('decode_note', $hookinfo);
|
||||
Hook::call('decode_note', $hookinfo);
|
||||
|
||||
$s = $hookinfo['s'];
|
||||
|
||||
|
@ -3956,7 +3957,7 @@ class Activity
|
|||
'item' => $item
|
||||
];
|
||||
|
||||
call_hooks('fetch_and_store', $hookinfo);
|
||||
Hook::call('fetch_and_store', $hookinfo);
|
||||
|
||||
$item = $hookinfo['item'];
|
||||
|
||||
|
|
285
Zotlabs/Lib/Addon.php
Normal file
285
Zotlabs/Lib/Addon.php
Normal file
|
@ -0,0 +1,285 @@
|
|||
<?php
|
||||
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
use App;
|
||||
|
||||
class Addon {
|
||||
|
||||
/**
|
||||
* @brief Handle errors in plugin calls
|
||||
*
|
||||
* @param string $addon name of the addon
|
||||
* @param string $error_text text of error
|
||||
* @param bool $uninstall uninstall plugin
|
||||
*/
|
||||
public static function ErrorHandler($addon, $notice, $log, $uninstall = false)
|
||||
{
|
||||
logger("Addons: [" . $addon . "] Error: ".$log, LOGGER_ERROR);
|
||||
if ($notice != '') {
|
||||
notice("[" . $addon . "] Error: ".$notice, LOGGER_ERROR);
|
||||
}
|
||||
|
||||
if ($uninstall) {
|
||||
self::uninstall($addon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Unloads an addon.
|
||||
*
|
||||
* @param string $addon name of the addon
|
||||
*/
|
||||
public static function unload($addon)
|
||||
{
|
||||
logger("Addons: unloading " . $addon, LOGGER_DEBUG);
|
||||
|
||||
@include_once('addon/' . $addon . '/' . $addon . '.php');
|
||||
if (function_exists($addon . '_unload')) {
|
||||
$func = $addon . '_unload';
|
||||
try {
|
||||
$func();
|
||||
} catch (Exception $e) {
|
||||
self::ErrorHandler($addon, "Unable to unload.", $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Uninstalls an addon.
|
||||
*
|
||||
* @param string $addon name of the addon
|
||||
* @return bool
|
||||
*/
|
||||
public static function uninstall($addon)
|
||||
{
|
||||
|
||||
self::unload($addon);
|
||||
|
||||
if (! file_exists('addon/' . $addon . '/' . $addon . '.php')) {
|
||||
q(
|
||||
"DELETE FROM addon WHERE aname = '%s' ",
|
||||
dbesc($addon)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
logger("Addons: uninstalling " . $addon);
|
||||
//$t = @filemtime('addon/' . $addon . '/' . $addon . '.php');
|
||||
@include_once('addon/' . $addon . '/' . $addon . '.php');
|
||||
if (function_exists($addon . '_uninstall')) {
|
||||
$func = $addon . '_uninstall';
|
||||
try {
|
||||
$func();
|
||||
} catch (Exception $e) {
|
||||
self::ErrorHandler($addon, "Unable to uninstall.", "Unable to run _uninstall : ".$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
q(
|
||||
"DELETE FROM addon WHERE aname = '%s' ",
|
||||
dbesc($addon)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Installs an addon.
|
||||
*
|
||||
* This function is called once to install the addon (either from the cli or via
|
||||
* the web admin). This will also call load_plugin() once.
|
||||
*
|
||||
* @param string $addon name of the addon
|
||||
* @return bool
|
||||
*/
|
||||
public static function install($addon)
|
||||
{
|
||||
if (! file_exists('addon/' . $addon . '/' . $addon . '.php')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logger("Addons: installing " . $addon);
|
||||
$t = @filemtime('addon/' . $addon . '/' . $addon . '.php');
|
||||
@include_once('addon/' . $addon . '/' . $addon . '.php');
|
||||
if (function_exists($addon . '_install')) {
|
||||
$func = $addon . '_install';
|
||||
try {
|
||||
$func();
|
||||
} catch (Exception $e) {
|
||||
self::ErrorHandler($addon, "Install failed.", "Install failed : ".$e->getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$addon_admin = (function_exists($addon . '_plugin_admin') ? 1 : 0);
|
||||
|
||||
$d = q(
|
||||
"select * from addon where aname = '%s' limit 1",
|
||||
dbesc($addon)
|
||||
);
|
||||
if (! $d) {
|
||||
q(
|
||||
"INSERT INTO addon (aname, installed, tstamp, plugin_admin) VALUES ( '%s', 1, %d , %d ) ",
|
||||
dbesc($addon),
|
||||
intval($t),
|
||||
$addon_admin
|
||||
);
|
||||
}
|
||||
|
||||
self::load($addon);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief loads an addon by it's name.
|
||||
*
|
||||
* @param string $addon name of the addon
|
||||
* @return bool
|
||||
*/
|
||||
public static function load($addon)
|
||||
{
|
||||
// silently fail if plugin was removed
|
||||
if (! file_exists('addon/' . $addon . '/' . $addon . '.php')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
logger("Addons: loading " . $addon, LOGGER_DEBUG);
|
||||
//$t = @filemtime('addon/' . $addon . '/' . $addon . '.php');
|
||||
@include_once('addon/' . $addon . '/' . $addon . '.php');
|
||||
if (function_exists($addon . '_load')) {
|
||||
$func = $addon . '_load';
|
||||
try {
|
||||
$func();
|
||||
} catch (Exception $e) {
|
||||
self::ErrorHandler($addon, "Unable to load.", "FAILED loading : ".$e->getMessage(), true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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/' . $addon . '/.hidden')) {
|
||||
q(
|
||||
"update addon set hidden = 1 where name = '%s'",
|
||||
dbesc($addon)
|
||||
);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
logger("Addons: FAILED loading " . $addon . " (missing _load function)");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Check if addon is installed.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
public static function is_installed($name)
|
||||
{
|
||||
$r = q(
|
||||
"select aname from addon where aname = '%s' and installed = 1 limit 1",
|
||||
dbesc($name)
|
||||
);
|
||||
if ($r) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reload all updated plugins.
|
||||
*/
|
||||
public static function reload_all()
|
||||
{
|
||||
$addons = get_config('system', 'addon');
|
||||
if (strlen($addons)) {
|
||||
$r = q("SELECT * FROM addon WHERE installed = 1");
|
||||
if (count($r)) {
|
||||
$installed = $r;
|
||||
} else {
|
||||
$installed = [];
|
||||
}
|
||||
|
||||
$parr = explode(',', $addons);
|
||||
|
||||
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['aname'] == $pl) && ($i['tstamp'] != $t)) {
|
||||
logger('Reloading plugin: ' . $i['aname']);
|
||||
@include_once($fname);
|
||||
|
||||
if (function_exists($pl . '_unload')) {
|
||||
$func = $pl . '_unload';
|
||||
try {
|
||||
$func();
|
||||
} catch (Exception $e) {
|
||||
self::ErrorHandler($addon, "", "UNLOAD FAILED (uninstalling) : ".$e->getMessage(), true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (function_exists($pl . '_load')) {
|
||||
$func = $pl . '_load';
|
||||
try {
|
||||
$func();
|
||||
} catch (Exception $e) {
|
||||
self::ErrorHandler($addon, "", "LOAD FAILED (uninstalling): ".$e->getMessage(), true);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
q(
|
||||
"UPDATE addon SET tstamp = %d WHERE id = %d",
|
||||
intval($t),
|
||||
intval($i['id'])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static function list_installed()
|
||||
{
|
||||
|
||||
$r = q("select * from addon where installed = 1 order by aname asc");
|
||||
return(($r) ? ids_to_array($r, 'aname') : []);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get a list of non hidden addons.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function list_visible()
|
||||
{
|
||||
|
||||
$r = q("select * from addon where hidden = 0 order by aname asc");
|
||||
$x = (($r) ? ids_to_array($r, 'aname') : []);
|
||||
$y = [];
|
||||
if ($x) {
|
||||
foreach ($x as $xv) {
|
||||
if (is_dir('addon/' . $xv)) {
|
||||
$y[] = $xv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $y;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -6,6 +6,8 @@ use App;
|
|||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Lib\Features;
|
||||
use Zotlabs\Extend\Hook;
|
||||
use Zotlabs\Lib\Addon;
|
||||
|
||||
/**
|
||||
* Apps
|
||||
|
@ -42,7 +44,7 @@ class Apps
|
|||
foreach ($files as $f) {
|
||||
$path = explode('/', $f);
|
||||
$plugin = trim($path[1]);
|
||||
if (addon_is_installed($plugin)) {
|
||||
if (Addon::is_installed($plugin)) {
|
||||
$x = self::parse_app_description($f, $translate);
|
||||
if ($x) {
|
||||
$x['plugin'] = $plugin;
|
||||
|
@ -52,7 +54,7 @@ class Apps
|
|||
}
|
||||
}
|
||||
|
||||
call_hooks('get_system_apps', $ret);
|
||||
Hook::call('get_system_apps', $ret);
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
@ -92,7 +94,7 @@ class Apps
|
|||
}
|
||||
|
||||
$x = get_config('system', 'base_apps', $default_apps);
|
||||
call_hooks('get_base_apps', $x);
|
||||
Hook::call('get_base_apps', $x);
|
||||
return $x;
|
||||
}
|
||||
|
||||
|
@ -464,7 +466,7 @@ class Apps
|
|||
|
||||
self::translate_system_apps($papp);
|
||||
|
||||
if (isset($papp['plugin']) && trim($papp['plugin']) && (!addon_is_installed(trim($papp['plugin'])))) {
|
||||
if (isset($papp['plugin']) && trim($papp['plugin']) && (!Addon::is_installed(trim($papp['plugin'])))) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -740,7 +742,7 @@ class Apps
|
|||
intval(TERM_OBJ_APP),
|
||||
intval($x[0]['id'])
|
||||
);
|
||||
call_hooks('app_destroy', $x[0]);
|
||||
Hook::call('app_destroy', $x[0]);
|
||||
} else {
|
||||
$r = q(
|
||||
"update app set app_deleted = 1 where app_id = '%s' and app_channel = %d",
|
||||
|
@ -825,7 +827,7 @@ class Apps
|
|||
'app' => $app,
|
||||
'installed' => $r
|
||||
];
|
||||
call_hooks('app_installed_filter', $filter_arr);
|
||||
Hook::call('app_installed_filter', $filter_arr);
|
||||
$r = $filter_arr['installed'];
|
||||
}
|
||||
|
||||
|
@ -846,7 +848,7 @@ class Apps
|
|||
'app' => $app,
|
||||
'installed' => $r
|
||||
];
|
||||
call_hooks('addon_app_installed_filter', $filter_arr);
|
||||
Hook::call('addon_app_installed_filter', $filter_arr);
|
||||
$r = $filter_arr['installed'];
|
||||
}
|
||||
|
||||
|
@ -867,7 +869,7 @@ class Apps
|
|||
'app' => $app,
|
||||
'installed' => $r
|
||||
];
|
||||
call_hooks('system_app_installed_filter', $filter_arr);
|
||||
Hook::call('system_app_installed_filter', $filter_arr);
|
||||
$r = $filter_arr['installed'];
|
||||
}
|
||||
|
||||
|
@ -911,7 +913,7 @@ class Apps
|
|||
|
||||
if ($r) {
|
||||
$hookinfo = ['uid' => $uid, 'deleted' => $deleted, 'cats' => $cats, 'apps' => $r];
|
||||
call_hooks('app_list', $hookinfo);
|
||||
Hook::call('app_list', $hookinfo);
|
||||
$r = $hookinfo['apps'];
|
||||
for ($x = 0; $x < count($r); $x++) {
|
||||
if (!$r[$x]['app_system']) {
|
||||
|
|
|
@ -20,6 +20,7 @@ use Zotlabs\Daemon\Run;
|
|||
use Zotlabs\Lib\System;
|
||||
use Zotlabs\Render\Comanche;
|
||||
use Zotlabs\Lib\ServiceClass;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/photo_factory.php');
|
||||
|
||||
|
@ -60,7 +61,7 @@ class Channel
|
|||
* * \e string \b name
|
||||
* * \e string \b message - return error message
|
||||
*/
|
||||
call_hooks('validate_channelname', $arr);
|
||||
Hook::call('validate_channelname', $arr);
|
||||
|
||||
if (x($arr, 'message')) {
|
||||
return $arr['message'];
|
||||
|
@ -360,7 +361,7 @@ class Channel
|
|||
* * \e array \b channel
|
||||
* * \e string \b photo_url - Return value
|
||||
*/
|
||||
call_hooks('create_channel_photo', $z);
|
||||
Hook::call('create_channel_photo', $z);
|
||||
|
||||
// The site channel gets the project logo as a profile photo.
|
||||
if ($arr['account_id'] === 'xxx') {
|
||||
|
@ -558,7 +559,7 @@ class Channel
|
|||
* * \e int - The UID of the created identity
|
||||
*/
|
||||
|
||||
call_hooks('create_identity', $newuid);
|
||||
Hook::call('create_identity', $newuid);
|
||||
|
||||
Run::Summon([ 'Directory', $ret['channel']['channel_id'] ]);
|
||||
}
|
||||
|
@ -851,7 +852,7 @@ class Channel
|
|||
* Called to get the default list of functional data groups to export in Channel::basic_export().
|
||||
* * \e array \b sections - return value
|
||||
*/
|
||||
call_hooks('get_default_export_sections', $cb);
|
||||
Hook::call('get_default_export_sections', $cb);
|
||||
|
||||
return $cb['sections'];
|
||||
}
|
||||
|
@ -1152,7 +1153,7 @@ class Channel
|
|||
* * \e array \b sections
|
||||
* * \e array \b data - The data will get returned
|
||||
*/
|
||||
call_hooks('identity_basic_export', $addon);
|
||||
Hook::call('identity_basic_export', $addon);
|
||||
$ret = $addon['data'];
|
||||
|
||||
return $ret;
|
||||
|
@ -1364,7 +1365,7 @@ class Channel
|
|||
* * \e string \b zid - their zid
|
||||
* * \e string \b url - the destination url
|
||||
*/
|
||||
call_hooks('zid_init', $arr);
|
||||
Hook::call('zid_init', $arr);
|
||||
|
||||
if (! local_channel()) {
|
||||
$r = q(
|
||||
|
@ -1472,7 +1473,7 @@ class Channel
|
|||
|
||||
if (! is_dir('images/default_profile_photos/' . $scheme)) {
|
||||
$x = [ 'scheme' => $scheme, 'size' => $size, 'url' => '' ];
|
||||
call_hooks('default_profile_photo', $x);
|
||||
Hook::call('default_profile_photo', $x);
|
||||
if ($x['url']) {
|
||||
return $x['url'];
|
||||
} else {
|
||||
|
@ -2252,7 +2253,7 @@ class Channel
|
|||
* * \e array with entry from channel tabel for $channel_id
|
||||
*/
|
||||
|
||||
call_hooks('channel_remove', $channel);
|
||||
Hook::call('channel_remove', $channel);
|
||||
|
||||
$r = q(
|
||||
"select iid from iconfig left join item on item.id = iconfig.iid
|
||||
|
@ -2428,7 +2429,7 @@ class Channel
|
|||
* * \e string \b xchan - return value
|
||||
* * \e string|int \b success - Must be a number, so xchan return value gets used
|
||||
*/
|
||||
call_hooks('anon_identity_init', $x);
|
||||
Hook::call('anon_identity_init', $x);
|
||||
|
||||
if ($x['success'] !== 'unset' && intval($x['success']) && $x['xchan']) {
|
||||
return $x['xchan'];
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Zotlabs\Lib;
|
|||
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Lib\ServiceClass;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
/**
|
||||
* @brief A class with chatroom related static methods.
|
||||
|
@ -297,7 +298,7 @@ class Chatroom
|
|||
* * \e string \b chat_xchan
|
||||
* * \e string \b chat_text
|
||||
*/
|
||||
call_hooks('chat_message', $arr);
|
||||
Hook::call('chat_message', $arr);
|
||||
|
||||
$x = q(
|
||||
"insert into chat ( chat_room, chat_xchan, created, chat_text )
|
||||
|
|
|
@ -6,6 +6,7 @@ use App;
|
|||
use Zotlabs\Lib\ServiceClass;
|
||||
use Zotlabs\Access\Permissions;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Connect
|
||||
{
|
||||
|
@ -293,7 +294,7 @@ class Connect
|
|||
|
||||
$arr = ['channel_id' => $uid, 'channel' => $channel, 'abook' => $result['abook']];
|
||||
|
||||
call_hooks('follow', $arr);
|
||||
Hook::call('follow', $arr);
|
||||
|
||||
/** If there is a default group for this channel, add this connection to it */
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Zotlabs\Lib;
|
||||
|
||||
use Exception;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Crypto
|
||||
{
|
||||
|
@ -26,7 +27,7 @@ class Crypto
|
|||
$ret[] = $ossl[0] . '.oaep';
|
||||
}
|
||||
|
||||
call_hooks('crypto_methods', $ret);
|
||||
Hook::call('crypto_methods', $ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
@ -35,7 +36,7 @@ class Crypto
|
|||
{
|
||||
|
||||
$ret = [ 'sha256' ];
|
||||
call_hooks('signing_methods', $ret);
|
||||
Hook::call('signing_methods', $ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
@ -162,7 +163,7 @@ class Crypto
|
|||
return $result;
|
||||
} else {
|
||||
$x = [ 'data' => $data, 'pubkey' => $pubkey, 'alg' => $alg, 'result' => $data ];
|
||||
call_hooks('crypto_encapsulate', $x);
|
||||
Hook::call('crypto_encapsulate', $x);
|
||||
return $x['result'];
|
||||
}
|
||||
}
|
||||
|
@ -206,7 +207,7 @@ class Crypto
|
|||
return openssl_decrypt(base64url_decode($data['data']), $method[1], substr($k, 0, $method[2]), OPENSSL_RAW_DATA, substr($i, 0, $method[3]));
|
||||
} else {
|
||||
$x = [ 'data' => $data, 'prvkey' => $prvkey, 'alg' => $data['alg'], 'result' => $data ];
|
||||
call_hooks('crypto_unencapsulate', $x);
|
||||
Hook::call('crypto_unencapsulate', $x);
|
||||
return $x['result'];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class DReport
|
||||
{
|
||||
|
||||
|
@ -84,7 +86,7 @@ class DReport
|
|||
* * \e array
|
||||
*/
|
||||
|
||||
call_hooks('dreport_is_storable', $dr);
|
||||
Hook::call('dreport_is_storable', $dr);
|
||||
|
||||
// let plugins accept or reject - if neither, continue on
|
||||
if (array_key_exists('accept', $dr) && intval($dr['accept'])) {
|
||||
|
|
|
@ -6,6 +6,7 @@ use App;
|
|||
use Zotlabs\Lib\LibBlock;
|
||||
use Zotlabs\Lib\System;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
/**
|
||||
* @brief File with functions and a class for generating system and email notifications.
|
||||
|
@ -510,7 +511,7 @@ class Enotify
|
|||
'recipient' => $recip
|
||||
);
|
||||
|
||||
call_hooks('enotify', $h);
|
||||
Hook::call('enotify', $h);
|
||||
|
||||
$subject = $h['subject'];
|
||||
$preamble = $h['preamble'];
|
||||
|
@ -568,7 +569,7 @@ class Enotify
|
|||
}
|
||||
}
|
||||
|
||||
call_hooks('enotify_store', $datarray);
|
||||
Hook::call('enotify_store', $datarray);
|
||||
|
||||
if ($datarray['abort']) {
|
||||
pop_lang();
|
||||
|
@ -718,7 +719,7 @@ class Enotify
|
|||
$datarray['headers'] = $additional_mail_header;
|
||||
$datarray['email_secure'] = false;
|
||||
|
||||
call_hooks('enotify_mail', $datarray);
|
||||
Hook::call('enotify_mail', $datarray);
|
||||
|
||||
// Default to private - don't disclose message contents over insecure channels (such as email)
|
||||
// Might be interesting to use GPG,PGP,S/MIME encryption instead
|
||||
|
@ -849,7 +850,7 @@ class Enotify
|
|||
$params['sent'] = false;
|
||||
$params['result'] = false;
|
||||
|
||||
call_hooks('email_send', $params);
|
||||
Hook::call('email_send', $params);
|
||||
|
||||
if ($params['sent']) {
|
||||
logger("notification: enotify::send (addon) returns " . (($params['result']) ? 'success' : 'failure'), LOGGER_DEBUG);
|
||||
|
@ -972,7 +973,7 @@ class Enotify
|
|||
return [];
|
||||
}
|
||||
|
||||
call_hooks('enotify_format', $x);
|
||||
Hook::call('enotify_format', $x);
|
||||
if (! $x['display']) {
|
||||
return [];
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Zotlabs\Lib;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
|
||||
class Features {
|
||||
|
@ -21,7 +22,7 @@ class Features {
|
|||
}
|
||||
}
|
||||
$arr = array('uid' => $uid, 'feature' => $feature, 'enabled' => $x);
|
||||
call_hooks('feature_enabled', $arr);
|
||||
Hook::call('feature_enabled', $arr);
|
||||
return($arr['enabled']);
|
||||
}
|
||||
|
||||
|
@ -531,7 +532,7 @@ class Features {
|
|||
];
|
||||
|
||||
$x = [ 'features' => $arr, ];
|
||||
call_hooks('get_features', $x);
|
||||
Hook::call('get_features', $x);
|
||||
|
||||
$arr = $x['features'];
|
||||
|
||||
|
|
209
Zotlabs/Lib/Head.php
Normal file
209
Zotlabs/Lib/Head.php
Normal file
|
@ -0,0 +1,209 @@
|
|||
<?php
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Render\Theme;
|
||||
|
||||
class Head {
|
||||
|
||||
/**
|
||||
* @brief add CSS to \<head\>
|
||||
*
|
||||
* @param string $src
|
||||
* @param string $media change media attribute (default to 'screen')
|
||||
*/
|
||||
public static function add_css($src, $media = 'screen')
|
||||
{
|
||||
App::$css_sources[] = [ $src, $media ];
|
||||
}
|
||||
|
||||
public static function remove_css($src, $media = 'screen')
|
||||
{
|
||||
|
||||
$index = array_search([$src, $media], App::$css_sources);
|
||||
if ($index !== false) {
|
||||
unset(App::$css_sources[$index]);
|
||||
}
|
||||
// re-index the array
|
||||
App::$css_sources = array_values(App::$css_sources);
|
||||
}
|
||||
|
||||
public static function get_css()
|
||||
{
|
||||
$str = EMPTY_STR;
|
||||
$sources = App::$css_sources;
|
||||
if (is_array($sources) && $sources) {
|
||||
foreach ($sources as $source) {
|
||||
$str .= self::format_css_if_exists($source);
|
||||
}
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function add_link($arr)
|
||||
{
|
||||
if ($arr) {
|
||||
App::$linkrel[] = $arr;
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_links()
|
||||
{
|
||||
$str = '';
|
||||
$sources = App::$linkrel;
|
||||
if (is_array($sources) && $sources) {
|
||||
foreach ($sources as $source) {
|
||||
if (is_array($source) && $source) {
|
||||
$str .= '<link';
|
||||
foreach ($source as $k => $v) {
|
||||
$str .= ' ' . $k . '="' . $v . '"';
|
||||
}
|
||||
$str .= ' />' . "\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function format_css_if_exists($source)
|
||||
{
|
||||
|
||||
// script_path() returns https://yoursite.tld
|
||||
|
||||
$path_prefix = self::script_path();
|
||||
|
||||
$script = $source[0];
|
||||
|
||||
if (strpos($script, '/') !== false) {
|
||||
// The script is a path relative to the server root
|
||||
$path = $script;
|
||||
// If the url starts with // then it's an absolute URL
|
||||
if (substr($script, 0, 2) === '//') {
|
||||
$path_prefix = '';
|
||||
}
|
||||
} else {
|
||||
// It's a file from the theme
|
||||
FIXME
|
||||
$path = '/' . Theme::include($script);
|
||||
}
|
||||
|
||||
if ($path) {
|
||||
$qstring = ((parse_url($path, PHP_URL_QUERY)) ? '&' : '?') . 'v=' . STD_VERSION;
|
||||
return '<link rel="stylesheet" href="' . $path_prefix . $path . $qstring . '" type="text/css" media="' . $source[1] . '">' . "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This basically calculates the baseurl. We have other functions to do that, but
|
||||
* there was an issue with script paths and mixed-content whose details are arcane
|
||||
* and perhaps lost in the message archives. The short answer is that we're ignoring
|
||||
* the URL which we are "supposed" to use, and generating script paths relative to
|
||||
* the URL which we are currently using; in order to ensure they are found and aren't
|
||||
* blocked due to mixed content issues.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function script_path()
|
||||
{
|
||||
if (x($_SERVER, 'HTTPS') && $_SERVER['HTTPS']) {
|
||||
$scheme = 'https';
|
||||
} elseif (x($_SERVER, 'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443)) {
|
||||
$scheme = 'https';
|
||||
} elseif (!empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' || !empty($_SERVER['HTTP_X_FORWARDED_SSL']) && $_SERVER['HTTP_X_FORWARDED_SSL'] == 'on') {
|
||||
$scheme = 'https';
|
||||
} else {
|
||||
$scheme = 'http';
|
||||
}
|
||||
|
||||
// Some proxy setups may require using http_host
|
||||
|
||||
if (isset(App::$config['system']['script_path_use_http_host']) && intval(App::$config['system']['script_path_use_http_host'])) {
|
||||
$server_var = 'HTTP_HOST';
|
||||
} else {
|
||||
$server_var = 'SERVER_NAME';
|
||||
}
|
||||
|
||||
|
||||
if (x($_SERVER, $server_var)) {
|
||||
$hostname = $_SERVER[$server_var];
|
||||
} else {
|
||||
return z_root();
|
||||
}
|
||||
|
||||
return $scheme . '://' . $hostname;
|
||||
}
|
||||
|
||||
public static function add_js($src, $priority = 0)
|
||||
{
|
||||
if (! (isset(App::$js_sources[$priority]) && is_array(App::$js_sources[$priority]))) {
|
||||
App::$js_sources[$priority] = [];
|
||||
}
|
||||
App::$js_sources[$priority][] = $src;
|
||||
}
|
||||
|
||||
public static function remove_js($src, $priority = 0)
|
||||
{
|
||||
|
||||
$index = array_search($src, App::$js_sources[$priority]);
|
||||
if ($index !== false) {
|
||||
unset(App::$js_sources[$priority][$index]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We should probably try to register main.js with a high priority, but currently
|
||||
* we handle it separately and put it at the end of the html head block in case
|
||||
* any other javascript is added outside the head_add_js construct.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_js()
|
||||
{
|
||||
|
||||
$str = '';
|
||||
if (App::$js_sources) {
|
||||
ksort(App::$js_sources, SORT_NUMERIC);
|
||||
foreach (App::$js_sources as $sources) {
|
||||
if (count($sources)) {
|
||||
foreach ($sources as $source) {
|
||||
if ($source === 'main.js') {
|
||||
continue;
|
||||
}
|
||||
$str .= self::format_js_if_exists($source);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
public static function get_main_js()
|
||||
{
|
||||
return self::self::format_js_if_exists('main.js', true);
|
||||
}
|
||||
|
||||
public static function format_js_if_exists($source)
|
||||
{
|
||||
$path_prefix = self::script_path();
|
||||
|
||||
if (strpos($source, '/') !== false) {
|
||||
// The source is a known path on the system
|
||||
$path = $source;
|
||||
// If the url starts with // then it's an absolute URL
|
||||
if (substr($source, 0, 2) === '//') {
|
||||
$path_prefix = '';
|
||||
}
|
||||
} else {
|
||||
// It's a file from the theme
|
||||
$path = '/' . Theme::include($source);
|
||||
}
|
||||
if ($path) {
|
||||
$qstring = ((parse_url($path, PHP_URL_QUERY)) ? '&' : '?') . 'v=' . STD_VERSION;
|
||||
return '<script src="' . $path_prefix . $path . $qstring . '" ></script>' . "\r\n" ;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
76
Zotlabs/Lib/Infocon.php
Normal file
76
Zotlabs/Lib/Infocon.php
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
namespace Zotlabs\Lib;
|
||||
|
||||
/**
|
||||
* Infocon class: extract information and configuration structures from source modules.
|
||||
*/
|
||||
|
||||
use Exception;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
|
||||
class Infocon {
|
||||
|
||||
public static function from_file($name) {
|
||||
$info = NULL;
|
||||
if (file_exists($name)) {
|
||||
try {
|
||||
$info = Yaml::parseFile($name, Yaml::PARSE_DATETIME);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
public static function from_str($str) {
|
||||
$info = NULL;
|
||||
if ($str) {
|
||||
try {
|
||||
$info = Yaml::parse($str, Yaml::PARSE_DATETIME);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
;
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
public static function from_c_comment($file) {
|
||||
$info = NULL;
|
||||
try {
|
||||
$code = file_get_contents($file);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
;
|
||||
}
|
||||
// Match and fetch the first C-style comment
|
||||
$result = preg_match("|/\*.*\*/|msU", $code, $matches);
|
||||
|
||||
if ($result) {
|
||||
$lines = explode("\n", $m[0]);
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line, "\t\n\r */");
|
||||
if ($line != "") {
|
||||
list($k, $v) = array_map("trim", explode(":", $line, 2));
|
||||
$k = strtolower($k);
|
||||
// multiple lines with the same key are turned into an array
|
||||
if (isset($info[$k])) {
|
||||
if (is_array($info[$k])) {
|
||||
$info[$k][] = $v;
|
||||
}
|
||||
else {
|
||||
$info[$k] = [ $info[$k], $v ];
|
||||
}
|
||||
}
|
||||
else {
|
||||
$info[$k] = $v;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $info;
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ use App;
|
|||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Lib\Features;
|
||||
use Zotlabs\Lib\Menu;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Libprofile
|
||||
{
|
||||
|
@ -281,7 +282,7 @@ class Libprofile
|
|||
* @hooks profile_sidebar_enter
|
||||
* Called before generating the 'channel sidebar' or mini-profile.
|
||||
*/
|
||||
call_hooks('profile_sidebar_enter', $profile);
|
||||
Hook::call('profile_sidebar_enter', $profile);
|
||||
|
||||
$profdm = EMPTY_STR;
|
||||
$profdm_url = EMPTY_STR;
|
||||
|
@ -418,7 +419,7 @@ class Libprofile
|
|||
* * \e array \b profile
|
||||
* * \e string \b entry - The parsed HTML template
|
||||
*/
|
||||
call_hooks('profile_sidebar', $arr);
|
||||
Hook::call('profile_sidebar', $arr);
|
||||
|
||||
return $arr['entry'];
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ use Zotlabs\Lib\Connect;
|
|||
use Zotlabs\Lib\ServiceClass;
|
||||
use Zotlabs\Lib\DReport;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Libsync
|
||||
{
|
||||
|
@ -887,7 +888,7 @@ class Libsync
|
|||
* * \e array \b channel
|
||||
* * \e array \b data
|
||||
*/
|
||||
call_hooks('process_channel_sync_delivery', $addon);
|
||||
Hook::call('process_channel_sync_delivery', $addon);
|
||||
|
||||
$DR = new DReport(z_root(), $d, $d, 'sync', 'channel sync delivered');
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ use Zotlabs\Lib\Channel;
|
|||
use Zotlabs\Lib\ASCollection;
|
||||
use Zotlabs\Lib\LDSignatures;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/html2bbcode.php');
|
||||
|
||||
|
@ -186,7 +187,7 @@ class Libzot
|
|||
* * \e string \b result - the algorithm to return
|
||||
*/
|
||||
|
||||
call_hooks('zot_best_algorithm', $x);
|
||||
Hook::call('zot_best_algorithm', $x);
|
||||
|
||||
if ($x['result']) {
|
||||
return $x['result'];
|
||||
|
@ -749,7 +750,7 @@ class Libzot
|
|||
* Called when processing the result of zot_finger() to store the result
|
||||
* * \e array
|
||||
*/
|
||||
call_hooks('import_xchan', $arr);
|
||||
Hook::call('import_xchan', $arr);
|
||||
|
||||
$ret = array('success' => false);
|
||||
$dirmode = intval(get_config('system', 'directory_mode'));
|
||||
|
@ -1194,7 +1195,7 @@ class Libzot
|
|||
|
||||
if (is_array($x) && array_key_exists('delivery_report', $x) && is_array($x['delivery_report'])) {
|
||||
foreach ($x['delivery_report'] as $xx) {
|
||||
call_hooks('dreport_process', $xx);
|
||||
Hook::call('dreport_process', $xx);
|
||||
if (is_array($xx) && array_key_exists('message_id', $xx) && DReport::is_storable($xx)) {
|
||||
q(
|
||||
"insert into dreport ( dreport_mid, dreport_site, dreport_recip, dreport_name, dreport_result, dreport_time, dreport_xchan, dreport_log ) values ( '%s', '%s', '%s','%s','%s','%s','%s','%s' ) ",
|
||||
|
@ -2203,7 +2204,7 @@ class Libzot
|
|||
* Called when an item has been posted on this machine via mod/item.php (also via API).
|
||||
* * \e array with an item
|
||||
*/
|
||||
call_hooks('post_local', $arr);
|
||||
Hook::call('post_local', $arr);
|
||||
}
|
||||
|
||||
$item_id = 0;
|
||||
|
@ -2246,7 +2247,7 @@ class Libzot
|
|||
* * \e array \b sender
|
||||
* * \e array \b channel
|
||||
*/
|
||||
call_hooks('activity_received', $parr);
|
||||
Hook::call('activity_received', $parr);
|
||||
// don't add a source route if it's a relay or later recipients will get a route mismatch
|
||||
if (!$relay) {
|
||||
add_source_route($item_id, $sender);
|
||||
|
@ -2785,7 +2786,7 @@ class Libzot
|
|||
* * \e array \b channel
|
||||
* * \e array \b locations
|
||||
*/
|
||||
call_hooks('location_move', $arr);
|
||||
Hook::call('location_move', $arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3399,7 +3400,7 @@ class Libzot
|
|||
}
|
||||
$ret['site'] = self::site_info();
|
||||
|
||||
call_hooks('zotinfo', $ret);
|
||||
Hook::call('zotinfo', $ret);
|
||||
|
||||
return ($ret);
|
||||
}
|
||||
|
@ -3473,15 +3474,15 @@ class Libzot
|
|||
$ret['site']['admin'] = get_config('system', 'admin_email');
|
||||
|
||||
$visible_plugins = [];
|
||||
if (is_array(App::$plugins) && count(App::$plugins)) {
|
||||
$r = q("select * from addon where hidden = 0");
|
||||
if ($r) {
|
||||
foreach ($r as $rr) {
|
||||
$visible_plugins[] = $rr['aname'];
|
||||
}
|
||||
|
||||
$r = q("select * from addon where hidden = 0");
|
||||
if ($r) {
|
||||
foreach ($r as $rr) {
|
||||
$visible_plugins[] = $rr['aname'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$ret['site']['about'] = bbcode(get_config('system', 'siteinfo'), ['export' => true]);
|
||||
$ret['site']['plugins'] = $visible_plugins;
|
||||
$ret['site']['sitehash'] = get_config('system', 'location_hash');
|
||||
|
|
|
@ -7,6 +7,7 @@ use Zotlabs\Lib\Libzot;
|
|||
use Zotlabs\Lib\Webfinger;
|
||||
use Zotlabs\Lib\Zotfinger;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/permissions.php');
|
||||
|
||||
|
@ -245,7 +246,7 @@ class Libzotdir
|
|||
}
|
||||
|
||||
$arr = ['channel_id' => $uid, 'hash' => $hash, 'profile' => $profile];
|
||||
call_hooks('local_dir_update', $arr);
|
||||
Hook::call('local_dir_update', $arr);
|
||||
|
||||
$address = Channel::get_webfinger($p[0]);
|
||||
|
||||
|
@ -436,7 +437,7 @@ class Libzotdir
|
|||
* * \e boolean \b update
|
||||
*/
|
||||
|
||||
call_hooks('import_directory_profile', $d);
|
||||
Hook::call('import_directory_profile', $d);
|
||||
|
||||
if (($d['update']) && (!$suppress_update)) {
|
||||
self::update_modtime($arr['xprof_hash'], new_uuid(), $addr, $ud_flags);
|
||||
|
|
|
@ -11,6 +11,7 @@ use League\HTMLToMarkdown\HtmlConverter;
|
|||
use League\HTMLToMarkdown\Environment;
|
||||
use League\HTMLToMarkdown\Converter\ConverterInterface;
|
||||
use League\HTMLToMarkdown\ElementInterface;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once("include/event.php");
|
||||
require_once("include/html2bbcode.php");
|
||||
|
@ -62,7 +63,7 @@ class Markdown
|
|||
* * \e boolean \b zrl
|
||||
* * \e array \b options
|
||||
*/
|
||||
call_hooks('markdown_to_bb_init', $x);
|
||||
Hook::call('markdown_to_bb_init', $x);
|
||||
|
||||
$s = $x['text'];
|
||||
|
||||
|
@ -99,7 +100,7 @@ class Markdown
|
|||
* @hooks markdown_to_bb
|
||||
* * \e string - The already converted message as bbcode
|
||||
*/
|
||||
call_hooks('markdown_to_bb', $s);
|
||||
Hook::call('markdown_to_bb', $s);
|
||||
|
||||
return $s;
|
||||
}
|
||||
|
@ -264,7 +265,7 @@ class Markdown
|
|||
* * \e string \b bbcode - The message as bbcode and what will get returned
|
||||
* * \e array \b options
|
||||
*/
|
||||
call_hooks('bb_to_markdown_bb', $x);
|
||||
Hook::call('bb_to_markdown_bb', $x);
|
||||
|
||||
$Text = $x['bbcode'];
|
||||
|
||||
|
@ -294,7 +295,7 @@ class Markdown
|
|||
* @hooks bb_to_markdown
|
||||
* * \e string - The already converted message as bbcode and what will get returned
|
||||
*/
|
||||
call_hooks('bb_to_markdown', $Text);
|
||||
Hook::call('bb_to_markdown', $Text);
|
||||
|
||||
return $Text;
|
||||
}
|
||||
|
|
|
@ -9,6 +9,8 @@ use Zotlabs\Lib\Channel;
|
|||
use Zotlabs\Lib\System;
|
||||
use Zotlabs\Lib\Features;
|
||||
use Zotlabs\Lib\Menu;
|
||||
use Zotlabs\Render\Theme;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/security.php');
|
||||
|
||||
|
@ -198,7 +200,7 @@ class Navbar {
|
|||
|
||||
$x = array('nav' => $nav, 'usermenu' => $userinfo );
|
||||
|
||||
call_hooks('nav', $x);
|
||||
Hook::call('nav', $x);
|
||||
|
||||
// Not sure the best place to put this on the page. So I'm implementing it but leaving it
|
||||
// turned off until somebody discovers this and figures out a good location for it.
|
||||
|
@ -285,7 +287,7 @@ class Navbar {
|
|||
}
|
||||
}
|
||||
|
||||
$c = theme_include('navbar_' . purify_filename($template) . '.css');
|
||||
$c = Theme::include('navbar_' . purify_filename($template) . '.css');
|
||||
$tpl = get_markup_template('navbar_' . purify_filename($template) . '.tpl');
|
||||
|
||||
if ($c && $tpl) {
|
||||
|
@ -338,7 +340,7 @@ class Navbar {
|
|||
unset($_SESSION['reload_avatar']);
|
||||
}
|
||||
|
||||
call_hooks('page_header', App::$page['nav']);
|
||||
Hook::call('page_header', App::$page['nav']);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -532,7 +534,7 @@ class Navbar {
|
|||
|
||||
$arr = array('is_owner' => $is_owner, 'nickname' => $nickname, 'tab' => (($tab) ? $tab : false), 'tabs' => $tabs);
|
||||
|
||||
call_hooks('channel_apps', $arr);
|
||||
Hook::call('channel_apps', $arr);
|
||||
|
||||
return replace_macros(
|
||||
get_markup_template('profile_tabs.tpl'),
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Zotlabs\Lib;
|
|||
|
||||
use App;
|
||||
use Zotlabs\Lib\Cache;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Oembed
|
||||
{
|
||||
|
@ -105,7 +106,7 @@ class Oembed
|
|||
}
|
||||
|
||||
$arr = array('url' => $embedurl, 'action' => $action);
|
||||
call_hooks('oembed_action', $arr);
|
||||
Hook::call('oembed_action', $arr);
|
||||
|
||||
//logger('action: ' . $arr['action'] . ' url: ' . $arr['url'], LOGGER_DEBUG,LOG_DEBUG);
|
||||
|
||||
|
@ -231,7 +232,7 @@ class Oembed
|
|||
|
||||
if ($txt == false || $txt == "") {
|
||||
$x = array('url' => $embedurl,'videowidth' => App::$videowidth);
|
||||
call_hooks('oembed_probe', $x);
|
||||
Hook::call('oembed_probe', $x);
|
||||
if (array_key_exists('embed', $x)) {
|
||||
$txt = $x['embed'];
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Zotlabs\Lib;
|
|||
use Zotlabs\Access\PermissionRoles;
|
||||
use Zotlabs\Access\Permissions;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
/**
|
||||
* @brief Permission Categories. Permission rules for various classes of connections.
|
||||
|
@ -195,7 +196,7 @@ class Permcat
|
|||
* @hooks permcats
|
||||
* * \e array
|
||||
*/
|
||||
call_hooks('permcats', $permcats);
|
||||
Hook::call('permcats', $permcats);
|
||||
|
||||
return $permcats;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ use Zotlabs\Lib\ActivityStreams;
|
|||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Zot6\Receiver;
|
||||
use Zotlabs\Zot6\Zot6Handler;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Queue
|
||||
{
|
||||
|
@ -226,7 +227,7 @@ class Queue
|
|||
}
|
||||
|
||||
$arr = array('outq' => $outq, 'base' => $base, 'handled' => false, 'immediate' => $immediate);
|
||||
call_hooks('queue_deliver', $arr);
|
||||
Hook::call('queue_deliver', $arr);
|
||||
if ($arr['handled']) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Zotlabs\Lib;
|
|||
|
||||
use App;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class ServiceClass {
|
||||
|
||||
|
@ -89,7 +90,7 @@ class ServiceClass {
|
|||
intval($rr['account_id'])
|
||||
);
|
||||
$ret = [ 'account' => $rr ];
|
||||
call_hooks('account_downgrade', $ret);
|
||||
Hook::call('account_downgrade', $ret);
|
||||
logger('downgrade_accounts: Account id ' . $rr['account_id'] . ' downgraded.');
|
||||
} else {
|
||||
$x = q(
|
||||
|
@ -98,7 +99,7 @@ class ServiceClass {
|
|||
intval($rr['account_id'])
|
||||
);
|
||||
$ret = [ 'account' => $rr ];
|
||||
call_hooks('account_downgrade', $ret);
|
||||
Hook::call('account_downgrade', $ret);
|
||||
logger('downgrade_accounts: Account id ' . $rr['account_id'] . ' expired.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ use App;
|
|||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Share
|
||||
{
|
||||
|
@ -146,7 +147,7 @@ class Share
|
|||
|
||||
$arr['id'] = $post_id;
|
||||
|
||||
call_hooks('post_local_end', $arr);
|
||||
Hook::call('post_local_end', $arr);
|
||||
|
||||
$r = q(
|
||||
"select * from item where id = %d",
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Zotlabs\Lib;
|
|||
|
||||
use App;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
use URLify;
|
||||
|
||||
class System
|
||||
|
@ -146,7 +147,7 @@ class System
|
|||
public static function get_zot_revision()
|
||||
{
|
||||
$x = [ 'revision' => ZOT_REVISION ];
|
||||
call_hooks('zot_revision', $x);
|
||||
Hook::call('zot_revision', $x);
|
||||
return $x['revision'];
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ namespace Zotlabs\Lib;
|
|||
|
||||
use App;
|
||||
use Zotlabs\Lib\Features;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/text.php');
|
||||
|
||||
|
@ -373,7 +374,7 @@ class ThreadItem
|
|||
$has_tags = (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false);
|
||||
|
||||
$dropdown_extras_arr = [ 'item' => $item , 'dropdown_extras' => '' ];
|
||||
call_hooks('dropdown_extras', $dropdown_extras_arr);
|
||||
Hook::call('dropdown_extras', $dropdown_extras_arr);
|
||||
$dropdown_extras = $dropdown_extras_arr['dropdown_extras'];
|
||||
|
||||
// Pinned item processing
|
||||
|
@ -513,7 +514,7 @@ class ThreadItem
|
|||
);
|
||||
|
||||
$arr = array('item' => $item, 'output' => $tmp_item);
|
||||
call_hooks('display_item', $arr);
|
||||
Hook::call('display_item', $arr);
|
||||
|
||||
$result = $arr['output'];
|
||||
|
||||
|
@ -927,7 +928,7 @@ class ThreadItem
|
|||
$observer = $conv->get_observer();
|
||||
|
||||
$arr = array('comment_buttons' => '','id' => $this->get_id());
|
||||
call_hooks('comment_buttons', $arr);
|
||||
Hook::call('comment_buttons', $arr);
|
||||
$comment_buttons = $arr['comment_buttons'];
|
||||
|
||||
$feature_auto_save_draft = ((Features::enabled($conv->get_profile_owner(), 'auto_save_draft')) ? "true" : "false");
|
||||
|
|
|
@ -15,7 +15,8 @@ use Zotlabs\Web\SubModule;
|
|||
use Zotlabs\Lib\Config;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Lib\Navbar;
|
||||
|
||||
use Zotlabs\Lib\Addon;
|
||||
|
||||
/**
|
||||
* @brief Admin area.
|
||||
*
|
||||
|
@ -151,18 +152,7 @@ class Admin extends Controller
|
|||
$queue = (($r) ? $r[0]['total'] : 0);
|
||||
$queues = ['label' => t('Message queues'), 'queue' => $queue];
|
||||
|
||||
$plugins = [];
|
||||
|
||||
if (is_array(App::$plugins) && App::$plugins) {
|
||||
foreach (App::$plugins as $p) {
|
||||
if ($p) {
|
||||
$plugins[] = $p;
|
||||
}
|
||||
}
|
||||
sort($plugins);
|
||||
} else {
|
||||
$plugins = 0;
|
||||
}
|
||||
$plugins = Addon::list_installed();
|
||||
|
||||
// Could be extended to provide also other alerts to the admin
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use App;
|
|||
use PHPGit\Exception\GitException;
|
||||
use Zotlabs\Storage\GitRepo;
|
||||
use Michelf\MarkdownExtra;
|
||||
use Zotlabs\Lib\Addon;
|
||||
|
||||
class Addons
|
||||
{
|
||||
|
@ -260,7 +261,7 @@ class Addons
|
|||
return '';
|
||||
}
|
||||
|
||||
$enabled = in_array($plugin, App::$plugins);
|
||||
$enabled = in_array($plugin, Addon::list_installed());
|
||||
$info = get_plugin_info($plugin);
|
||||
$x = check_plugin_versions($info);
|
||||
|
||||
|
@ -268,12 +269,7 @@ class Addons
|
|||
|
||||
if ($enabled && !$x) {
|
||||
$enabled = false;
|
||||
$idz = array_search($plugin, App::$plugins);
|
||||
if ($idz !== false) {
|
||||
unset(App::$plugins[$idz]);
|
||||
uninstall_plugin($plugin);
|
||||
set_config("system", "addon", implode(", ", App::$plugins));
|
||||
}
|
||||
uninstall_plugin($plugin);
|
||||
}
|
||||
$info['disabled'] = 1 - intval($x);
|
||||
|
||||
|
@ -281,19 +277,16 @@ class Addons
|
|||
check_form_security_token_redirectOnErr('/admin/addons', 'admin_addons', 't');
|
||||
$pinstalled = false;
|
||||
// Toggle plugin status
|
||||
$idx = array_search($plugin, App::$plugins);
|
||||
$idx = array_search($plugin, Addon::list_installed());
|
||||
if ($idx !== false) {
|
||||
unset(App::$plugins[$idx]);
|
||||
uninstall_plugin($plugin);
|
||||
Addon::uninstall($plugin);
|
||||
$pinstalled = false;
|
||||
info(sprintf(t("Plugin %s disabled."), $plugin));
|
||||
} else {
|
||||
App::$plugins[] = $plugin;
|
||||
install_plugin($plugin);
|
||||
Addon::install($plugin);
|
||||
$pinstalled = true;
|
||||
info(sprintf(t("Plugin %s enabled."), $plugin));
|
||||
}
|
||||
set_config("system", "addon", implode(", ", App::$plugins));
|
||||
|
||||
if ($pinstalled) {
|
||||
@require_once("addon/$plugin/$plugin.php");
|
||||
|
@ -306,7 +299,7 @@ class Addons
|
|||
|
||||
// display plugin details
|
||||
|
||||
if (in_array($plugin, App::$plugins)) {
|
||||
if (in_array($plugin, Addon::list_installed())) {
|
||||
$status = 'on';
|
||||
$action = t('Disable');
|
||||
} else {
|
||||
|
@ -389,11 +382,9 @@ class Addons
|
|||
|
||||
if ($enabled && !$x) {
|
||||
$enabled = false;
|
||||
$idz = array_search($id, App::$plugins);
|
||||
$idz = array_search($id, Addon::list_installed());
|
||||
if ($idz !== false) {
|
||||
unset(App::$plugins[$idz]);
|
||||
uninstall_plugin($id);
|
||||
set_config("system", "addon", implode(", ", App::$plugins));
|
||||
}
|
||||
}
|
||||
$info['disabled'] = 1 - intval($x);
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Zotlabs\Module\Admin;
|
|||
use App;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
/**
|
||||
* @brief Admin Module for Channels.
|
||||
|
@ -163,7 +164,7 @@ class Channels
|
|||
}
|
||||
}
|
||||
|
||||
call_hooks('admin_channels', $channels);
|
||||
Hook::call('admin_channels', $channels);
|
||||
|
||||
$o = replace_macros(get_markup_template('admin_channels.tpl'), [
|
||||
// strings //
|
||||
|
|
|
@ -8,6 +8,7 @@ use Zotlabs\Lib\Libprofile;
|
|||
use Zotlabs\Access\AccessControl;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
/*
|
||||
@file cover_photo.php
|
||||
|
@ -389,7 +390,7 @@ class Cover_photo
|
|||
|
||||
]);
|
||||
|
||||
call_hooks('cover_photo_content_end', $o);
|
||||
Hook::call('cover_photo_content_end', $o);
|
||||
|
||||
return $o;
|
||||
} else {
|
||||
|
|
|
@ -15,6 +15,7 @@ use Zotlabs\Lib\Libprofile;
|
|||
use Zotlabs\Lib\Config;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/photo_factory.php');
|
||||
require_once('include/photos.php');
|
||||
|
@ -484,7 +485,7 @@ class Profile_photo
|
|||
'$select' => t('Select previously uploaded photo'),
|
||||
]);
|
||||
|
||||
call_hooks('profile_photo_content_end', $o);
|
||||
Hook::call('profile_photo_content_end', $o);
|
||||
return $o;
|
||||
} else {
|
||||
// present a cropping form
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Zotlabs\Module;
|
|||
use Zotlabs\Lib\Apps;
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Affinity extends Controller
|
||||
{
|
||||
|
@ -65,7 +66,7 @@ class Affinity extends Controller
|
|||
80 => t('Connections'),
|
||||
99 => t('All')
|
||||
);
|
||||
call_hooks('affinity_labels', $labels);
|
||||
Hook::call('affinity_labels', $labels);
|
||||
|
||||
$tpl = get_markup_template('affinity.tpl');
|
||||
$x = replace_macros($tpl, [
|
||||
|
@ -78,7 +79,7 @@ class Affinity extends Controller
|
|||
|
||||
|
||||
$arr = array('html' => $x);
|
||||
call_hooks('affinity_slider', $arr);
|
||||
Hook::call('affinity_slider', $arr);
|
||||
$setting_fields .= $arr['html'];
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ use OAuth1Request;
|
|||
use OAuth1Consumer;
|
||||
use OAuth1Util;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/api.php');
|
||||
|
||||
|
@ -24,7 +25,7 @@ class Api extends Controller
|
|||
api_register_func('api/oauth/access_token', 'api_oauth_access_token', false);
|
||||
|
||||
$args = [];
|
||||
call_hooks('api_register', $args);
|
||||
Hook::call('api_register', $args);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ use Zotlabs\Lib\PermissionDescription;
|
|||
use Zotlabs\Widget\Pinned;
|
||||
use Zotlabs\Lib\Navbar;
|
||||
use Zotlabs\Lib\Libacl;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/items.php');
|
||||
require_once('include/security.php');
|
||||
|
@ -528,7 +529,7 @@ class Channel extends Controller
|
|||
|
||||
if ($is_owner && $update_unseen && (!$_SESSION['sudo'])) {
|
||||
$x = ['channel_id' => local_channel(), 'update' => 'unset'];
|
||||
call_hooks('update_unseen', $x);
|
||||
Hook::call('update_unseen', $x);
|
||||
if ($x['update'] === 'unset' || intval($x['update'])) {
|
||||
$r = q(
|
||||
"UPDATE item SET item_unseen = 0 where item_unseen = 1 and item_wall = 1 AND uid = %d $update_unseen",
|
||||
|
|
|
@ -9,6 +9,7 @@ use App;
|
|||
use Zotlabs\Lib as Zlib;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/security.php');
|
||||
|
||||
|
@ -66,7 +67,7 @@ class Chatsvc extends Controller
|
|||
'chat_text' => $text
|
||||
);
|
||||
|
||||
call_hooks('chat_post', $arr);
|
||||
Hook::call('chat_post', $arr);
|
||||
|
||||
$x = q(
|
||||
"insert into chat ( chat_room, chat_xchan, created, chat_text )
|
||||
|
|
|
@ -7,6 +7,7 @@ use Zotlabs\Web\Controller;
|
|||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Lib\Libprofile;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Connect extends Controller
|
||||
{
|
||||
|
@ -119,7 +120,7 @@ class Connect extends Controller
|
|||
));
|
||||
|
||||
$arr = array('channel' => App::$data['channel'], 'observer' => App::get_observer(), 'sellpage' => $o, 'submit' => $submit);
|
||||
call_hooks('connect_premium', $arr);
|
||||
Hook::call('connect_premium', $arr);
|
||||
$o = $arr['sellpage'];
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ use Zotlabs\Access\PermissionLimits;
|
|||
use Zotlabs\Lib\Permcat;
|
||||
use Zotlabs\Lib\Features;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Extend\Hook;
|
||||
use Zotlabs\Web\HTTPHeaders;
|
||||
use Sabre\VObject\Reader;
|
||||
|
||||
|
@ -92,7 +93,7 @@ class Connedit extends Controller
|
|||
|
||||
$orig_record = array_shift($orig_record);
|
||||
|
||||
call_hooks('contact_edit_post', $_POST);
|
||||
Hook::call('contact_edit_post', $_POST);
|
||||
|
||||
$vc = get_abconfig(local_channel(), $orig_record['abook_xchan'], 'system', 'vcard');
|
||||
$vcard = (($vc) ? Reader::read($vc) : null);
|
||||
|
@ -274,7 +275,7 @@ class Connedit extends Controller
|
|||
|
||||
if ($new_friend) {
|
||||
$arr = ['channel_id' => local_channel(), 'abook' => App::$poi];
|
||||
call_hooks('accept_follow', $arr);
|
||||
Hook::call('accept_follow', $arr);
|
||||
}
|
||||
|
||||
$this->connedit_clone($a);
|
||||
|
@ -675,7 +676,7 @@ class Connedit extends Controller
|
|||
80 => t('Connections'),
|
||||
99 => t('All')
|
||||
];
|
||||
call_hooks('affinity_labels', $labels);
|
||||
Hook::call('affinity_labels', $labels);
|
||||
|
||||
$slider_tpl = get_markup_template('contact_slider.tpl');
|
||||
|
||||
|
@ -897,7 +898,7 @@ class Connedit extends Controller
|
|||
|
||||
$arr = array('contact' => $contact, 'output' => $o);
|
||||
|
||||
call_hooks('contact_edit', $arr);
|
||||
Hook::call('contact_edit', $arr);
|
||||
|
||||
return $arr['output'];
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use Zotlabs\Lib\Libprofile;
|
|||
use Zotlabs\Access\AccessControl;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
/*
|
||||
@file cover_photo.php
|
||||
|
@ -435,7 +436,7 @@ class Cover_photo extends Controller
|
|||
|
||||
]);
|
||||
|
||||
call_hooks('cover_photo_content_end', $o);
|
||||
Hook::call('cover_photo_content_end', $o);
|
||||
|
||||
return $o;
|
||||
} else {
|
||||
|
|
|
@ -9,6 +9,7 @@ use Zotlabs\Lib\Apps;
|
|||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Access\Permissions;
|
||||
use Zotlabs\Access\PermissionLimits;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/socgraph.php');
|
||||
|
||||
|
@ -268,7 +269,7 @@ class Defperms extends Controller
|
|||
|
||||
$arr = array('contact' => $contact, 'output' => $o);
|
||||
|
||||
call_hooks('contact_edit', $arr);
|
||||
Hook::call('contact_edit', $arr);
|
||||
|
||||
return $arr['output'];
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ use Zotlabs\Lib\Libsync;
|
|||
use Zotlabs\Lib\LibBlock;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Lib\Navbar;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/socgraph.php');
|
||||
require_once('include/bbcode.php');
|
||||
|
@ -435,7 +436,7 @@ class Directory extends Controller
|
|||
|
||||
$arr = array('contact' => $rr, 'entry' => $entry);
|
||||
|
||||
call_hooks('directory_item', $arr);
|
||||
Hook::call('directory_item', $arr);
|
||||
|
||||
unset($profile);
|
||||
unset($location);
|
||||
|
|
|
@ -9,6 +9,7 @@ use Zotlabs\Lib\PConfig;
|
|||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Lib\Libacl;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once("include/bbcode.php");
|
||||
require_once('include/security.php');
|
||||
|
@ -197,7 +198,7 @@ class Display extends Controller
|
|||
}
|
||||
}
|
||||
if ($target_item['item_type'] == ITEM_TYPE_CUSTOM) {
|
||||
call_hooks('item_custom_display', $target_item);
|
||||
Hook::call('item_custom_display', $target_item);
|
||||
notice(t('Page not found.') . EOL);
|
||||
return '';
|
||||
}
|
||||
|
@ -460,12 +461,12 @@ class Display extends Controller
|
|||
));
|
||||
|
||||
$x = ['xml' => $atom, 'channel' => $channel, 'observer_hash' => $observer_hash, 'params' => $params];
|
||||
call_hooks('atom_feed_top', $x);
|
||||
Hook::call('atom_feed_top', $x);
|
||||
|
||||
$atom = $x['xml'];
|
||||
|
||||
// a much simpler interface
|
||||
call_hooks('atom_feed', $atom);
|
||||
Hook::call('atom_feed', $atom);
|
||||
|
||||
|
||||
if ($items) {
|
||||
|
@ -478,7 +479,7 @@ class Display extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
call_hooks('atom_feed_end', $atom);
|
||||
Hook::call('atom_feed_end', $atom);
|
||||
|
||||
$atom .= '</feed>' . "\r\n";
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ use Zotlabs\Lib\Crypto;
|
|||
use Zotlabs\Web\HTTPSig;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/conversation.php');
|
||||
|
||||
|
@ -23,7 +24,7 @@ class Home extends Controller
|
|||
|
||||
$ret = [];
|
||||
|
||||
call_hooks('home_init', $ret);
|
||||
Hook::call('home_init', $ret);
|
||||
|
||||
if (ActivityStreams::is_as_request()) {
|
||||
$x = array_merge(['@context' => [
|
||||
|
@ -129,7 +130,7 @@ class Home extends Controller
|
|||
|
||||
$splash = ((argc() > 1 && argv(1) === 'splash') ? true : false);
|
||||
|
||||
call_hooks('home_content', $o);
|
||||
Hook::call('home_content', $o);
|
||||
if ($o) {
|
||||
return $o;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Zotlabs\Module;
|
|||
|
||||
use App;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Hostxrd extends Controller
|
||||
{
|
||||
|
@ -21,7 +22,7 @@ class Hostxrd extends Controller
|
|||
'$zroot' => z_root()
|
||||
));
|
||||
$arr = array('xrd' => $x);
|
||||
call_hooks('hostxrd', $arr);
|
||||
Hook::call('hostxrd', $arr);
|
||||
|
||||
echo $arr['xrd'];
|
||||
killme();
|
||||
|
|
|
@ -12,6 +12,7 @@ use Zotlabs\Lib\Channel;
|
|||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Import\Friendica;
|
||||
use Zotlabs\Lib\ServiceClass;
|
||||
use Zotlabs\Extend\Hook;
|
||||
require_once('include/import.php');
|
||||
require_once('include/photo_factory.php');
|
||||
|
||||
|
@ -128,7 +129,7 @@ class Import extends Controller
|
|||
}
|
||||
|
||||
if (!array_key_exists('compatibility', $data)) {
|
||||
call_hooks('import_foreign_channel_data', $data);
|
||||
Hook::call('import_foreign_channel_data', $data);
|
||||
if ($data['handled']) {
|
||||
return;
|
||||
}
|
||||
|
@ -539,7 +540,7 @@ class Import extends Controller
|
|||
// import_items($channel,$data['webpages'],false,$relocate);
|
||||
// }
|
||||
$addon = array('channel' => $channel, 'data' => $data);
|
||||
call_hooks('import_channel', $addon);
|
||||
Hook::call('import_channel', $addon);
|
||||
|
||||
$saved_notification_flags = Channel::notifications_off($channel['channel_id']);
|
||||
if ($import_posts && array_key_exists('item', $data) && $data['item']) {
|
||||
|
|
|
@ -38,6 +38,7 @@ use Zotlabs\Lib\Apps;
|
|||
use Zotlabs\Access\PermissionLimits;
|
||||
use Zotlabs\Access\PermissionRoles;
|
||||
use Zotlabs\Access\AccessControl;
|
||||
use Zotlabs\Extend\Hook;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use App;
|
||||
use URLify;
|
||||
|
@ -416,7 +417,7 @@ class Item extends Controller
|
|||
$observer = $sys;
|
||||
}
|
||||
|
||||
call_hooks('post_local_start', $_REQUEST);
|
||||
Hook::call('post_local_start', $_REQUEST);
|
||||
|
||||
// logger('postvars ' . print_r($_REQUEST,true), LOGGER_DATA);
|
||||
|
||||
|
@ -940,7 +941,7 @@ class Item extends Controller
|
|||
|
||||
|
||||
$arr = ['profile_uid' => $profile_uid, 'summary' => $summary, 'content' => $body, 'mimetype' => $mimetype];
|
||||
call_hooks('post_content', $arr);
|
||||
Hook::call('post_content', $arr);
|
||||
$summary = $arr['summary'];
|
||||
$body = $arr['content'];
|
||||
$mimetype = $arr['mimetype'];
|
||||
|
@ -1517,7 +1518,7 @@ class Item extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
call_hooks('post_local', $datarray);
|
||||
Hook::call('post_local', $datarray);
|
||||
|
||||
// This is no longer needed
|
||||
unset($datarray['edit']);
|
||||
|
@ -1702,7 +1703,7 @@ class Item extends Controller
|
|||
$datarray['id'] = $post_id;
|
||||
$datarray['llink'] = z_root() . '/display/' . gen_link_id($datarray['mid']);
|
||||
|
||||
call_hooks('post_local_end', $datarray);
|
||||
Hook::call('post_local_end', $datarray);
|
||||
|
||||
if ($groupww) {
|
||||
$nopush = false;
|
||||
|
|
|
@ -8,6 +8,7 @@ use Zotlabs\Lib\Activity;
|
|||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/security.php');
|
||||
require_once('include/bbcode.php');
|
||||
|
@ -284,7 +285,7 @@ class Like extends Controller
|
|||
$arr['deny_gid'] = $deny_gid;
|
||||
$arr['item_private'] = $private;
|
||||
|
||||
call_hooks('post_local', $arr);
|
||||
Hook::call('post_local', $arr);
|
||||
|
||||
$post = item_store($arr);
|
||||
$post_id = $post['item_id'];
|
||||
|
@ -297,7 +298,7 @@ class Like extends Controller
|
|||
|
||||
$arr['id'] = $post_id;
|
||||
|
||||
call_hooks('post_local_end', $arr);
|
||||
Hook::call('post_local_end', $arr);
|
||||
|
||||
$r = q(
|
||||
"select * from item where id = %d",
|
||||
|
|
|
@ -12,6 +12,7 @@ use Zotlabs\Lib\Libzot;
|
|||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Lib\Oembed;
|
||||
use Zotlabs\Lib as Zlib;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/security.php');
|
||||
|
||||
|
@ -188,7 +189,7 @@ class Linkinfo extends Controller
|
|||
|
||||
$arr = array('url' => $url, 'text' => '');
|
||||
|
||||
call_hooks('parse_link', $arr);
|
||||
Hook::call('parse_link', $arr);
|
||||
|
||||
if (strlen($arr['text'])) {
|
||||
echo $arr['text'];
|
||||
|
|
|
@ -8,6 +8,7 @@ use Zotlabs\Web\HTTPSig;
|
|||
use Zotlabs\Lib\Libzot;
|
||||
use Zotlabs\Lib\SConfig;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Magic extends Controller
|
||||
{
|
||||
|
@ -56,7 +57,7 @@ class Magic extends Controller
|
|||
'proceed' => true
|
||||
];
|
||||
|
||||
call_hooks('magic_auth', $arr);
|
||||
Hook::call('magic_auth', $arr);
|
||||
$dest = $arr['destination'];
|
||||
if (!$arr['proceed']) {
|
||||
goaway($dest);
|
||||
|
|
|
@ -7,6 +7,7 @@ use Zotlabs\Lib\Apps;
|
|||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Lib\Navbar;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/security.php');
|
||||
require_once('include/bbcode.php');
|
||||
|
@ -116,7 +117,7 @@ class Mood extends Controller
|
|||
Run::Summon(['Notifier', 'activity', $item_id]);
|
||||
}
|
||||
|
||||
call_hooks('post_local_end', $arr);
|
||||
Hook::call('post_local_end', $arr);
|
||||
|
||||
if ($_SESSION['return_url']) {
|
||||
goaway(z_root() . '/' . $_SESSION['return_url']);
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Zotlabs\Module;
|
|||
|
||||
use App;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Notify extends Controller
|
||||
{
|
||||
|
@ -27,7 +28,7 @@ class Notify extends Controller
|
|||
);
|
||||
if ($r) {
|
||||
$x = ['channel_id' => local_channel(), 'update' => 'unset'];
|
||||
call_hooks('update_unseen', $x);
|
||||
Hook::call('update_unseen', $x);
|
||||
if ((!$_SESSION['sudo']) && ($x['update'] === 'unset' || intval($x['update']))) {
|
||||
q(
|
||||
"update notify set seen = 1 where (( parent != '' and parent = '%s' and otype = '%s' ) or link = '%s' ) and uid = %d",
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Zotlabs\Module;
|
|||
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Render\Theme;
|
||||
|
||||
class Pdledit extends Controller
|
||||
{
|
||||
|
@ -66,7 +67,7 @@ class Pdledit extends Controller
|
|||
if ($files) {
|
||||
foreach ($files as $f) {
|
||||
$name = lcfirst(basename($f, '.php'));
|
||||
$x = theme_include('mod_' . $name . '.pdl');
|
||||
$x = Theme::include('mod_' . $name . '.pdl');
|
||||
if ($x) {
|
||||
$o .= '<a href="pdledit/' . $name . '" >' . $name . '</a>' . ((in_array($name, $edited)) ? ' ' . t('(modified)') . ' <a href="pdledit/' . $name . '/reset" >' . t('Reset') . '</a>' : '') . '<br>';
|
||||
}
|
||||
|
@ -87,7 +88,7 @@ class Pdledit extends Controller
|
|||
}
|
||||
|
||||
$t = get_pconfig(local_channel(), 'system', $module);
|
||||
$s = @file_get_contents(theme_include($module));
|
||||
$s = @file_get_contents(Theme::include($module));
|
||||
if (!$s) {
|
||||
$a = glob('addon/*/' . $module);
|
||||
if ($a) {
|
||||
|
|
|
@ -9,6 +9,7 @@ use Zotlabs\Lib\Config;
|
|||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Lib\LDSignatures;
|
||||
use Zotlabs\Web\HTTPSig;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/security.php');
|
||||
require_once('include/attach.php');
|
||||
|
@ -114,7 +115,7 @@ class Photo extends Controller
|
|||
$uid = $person;
|
||||
|
||||
$d = ['imgscale' => $resolution, 'channel_id' => $uid, 'default' => $default, 'data' => '', 'mimetype' => ''];
|
||||
call_hooks('get_profile_photo', $d);
|
||||
Hook::call('get_profile_photo', $d);
|
||||
|
||||
$resolution = $d['imgscale'];
|
||||
$uid = $d['channel_id'];
|
||||
|
|
|
@ -15,6 +15,7 @@ use Zotlabs\Daemon\Run;
|
|||
use Zotlabs\Lib\Navbar;
|
||||
use Zotlabs\Lib\Libacl;
|
||||
use Zotlabs\Lib\Features;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/photo_factory.php');
|
||||
require_once('include/photos.php');
|
||||
|
@ -669,7 +670,7 @@ class Photos extends Controller
|
|||
'addon_text' => $uploader,
|
||||
'default_upload' => true);
|
||||
|
||||
call_hooks('photo_upload_form', $ret);
|
||||
Hook::call('photo_upload_form', $ret);
|
||||
|
||||
/* Show space usage */
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ use Zotlabs\Lib\Enotify;
|
|||
use Zotlabs\Lib\Apps;
|
||||
use Zotlabs\Lib\PConfig;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/bbcode.php');
|
||||
|
||||
|
@ -611,7 +612,7 @@ class Ping extends Controller
|
|||
|
||||
if ($r) {
|
||||
$arr = array('items' => $r);
|
||||
call_hooks('network_ping', $arr);
|
||||
Hook::call('network_ping', $arr);
|
||||
|
||||
foreach ($r as $it) {
|
||||
if ($it['author_xchan'] === $ob_hash) {
|
||||
|
|
|
@ -8,6 +8,7 @@ use Zotlabs\Lib\Activity;
|
|||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/security.php');
|
||||
require_once('include/bbcode.php');
|
||||
|
@ -254,7 +255,7 @@ class Plike extends Controller
|
|||
$arr['deny_gid'] = $deny_gid;
|
||||
$arr['item_private'] = $private;
|
||||
|
||||
call_hooks('post_local', $arr);
|
||||
Hook::call('post_local', $arr);
|
||||
|
||||
$post = item_store($arr);
|
||||
$post_id = $post['item_id'];
|
||||
|
@ -267,7 +268,7 @@ class Plike extends Controller
|
|||
|
||||
$arr['id'] = $post_id;
|
||||
|
||||
call_hooks('post_local_end', $arr);
|
||||
Hook::call('post_local_end', $arr);
|
||||
|
||||
$r = q(
|
||||
"select * from item where id = %d",
|
||||
|
|
|
@ -11,6 +11,7 @@ use Zotlabs\Lib\LDSignatures;
|
|||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Web\HTTPSig;
|
||||
use Zotlabs\Lib\Navbar;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once("include/bbcode.php");
|
||||
require_once('include/security.php');
|
||||
|
@ -132,7 +133,7 @@ class Profile extends Controller
|
|||
]);
|
||||
|
||||
$o .= Libprofile::advanced();
|
||||
call_hooks('profile_advanced', $o);
|
||||
Hook::call('profile_advanced', $o);
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ use Zotlabs\Lib\Libsync;
|
|||
use Zotlabs\Lib\Libprofile;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/photo_factory.php');
|
||||
require_once('include/photos.php');
|
||||
|
@ -523,7 +524,7 @@ class Profile_photo extends Controller
|
|||
'$select' => t('Select previously uploaded photo'),
|
||||
]);
|
||||
|
||||
call_hooks('profile_photo_content_end', $o);
|
||||
Hook::call('profile_photo_content_end', $o);
|
||||
return $o;
|
||||
} else {
|
||||
// present a cropping form
|
||||
|
|
|
@ -11,6 +11,7 @@ use Zotlabs\Lib\Channel;
|
|||
use Zotlabs\Lib\Navbar;
|
||||
use Zotlabs\Lib\Features;
|
||||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Extend\Hook;
|
||||
use Sabre\VObject\Reader;
|
||||
|
||||
class Profiles extends Controller
|
||||
|
@ -244,7 +245,7 @@ class Profiles extends Controller
|
|||
}
|
||||
}
|
||||
|
||||
call_hooks('profile_post', $_POST);
|
||||
Hook::call('profile_post', $_POST);
|
||||
|
||||
|
||||
if ((argc() > 1) && (argv(1) !== "new") && intval(argv(1))) {
|
||||
|
@ -852,7 +853,7 @@ class Profiles extends Controller
|
|||
));
|
||||
|
||||
$arr = array('profile' => $r[0], 'entry' => $o);
|
||||
call_hooks('profile_edit', $arr);
|
||||
Hook::call('profile_edit', $arr);
|
||||
|
||||
return $o;
|
||||
} else {
|
||||
|
@ -985,7 +986,7 @@ class Profiles extends Controller
|
|||
$o = '';
|
||||
$select = array('', 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);
|
||||
Hook::call('gender_selector', $select);
|
||||
|
||||
$o .= "<select class=\"form-control\" name=\"gender$suffix\" id=\"gender-select$suffix\" size=\"1\" >";
|
||||
foreach ($select as $selection) {
|
||||
|
@ -1003,7 +1004,7 @@ class Profiles extends Controller
|
|||
$o = '';
|
||||
$select = array('', t('Male'), t('Female'), t('Other'));
|
||||
|
||||
call_hooks('gender_selector_min', $select);
|
||||
Hook::call('gender_selector_min', $select);
|
||||
|
||||
$o .= "<select class=\"form-control\" name=\"gender$suffix\" id=\"gender-select$suffix\" size=\"1\" >";
|
||||
foreach ($select as $selection) {
|
||||
|
@ -1021,7 +1022,7 @@ class Profiles extends Controller
|
|||
$o = '';
|
||||
$select = array('', t('He/Him'), t('She/Her'), t('They/Them'));
|
||||
|
||||
call_hooks('pronouns_selector', $select);
|
||||
Hook::call('pronouns_selector', $select);
|
||||
|
||||
$o .= "<select class=\"form-control\" name=\"pronouns$suffix\" id=\"pronouns-select$suffix\" size=\"1\" >";
|
||||
foreach ($select as $selection) {
|
||||
|
@ -1054,7 +1055,7 @@ class Profiles extends Controller
|
|||
$select = array('', 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);
|
||||
Hook::call('sexpref_selector', $select);
|
||||
|
||||
$o .= "<select class=\"form-control\" name=\"sexual$suffix\" id=\"sexual-select$suffix\" size=\"1\" >";
|
||||
foreach ($select as $selection) {
|
||||
|
@ -1073,7 +1074,7 @@ class Profiles extends Controller
|
|||
$o = '';
|
||||
$select = array('', t('Males'), t('Females'), t('Other'));
|
||||
|
||||
call_hooks('sexpref_selector_min', $select);
|
||||
Hook::call('sexpref_selector_min', $select);
|
||||
|
||||
$o .= "<select class=\"form-control\" name=\"sexual$suffix\" id=\"sexual-select$suffix\" size=\"1\" >";
|
||||
foreach ($select as $selection) {
|
||||
|
@ -1092,7 +1093,7 @@ class Profiles extends Controller
|
|||
$o = '';
|
||||
$select = array('', 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);
|
||||
Hook::call('marital_selector', $select);
|
||||
|
||||
$o .= "<select class=\"form-control\" name=\"marital\" id=\"marital-select\" size=\"1\" >";
|
||||
foreach ($select as $selection) {
|
||||
|
@ -1110,7 +1111,7 @@ class Profiles extends Controller
|
|||
$o = '';
|
||||
$select = array('', t('Single'), t('Dating'), t('Cohabiting'), t('Married'), t('Separated'), t('Divorced'), t('Widowed'), t('It\'s complicated'), t('Other'));
|
||||
|
||||
call_hooks('marital_selector_min', $select);
|
||||
Hook::call('marital_selector_min', $select);
|
||||
|
||||
$o .= "<select class=\"form-control\" name=\"marital\" id=\"marital-select\" size=\"1\" >";
|
||||
foreach ($select as $selection) {
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Zotlabs\Module;
|
|||
use App;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Rmagic extends Controller
|
||||
{
|
||||
|
@ -39,7 +40,7 @@ class Rmagic extends Controller
|
|||
|
||||
if (strpos($address, '@') === false) {
|
||||
$arr = ['address' => $address];
|
||||
call_hooks('reverse_magic_auth', $arr);
|
||||
Hook::call('reverse_magic_auth', $arr);
|
||||
|
||||
// if they're still here...
|
||||
notice(t('Authentication failed.') . EOL);
|
||||
|
|
|
@ -9,7 +9,8 @@ use Zotlabs\Lib\PermissionDescription;
|
|||
use Zotlabs\Lib\Libzot;
|
||||
use Zotlabs\Lib\Navbar;
|
||||
use Zotlabs\Lib\Libacl;
|
||||
|
||||
use Zotlabs\Lib\Addon;
|
||||
|
||||
require_once('include/items.php');
|
||||
require_once('include/taxonomy.php');
|
||||
require_once('include/conversation.php');
|
||||
|
@ -127,7 +128,7 @@ class Rpost extends Controller
|
|||
logger('unable to read svg data file: ' . 'store/' . $channel['channel_address'] . '/' . $r['data']['os_path']);
|
||||
}
|
||||
}
|
||||
if ($r['data']['filetype'] === 'text/vnd.abc' && addon_is_installed('abc')) {
|
||||
if ($r['data']['filetype'] === 'text/vnd.abc' && Addon::is_installed('abc')) {
|
||||
$x = @file_get_contents('store/' . $channel['channel_address'] . '/' . $r['data']['os_path']);
|
||||
if ($x) {
|
||||
$s .= "\n\n" . '[abc]' . $x . '[/abc]';
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Zotlabs\Module\Settings;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Account
|
||||
{
|
||||
|
@ -11,7 +12,7 @@ class Account
|
|||
{
|
||||
check_form_security_token_redirectOnErr('/settings/account', 'settings_account');
|
||||
|
||||
call_hooks('account_settings_post', $_POST);
|
||||
Hook::call('account_settings_post', $_POST);
|
||||
|
||||
$errs = [];
|
||||
|
||||
|
@ -99,7 +100,7 @@ class Account
|
|||
{
|
||||
$account_settings = "";
|
||||
|
||||
call_hooks('account_settings', $account_settings);
|
||||
Hook::call('account_settings', $account_settings);
|
||||
|
||||
$email = App::$account['account_email'];
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ use Zotlabs\Lib\Permcat;
|
|||
use Zotlabs\Lib\Libacl;
|
||||
use Zotlabs\Lib\Features;
|
||||
use Zotlabs\Lib\Menu;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Channel
|
||||
{
|
||||
|
@ -29,7 +30,7 @@ class Channel
|
|||
|
||||
check_form_security_token_redirectOnErr('/settings', 'settings');
|
||||
|
||||
call_hooks('settings_post', $_POST);
|
||||
Hook::call('settings_post', $_POST);
|
||||
|
||||
$set_perms = '';
|
||||
|
||||
|
@ -611,7 +612,7 @@ class Channel
|
|||
}
|
||||
|
||||
$plugin = ['basic' => '', 'security' => '', 'notify' => '', 'misc' => ''];
|
||||
call_hooks('channel_settings', $plugin);
|
||||
Hook::call('channel_settings', $plugin);
|
||||
|
||||
$public_stream_mode = intval(get_config('system', 'public_stream_mode', PUBLIC_STREAM_NONE));
|
||||
|
||||
|
@ -764,7 +765,7 @@ class Channel
|
|||
]),
|
||||
]);
|
||||
|
||||
call_hooks('settings_form', $o);
|
||||
Hook::call('settings_form', $o);
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Zotlabs\Module\Settings;
|
|||
use App;
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Lib\Features;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Display
|
||||
{
|
||||
|
@ -101,7 +102,7 @@ class Display
|
|||
intval(local_channel())
|
||||
);
|
||||
|
||||
call_hooks('display_settings_post', $_POST);
|
||||
Hook::call('display_settings_post', $_POST);
|
||||
Libsync::build_sync_packet();
|
||||
goaway(z_root() . '/settings/display');
|
||||
return; // NOTREACHED
|
||||
|
@ -224,7 +225,7 @@ class Display
|
|||
|
||||
));
|
||||
|
||||
call_hooks('display_settings', $o);
|
||||
Hook::call('display_settings', $o);
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Zotlabs\Module\Settings;
|
|||
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Lib\Features;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Featured
|
||||
{
|
||||
|
@ -12,7 +13,7 @@ class Featured
|
|||
{
|
||||
check_form_security_token_redirectOnErr('/settings/featured', 'settings_featured');
|
||||
|
||||
call_hooks('feature_settings_post', $_POST);
|
||||
Hook::call('feature_settings_post', $_POST);
|
||||
|
||||
if ($_POST['affinity_slider-submit']) {
|
||||
$cmax = intval($_POST['affinity_cmax']);
|
||||
|
@ -62,7 +63,7 @@ class Featured
|
|||
));
|
||||
}
|
||||
|
||||
call_hooks('feature_settings', $settings_addons);
|
||||
Hook::call('feature_settings', $settings_addons);
|
||||
|
||||
$this->sortpanels($settings_addons);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ use App;
|
|||
use Zotlabs\Daemon\Run;
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/security.php');
|
||||
require_once('include/bbcode.php');
|
||||
|
@ -129,7 +130,7 @@ class Share extends Controller
|
|||
|
||||
$arr['id'] = $post_id;
|
||||
|
||||
call_hooks('post_local_end', $arr);
|
||||
Hook::call('post_local_end', $arr);
|
||||
|
||||
info(t('Post repeated') . EOL);
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Zotlabs\Module;
|
|||
use Zotlabs\Lib\System;
|
||||
use Zotlabs\Lib\Config;
|
||||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Siteinfo extends Controller
|
||||
{
|
||||
|
@ -26,7 +27,7 @@ class Siteinfo extends Controller
|
|||
}
|
||||
|
||||
|
||||
call_hooks('federated_transports', $federated);
|
||||
Hook::call('federated_transports', $federated);
|
||||
|
||||
$siteinfo = replace_macros(
|
||||
get_markup_template('siteinfo.tpl'),
|
||||
|
@ -57,7 +58,7 @@ class Siteinfo extends Controller
|
|||
]
|
||||
);
|
||||
|
||||
call_hooks('about_hook', $siteinfo);
|
||||
Hook::call('about_hook', $siteinfo);
|
||||
|
||||
return $siteinfo;
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ use Zotlabs\Lib\PermissionDescription;
|
|||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Lib\Navbar;
|
||||
use Zotlabs\Lib\Libacl;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/conversation.php');
|
||||
|
||||
|
@ -58,7 +59,7 @@ class Stream extends Controller
|
|||
}
|
||||
|
||||
$arr = ['query' => App::$query_string];
|
||||
call_hooks('stream_content_init', $arr);
|
||||
Hook::call('stream_content_init', $arr);
|
||||
|
||||
$channel = ((isset(App::$data['channel'])) ? App::$data['channel'] : null);
|
||||
|
||||
|
@ -641,7 +642,7 @@ class Stream extends Controller
|
|||
|
||||
if ($update_unseen && (!(isset($_SESSION['sudo']) && $_SESSION['sudo']))) {
|
||||
$x = ['channel_id' => local_channel(), 'update' => 'unset'];
|
||||
call_hooks('update_unseen', $x);
|
||||
Hook::call('update_unseen', $x);
|
||||
if ($x['update'] === 'unset' || intval($x['update'])) {
|
||||
$r = q(
|
||||
"UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 AND uid = %d $update_unseen ",
|
||||
|
|
|
@ -6,6 +6,7 @@ use App;
|
|||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Lib\Activity;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once('include/security.php');
|
||||
require_once('include/bbcode.php');
|
||||
|
@ -183,7 +184,7 @@ class Subthread extends Controller
|
|||
|
||||
$arr['id'] = $post_id;
|
||||
|
||||
call_hooks('post_local_end', $arr);
|
||||
Hook::call('post_local_end', $arr);
|
||||
|
||||
killme();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,8 @@ use App;
|
|||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Lib\Channel;
|
||||
|
||||
use Zotlabs\Lib\Addon;
|
||||
|
||||
require_once('include/attach.php');
|
||||
require_once('include/photos.php');
|
||||
|
||||
|
@ -148,7 +149,7 @@ class Wall_attach extends Controller
|
|||
logger('unable to read svg data file: ' . 'store/' . $channel['channel_address'] . '/' . $r['data']['os_path']);
|
||||
}
|
||||
}
|
||||
if ($r['data']['filetype'] === 'text/vnd.abc' && addon_is_installed('abc')) {
|
||||
if ($r['data']['filetype'] === 'text/vnd.abc' && Addon::is_installed('abc')) {
|
||||
$x = @file_get_contents('store/' . $channel['channel_address'] . '/' . $r['data']['os_path']);
|
||||
if ($x) {
|
||||
$s .= "\n\n" . '[abc]' . $x . '[/abc]';
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Zotlabs\Module;
|
|||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Lib\System;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
use App;
|
||||
|
||||
class Webfinger extends Controller
|
||||
|
@ -185,7 +186,7 @@ class Webfinger extends Controller
|
|||
}
|
||||
|
||||
$arr = ['channel' => $channel_target, 'request' => $_REQUEST, 'result' => $result];
|
||||
call_hooks('webfinger', $arr);
|
||||
Hook::call('webfinger', $arr);
|
||||
|
||||
|
||||
json_return_and_die($arr['result'], 'application/jrd+json', true);
|
||||
|
|
|
@ -6,6 +6,7 @@ use App;
|
|||
use Zotlabs\Web\Controller;
|
||||
use Zotlabs\Module\Webfinger;
|
||||
use Zotlabs\Module\Oauthinfo;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Well_known extends Controller
|
||||
{
|
||||
|
@ -15,7 +16,7 @@ class Well_known extends Controller
|
|||
|
||||
if (argc() > 1) {
|
||||
$arr = ['server' => $_SERVER, 'request' => $_REQUEST];
|
||||
call_hooks('well_known', $arr);
|
||||
Hook::call('well_known', $arr);
|
||||
|
||||
if (!check_siteallowed($_SERVER['REMOTE_ADDR'])) {
|
||||
logger('well_known: site not allowed. ' . $_SERVER['REMOTE_ADDR']);
|
||||
|
|
|
@ -567,7 +567,7 @@ class Comanche
|
|||
} elseif (file_exists('Zotlabs/Widget/' . $clsname . '.php')) {
|
||||
require_once('Zotlabs/Widget/' . $clsname . '.php');
|
||||
} else {
|
||||
$pth = theme_include($clsname . '.php');
|
||||
$pth = Theme::include($clsname . '.php');
|
||||
if ($pth) {
|
||||
require_once($pth);
|
||||
}
|
||||
|
@ -592,8 +592,8 @@ class Comanche
|
|||
}
|
||||
if (!function_exists($func)) {
|
||||
$theme_widget = $func . '.php';
|
||||
if (theme_include($theme_widget)) {
|
||||
require_once(theme_include($theme_widget));
|
||||
if (Theme::include($theme_widget)) {
|
||||
require_once(Theme::include($theme_widget));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ class SimpleTemplate implements TemplateEngine
|
|||
|
||||
public function get_markup_template($file, $root = '')
|
||||
{
|
||||
$template_file = theme_include($file, $root);
|
||||
$template_file = Theme::include($file, $root);
|
||||
if ($template_file) {
|
||||
$content = file_get_contents($template_file);
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ class SmartyTemplate implements TemplateEngine
|
|||
|
||||
public function get_markup_template($file, $root = '')
|
||||
{
|
||||
$template_file = theme_include($file, $root);
|
||||
$template_file = Theme::include($file, $root);
|
||||
if ($template_file) {
|
||||
$template = new SmartyInterface();
|
||||
$template->filename = $template_file;
|
||||
|
@ -84,7 +84,7 @@ class SmartyTemplate implements TemplateEngine
|
|||
}
|
||||
}
|
||||
if ($template_file == '') {
|
||||
$template_file = theme_include($file, $root);
|
||||
$template_file = Theme::include($file, $root);
|
||||
}
|
||||
if ($template_file) {
|
||||
$template = new SmartyInterface();
|
||||
|
|
|
@ -134,6 +134,51 @@ class Theme
|
|||
return ('/view/theme/' . $t . '/css/style.css');
|
||||
}
|
||||
|
||||
public static function include($file, $root = '')
|
||||
{
|
||||
|
||||
// Make sure $root ends with a slash / if it's not blank
|
||||
if ($root) {
|
||||
$root = rtrim($root,'/') . '/';
|
||||
}
|
||||
|
||||
$theme_info = App::$theme_info;
|
||||
|
||||
if (array_key_exists('extends', $theme_info)) {
|
||||
$parent = $theme_info['extends'];
|
||||
} else {
|
||||
$parent = 'NOPATH';
|
||||
}
|
||||
|
||||
$theme = self::current();
|
||||
$thname = $theme[0];
|
||||
|
||||
$ext = substr($file, strrpos($file, '.') + 1);
|
||||
|
||||
$paths = array(
|
||||
"{$root}view/theme/$thname/$ext/$file",
|
||||
"{$root}view/theme/$parent/$ext/$file",
|
||||
"{$root}view/site/$ext/$file",
|
||||
"{$root}view/$ext/$file",
|
||||
);
|
||||
|
||||
foreach ($paths as $p) {
|
||||
|
||||
if (strpos($p, 'NOPATH') !== false) {
|
||||
continue;
|
||||
}
|
||||
if (file_exists($p)) {
|
||||
return $p;
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public function debug()
|
||||
{
|
||||
logger('system_theme: ' . self::$system_theme);
|
||||
|
|
|
@ -12,6 +12,7 @@ use Zotlabs\Lib\ServiceClass;
|
|||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Lib\Navbar;
|
||||
use Zotlabs\Lib\Libacl;
|
||||
use Zotlabs\Extend\Hook;
|
||||
use function Sabre\HTTP\encodePath;
|
||||
|
||||
|
||||
|
@ -253,7 +254,7 @@ class Browser extends DAV\Browser\Plugin {
|
|||
}
|
||||
|
||||
$g = [ 'resource_id' => $attachHash, 'thumbnail' => $photo_icon, 'security' => $preview_style ];
|
||||
call_hooks('file_thumbnail', $g);
|
||||
Hook::call('file_thumbnail', $g);
|
||||
$photo_icon = $g['thumbnail'];
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
65;6402;1c<?php
|
||||
|
||||
namespace Zotlabs\Web;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Extend\Route;
|
||||
use Zotlabs\Render\Theme;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
|
@ -117,7 +119,7 @@ class Router
|
|||
* * \e boolean \b installed
|
||||
* * \e mixed \b controller - The initialized module object
|
||||
*/
|
||||
call_hooks('module_loaded', $x);
|
||||
Hook::call('module_loaded', $x);
|
||||
if ($x['installed']) {
|
||||
App::$module_loaded = true;
|
||||
$this->controller = $x['controller'];
|
||||
|
@ -145,7 +147,7 @@ class Router
|
|||
'installed' => App::$module_loaded,
|
||||
'controller' => $this->controller
|
||||
];
|
||||
call_hooks('page_not_found', $x);
|
||||
Hook::call('page_not_found', $x);
|
||||
|
||||
// Stupid browser tried to pre-fetch our Javascript img template.
|
||||
// Don't log the event or return anything - just quietly exit.
|
||||
|
@ -196,7 +198,7 @@ class Router
|
|||
*/
|
||||
|
||||
$arr = ['init' => true, 'replace' => false];
|
||||
call_hooks(App::$module . '_mod_init', $arr);
|
||||
Hook::call(App::$module . '_mod_init', $arr);
|
||||
if (!$arr['replace']) {
|
||||
if ($this->controller && method_exists($this->controller, 'init')) {
|
||||
$this->controller->init();
|
||||
|
@ -242,7 +244,7 @@ class Router
|
|||
}
|
||||
|
||||
if (($_SERVER['REQUEST_METHOD'] === 'POST') && (!App::$error) && (!x($_POST, 'auth-params'))) {
|
||||
call_hooks(App::$module . '_mod_post', $_POST);
|
||||
Hook::call(App::$module . '_mod_post', $_POST);
|
||||
if ($this->controller && method_exists($this->controller, 'post')) {
|
||||
$this->controller->post();
|
||||
}
|
||||
|
@ -250,14 +252,14 @@ class Router
|
|||
|
||||
if (!App::$error) {
|
||||
$arr = ['content' => App::$page['content'], 'replace' => false];
|
||||
call_hooks(App::$module . '_mod_content', $arr);
|
||||
Hook::call(App::$module . '_mod_content', $arr);
|
||||
|
||||
if (!$arr['replace']) {
|
||||
if ($this->controller && method_exists($this->controller, 'get')) {
|
||||
$arr = ['content' => $this->controller->get(), 'replace' => false];
|
||||
}
|
||||
}
|
||||
call_hooks(App::$module . '_mod_aftercontent', $arr);
|
||||
Hook::call(App::$module . '_mod_aftercontent', $arr);
|
||||
App::$page['content'] = (($arr['replace']) ? $arr['content'] : App::$page['content'] . $arr['content']);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
|
||||
namespace Zotlabs\Web;
|
||||
|
||||
use Zotlabs\Web\SessionHandler
|
||||
;
|
||||
use Zotlabs\Web\SessionHandler;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -152,7 +153,7 @@ class Session
|
|||
);
|
||||
|
||||
$arr = array('expire' => $xtime);
|
||||
call_hooks('new_cookie', $arr);
|
||||
Hook::call('new_cookie', $arr);
|
||||
}
|
||||
|
||||
public function extend_cookie()
|
||||
|
@ -180,7 +181,7 @@ class Session
|
|||
}
|
||||
|
||||
$arr = array('expire' => $xtime);
|
||||
call_hooks('extend_cookie', $arr);
|
||||
Hook::call('extend_cookie', $arr);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ namespace Zotlabs\Web;
|
|||
|
||||
use App;
|
||||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class WebServer
|
||||
{
|
||||
|
@ -173,7 +174,7 @@ class WebServer
|
|||
App::$page['content'] = EMPTY_STR;
|
||||
}
|
||||
|
||||
call_hooks('page_content_top', App::$page['content']);
|
||||
Hook::call('page_content_top', App::$page['content']);
|
||||
}
|
||||
|
||||
private function create_channel_links()
|
||||
|
@ -219,7 +220,7 @@ class WebServer
|
|||
];
|
||||
|
||||
$x = [ 'channel_address' => argv(1), 'channel_links' => App::$channel_links ];
|
||||
call_hooks('channel_links', $x);
|
||||
Hook::call('channel_links', $x);
|
||||
App::$channel_links = $x['channel_links'];
|
||||
header('Link: ' . App::get_channel_links());
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Zotlabs\Widget;
|
||||
|
||||
use Zotlabs\Lib\LibBlock;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Activity
|
||||
{
|
||||
|
@ -50,7 +51,7 @@ class Activity
|
|||
}
|
||||
|
||||
$x = ['entries' => $arr];
|
||||
call_hooks('activity_widget', $x);
|
||||
Hook::call('activity_widget', $x);
|
||||
$arr = $x['entries'];
|
||||
|
||||
if ($arr) {
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Zotlabs\Widget;
|
|||
use App;
|
||||
use Zotlabs\Lib\Apps;
|
||||
use Zotlabs\Lib\Features;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Activity_filter
|
||||
{
|
||||
|
@ -312,7 +313,7 @@ class Activity_filter
|
|||
|
||||
$arr = ['tabs' => $tabs];
|
||||
|
||||
call_hooks('activity_filter', $arr);
|
||||
Hook::call('activity_filter', $arr);
|
||||
|
||||
$o = '';
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Zotlabs\Widget;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Admin
|
||||
{
|
||||
|
@ -47,14 +48,14 @@ class Admin
|
|||
$plugin = $h['aname'];
|
||||
$plugins[] = array(z_root() . '/admin/addons/' . $plugin, $plugin, 'plugin');
|
||||
// temp plugins with admin
|
||||
App::$plugins_admin[] = $plugin;
|
||||
App::$addons_admin[] = $plugin;
|
||||
}
|
||||
}
|
||||
|
||||
$logs = array(z_root() . '/admin/logs/', t('Logs'), 'logs');
|
||||
|
||||
$arr = array('links' => $aside, 'plugins' => $plugins, 'logs' => $logs);
|
||||
call_hooks('admin_aside', $arr);
|
||||
Hook::call('admin_aside', $arr);
|
||||
|
||||
$o .= replace_macros(get_markup_template('admin_aside.tpl'), array(
|
||||
'$admin' => $aside,
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Zotlabs\Widget;
|
||||
|
||||
use Zotlabs\Lib\Apps;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
class Affinity
|
||||
{
|
||||
|
@ -30,7 +31,7 @@ class Affinity
|
|||
80 => t('Connections'),
|
||||
99 => t('All')
|
||||
);
|
||||
call_hooks('affinity_labels', $labels);
|
||||
Hook::call('affinity_labels', $labels);
|
||||
|
||||
$tpl = get_markup_template('main_slider.tpl');
|
||||
$x = replace_macros($tpl, [
|
||||
|
@ -42,7 +43,7 @@ class Affinity
|
|||
]);
|
||||
|
||||
$arr = array('html' => $x);
|
||||
call_hooks('main_slider', $arr);
|
||||
Hook::call('main_slider', $arr);
|
||||
return $arr['html'];
|
||||
}
|
||||
return '';
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Zotlabs\Widget;
|
||||
|
||||
use Zotlabs\Lib\Apps;
|
||||
use Zotlabs\Extend\Hook;
|
||||
use App;
|
||||
|
||||
class Stream_order
|
||||
|
@ -124,7 +125,7 @@ class Stream_order
|
|||
|
||||
$arr = ['tabs' => $tabs];
|
||||
|
||||
call_hooks('activity_order', $arr);
|
||||
Hook::call('activity_order', $arr);
|
||||
|
||||
$o = '';
|
||||
|
||||
|
|
39
boot.php
39
boot.php
|
@ -14,6 +14,7 @@ use Zotlabs\Daemon\Run;
|
|||
use Zotlabs\Lib\Channel;
|
||||
use Zotlabs\Lib\Navbar;
|
||||
use Zotlabs\Lib\Stringsjs;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
/**
|
||||
* @file boot.php
|
||||
|
@ -708,7 +709,7 @@ function sys_boot() {
|
|||
* @hooks 'startup'
|
||||
*/
|
||||
$arr = [];
|
||||
call_hooks('startup',$arr);
|
||||
Hook::call('startup',$arr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -771,7 +772,7 @@ class App {
|
|||
public static $language;
|
||||
public static $langsave;
|
||||
public static $rtl = false;
|
||||
public static $plugins_admin;
|
||||
public static $addons_admin;
|
||||
public static $module_loaded = false;
|
||||
public static $query_string;
|
||||
public static $page;
|
||||
|
@ -794,7 +795,7 @@ class App {
|
|||
public static $hooks;
|
||||
public static $timezone;
|
||||
public static $interactive = true;
|
||||
public static $plugins;
|
||||
public static $addons;
|
||||
private static $apps = [];
|
||||
public static $identities;
|
||||
public static $css_sources = [];
|
||||
|
@ -1204,7 +1205,7 @@ class App {
|
|||
* Called when creating the HTML page header.
|
||||
* * \e string \b header - Return the HTML header which should be added
|
||||
*/
|
||||
call_hooks('build_pagehead', $x);
|
||||
Hook::call('build_pagehead', $x);
|
||||
|
||||
/* put the head template at the beginning of page['htmlhead']
|
||||
* since the code added by the modules frequently depends on it
|
||||
|
@ -1512,8 +1513,6 @@ function check_config() {
|
|||
|
||||
$x = new DB_Upgrade(DB_UPDATE_VERSION);
|
||||
|
||||
plugins_sync();
|
||||
|
||||
load_hooks();
|
||||
|
||||
check_cron_broken();
|
||||
|
@ -1740,7 +1739,7 @@ function login($register = false, $form_id = 'main-login', $hiddens = false, $lo
|
|||
* Called when generating the login form.
|
||||
* * \e string with parsed HTML
|
||||
*/
|
||||
call_hooks('login_hook', $o);
|
||||
Hook::call('login_hook', $o);
|
||||
|
||||
return $o;
|
||||
}
|
||||
|
@ -1953,7 +1952,7 @@ function proc_run() {
|
|||
* * \e boolean \b run_cmd
|
||||
*/
|
||||
|
||||
call_hooks('proc_run', $arr);
|
||||
Hook::call('proc_run', $arr);
|
||||
|
||||
if (! $arr['run_cmd']) {
|
||||
return;
|
||||
|
@ -2212,7 +2211,7 @@ function load_pdl() {
|
|||
* * \e string \b module
|
||||
* * \e string \b layout
|
||||
*/
|
||||
call_hooks('load_pdl', $arr);
|
||||
Hook::call('load_pdl', $arr);
|
||||
$layout = $arr['layout'];
|
||||
|
||||
$n = 'mod_' . App::$module . '.pdl' ;
|
||||
|
@ -2222,7 +2221,7 @@ function load_pdl() {
|
|||
if(! (isset($s) && $s))
|
||||
$s = $layout;
|
||||
|
||||
if((! $s) && (($p = theme_include($n)) != ''))
|
||||
if((! $s) && (($p = Theme::include($n)) != ''))
|
||||
$s = @file_get_contents($p);
|
||||
elseif(file_exists('addon/'. App::$module . '/' . $n))
|
||||
$s = @file_get_contents('addon/'. App::$module . '/' . $n);
|
||||
|
@ -2231,7 +2230,7 @@ function load_pdl() {
|
|||
'module' => App::$module,
|
||||
'layout' => $s
|
||||
];
|
||||
call_hooks('alter_pdl',$arr);
|
||||
Hook::call('alter_pdl',$arr);
|
||||
$s = $arr['layout'];
|
||||
|
||||
if($s) {
|
||||
|
@ -2257,13 +2256,13 @@ function exec_pdl() {
|
|||
*/
|
||||
function construct_page() {
|
||||
|
||||
call_hooks('page_end', App::$page['content']);
|
||||
Hook::call('page_end', App::$page['content']);
|
||||
|
||||
exec_pdl();
|
||||
|
||||
$comanche = ((isset(App::$layout) && is_array(App::$layout) && count(App::$layout)) ? true : false);
|
||||
|
||||
require_once(theme_include('theme_init.php'));
|
||||
require_once(Theme::include('theme_init.php'));
|
||||
|
||||
$installing = false;
|
||||
|
||||
|
@ -2291,10 +2290,10 @@ function construct_page() {
|
|||
// logger('current_theme: ' . print_r($current_theme,true));
|
||||
// Theme::debug();
|
||||
|
||||
if (($p = theme_include($current_theme[0] . '.js')) != '')
|
||||
if (($p = Theme::include($current_theme[0] . '.js')) != '')
|
||||
head_add_js('/' . $p);
|
||||
|
||||
if (($p = theme_include('mod_' . App::$module . '.php')) != '')
|
||||
if (($p = Theme::include('mod_' . App::$module . '.php')) != '')
|
||||
require_once($p);
|
||||
|
||||
if (isset(App::$page['template_style']))
|
||||
|
@ -2302,12 +2301,12 @@ function construct_page() {
|
|||
else
|
||||
head_add_css(((isset(App::$page['template'])) ? App::$page['template'] : 'default' ) . '.css');
|
||||
|
||||
if (($p = theme_include('mod_' . App::$module . '.css')) != '')
|
||||
if (($p = Theme::include('mod_' . App::$module . '.css')) != '')
|
||||
head_add_css('mod_' . App::$module . '.css');
|
||||
|
||||
head_add_css(Theme::url($installing));
|
||||
|
||||
if (($p = theme_include('mod_' . App::$module . '.js')) != '')
|
||||
if (($p = Theme::include('mod_' . App::$module . '.js')) != '')
|
||||
head_add_js('mod_' . App::$module . '.js');
|
||||
|
||||
App::build_pagehead();
|
||||
|
@ -2337,7 +2336,7 @@ function construct_page() {
|
|||
* * \e string \b module
|
||||
* * \e string \b layout
|
||||
*/
|
||||
call_hooks('construct_page', $arr);
|
||||
Hook::call('construct_page', $arr);
|
||||
App::$layout = ((isset($arr['layout']) && is_array($arr['layout'])) ? $arr['layout'] : []);
|
||||
|
||||
foreach(App::$layout as $k => $v) {
|
||||
|
@ -2384,7 +2383,7 @@ function construct_page() {
|
|||
'script-src' => Array ("'self'","'unsafe-inline'","'unsafe-eval'"),
|
||||
'style-src' => Array ("'self'","'unsafe-inline'")
|
||||
);
|
||||
call_hooks('content_security_policy',$cspsettings);
|
||||
Hook::call('content_security_policy',$cspsettings);
|
||||
|
||||
// Legitimate CSP directives (cxref: https://content-security-policy.com/)
|
||||
$validcspdirectives=Array(
|
||||
|
@ -2428,7 +2427,7 @@ function construct_page() {
|
|||
header("Public-Key-Pins: " . App::$config['system']['public_key_pins']);
|
||||
}
|
||||
|
||||
require_once(theme_include(
|
||||
require_once(Theme::include(
|
||||
((isset(App::$page['template']) && App::$page['template']) ? App::$page['template'] : 'default' ) . '.php' )
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
|
||||
/**
|
||||
* @file include/addon.php
|
||||
*
|
||||
|
@ -200,7 +204,7 @@ function plugin_is_installed($name)
|
|||
* @return bool
|
||||
*/
|
||||
|
||||
function addon_is_installed($name)
|
||||
function Addon::is_installed($name)
|
||||
{
|
||||
$r = q(
|
||||
"select aname from addon where aname = '%s' and installed = 1 limit 1",
|
||||
|
@ -500,7 +504,7 @@ function insert_hook($hook, $fn, $version = 0, $priority = 0)
|
|||
* @param string $name of the hook to call
|
||||
* @param[in,out] string|array &$data to transmit to the callback handler
|
||||
*/
|
||||
function call_hooks($name, &$data = null)
|
||||
function Hook::call($name, &$data = null)
|
||||
{
|
||||
$a = 0;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
use Zotlabs\Lib\Api_router;
|
||||
use Zotlabs\Extend\Hook;
|
||||
|
||||
require_once("include/conversation.php");
|
||||
require_once("include/oauth.php");
|
||||
|
@ -136,7 +137,7 @@ function api_call()
|
|||
|
||||
|
||||
$x = [ 'path' => App::$query_string ];
|
||||
call_hooks('api_not_found', $x);
|
||||
Hook::call('api_not_found', $x);
|
||||
|
||||
header('HTTP/1.1 404 Not Found');
|
||||
logger('API call not implemented: ' . App::$query_string . ' - ' . print_r($_REQUEST, true));
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue