diff --git a/Sources/Actions/Activate.php b/Sources/Actions/Activate.php index 52b9eca6741..22930e504e1 100644 --- a/Sources/Actions/Activate.php +++ b/Sources/Actions/Activate.php @@ -17,6 +17,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Logging; use SMF\Mail; @@ -225,7 +226,7 @@ public function execute(): void } // Let the integration know that they've been activated! - call_integration_hook('integrate_activate', array($row['member_name'])); + IntegrationHook::call('integrate_activate', array($row['member_name'])); // Validation complete - update the database! User::updateMemberData($row['id_member'], array('is_activated' => 1, 'validation_code' => '')); diff --git a/Sources/Actions/Admin/ACP.php b/Sources/Actions/Admin/ACP.php index 3f4b0b4d55d..9b8296293ba 100644 --- a/Sources/Actions/Admin/ACP.php +++ b/Sources/Actions/Admin/ACP.php @@ -19,6 +19,7 @@ use SMF\BBCodeParser; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Mail; use SMF\Menu; @@ -1107,7 +1108,7 @@ public static function prepareDBSettingContext(&$config_vars): void } } - call_integration_hook('integrate_prepare_db_settings', array(&$config_vars)); + IntegrationHook::call('integrate_prepare_db_settings', array(&$config_vars)); SecurityToken::create('admin-dbsc'); } @@ -1905,7 +1906,7 @@ public static function adminLogin($type = 'admin') // Validate what type of session check this is. $types = array(); - call_integration_hook('integrate_validateSession', array(&$types)); + IntegrationHook::call('integrate_validateSession', array(&$types)); $type = in_array($type, $types) || $type == 'moderate' ? $type : 'admin'; // They used a wrong password, log it and unset that. @@ -2049,7 +2050,7 @@ function(&$value, $key) $this->admin_areas['maintenance']['areas']['logs']['subsections']['spiderlog']['enabled'] = !empty(Config::$modSettings['spider_mode']); // Give mods access to the menu. - call_integration_hook('integrate_admin_areas', array(&$this->admin_areas)); + IntegrationHook::call('integrate_admin_areas', array(&$this->admin_areas)); } /************************* diff --git a/Sources/Actions/Admin/AntiSpam.php b/Sources/Actions/Admin/AntiSpam.php index d84c7081fd8..f364b39ba8c 100644 --- a/Sources/Actions/Admin/AntiSpam.php +++ b/Sources/Actions/Admin/AntiSpam.php @@ -17,6 +17,7 @@ use SMF\Actions\ActionInterface; use SMF\Config; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\Theme; @@ -306,7 +307,7 @@ public function execute(): void if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) $_POST['qa_verification_number'] = $count_questions; - call_integration_hook('integrate_save_spam_settings', array(&$save_vars)); + IntegrationHook::call('integrate_save_spam_settings', array(&$save_vars)); // Now save. ACP::saveDBSettings($save_vars); @@ -464,7 +465,7 @@ public static function getConfigVars(): array array('callback', 'question_answer_list'), ); - call_integration_hook('integrate_spam_settings', array(&$config_vars)); + IntegrationHook::call('integrate_spam_settings', array(&$config_vars)); return $config_vars; } diff --git a/Sources/Actions/Admin/Attachments.php b/Sources/Actions/Admin/Attachments.php index f1306653e2c..22c10eb877a 100644 --- a/Sources/Actions/Admin/Attachments.php +++ b/Sources/Actions/Admin/Attachments.php @@ -22,6 +22,7 @@ use SMF\Attachment; use SMF\Config; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Menu; @@ -203,7 +204,7 @@ public function attachmentSettings(): void } } - call_integration_hook('integrate_save_attachment_settings'); + IntegrationHook::call('integrate_save_attachment_settings'); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -245,7 +246,7 @@ public function avatarSettings(): void if (empty($_POST['avatar_url'])) $_POST['avatar_url'] = Config::$boardurl . '/avatars'; - call_integration_hook('integrate_save_avatar_settings'); + IntegrationHook::call('integrate_save_avatar_settings'); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -467,7 +468,7 @@ public function browse(): void $list_title = Lang::$txt['attachment_manager_browse_files'] . ': '; // Does a hook want to display their attachments better? - call_integration_hook('integrate_attachments_browse', array(&$listOptions, &$titles)); + IntegrationHook::call('integrate_attachments_browse', array(&$listOptions, &$titles)); foreach ($titles as $browse_type => $details) { @@ -615,7 +616,7 @@ public function remove(): void // If the attachments are from a 3rd party, let them remove it. Hooks should remove their ids from the array. $filesRemoved = false; - call_integration_hook('integrate_attachment_remove', array(&$filesRemoved, $attachments)); + IntegrationHook::call('integrate_attachment_remove', array(&$filesRemoved, $attachments)); if ($_REQUEST['type'] == 'avatars' && !empty($attachments)) { @@ -1200,7 +1201,7 @@ public function repair(): void $ignore_ids = array(0); // returns an array of ints of id_attach's that should not be deleted - call_integration_hook('integrate_repair_attachments_nomsg', array(&$ignore_ids, $_GET['substep'], $_GET['substep'] + 500)); + IntegrationHook::call('integrate_repair_attachments_nomsg', array(&$ignore_ids, $_GET['substep'], $_GET['substep'] + 500)); $result = Db::$db->query('', ' SELECT a.id_attach, a.id_folder, a.filename, a.file_hash @@ -2341,7 +2342,7 @@ public static function attachConfigVars(): array array('int', 'max_image_height', 'subtext' => Lang::$txt['zero_for_no_limit']), ); - call_integration_hook('integrate_modify_attachment_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_attachment_settings', array(&$config_vars)); return $config_vars; } @@ -2424,7 +2425,7 @@ public static function avatarConfigVars(): array ), ); - call_integration_hook('integrate_modify_avatar_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_avatar_settings', array(&$config_vars)); return $config_vars; } @@ -2871,7 +2872,7 @@ protected function __construct() 'description' => Lang::$txt['attachments_desc'], ); - call_integration_hook('integrate_manage_attachments', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_attachments', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[strtolower($_REQUEST['sa'])])) $this->subaction = strtolower($_REQUEST['sa']); diff --git a/Sources/Actions/Admin/Bans.php b/Sources/Actions/Admin/Bans.php index 87549ea7b79..35501d13aab 100644 --- a/Sources/Actions/Admin/Bans.php +++ b/Sources/Actions/Admin/Bans.php @@ -23,6 +23,7 @@ use SMF\Config; use SMF\ErrorHandler; use SMF\IP; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Logging; @@ -493,7 +494,7 @@ public function edit(): void });', ); - call_integration_hook('integrate_ban_edit_list', array(&$listOptions)); + IntegrationHook::call('integrate_ban_edit_list', array(&$listOptions)); new ItemList($listOptions); } @@ -599,7 +600,7 @@ public function edit(): void Utils::$context['ban']['from_user'] = true; } - call_integration_hook('integrate_ban_edit_new', array()); + IntegrationHook::call('integrate_ban_edit_new', array()); } } @@ -1379,7 +1380,7 @@ public static function list_getBanItems($start = 0, $items_per_page = 0, $sort = } Db::$db->free_result($request); - call_integration_hook('integrate_ban_list', array(&$ban_items)); + IntegrationHook::call('integrate_ban_list', array(&$ban_items)); return $ban_items; } @@ -1635,7 +1636,7 @@ protected function __construct() ); } - call_integration_hook('integrate_manage_bans', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_bans', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; @@ -1680,7 +1681,7 @@ protected function edit2(): void $ban_info['cannot']['register'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_register']) ? 0 : 1; $ban_info['cannot']['login'] = !empty($ban_info['full_ban']) || empty($_POST['cannot_login']) ? 0 : 1; - call_integration_hook('integrate_edit_bans', array(&$ban_info, empty($_REQUEST['bg']))); + IntegrationHook::call('integrate_edit_bans', array(&$ban_info, empty($_REQUEST['bg']))); // Limit 'reason' characters $ban_info['reason'] = Utils::truncate($ban_info['reason'], 255); @@ -1742,7 +1743,7 @@ protected function edit2(): void self::removeBanTriggers($_POST['ban_items'], $ban_group_id); } - call_integration_hook('integrate_edit_bans_post', array()); + IntegrationHook::call('integrate_edit_bans_post', array()); // Register the last modified date. Config::updateModSettings(array('banLastUpdated' => time())); @@ -1764,7 +1765,7 @@ protected function banLoadAdditionalIPs($member_id): array Lang::load('Profile'); $search_list = array(); - call_integration_hook('integrate_load_addtional_ip_ban', array(&$search_list)); + IntegrationHook::call('integrate_load_addtional_ip_ban', array(&$search_list)); $search_list += array( 'ips_in_messages' => array($this, 'banLoadAdditionalIPsMember'), @@ -1876,7 +1877,7 @@ protected function saveTriggers(array $suggestions, $ban_group, $member = 0, $ba $ban_triggers = $this->validateTriggers($triggers); - call_integration_hook('integrate_save_triggers', array(&$ban_triggers, &$ban_group)); + IntegrationHook::call('integrate_save_triggers', array(&$ban_triggers, &$ban_group)); // Time to save! if (!empty($ban_triggers['ban_triggers']) && empty(Utils::$context['ban_errors'])) @@ -2535,7 +2536,7 @@ protected static function removeBanTriggers($items_ids = array(), $group_id = nu $log_info = array(); $ban_items = array(); - call_integration_hook('integrate_remove_triggers', array(&$items_ids, $group_id)); + IntegrationHook::call('integrate_remove_triggers', array(&$items_ids, $group_id)); // First order of business: Load up the info so we can log this... $request = Db::$db->query('', ' diff --git a/Sources/Actions/Admin/Boards.php b/Sources/Actions/Admin/Boards.php index c5572c170eb..8d35596547e 100644 --- a/Sources/Actions/Admin/Boards.php +++ b/Sources/Actions/Admin/Boards.php @@ -22,6 +22,7 @@ use SMF\Config; use SMF\ErrorHandler; use SMF\Group; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\SecurityToken; @@ -282,7 +283,7 @@ public function main(): void } } - call_integration_hook('integrate_boards_main'); + IntegrationHook::call('integrate_boards_main'); Utils::$context['page_title'] = Lang::$txt['boards_and_cats']; Utils::$context['can_manage_permissions'] = User::$me->allowedTo('manage_permissions'); @@ -390,7 +391,7 @@ public function editCategory(): void SecurityToken::create('admin-bc-' . $_REQUEST['cat']); Utils::$context['token_check'] = 'admin-bc-' . $_REQUEST['cat']; - call_integration_hook('integrate_edit_category'); + IntegrationHook::call('integrate_edit_category'); } /** @@ -686,7 +687,7 @@ public function editBoard(): void // Create a special token. SecurityToken::create('admin-be-' . $_REQUEST['boardid']); - call_integration_hook('integrate_edit_board'); + IntegrationHook::call('integrate_edit_board'); } /** @@ -935,7 +936,7 @@ public function settings(): void { User::$me->checkSession(); - call_integration_hook('integrate_save_board_settings'); + IntegrationHook::call('integrate_save_board_settings'); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -1023,7 +1024,7 @@ public static function getConfigVars(): array array('check', 'deny_boards_access'), ); - call_integration_hook('integrate_modify_board_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_board_settings', array(&$config_vars)); return $config_vars; } @@ -1072,7 +1073,7 @@ protected function __construct() ), ); - call_integration_hook('integrate_manage_boards', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_boards', array(&self::$subactions)); // Default to sub action 'main' or 'settings' depending on permissions. $this->subaction = isset($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (User::$me->allowedTo('manage_boards') ? 'main' : 'settings'); diff --git a/Sources/Actions/Admin/Calendar.php b/Sources/Actions/Admin/Calendar.php index 7c98fceb712..766397ecaad 100644 --- a/Sources/Actions/Admin/Calendar.php +++ b/Sources/Actions/Admin/Calendar.php @@ -20,6 +20,7 @@ use SMF\Board; use SMF\Config; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Menu; @@ -355,7 +356,7 @@ public function settings(): void if (isset($_GET['save'])) { User::$me->checkSession(); - call_integration_hook('integrate_save_calendar_settings'); + IntegrationHook::call('integrate_save_calendar_settings'); ACP::saveDBSettings($config_vars); // Update the stats in case. @@ -476,7 +477,7 @@ public static function getConfigVars(): array ); } - call_integration_hook('integrate_modify_calendar_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_calendar_settings', array(&$config_vars)); return $config_vars; } @@ -551,7 +552,7 @@ protected function __construct() ); } - call_integration_hook('integrate_manage_calendar', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_calendar', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/Features.php b/Sources/Actions/Admin/Features.php index e3a41de5d7a..e5dc643c749 100644 --- a/Sources/Actions/Admin/Features.php +++ b/Sources/Actions/Admin/Features.php @@ -19,6 +19,7 @@ use SMF\BBCodeParser; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Menu; @@ -144,7 +145,7 @@ public function basic(): void if (isset($_POST['lastActive'])) $_POST['lastActive'] = min((int) $_POST['lastActive'], 1440); - call_integration_hook('integrate_save_basic_settings'); + IntegrationHook::call('integrate_save_basic_settings'); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -273,7 +274,7 @@ function($config_var) } ); - call_integration_hook('integrate_save_bbc_settings', array($bbcTags)); + IntegrationHook::call('integrate_save_bbc_settings', array($bbcTags)); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -300,7 +301,7 @@ public function layout(): void { User::$me->checkSession(); - call_integration_hook('integrate_save_layout_settings'); + IntegrationHook::call('integrate_save_layout_settings'); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -580,7 +581,7 @@ public function signature(): void $sig = strtr($sig, array("\n" => '
')); - call_integration_hook('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); + IntegrationHook::call('integrate_apply_signature_settings', array(&$sig, $sig_limits, $disabledTags)); if ($sig != $row['signature']) $changes[$row['id_member']] = $sig; @@ -672,7 +673,7 @@ public function signature(): void } } - call_integration_hook('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); + IntegrationHook::call('integrate_save_signature_settings', array(&$sig_limits, &$bbcTags)); $_POST['signature_settings'] = implode(',', $sig_limits) . ':' . implode(',', array_diff($bbcTags, $_POST['signature_bbc_enabledTags'])); @@ -1510,7 +1511,7 @@ public function likes(): void { User::$me->checkSession(); - call_integration_hook('integrate_save_likes_settings'); + IntegrationHook::call('integrate_save_likes_settings'); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -1537,7 +1538,7 @@ public function mentions(): void { User::$me->checkSession(); - call_integration_hook('integrate_save_mentions_settings'); + IntegrationHook::call('integrate_save_mentions_settings'); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -1693,7 +1694,7 @@ public static function basicConfigVars(): array array('int', 'alerts_per_page', 'step' => 1, 'min' => 0, 'max' => 999), ); - call_integration_hook('integrate_modify_basic_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_basic_settings', array(&$config_vars)); return $config_vars; } @@ -1730,7 +1731,7 @@ public static function bbcConfigVars(): array toggleBBCDisabled(\'disabledBBC\', ' . (empty(Config::$modSettings['enableBBC']) ? 'true' : 'false') . '); toggleBBCDisabled(\'legacyBBC\', ' . (empty(Config::$modSettings['enableBBC']) ? 'true' : 'false') . ');'; - call_integration_hook('integrate_modify_bbc_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_bbc_settings', array(&$config_vars)); return $config_vars; } @@ -1763,7 +1764,7 @@ public static function layoutConfigVars(): array array('check', 'timeLoadPageEnable'), ); - call_integration_hook('integrate_layout_settings', array(&$config_vars)); + IntegrationHook::call('integrate_layout_settings', array(&$config_vars)); return $config_vars; } @@ -1797,7 +1798,7 @@ public static function sigConfigVars(): array array('bbc', 'signature_bbc'), ); - call_integration_hook('integrate_signature_settings', array(&$config_vars)); + IntegrationHook::call('integrate_signature_settings', array(&$config_vars)); return $config_vars; } @@ -1814,7 +1815,7 @@ public static function likesConfigVars(): array array('permissions', 'likes_like'), ); - call_integration_hook('integrate_likes_settings', array(&$config_vars)); + IntegrationHook::call('integrate_likes_settings', array(&$config_vars)); return $config_vars; } @@ -1831,7 +1832,7 @@ public static function mentionsConfigVars(): array array('permissions', 'mention'), ); - call_integration_hook('integrate_mentions_settings', array(&$config_vars)); + IntegrationHook::call('integrate_mentions_settings', array(&$config_vars)); return $config_vars; } @@ -2077,7 +2078,7 @@ protected function __construct() ), ); - call_integration_hook('integrate_modify_features', array(&self::$subactions)); + IntegrationHook::call('integrate_modify_features', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/Find.php b/Sources/Actions/Admin/Find.php index 32a9fbd8ec6..14e06e708a8 100644 --- a/Sources/Actions/Admin/Find.php +++ b/Sources/Actions/Admin/Find.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\User; @@ -205,7 +206,7 @@ public function internal() // Try to get some more memory. Config::setMemoryLimit('128M'); - call_integration_hook('integrate_admin_search', array(&$this->language_files, &$this->include_files, &$this->settings_search)); + IntegrationHook::call('integrate_admin_search', array(&$this->language_files, &$this->include_files, &$this->settings_search)); Lang::load(implode('+', $this->language_files)); diff --git a/Sources/Actions/Admin/Languages.php b/Sources/Actions/Admin/Languages.php index b92712958a6..240d85bc838 100644 --- a/Sources/Actions/Admin/Languages.php +++ b/Sources/Actions/Admin/Languages.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Menu; @@ -671,7 +672,7 @@ public function settings($return_config = false) { User::$me->checkSession(); - call_integration_hook('integrate_save_language_settings', array(&$config_vars)); + IntegrationHook::call('integrate_save_language_settings', array(&$config_vars)); ACP::saveSettings($config_vars); @@ -778,7 +779,7 @@ public function editEntries() ); // Does a hook need to add in some additional places to look for languages or info about how to handle them? - call_integration_hook('integrate_modifylanguages', array(&$themes, &$lang_dirs, &$allows_add_remove, &$additional_string_types)); + IntegrationHook::call('integrate_modifylanguages', array(&$themes, &$lang_dirs, &$allows_add_remove, &$additional_string_types)); $string_types = array_unique(array_merge($string_types, $additional_string_types)); @@ -1064,7 +1065,7 @@ function($val1, $val2) 'EmailTemplates' => array('txt' => 'txt_for_email_templates', 'txtBirthdayEmails' => 'txt_for_email_templates'), ); - call_integration_hook('integrate_language_edit_helptext', array(&$special_groups)); + IntegrationHook::call('integrate_language_edit_helptext', array(&$special_groups)); // Determine which groups of strings (if any) allow adding new entries if (isset($allows_add_remove[$file_id]['add'])) @@ -1578,7 +1579,7 @@ public static function getConfigVars(): array array('userLanguage', Lang::$txt['userLanguage'], 'db', 'check', null, 'userLanguage'), ); - call_integration_hook('integrate_language_settings', array(&$config_vars)); + IntegrationHook::call('integrate_language_settings', array(&$config_vars)); return $config_vars; } @@ -1809,7 +1810,7 @@ protected function __construct() 'description' => Lang::$txt['language_description'], ); - call_integration_hook('integrate_manage_languages', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_languages', array(&self::$subactions)); // By default we're managing languages. if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) diff --git a/Sources/Actions/Admin/Logs.php b/Sources/Actions/Admin/Logs.php index 5ff2951afcd..c3da05c8f47 100644 --- a/Sources/Actions/Admin/Logs.php +++ b/Sources/Actions/Admin/Logs.php @@ -17,6 +17,7 @@ use SMF\Actions\ActionInterface; use SMF\Config; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\Theme; @@ -396,7 +397,7 @@ public static function getConfigVars(): array ); // MOD AUTHORS: If you want to add your own logs, use this hook. - call_integration_hook('integrate_prune_settings', array(&$config_vars, &self::$prune_toggle, false)); + IntegrationHook::call('integrate_prune_settings', array(&$config_vars, &self::$prune_toggle, false)); return $config_vars; } @@ -431,7 +432,7 @@ protected function __construct() $subaction['disabled'] = empty(Config::$modSettings[$subaction['disabled']]); } - call_integration_hook('integrate_manage_logs', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_logs', array(&self::$subactions)); // By default, error log should be shown in descending order. if (!isset($_REQUEST['sa'])) diff --git a/Sources/Actions/Admin/Mail.php b/Sources/Actions/Admin/Mail.php index 0a80771812e..2b3afc37131 100644 --- a/Sources/Actions/Admin/Mail.php +++ b/Sources/Actions/Admin/Mail.php @@ -17,6 +17,7 @@ use SMF\Actions\ActionInterface; use SMF\Config; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Menu; @@ -283,7 +284,7 @@ public function settings(): void // We don't want to save the subject and body previews. unset($config_vars['birthday_subject'], $config_vars['birthday_body']); - call_integration_hook('integrate_save_mail_settings'); + IntegrationHook::call('integrate_save_mail_settings'); ACP::saveDBSettings($config_vars); Utils::redirectexit('action=admin;area=mailqueue;sa=settings'); @@ -457,7 +458,7 @@ public static function getConfigVars(): array 'birthday_body' => array('var_message', 'birthday_body', 'var_message' => nl2br($body), 'disabled' => true, 'size' => ceil(strlen($body) / 25)), ); - call_integration_hook('integrate_modify_mail_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_mail_settings', array(&$config_vars)); return $config_vars; } @@ -624,7 +625,7 @@ protected function __construct() Utils::$context['page_title'] = Lang::$txt['mailqueue_title']; Utils::$context['sub_template'] = 'show_settings'; - call_integration_hook('integrate_manage_mail', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_mail', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/Maintenance.php b/Sources/Actions/Admin/Maintenance.php index 159373d9a55..b45c452ce25 100644 --- a/Sources/Actions/Admin/Maintenance.php +++ b/Sources/Actions/Admin/Maintenance.php @@ -21,6 +21,7 @@ use SMF\Draft; use SMF\ErrorHandler; use SMF\Group; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Logging; @@ -1273,7 +1274,7 @@ public function changeMsgBodyLength(): void Db::$db->change_column('{db_prefix}messages', 'body', array('type' => 'text')); // 3rd party integrations may be interested in knowning about this. - call_integration_hook('integrate_convert_msgbody', array($body_type)); + IntegrationHook::call('integrate_convert_msgbody', array($body_type)); $colData = Db::$db->list_columns('{db_prefix}messages', true); foreach ($colData as $column) @@ -1871,16 +1872,17 @@ function($hook) use ($current_filter) SecurityToken::validate('admin-hook', 'request'); if ($_REQUEST['do'] == 'remove') - remove_integration_function($_REQUEST['hook'], urldecode($_REQUEST['function'])); - + { + IntegrationHook::remove($_REQUEST['hook'], urldecode($_REQUEST['function'])); + } else { // Disable/enable logic; always remove exactly what was passed $function_remove = urldecode($_REQUEST['function']); $function_add = urldecode(rtrim($_REQUEST['function'], '!')) . (($_REQUEST['do'] == 'disable') ? '!' : ''); - remove_integration_function($_REQUEST['hook'], $function_remove); - add_integration_function($_REQUEST['hook'], $function_add); + IntegrationHook::remove($_REQUEST['hook'], $function_remove); + IntegrationHook::add($_REQUEST['hook'], $function_add); } Utils::redirectexit('action=admin;area=maintain;sa=hooks' . $filter_url); @@ -2259,7 +2261,7 @@ public static function reattributePosts(int $memID, string $email = null, string } // Allow mods with their own post tables to reattribute posts as well :) - call_integration_hook('integrate_reattribute_posts', array($memID, $email, $membername, $post_count, &$updated)); + IntegrationHook::call('integrate_reattribute_posts', array($memID, $email, $membername, $post_count, &$updated)); return $updated; } @@ -2507,7 +2509,7 @@ protected function __construct() ), ); - call_integration_hook('integrate_manage_maintenance', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_maintenance', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/Membergroups.php b/Sources/Actions/Admin/Membergroups.php index 31df38f2cdd..cd0cdef4cf2 100644 --- a/Sources/Actions/Admin/Membergroups.php +++ b/Sources/Actions/Admin/Membergroups.php @@ -20,6 +20,7 @@ use SMF\Config; use SMF\ErrorHandler; use SMF\Group; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Logging; @@ -353,7 +354,7 @@ public function add(): void $_POST['group_type'] = !isset($_POST['group_type']) || $_POST['group_type'] < 0 || $_POST['group_type'] > 3 || ($_POST['group_type'] == 1 && !User::$me->allowedTo('admin_forum')) ? 0 : (int) $_POST['group_type']; - call_integration_hook('integrate_pre_add_membergroup', array()); + IntegrationHook::call('integrate_pre_add_membergroup', array()); $id_group = Db::$db->insert('', '{db_prefix}membergroups', @@ -369,7 +370,7 @@ public function add(): void 1 ); - call_integration_hook('integrate_add_membergroup', array($id_group, $postCountBasedGroup)); + IntegrationHook::call('integrate_add_membergroup', array($id_group, $postCountBasedGroup)); // Update the post groups now, if this is a post group! if (isset($_POST['min_posts'])) @@ -906,7 +907,7 @@ public function edit(): void Utils::$context['inheritable_groups'][$inheritable_group->id] = $inheritable_group->name; } - call_integration_hook('integrate_view_membergroup'); + IntegrationHook::call('integrate_view_membergroup'); Utils::$context['sub_template'] = 'edit_group'; Utils::$context['page_title'] = Lang::$txt['membergroups_edit_group']; @@ -931,7 +932,7 @@ public function settings(): void if (isset($_REQUEST['save'])) { User::$me->checkSession(); - call_integration_hook('integrate_save_membergroup_settings'); + IntegrationHook::call('integrate_save_membergroup_settings'); // Yeppers, saving this... ACP::saveDBSettings($config_vars); @@ -987,7 +988,7 @@ public static function getConfigVars(): array array('permissions', 'manage_membergroups'), ); - call_integration_hook('integrate_modify_membergroup_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_membergroup_settings', array(&$config_vars)); return $config_vars; } @@ -1068,7 +1069,7 @@ protected function __construct() 'description' => Lang::$txt['membergroups_description'], ); - call_integration_hook('integrate_manage_membergroups', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_membergroups', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) { diff --git a/Sources/Actions/Admin/Members.php b/Sources/Actions/Admin/Members.php index 814c5e5297c..ec2403b47a3 100644 --- a/Sources/Actions/Admin/Members.php +++ b/Sources/Actions/Admin/Members.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\Group; +use SMF\IntegrationHook; use SMF\IP; use SMF\ItemList; use SMF\Lang; @@ -273,7 +274,7 @@ public function view() '++' => '>' ); - call_integration_hook('integrate_view_members_params', array(&$params)); + IntegrationHook::call('integrate_view_members_params', array(&$params)); $search_params = array(); if ($this->subaction == 'query' && !empty($_REQUEST['params']) && empty($_POST['types'])) @@ -1209,7 +1210,7 @@ public function approve() if (!empty(Config::$modSettings['integrate_activate'])) { foreach ($member_info as $member) - call_integration_hook('integrate_activate', array($member['username'])); + IntegrationHook::call('integrate_activate', array($member['username'])); } // Check for email. @@ -1572,7 +1573,7 @@ protected function __construct() } // Call our hook now, letting customizations add to the subActions and/or modify Utils::$context as needed. - call_integration_hook('integrate_manage_members', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_members', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/Mods.php b/Sources/Actions/Admin/Mods.php index ae9fefa41c6..559322314ea 100644 --- a/Sources/Actions/Admin/Mods.php +++ b/Sources/Actions/Admin/Mods.php @@ -17,6 +17,7 @@ use SMF\Actions\ActionInterface; use SMF\Config; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\User; @@ -124,7 +125,7 @@ public function general(): void $save_vars = $config_vars; - call_integration_hook('integrate_save_general_mod_settings', array(&$save_vars)); + IntegrationHook::call('integrate_save_general_mod_settings', array(&$save_vars)); // This line is to help mod authors do a search/add after if you want to add something here. Keyword: FOOT TAPPING SUCKS! ACP::saveDBSettings($save_vars); @@ -179,7 +180,7 @@ public static function getConfigVars(): array ); // MOD AUTHORS: This hook is the right way to add new settings. - call_integration_hook('integrate_general_mod_settings', array(&$config_vars)); + IntegrationHook::call('integrate_general_mod_settings', array(&$config_vars)); return $config_vars; } @@ -225,7 +226,7 @@ protected function __construct() ); // Make it easier for mods to add new areas. - call_integration_hook('integrate_modify_modifications', array(&self::$subactions)); + IntegrationHook::call('integrate_modify_modifications', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/News.php b/Sources/Actions/Admin/News.php index f23bf83298b..96c407b90a4 100644 --- a/Sources/Actions/Admin/News.php +++ b/Sources/Actions/Admin/News.php @@ -20,6 +20,7 @@ use SMF\Config; use SMF\Editor; use SMF\Group; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Logging; @@ -1107,7 +1108,7 @@ public function settings(): void { User::$me->checkSession(); - call_integration_hook('integrate_save_news_settings'); + IntegrationHook::call('integrate_save_news_settings'); self::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -1166,7 +1167,7 @@ public static function getConfigVars(): array array('check', 'xmlnews_attachments', 'subtext' => Lang::$txt['xmlnews_attachments_note']), ); - call_integration_hook('integrate_modify_news_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_news_settings', array(&$config_vars)); return $config_vars; } @@ -1381,7 +1382,7 @@ protected function __construct() ), ); - call_integration_hook('integrate_manage_news', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_news', array(&self::$subactions)); // Default to sub action 'main' or 'settings' depending on permissions. $this->subaction = isset($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : (User::$me->allowedTo('edit_news') ? 'editnews' : (User::$me->allowedTo('send_mail') ? 'mailingmembers' : 'settings')); diff --git a/Sources/Actions/Admin/Permissions.php b/Sources/Actions/Admin/Permissions.php index 6d1b455de64..d2319a07c1d 100644 --- a/Sources/Actions/Admin/Permissions.php +++ b/Sources/Actions/Admin/Permissions.php @@ -21,6 +21,7 @@ use SMF\Config; use SMF\ErrorHandler; use SMF\Group; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\SecurityToken; @@ -1244,7 +1245,7 @@ public function settings(): void { User::$me->checkSession(); - call_integration_hook('integrate_save_permission_settings'); + IntegrationHook::call('integrate_save_permission_settings'); ACP::saveDBSettings($config_vars); @@ -1405,7 +1406,7 @@ public function postmod(): void // Load all the permission profiles. self::loadPermissionProfiles(); - call_integration_hook('integrate_post_moderation_mapping', array(&$this->postmod_maps)); + IntegrationHook::call('integrate_post_moderation_mapping', array(&$this->postmod_maps)); // Start this with the guests/members. Utils::$context['profile_groups'] = array( @@ -1632,7 +1633,7 @@ public static function getConfigVars(): array array('check', 'permission_enable_postgroups', 0, Lang::$txt['permission_settings_enable_postgroups'], 'help' => 'permissions_postgroups'), ); - call_integration_hook('integrate_modify_permission_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_permission_settings', array(&$config_vars)); return $config_vars; } @@ -1650,7 +1651,7 @@ public static function getPermissions(): array if (!empty(self::$processed)) return self::$permissions; - call_integration_hook('integrate_permissions_list', array(&self::$permissions)); + IntegrationHook::call('integrate_permissions_list', array(&self::$permissions)); // In case a mod screwed things up... if (!in_array('html', Utils::$context['restricted_bbc'])) @@ -1816,7 +1817,7 @@ public static function setPermissionLevel($level, $group, $profile = 'null'): vo } } - call_integration_hook('integrate_load_permission_levels', array(&$group_levels, &$board_levels)); + IntegrationHook::call('integrate_load_permission_levels', array(&$group_levels, &$board_levels)); // Make sure we're not granting someone too many permissions! foreach (array('global', 'board') as $scope) @@ -2513,7 +2514,7 @@ protected function __construct() ), ); - call_integration_hook('integrate_manage_permissions', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_permissions', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; @@ -3567,7 +3568,7 @@ protected static function integrateLoadPermissions(): void } // Provide a practical way to modify permissions. - call_integration_hook('integrate_load_permissions', array(&self::$permission_groups, &$permissions_by_scope, &self::$left_permission_groups, &$hidden_permissions, &$relabel_permissions)); + IntegrationHook::call('integrate_load_permissions', array(&self::$permission_groups, &$permissions_by_scope, &self::$left_permission_groups, &$hidden_permissions, &$relabel_permissions)); // If the hook made changes, sync them back to our master list. foreach ($permissions_by_scope as $scope => $permissions) @@ -3645,7 +3646,7 @@ protected static function integrateLoadIllegalPermissions(): void $temp = Utils::jsonEncode(self::$illegal); // Give mods access to this list. - call_integration_hook('integrate_load_illegal_permissions'); + IntegrationHook::call('integrate_load_illegal_permissions'); // If the hook added anything, sync that back to our master list. // Because this hook can't tell us what the prerequistes are, we assume @@ -3688,7 +3689,7 @@ protected static function integrateLoadIllegalGuestPermissions(): void $temp = Utils::jsonEncode(self::$never_guests); // Give mods access to this list. - call_integration_hook('integrate_load_illegal_guest_permissions'); + IntegrationHook::call('integrate_load_illegal_guest_permissions'); // If the hook changed anything, sync that back to our master list. if ($temp != Utils::jsonEncode(self::$never_guests)) diff --git a/Sources/Actions/Admin/Posts.php b/Sources/Actions/Admin/Posts.php index bda1beba24f..7b743e91924 100644 --- a/Sources/Actions/Admin/Posts.php +++ b/Sources/Actions/Admin/Posts.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\Msg; @@ -160,7 +161,7 @@ public function censor(): void 'censorIgnoreCase' => empty($_POST['censorIgnoreCase']) ? '0' : '1', ); - call_integration_hook('integrate_save_censors', array(&$updates)); + IntegrationHook::call('integrate_save_censors', array(&$updates)); Utils::$context['saved_successful'] = true; Config::updateModSettings($updates); @@ -190,7 +191,7 @@ public function censor(): void Utils::$context['censored_words'][Utils::htmlspecialchars(trim($censor_vulgar[$i]))] = isset($censor_proper[$i]) ? Utils::htmlspecialchars($censor_proper[$i]) : ''; } - call_integration_hook('integrate_censors'); + IntegrationHook::call('integrate_censors'); // Since the "Allow users to disable the word censor" stuff was moved from a theme setting to a global one, we need this... Lang::load('Themes'); @@ -240,7 +241,7 @@ public function posts($return_config = false) if (!empty($_POST['preview_characters'])) $_POST['preview_characters'] = (int) min(max(0, $_POST['preview_characters']), 512); - call_integration_hook('integrate_save_post_settings'); + IntegrationHook::call('integrate_save_post_settings'); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -272,7 +273,7 @@ public function topics($return_config = false) if (isset($_GET['save'])) { User::$me->checkSession(); - call_integration_hook('integrate_save_topic_settings'); + IntegrationHook::call('integrate_save_topic_settings'); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -410,7 +411,7 @@ public static function postConfigVars(): array array('int', 'quote_expand', 'subtext' => Lang::$txt['zero_to_disable'], 'postinput' => Lang::$txt['quote_expand_pixels_units']), ); - call_integration_hook('integrate_modify_post_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_post_settings', array(&$config_vars)); return $config_vars; } @@ -455,7 +456,7 @@ public static function topicConfigVars(): array array('check', 'message_index_preview_first', 'subtext' => Lang::$txt['message_index_preview_first_desc']), ); - call_integration_hook('integrate_modify_topic_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_topic_settings', array(&$config_vars)); return $config_vars; } @@ -479,7 +480,7 @@ public static function draftConfigVars(): array array('int', 'drafts_autosave_frequency', 'postinput' => Lang::$txt['manageposts_seconds'], 'subtext' => Lang::$txt['drafts_autosave_frequency_subnote']), ); - call_integration_hook('integrate_modify_draft_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_draft_settings', array(&$config_vars)); return $config_vars; } @@ -568,7 +569,7 @@ protected function __construct() ), ); - call_integration_hook('integrate_manage_posts', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_posts', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/Registration.php b/Sources/Actions/Admin/Registration.php index 9ac61d41f74..bfd704b11a4 100644 --- a/Sources/Actions/Admin/Registration.php +++ b/Sources/Actions/Admin/Registration.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Logging; use SMF\Menu; @@ -451,7 +452,7 @@ public function settings(): void // Post needs to take into account line breaks. $_POST['coppaPost'] = str_replace("\n", '
', empty($_POST['coppaPost']) ? '' : Utils::normalize($_POST['coppaPost'])); - call_integration_hook('integrate_save_registration_settings'); + IntegrationHook::call('integrate_save_registration_settings'); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -538,7 +539,7 @@ public static function getConfigVars(): array array('text', 'coppaPhone'), ); - call_integration_hook('integrate_modify_registration_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_registration_settings', array(&$config_vars)); return $config_vars; } @@ -637,7 +638,7 @@ protected function __construct() ) ); - call_integration_hook('integrate_manage_registrations', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_registrations', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) { diff --git a/Sources/Actions/Admin/RepairBoards.php b/Sources/Actions/Admin/RepairBoards.php index f51f2cfde14..bea7ed4b92f 100644 --- a/Sources/Actions/Admin/RepairBoards.php +++ b/Sources/Actions/Admin/RepairBoards.php @@ -19,6 +19,7 @@ use SMF\Board; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Logging; use SMF\Menu; @@ -943,7 +944,7 @@ protected function findForumErrors(bool $do_fix = false): array $_GET['substep'] = empty($_GET['substep']) ? 0 : (int) $_GET['substep']; // Do mods want to add anything here to allow repairing their data? - call_integration_hook('integrate_repair_boards', array(&$this->errorTests)); + IntegrationHook::call('integrate_repair_boards', array(&$this->errorTests)); // Don't allow the cache to get too full. Utils::$context['db_cache'] = Db::$cache; diff --git a/Sources/Actions/Admin/Reports.php b/Sources/Actions/Admin/Reports.php index 30cc2dbb8f2..87d39fbfbac 100644 --- a/Sources/Actions/Admin/Reports.php +++ b/Sources/Actions/Admin/Reports.php @@ -19,6 +19,7 @@ use SMF\Config; use SMF\ErrorHandler; use SMF\Group; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\Theme; @@ -193,7 +194,7 @@ public function execute(): void ); // Allow mods to add additional buttons here. - call_integration_hook('integrate_report_buttons'); + IntegrationHook::call('integrate_report_buttons'); // Now generate the data. call_helper(method_exists($this, self::$subactions[$this->subaction]) ? array($this, self::$subactions[$this->subaction]) : self::$subactions[$this->subaction]); @@ -490,7 +491,7 @@ public function boardPerms(): void $disabled_permissions[] = 'post_unapproved_attachments'; } - call_integration_hook('integrate_reports_boardperm', array(&$disabled_permissions)); + IntegrationHook::call('integrate_reports_boardperm', array(&$disabled_permissions)); // Cache every permission setting, to make sure we don't miss any allows. $permissions = array(); @@ -771,7 +772,7 @@ public function groupPerms(): void $disabled_permissions[] = 'issue_warning'; } - call_integration_hook('integrate_reports_groupperm', array(&$disabled_permissions)); + IntegrationHook::call('integrate_reports_groupperm', array(&$disabled_permissions)); // Now the big permission fetch! $lastPermission = null; @@ -1074,7 +1075,7 @@ protected function __construct() // For backward compatibility... Utils::$context['report_types'] = &self::$subactions; - call_integration_hook('integrate_report_types', array(&self::$subactions)); + IntegrationHook::call('integrate_report_types', array(&self::$subactions)); // Load up all the tabs... Menu::$loaded['admin']->tab_data = array( diff --git a/Sources/Actions/Admin/Search.php b/Sources/Actions/Admin/Search.php index f55007d72b0..e09a5a7dc25 100644 --- a/Sources/Actions/Admin/Search.php +++ b/Sources/Actions/Admin/Search.php @@ -17,6 +17,7 @@ use SMF\Actions\ActionInterface; use SMF\Config; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\SecurityToken; @@ -130,7 +131,7 @@ public function settings(): void { User::$me->checkSession(); - call_integration_hook('integrate_save_search_settings'); + IntegrationHook::call('integrate_save_search_settings'); if (empty($_POST['search_results_per_page'])) { @@ -172,7 +173,7 @@ public function weights() 'search_weight_sticky', ); - call_integration_hook('integrate_modify_search_weights', array(&$factors)); + IntegrationHook::call('integrate_modify_search_weights', array(&$factors)); // A form was submitted. if (isset($_POST['save'])) @@ -180,7 +181,7 @@ public function weights() User::$me->checkSession(); SecurityToken::validate('admin-msw'); - call_integration_hook('integrate_save_search_weights'); + IntegrationHook::call('integrate_save_search_weights'); $changes = array(); @@ -937,7 +938,7 @@ public static function getConfigVars(): array array('int', 'search_floodcontrol_time', 'subtext' => Lang::$txt['search_floodcontrol_time_desc'], 6, 'postinput' => Lang::$txt['seconds']), ); - call_integration_hook('integrate_modify_search_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_search_settings', array(&$config_vars)); // Perhaps the search method wants to add some settings? $searchAPI = SearchApi::load(); @@ -1023,7 +1024,7 @@ protected function __construct() ), ); - call_integration_hook('integrate_manage_search', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_search', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/SearchEngines.php b/Sources/Actions/Admin/SearchEngines.php index d6c122d5b82..79502f41105 100644 --- a/Sources/Actions/Admin/SearchEngines.php +++ b/Sources/Actions/Admin/SearchEngines.php @@ -17,6 +17,7 @@ use SMF\Actions\ActionInterface; use SMF\Config; +use SMF\IntegrationHook; use SMF\IP; use SMF\ItemList; use SMF\Lang; @@ -663,7 +664,7 @@ public function settings(): void { User::$me->checkSession(); - call_integration_hook('integrate_save_search_engine_settings'); + IntegrationHook::call('integrate_save_search_engine_settings'); ACP::saveDBSettings($config_vars); @@ -849,7 +850,7 @@ function disableFields() } disableFields();'; - call_integration_hook('integrate_modify_search_engine_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_search_engine_settings', array(&$config_vars)); return $config_vars; } @@ -1196,7 +1197,7 @@ protected function __construct() ); } - call_integration_hook('integrate_manage_search_engines', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_search_engines', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/Server.php b/Sources/Actions/Admin/Server.php index 2783df4ae06..fa3ca2a8e9b 100644 --- a/Sources/Actions/Admin/Server.php +++ b/Sources/Actions/Admin/Server.php @@ -20,6 +20,7 @@ use SMF\Config; use SMF\Cookie; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\MessageIndex; @@ -252,7 +253,7 @@ public function general(): void // Saving settings? if (isset($_REQUEST['save'])) { - call_integration_hook('integrate_save_general_settings'); + IntegrationHook::call('integrate_save_general_settings'); foreach ($config_vars as $config_var) { @@ -333,7 +334,7 @@ public function database(): void // Saving settings? if (isset($_REQUEST['save'])) { - call_integration_hook('integrate_save_database_settings'); + IntegrationHook::call('integrate_save_database_settings'); ACP::saveSettings($config_vars); $_SESSION['adm-save'] = true; @@ -376,7 +377,7 @@ function hideGlobalCookies() // Saving settings? if (isset($_REQUEST['save'])) { - call_integration_hook('integrate_save_cookie_settings'); + IntegrationHook::call('integrate_save_cookie_settings'); $_POST['cookiename'] = Utils::normalize($_POST['cookiename']); @@ -484,7 +485,7 @@ public function security(): void ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; - call_integration_hook('integrate_save_general_security_settings'); + IntegrationHook::call('integrate_save_general_security_settings'); User::$me->logOnline(); Utils::redirectexit('action=admin;area=serversettings;sa=security;' . Utils::$context['session_var'] . '=' . Utils::$context['session_id']); @@ -506,7 +507,7 @@ public function cache(): void // Saving again? if (isset($_GET['save'])) { - call_integration_hook('integrate_save_cache_settings'); + IntegrationHook::call('integrate_save_cache_settings'); if (is_callable(array(CacheApi::$loadedApi, 'cleanCache')) && ((int) $_POST['cache_enable'] < CacheApi::$enable || $_POST['cache_accelerator'] != CacheApi::$accelerator)) { @@ -582,7 +583,7 @@ public function export(): void } } - call_integration_hook('integrate_save_export_settings'); + IntegrationHook::call('integrate_save_export_settings'); $_SESSION['adm-save'] = true; Utils::redirectexit('action=admin;area=serversettings;sa=export;' . Utils::$context['session_var'] . '=' . Utils::$context['session_id']); @@ -655,7 +656,7 @@ public function loadBalancing(): void $_POST[$key] = max((float) $value, $min_value); } - call_integration_hook('integrate_save_loadavg_settings'); + IntegrationHook::call('integrate_save_loadavg_settings'); ACP::saveDBSettings($config_vars); @@ -779,7 +780,7 @@ public static function generalConfigVars(): array array('enable_sm_stats', Lang::$txt['enable_sm_stats'], 'db', 'check', null, 'enable_sm_stats'), ); - call_integration_hook('integrate_general_settings', array(&$config_vars)); + IntegrationHook::call('integrate_general_settings', array(&$config_vars)); return $config_vars; } @@ -830,7 +831,7 @@ public static function databaseConfigVars(): array ); } - call_integration_hook('integrate_database_settings', array(&$config_vars)); + IntegrationHook::call('integrate_database_settings', array(&$config_vars)); return $config_vars; } @@ -882,7 +883,7 @@ function ($str) )), 'subtext' => Lang::$txt['tfa_mode_subtext'] . (empty(User::$me->tfa_secret) ? '
' . Lang::$txt['tfa_mode_forced_help'] . '' : ''), 'tfa_mode'), ); - call_integration_hook('integrate_cookie_settings', array(&$config_vars)); + IntegrationHook::call('integrate_cookie_settings', array(&$config_vars)); return $config_vars; } @@ -957,7 +958,7 @@ public static function securityConfigVars(): array array('text', 'proxy_ip_servers'), ); - call_integration_hook('integrate_general_security_settings', array(&$config_vars)); + IntegrationHook::call('integrate_general_security_settings', array(&$config_vars)); return $config_vars; } @@ -1009,7 +1010,7 @@ public static function cacheConfigVars(): array $("#cache_accelerator").change(); });'; - call_integration_hook('integrate_modify_cache_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_cache_settings', array(&$config_vars)); // Maybe we have some additional settings from the selected accelerator. if (!empty($detectedCacheApis)) @@ -1056,7 +1057,7 @@ public static function exportConfigVars(): array array('int', 'export_rate', 'min' => 5, 'max' => 500, 'step' => 5, 'subtext' => Lang::$txt['export_rate_desc']), ); - call_integration_hook('integrate_export_settings', array(&$config_vars)); + IntegrationHook::call('integrate_export_settings', array(&$config_vars)); return $config_vars; } @@ -1082,7 +1083,7 @@ public static function loadBalancingConfigVars(): array $config_vars[] = array('float', $name, 'value' => $value, 'disabled' => self::getLoadAverageDisabled()); } - call_integration_hook('integrate_loadavg_settings', array(&$config_vars)); + IntegrationHook::call('integrate_loadavg_settings', array(&$config_vars)); return $config_vars; } @@ -1430,7 +1431,7 @@ protected function __construct() 'description' => Lang::$txt['admin_basic_settings'], ); - call_integration_hook('integrate_server_settings', array(&self::$subactions)); + IntegrationHook::call('integrate_server_settings', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/Smileys.php b/Sources/Actions/Admin/Smileys.php index 80b4b457be2..dbb6cf9bd22 100644 --- a/Sources/Actions/Admin/Smileys.php +++ b/Sources/Actions/Admin/Smileys.php @@ -21,6 +21,7 @@ use SMF\BBCodeParser; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Logging; @@ -2093,7 +2094,7 @@ public function settings(): void // Validate the smiley set name. $_POST['smiley_sets_default'] = empty(self::$smiley_sets[$_POST['smiley_sets_default']]) ? Config::$modSettings['smiley_sets_default'] : $_POST['smiley_sets_default']; - call_integration_hook('integrate_save_smiley_settings'); + IntegrationHook::call('integrate_save_smiley_settings'); ACP::saveDBSettings($config_vars); $_SESSION['adm-save'] = true; @@ -2168,7 +2169,7 @@ public static function getConfigVars(): array array('check', 'messageIconChecks_enable', 'subtext' => Lang::$txt['setting_messageIconChecks_enable_note']) ); - call_integration_hook('integrate_modify_smiley_settings', array(&$config_vars)); + IntegrationHook::call('integrate_modify_smiley_settings', array(&$config_vars)); return $config_vars; } @@ -2477,7 +2478,7 @@ protected function __construct() Menu::$loaded['admin']->tab_data['tabs']['setorder']['disabled'] = true; } - call_integration_hook('integrate_manage_smileys', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_smileys', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/Subscriptions.php b/Sources/Actions/Admin/Subscriptions.php index 6e9faff013b..da19fda1a5a 100644 --- a/Sources/Actions/Admin/Subscriptions.php +++ b/Sources/Actions/Admin/Subscriptions.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Menu; @@ -600,7 +601,7 @@ public function modify(): void ) ); - call_integration_hook('integrate_delete_subscription', array(Utils::$context['sub_id'])); + IntegrationHook::call('integrate_delete_subscription', array(Utils::$context['sub_id'])); Utils::redirectexit('action=admin;area=paidsubscribe;view'); } @@ -750,7 +751,7 @@ public function modify(): void ); } - call_integration_hook('integrate_save_subscription', array((Utils::$context['action_type'] == 'add' ? $id_subscribe : Utils::$context['sub_id']), $_POST['name'], $_POST['desc'], $isActive, $span, $cost, $_POST['prim_group'], $addgroups, $isRepeatable, $allowpartial, $emailComplete, $reminder)); + IntegrationHook::call('integrate_save_subscription', array((Utils::$context['action_type'] == 'add' ? $id_subscribe : Utils::$context['sub_id']), $_POST['name'], $_POST['desc'], $isActive, $span, $cost, $_POST['prim_group'], $addgroups, $isRepeatable, $allowpartial, $emailComplete, $reminder)); Utils::redirectexit('action=admin;area=paidsubscribe;view'); } @@ -1481,7 +1482,7 @@ public static function getConfigVars(): array ); } - call_integration_hook('integrate_paidsubs_settings', array(&$config_vars)); + IntegrationHook::call('integrate_paidsubs_settings', array(&$config_vars)); return $config_vars; } @@ -2354,7 +2355,7 @@ protected function __construct() ); } - call_integration_hook('integrate_manage_subscriptions', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_subscriptions', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/Tasks.php b/Sources/Actions/Admin/Tasks.php index a233de099fa..00cb95c9096 100644 --- a/Sources/Actions/Admin/Tasks.php +++ b/Sources/Actions/Admin/Tasks.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Menu; @@ -513,7 +514,7 @@ public function settings(): void $save_vars = $config_vars; - call_integration_hook('integrate_save_scheduled_tasks_settings', array(&$save_vars)); + IntegrationHook::call('integrate_save_scheduled_tasks_settings', array(&$save_vars)); ACP::saveDBSettings($save_vars); @@ -563,7 +564,7 @@ public static function getConfigVars(): array array('check', 'cron_is_real_cron', 'subtext' => Lang::$txt['cron_is_real_cron_desc'], 'help' => 'cron_is_real_cron'), ); - call_integration_hook('integrate_scheduled_tasks_settings', array(&$config_vars)); + IntegrationHook::call('integrate_scheduled_tasks_settings', array(&$config_vars)); return $config_vars; } @@ -749,7 +750,7 @@ protected function __construct() ); } - call_integration_hook('integrate_manage_scheduled_tasks', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_scheduled_tasks', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Admin/Themes.php b/Sources/Actions/Admin/Themes.php index fd199dc172c..0bb3daf849d 100644 --- a/Sources/Actions/Admin/Themes.php +++ b/Sources/Actions/Admin/Themes.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\SecurityToken; @@ -603,7 +604,7 @@ public function setOptions() Theme::loadSubTemplate('options'); // Let mods hook into the theme options. - call_integration_hook('integrate_theme_options'); + IntegrationHook::call('integrate_theme_options'); Utils::$context['sub_template'] = 'set_options'; Utils::$context['page_title'] = Lang::$txt['theme_settings']; @@ -746,7 +747,7 @@ public function setSettings() } // Let mods hook into the theme settings. - call_integration_hook('integrate_theme_settings'); + IntegrationHook::call('integrate_theme_settings'); // Submitting! if (isset($_POST['save'])) @@ -1562,7 +1563,7 @@ protected function __construct() } // CRUD self::$subactions as needed. - call_integration_hook('integrate_manage_themes', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_themes', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; @@ -1823,7 +1824,7 @@ protected function getSingleTheme($id, array $variables = array()) $id = (int) $id; // Make changes if you really want it. - call_integration_hook('integrate_get_single_theme', array(&$variables, $id)); + IntegrationHook::call('integrate_get_single_theme', array(&$variables, $id)); $single = array( 'id' => $id, @@ -1895,7 +1896,7 @@ protected function getAllThemes($enable_only = false) ); // Make changes if you really want it. - call_integration_hook('integrate_get_all_themes', array(&$themeValues, $enable_only)); + IntegrationHook::call('integrate_get_all_themes', array(&$themeValues, $enable_only)); // So, what is it going to be? $query_where = $enable_only ? $enableThemes : $knownThemes; @@ -1964,7 +1965,7 @@ protected function getInstalledThemes() ); // Make changes if you really want it. - call_integration_hook('integrate_get_installed_themes', array(&$themeValues)); + IntegrationHook::call('integrate_get_installed_themes', array(&$themeValues)); // Perform the query as requested. $request = Db::$db->query('', ' @@ -2225,7 +2226,7 @@ protected function addToDb($to_install = array()) $id_theme++; // Last minute changes? although, the actual array is a context value you might want to use the new ID. - call_integration_hook('integrate_theme_install', array(&Utils::$context['to_install'], $id_theme)); + IntegrationHook::call('integrate_theme_install', array(&Utils::$context['to_install'], $id_theme)); $inserts = array(); diff --git a/Sources/Actions/Admin/Warnings.php b/Sources/Actions/Admin/Warnings.php index 3d8e333d3d9..a8f039d83a6 100644 --- a/Sources/Actions/Admin/Warnings.php +++ b/Sources/Actions/Admin/Warnings.php @@ -17,6 +17,7 @@ use SMF\Actions\ActionInterface; use SMF\Config; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\User; @@ -118,7 +119,7 @@ public function execute(): void $save_vars[] = array('text', 'warning_settings'); unset($save_vars['enable'], $save_vars['rem1'], $save_vars['rem2']); - call_integration_hook('integrate_save_warning_settings', array(&$save_vars)); + IntegrationHook::call('integrate_save_warning_settings', array(&$save_vars)); ACP::saveDBSettings($save_vars); $_SESSION['adm-save'] = true; @@ -219,7 +220,7 @@ public static function getConfigVars(): array ); } - call_integration_hook('integrate_warning_settings', array(&$config_vars)); + IntegrationHook::call('integrate_warning_settings', array(&$config_vars)); return $config_vars; } diff --git a/Sources/Actions/AttachmentDownload.php b/Sources/Actions/AttachmentDownload.php index 6ea68d1615a..eccc0917136 100644 --- a/Sources/Actions/AttachmentDownload.php +++ b/Sources/Actions/AttachmentDownload.php @@ -18,6 +18,7 @@ use SMF\Attachment; use SMF\BrowserDetector; use SMF\Config; +use SMF\IntegrationHook; use SMF\Lang; use SMF\User; use SMF\Utils; @@ -88,7 +89,7 @@ class AttachmentDownload implements ActionInterface public function execute(): void { // An early hook to set up global vars, clean cache and other early process. - call_integration_hook('integrate_pre_download_request'); + IntegrationHook::call('integrate_pre_download_request'); // This is done to clear any output that was made before now. ob_end_clean(); @@ -128,7 +129,7 @@ public function execute(): void * SMF\Attachment::load() method. */ $request = null; - call_integration_hook('integrate_download_request', array(&$request)); + IntegrationHook::call('integrate_download_request', array(&$request)); if (!is_null($request) && Db::$db->is_resource($request)) { // No attachment has been found. diff --git a/Sources/Actions/AttachmentUpload.php b/Sources/Actions/AttachmentUpload.php index 3f47adbaff0..099fdae5442 100644 --- a/Sources/Actions/AttachmentUpload.php +++ b/Sources/Actions/AttachmentUpload.php @@ -16,6 +16,7 @@ use SMF\Attachment; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\User; use SMF\Utils; @@ -426,7 +427,7 @@ protected function processAttachments(): void // id_folder => Config::$modSettings['currentAttachmentUploadDir'] // errors => An array of errors (use the index of the Lang::$txt variable for that error). // Template changes can be done using "integrate_upload_template". - call_integration_hook('integrate_attachment_upload', array()); + IntegrationHook::call('integrate_attachment_upload', array()); } /** diff --git a/Sources/Actions/AutoSuggest.php b/Sources/Actions/AutoSuggest.php index de45e1c6bca..3c591ebefda 100644 --- a/Sources/Actions/AutoSuggest.php +++ b/Sources/Actions/AutoSuggest.php @@ -15,6 +15,7 @@ use SMF\BackwardCompatibility; +use SMF\IntegrationHook; use SMF\Theme; use SMF\User; use SMF\Utils; @@ -321,7 +322,7 @@ public static function call(): void */ public static function checkRegistered(string $suggest_type): bool { - call_integration_hook('integrate_autosuggest', array(&$suggest_types)); + IntegrationHook::call('integrate_autosuggest', array(&$suggest_types)); return isset(self::$suggest_types[$suggest_type]) && (method_exists(__CLASS__, $suggest_type) || function_exists('AutoSuggest_Search_' . self::$suggest_types[$this->suggest_type]) || function_exists('AutoSuggest_Search_' . $suggest_type)); } @@ -379,7 +380,7 @@ public static function AutoSuggest_Search_SMFVersions(): void */ protected function __construct() { - call_integration_hook('integrate_autosuggest', array(&self::$suggest_types)); + IntegrationHook::call('integrate_autosuggest', array(&self::$suggest_types)); if (!empty($_REQUEST['suggest_type']) && isset(self::$suggest_types[$_REQUEST['suggest_type']])) $this->suggest_type = $_REQUEST['suggest_type']; diff --git a/Sources/Actions/BoardIndex.php b/Sources/Actions/BoardIndex.php index 0bd885d55d2..d2a52c93f63 100644 --- a/Sources/Actions/BoardIndex.php +++ b/Sources/Actions/BoardIndex.php @@ -19,6 +19,7 @@ use SMF\Category; use SMF\Config; use SMF\Group; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Logging; use SMF\Msg; @@ -170,7 +171,7 @@ public function execute(): void ); // Allow mods to add additional buttons here - call_integration_hook('integrate_mark_read_button'); + IntegrationHook::call('integrate_mark_read_button'); } /** @@ -407,7 +408,7 @@ public static function get($board_index_options): array } // Give mods access to the query. - call_integration_hook('integrate_pre_boardindex', array(&$selects, &$params, &$joins, &$where, &$order)); + IntegrationHook::call('integrate_pre_boardindex', array(&$selects, &$params, &$joins, &$where, &$order)); // Start with empty arrays. $boards = array(); @@ -497,7 +498,7 @@ public static function get($board_index_options): array if (!isset($parent) || $parent->id == $board_index_options['parent_id']) { // @todo Should this be called for every board, not just parent boards? - call_integration_hook('integrate_boardindex_board', array(&$cat_boards, $row_board)); + IntegrationHook::call('integrate_boardindex_board', array(&$cat_boards, $row_board)); // Add parent boards to the $boards list later used to fetch moderators. $boards[] = $row_board['id_board']; @@ -646,11 +647,11 @@ public static function get($board_index_options): array // I can't remember why but trying to make a ternary to get this all in one line is actually a Very Bad Idea. if ($board_index_options['include_categories']) { - call_integration_hook('integrate_getboardtree', array($board_index_options, &Category::$loaded)); + IntegrationHook::call('integrate_getboardtree', array($board_index_options, &Category::$loaded)); } else { - call_integration_hook('integrate_getboardtree', array($board_index_options, &$cat_boards)); + IntegrationHook::call('integrate_getboardtree', array($board_index_options, &$cat_boards)); } return $board_index_options['include_categories'] ? Category::$loaded : $cat_boards; @@ -814,7 +815,7 @@ protected static function prepareLastPost($row_board): array )); } - call_integration_hook('integrate_boardindex_last_post', array(&$last_post, $row_board)); + IntegrationHook::call('integrate_boardindex_last_post', array(&$last_post, $row_board)); return $last_post; } diff --git a/Sources/Actions/Calendar.php b/Sources/Actions/Calendar.php index 75b716943bb..cd19507c6a7 100644 --- a/Sources/Actions/Calendar.php +++ b/Sources/Actions/Calendar.php @@ -20,6 +20,7 @@ use SMF\Config; use SMF\ErrorHandler; use SMF\Event; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Theme; use SMF\Time; @@ -331,7 +332,7 @@ public function show(): void Utils::$context['calendar_buttons']['post_event'] = array('text' => 'calendar_post_event', 'image' => 'calendarpe.png', 'url' => Config::$scripturl . '?action=calendar;sa=post;month=' . Utils::$context['current_month'] . ';year=' . Utils::$context['current_year'] . ';' . Utils::$context['session_var'] . '=' . Utils::$context['session_id']); // Allow mods to add additional buttons here - call_integration_hook('integrate_calendar_buttons'); + IntegrationHook::call('integrate_calendar_buttons'); } /** diff --git a/Sources/Actions/Credits.php b/Sources/Actions/Credits.php index 78a4dc5d0d1..59eb690dea3 100644 --- a/Sources/Actions/Credits.php +++ b/Sources/Actions/Credits.php @@ -16,6 +16,7 @@ use SMF\BackwardCompatibility; use SMF\Config; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\Theme; @@ -414,7 +415,7 @@ public function execute(): void ); // Support for those that want to use a hook as well - call_integration_hook('integrate_credits'); + IntegrationHook::call('integrate_credits'); if (!$this->in_admin) { diff --git a/Sources/Actions/Display.php b/Sources/Actions/Display.php index 513dd541fa6..be59159e640 100644 --- a/Sources/Actions/Display.php +++ b/Sources/Actions/Display.php @@ -22,6 +22,7 @@ use SMF\Editor; use SMF\ErrorHandler; use SMF\Event; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Msg; use SMF\PageIndex; @@ -285,7 +286,7 @@ public function prepareDisplayContext() else $counter--; - call_integration_hook('integrate_prepare_display_context', array(&$output, $message, $counter)); + IntegrationHook::call('integrate_prepare_display_context', array(&$output, $message, $counter)); return $output; } @@ -1162,7 +1163,7 @@ protected function getMessagesAndPosters(): void Db::$db->free_result($request); $this->posters = array_unique($all_posters); - call_integration_hook('integrate_display_message_list', array(&$this->messages, &$this->posters)); + IntegrationHook::call('integrate_display_message_list', array(&$this->messages, &$this->posters)); } /** @@ -1367,9 +1368,9 @@ protected function buildButtons(): void // Allow adding new buttons easily. // Note: Utils::$context['normal_buttons'] and Utils::$context['mod_buttons'] are added for backward compatibility with 2.0, but are deprecated and should not be used - call_integration_hook('integrate_display_buttons', array(&Utils::$context['normal_buttons'])); + IntegrationHook::call('integrate_display_buttons', array(&Utils::$context['normal_buttons'])); // Note: integrate_mod_buttons is no longer necessary and deprecated, but is kept for backward compatibility with 2.0 - call_integration_hook('integrate_mod_buttons', array(&Utils::$context['mod_buttons'])); + IntegrationHook::call('integrate_mod_buttons', array(&Utils::$context['mod_buttons'])); // If any buttons have a 'test' check, run those tests now to keep things clean. foreach (array('normal_buttons', 'mod_buttons') as $button_strip) diff --git a/Sources/Actions/Feed.php b/Sources/Actions/Feed.php index 15304f9a943..09ac8190382 100644 --- a/Sources/Actions/Feed.php +++ b/Sources/Actions/Feed.php @@ -21,6 +21,7 @@ use SMF\Board; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\IP; use SMF\Lang; use SMF\Theme; @@ -284,7 +285,7 @@ public function __construct(string $subaction = null, int $member = null) $this->host = Url::create(Config::$scripturl)->host; // Easy adding of sub actions - call_integration_hook('integrate_xmlfeeds', array(&self::$subactions)); + IntegrationHook::call('integrate_xmlfeeds', array(&self::$subactions)); // These things are simple to set. $this->setSubaction($subaction); @@ -2826,7 +2827,7 @@ public static function build(string $format, array $data, array $metadata, strin // If mods want to do something with this feed, let them do that now. // Provide the feed's data, metadata, namespaces, extra feed-level tags, keys that need special handling, the feed format, and the requested subaction. - call_integration_hook('integrate_xml_data', array(&$data, &$metadata, &$namespaces, &$extraFeedTags, &$forceCdataKeys, &$nsKeys, $format, $subaction, &$doctype)); + IntegrationHook::call('integrate_xml_data', array(&$data, &$metadata, &$namespaces, &$extraFeedTags, &$forceCdataKeys, &$nsKeys, $format, $subaction, &$doctype)); // These can't be empty. foreach (array('title', 'desc', 'source', 'self') as $mkey) @@ -3252,7 +3253,7 @@ protected static function fixPossibleUrl($val) if (substr($val, 0, strlen(Config::$scripturl)) != Config::$scripturl) return $val; - call_integration_hook('integrate_fix_url', array(&$val)); + IntegrationHook::call('integrate_fix_url', array(&$val)); if ( empty(Config::$modSettings['queryless_urls']) diff --git a/Sources/Actions/Groups.php b/Sources/Actions/Groups.php index 31fe22b3b09..9dde12ece6c 100644 --- a/Sources/Actions/Groups.php +++ b/Sources/Actions/Groups.php @@ -19,6 +19,7 @@ use SMF\Config; use SMF\ErrorHandler; use SMF\Group; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Logging; @@ -1005,7 +1006,7 @@ public static function GroupRequests(): void */ protected function __construct() { - call_integration_hook('integrate_manage_groups', array(&self::$subactions)); + IntegrationHook::call('integrate_manage_groups', array(&self::$subactions)); if (!empty($_GET['sa']) && isset(self::$subactions[$_GET['sa']])) $this->subaction = $_GET['sa']; diff --git a/Sources/Actions/Help.php b/Sources/Actions/Help.php index 878efafd8b9..dea48478845 100644 --- a/Sources/Actions/Help.php +++ b/Sources/Actions/Help.php @@ -16,6 +16,7 @@ use SMF\BackwardCompatibility; use SMF\Config; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Theme; use SMF\Utils; @@ -178,7 +179,7 @@ protected function __construct() Lang::load('Manual'); // CRUD $subactions as needed. - call_integration_hook('integrate_manage_help', array(&$subactions)); + IntegrationHook::call('integrate_manage_help', array(&$subactions)); if (!empty($_GET['sa']) && isset(self::$subactions[$_GET['sa']])) $this->subaction = $_GET['sa']; diff --git a/Sources/Actions/HelpAdmin.php b/Sources/Actions/HelpAdmin.php index 12f7aaeef0b..a73af97a819 100644 --- a/Sources/Actions/HelpAdmin.php +++ b/Sources/Actions/HelpAdmin.php @@ -17,6 +17,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Theme; use SMF\User; @@ -83,7 +84,7 @@ public function execute(): void Theme::loadTemplate('Help'); // Allow mods to load their own language file here - call_integration_hook('integrate_helpadmin'); + IntegrationHook::call('integrate_helpadmin'); // What help string should be used? if (isset(Lang::$helptxt[$_GET['help']])) diff --git a/Sources/Actions/JavaScriptModify.php b/Sources/Actions/JavaScriptModify.php index 57d71509d43..0501a57293d 100644 --- a/Sources/Actions/JavaScriptModify.php +++ b/Sources/Actions/JavaScriptModify.php @@ -19,6 +19,7 @@ use SMF\Board; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Logging; use SMF\Msg; @@ -176,7 +177,7 @@ public function execute(): void } } - call_integration_hook('integrate_post_JavascriptModify', array(&$post_errors, $row)); + IntegrationHook::call('integrate_post_JavascriptModify', array(&$post_errors, $row)); if (isset($_POST['lock'])) { @@ -368,7 +369,7 @@ public function execute(): void } // Allow mods to do something with Utils::$context before we return. - call_integration_hook('integrate_jsmodify_xml'); + IntegrationHook::call('integrate_jsmodify_xml'); } else { diff --git a/Sources/Actions/Like.php b/Sources/Actions/Like.php index 7a70635a6b7..74fd05dfeac 100644 --- a/Sources/Actions/Like.php +++ b/Sources/Actions/Like.php @@ -15,6 +15,7 @@ use SMF\Alert; use SMF\Config; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Theme; use SMF\Time; @@ -387,7 +388,7 @@ protected function check(): void * * See also issueLike() for further notes. */ - $can_like = call_integration_hook('integrate_valid_likes', array($this->type, $this->content, $this->subaction, $this->js, $this->extra)); + $can_like = IntegrationHook::call('integrate_valid_likes', array($this->type, $this->content, $this->subaction, $this->js, $this->extra)); $found = false; @@ -487,7 +488,7 @@ protected function insert(): void $user = (array) User::$me; $time = time(); - call_integration_hook('integrate_issue_like_before', array(&$type, &$content, &$user, &$time)); + IntegrationHook::call('integrate_issue_like_before', array(&$type, &$content, &$user, &$time)); // Insert the like. Db::$db->insert('insert', @@ -634,7 +635,7 @@ protected function like(): void } // Sometimes there might be other things that need updating after we do this like. - call_integration_hook('integrate_issue_like', array($this)); + IntegrationHook::call('integrate_issue_like', array($this)); // Now some clean up. This is provided here for any like handlers that // want to do any cache flushing. @@ -817,7 +818,7 @@ protected function sendJsonReponse(): void } // Do you want to add something at the very last minute? - call_integration_hook('integrate_likes_json_response', array(&$print)); + IntegrationHook::call('integrate_likes_json_response', array(&$print)); // Print the data. Utils::serverResponse(Utils::jsonEncode($print)); diff --git a/Sources/Actions/Login2.php b/Sources/Actions/Login2.php index 0558512c0d1..8b2336f6bee 100644 --- a/Sources/Actions/Login2.php +++ b/Sources/Actions/Login2.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\Cookie; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Security; use SMF\SecurityToken; @@ -286,7 +287,7 @@ public function main(): void return; // Are we using any sort of integration to validate the login? - if (in_array('retry', call_integration_hook('integrate_validate_login', array($_POST['user'], isset($_POST['passwrd']) ? $_POST['passwrd'] : null, Config::$modSettings['cookieTime'])), true)) + if (in_array('retry', IntegrationHook::call('integrate_validate_login', array($_POST['user'], isset($_POST['passwrd']) ? $_POST['passwrd'] : null, Config::$modSettings['cookieTime'])), true)) { Utils::$context['login_errors'] = array(Lang::$txt['incorrect_password']); return; @@ -634,7 +635,7 @@ protected function checkPasswordFallbacks(): bool } // Allows mods to easily extend the $other_passwords array - call_integration_hook('integrate_other_passwords', array(&$other_passwords)); + IntegrationHook::call('integrate_other_passwords', array(&$other_passwords)); // Whichever encryption it was using, let's make it use SMF's now ;). if (in_array(User::$profiles[User::$my_id]['passwd'], $other_passwords)) @@ -787,7 +788,7 @@ protected function checkActivation() protected function DoLogin() { // Call login integration functions. - call_integration_hook('integrate_login', array(User::$profiles[User::$my_id]['member_name'], null, Config::$modSettings['cookieTime'])); + IntegrationHook::call('integrate_login', array(User::$profiles[User::$my_id]['member_name'], null, Config::$modSettings['cookieTime'])); // Get ready to set the cookie... User::setMe(User::$my_id); diff --git a/Sources/Actions/Logout.php b/Sources/Actions/Logout.php index af906a2e297..a504c237274 100644 --- a/Sources/Actions/Logout.php +++ b/Sources/Actions/Logout.php @@ -17,6 +17,7 @@ use SMF\Config; use SMF\Cookie; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Theme; use SMF\User; @@ -116,7 +117,7 @@ public function execute(bool $internal = false, bool $redirect = true): void if (!User::$me->is_guest) { // Pass the logout information to integrations. - call_integration_hook('integrate_logout', array(User::$me->username)); + IntegrationHook::call('integrate_logout', array(User::$me->username)); // If you log out, you aren't online anymore :P. Db::$db->query('', ' diff --git a/Sources/Actions/Memberlist.php b/Sources/Actions/Memberlist.php index ab9fcf9e718..dc76102d745 100644 --- a/Sources/Actions/Memberlist.php +++ b/Sources/Actions/Memberlist.php @@ -18,6 +18,7 @@ use SMF\BBCodeParser; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\PageIndex; use SMF\Theme; @@ -231,7 +232,7 @@ public function execute(): void ); // Allow mods to add additional buttons here - call_integration_hook('integrate_memberlist_buttons'); + IntegrationHook::call('integrate_memberlist_buttons'); call_helper(method_exists($this, self::$subactions[$this->subaction]) ? array($this, self::$subactions[$this->subaction]) : self::$subactions[$this->subaction]); } @@ -862,7 +863,7 @@ public static function getCustFields() protected function __construct() { // Allow mods to add sub-actions and sort_links. - call_integration_hook('integrate_memberlist_subactions', array(&self::$subactions, $this->sort_links)); + IntegrationHook::call('integrate_memberlist_subactions', array(&self::$subactions, $this->sort_links)); if (!empty($_GET['sa']) && isset(self::$subactions[$_GET['sa']])) $this->subaction = $_GET['sa']; diff --git a/Sources/Actions/MessageIndex.php b/Sources/Actions/MessageIndex.php index ccd8552149c..1dbeb4bffd3 100644 --- a/Sources/Actions/MessageIndex.php +++ b/Sources/Actions/MessageIndex.php @@ -20,6 +20,7 @@ use SMF\Category; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\PageIndex; use SMF\Theme; @@ -529,7 +530,7 @@ protected function setSortMethod(): void } // Bring in any changes we want to make before the query. - call_integration_hook('integrate_pre_messageindex', array(&$sort_columns, &$sort_joins, &$sort_asc_defaults, &$this->sort_default)); + IntegrationHook::call('integrate_pre_messageindex', array(&$sort_columns, &$sort_joins, &$sort_asc_defaults, &$this->sort_default)); // Default to sorting by last post descending. $this->sort_by = !isset($_REQUEST['sort']) || !isset($this->sort_methods[$_REQUEST['sort']]) ? $this->sort_default : $_REQUEST['sort']; @@ -642,7 +643,7 @@ protected function buildTopicList(): void $main_where = array(); $sort_where = array(); - call_integration_hook('integrate_message_index', array(&$selects, &$joins, &$params, &$main_where, &$topic_ids, &$sort_where)); + IntegrationHook::call('integrate_message_index', array(&$selects, &$joins, &$params, &$main_where, &$topic_ids, &$sort_where)); if (!empty(Config::$modSettings['enableParticipation']) && !User::$me->is_guest) $enableParticipation = true; @@ -1093,7 +1094,7 @@ protected function buildButtons(): void // Allow adding new buttons easily. // Note: Utils::$context['normal_buttons'] is added for backward compatibility with 2.0, but is deprecated and should not be used - call_integration_hook('integrate_messageindex_buttons', array(&Utils::$context['normal_buttons'])); + IntegrationHook::call('integrate_messageindex_buttons', array(&Utils::$context['normal_buttons'])); } } diff --git a/Sources/Actions/Moderation/Home.php b/Sources/Actions/Moderation/Home.php index d4e64172b6e..7bde28e96bf 100644 --- a/Sources/Actions/Moderation/Home.php +++ b/Sources/Actions/Moderation/Home.php @@ -19,6 +19,7 @@ use SMF\BBCodeParser; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\PageIndex; use SMF\SecurityToken; @@ -114,7 +115,7 @@ public function execute(): void // Handle moderators' notes. $this->notes(); - call_integration_hook('integrate_moderation_home_blocks', array(&$this->blocks)); + IntegrationHook::call('integrate_moderation_home_blocks', array(&$this->blocks)); foreach ($this->blocks as $k => $block) { @@ -571,7 +572,7 @@ protected static function integrateModBlocks() { $valid_blocks = array(); - call_integration_hook('integrate_mod_centre_blocks', array(&$valid_blocks)); + IntegrationHook::call('integrate_mod_centre_blocks', array(&$valid_blocks)); if (empty($valid_blocks)) return; diff --git a/Sources/Actions/Moderation/Logs.php b/Sources/Actions/Moderation/Logs.php index 872c7549103..24535be9850 100644 --- a/Sources/Actions/Moderation/Logs.php +++ b/Sources/Actions/Moderation/Logs.php @@ -17,6 +17,7 @@ use SMF\Actions\ActionInterface; use SMF\Config; +use SMF\IntegrationHook; use SMF\IP; use SMF\ItemList; use SMF\Lang; @@ -960,7 +961,7 @@ protected function createList(): void // Overriding this with a hook? $moderation_menu_name = array(); - call_integration_hook('integrate_viewModLog', array(&$listOptions, &$moderation_menu_name)); + IntegrationHook::call('integrate_viewModLog', array(&$listOptions, &$moderation_menu_name)); SecurityToken::create('mod-ml'); diff --git a/Sources/Actions/Moderation/Posts.php b/Sources/Actions/Moderation/Posts.php index 3248618bf58..9038e3915a3 100644 --- a/Sources/Actions/Moderation/Posts.php +++ b/Sources/Actions/Moderation/Posts.php @@ -20,6 +20,7 @@ use SMF\BBCodeParser; use SMF\Board; use SMF\Config; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Logging; @@ -964,7 +965,7 @@ protected function __construct() Lang::load('ModerationCenter'); Theme::loadTemplate('ModerationCenter'); - call_integration_hook('integrate_post_moderation', array(&self::$subactions)); + IntegrationHook::call('integrate_post_moderation', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Moderation/ReportedContent.php b/Sources/Actions/Moderation/ReportedContent.php index 242122c2929..76e120f9e9e 100644 --- a/Sources/Actions/Moderation/ReportedContent.php +++ b/Sources/Actions/Moderation/ReportedContent.php @@ -20,6 +20,7 @@ use SMF\BBCodeParser; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\IP; use SMF\ItemList; use SMF\Lang; @@ -746,7 +747,7 @@ protected function __construct() User::$me->isAllowedTo('moderate_forum'); // Go ahead and add your own sub-actions. - call_integration_hook('integrate_reported_' . $this->type, array(&self::$subactions)); + IntegrationHook::call('integrate_reported_' . $this->type, array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/Moderation/Warnings.php b/Sources/Actions/Moderation/Warnings.php index aaf4aad9321..e50327d1c6a 100644 --- a/Sources/Actions/Moderation/Warnings.php +++ b/Sources/Actions/Moderation/Warnings.php @@ -17,6 +17,7 @@ use SMF\Actions\ActionInterface; use SMF\Config; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Logging; @@ -786,7 +787,7 @@ public static function ModifyWarningTemplate(): void */ protected function __construct() { - call_integration_hook('integrate_warning_log_actions', array(&self::$subactions)); + IntegrationHook::call('integrate_warning_log_actions', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Actions/PersonalMessage.php b/Sources/Actions/PersonalMessage.php index 62bd9a2aef7..e28d132becd 100644 --- a/Sources/Actions/PersonalMessage.php +++ b/Sources/Actions/PersonalMessage.php @@ -19,6 +19,7 @@ use SMF\BrowserDetector; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\Msg; @@ -1004,7 +1005,7 @@ function(&$value, $key) $this->pm_areas['folders']['areas']['drafts']['enabled'] = !empty(Config::$modSettings['drafts_pm_enabled']); // Give mods access to the menu. - call_integration_hook('integrate_pm_areas', array(&$this->pm_areas)); + IntegrationHook::call('integrate_pm_areas', array(&$this->pm_areas)); // Handle labels. if (empty(Label::$loaded)) diff --git a/Sources/Actions/Post.php b/Sources/Actions/Post.php index 9d837c85dec..b8286cb017e 100644 --- a/Sources/Actions/Post.php +++ b/Sources/Actions/Post.php @@ -20,10 +20,11 @@ use SMF\BBCodeParser; use SMF\Board; use SMF\Config; +use SMF\Draft; use SMF\Editor; use SMF\ErrorHandler; use SMF\Event; -use SMF\Draft; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Msg; use SMF\Poll; @@ -223,7 +224,7 @@ public function execute(): void $this->loadTopic(); // Allow mods to add new sub-actions. - call_integration_hook('integrate_post_subactions', array(&self::$subactions)); + IntegrationHook::call('integrate_post_subactions', array(&self::$subactions)); call_helper(method_exists($this, self::$subactions[$this->subaction]) ? array($this, self::$subactions[$this->subaction]) : self::$subactions[$this->subaction]); } @@ -255,7 +256,7 @@ public function show(): void Utils::$context['make_event'] = isset($_REQUEST['calendar']); Utils::$context['robot_no_index'] = true; - call_integration_hook('integrate_post_start'); + IntegrationHook::call('integrate_post_start'); // Where are we posting this (or where might we)? $this->setBoards(); @@ -390,7 +391,7 @@ public function show(): void if (!isset($_REQUEST['xml'])) Theme::loadTemplate('Post'); - call_integration_hook('integrate_post_end'); + IntegrationHook::call('integrate_post_end'); } /*********************** @@ -495,7 +496,7 @@ protected function getTopicSummary(): void $row['body'] = BBCodeParser::load()->parse($row['body'], $row['smileys_enabled'], $row['id_msg']); - call_integration_hook('integrate_getTopic_previous_post', array(&$row)); + IntegrationHook::call('integrate_getTopic_previous_post', array(&$row)); // ...and store. Utils::$context['previous_posts'][] = array( @@ -1016,7 +1017,7 @@ protected function showPreview(): void Utils::$context['preview_subject'] = '' . Lang::$txt['no_subject'] . ''; } - call_integration_hook('integrate_preview_post', array(&$this->form_message, &$this->form_subject)); + IntegrationHook::call('integrate_preview_post', array(&$this->form_message, &$this->form_subject)); // Protect any CDATA blocks. if (isset($_REQUEST['xml'])) @@ -1690,7 +1691,7 @@ protected function showVerification(): void */ protected function checkForErrors(): void { - call_integration_hook('integrate_post_errors', array(&$this->errors, &$this->minor_errors, $this->form_message, $this->form_subject)); + IntegrationHook::call('integrate_post_errors', array(&$this->errors, &$this->minor_errors, $this->form_message, $this->form_subject)); if (empty($this->errors)) return; diff --git a/Sources/Actions/Post2.php b/Sources/Actions/Post2.php index af78366b898..7de31ef9ee5 100644 --- a/Sources/Actions/Post2.php +++ b/Sources/Actions/Post2.php @@ -23,6 +23,7 @@ use SMF\Draft; use SMF\ErrorHandler; use SMF\Event; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Logging; use SMF\MessageIndex; @@ -139,7 +140,7 @@ public function execute(): void $this->loadTopic(); // Allow mods to add new sub-actions. - call_integration_hook('integrate_post2_subactions', array(&self::$subactions)); + IntegrationHook::call('integrate_post2_subactions', array(&self::$subactions)); call_helper(method_exists($this, self::$subactions[$this->subaction]) ? array($this, self::$subactions[$this->subaction]) : self::$subactions[$this->subaction]); } @@ -189,7 +190,7 @@ public function submit(): void Lang::load('Post'); - call_integration_hook('integrate_post2_start', array(&$this->errors)); + IntegrationHook::call('integrate_post2_start', array(&$this->errors)); $this->submitAttachments(); @@ -339,7 +340,7 @@ public function submit(): void $_POST['email'] = User::$me->email; } - call_integration_hook('integrate_post2_pre', array(&$this->errors)); + IntegrationHook::call('integrate_post2_pre', array(&$this->errors)); // Any mistakes? if (!empty($this->errors)) @@ -686,7 +687,7 @@ public function submit(): void if (Board::$info->num_topics == 0) CacheApi::put('board-' . Board::$info->id, null, 120); - call_integration_hook('integrate_post2_end'); + IntegrationHook::call('integrate_post2_end'); if (!empty($_POST['announce_topic']) && User::$me->allowedTo('announce_topic')) { diff --git a/Sources/Actions/Profile/Activate.php b/Sources/Actions/Profile/Activate.php index b24736ade42..5218d44a683 100644 --- a/Sources/Actions/Profile/Activate.php +++ b/Sources/Actions/Profile/Activate.php @@ -17,6 +17,7 @@ use SMF\Actions\ActionInterface; use SMF\Config; +use SMF\IntegrationHook; use SMF\Logging; use SMF\Profile; use SMF\User; @@ -78,7 +79,7 @@ public function execute(): void $prev_is_activated = Profile::$member->is_activated; // Let the integrations know of the activation. - call_integration_hook('integrate_activate', array(Profile::$member->username)); + IntegrationHook::call('integrate_activate', array(Profile::$member->username)); // Actually update this member now, as it guarantees the unapproved count can't get corrupted. User::updateMemberData(Utils::$context['id_member'], array('is_activated' => Profile::$member->is_activated >= 10 ? 11 : 1, 'validation_code' => '')); diff --git a/Sources/Actions/Profile/BuddyIgnoreLists.php b/Sources/Actions/Profile/BuddyIgnoreLists.php index 6d7a95bc22b..802f3830ac0 100644 --- a/Sources/Actions/Profile/BuddyIgnoreLists.php +++ b/Sources/Actions/Profile/BuddyIgnoreLists.php @@ -19,6 +19,7 @@ use SMF\BBCodeParser; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\Profile; @@ -148,7 +149,7 @@ public function buddies(): void { User::$me->checkSession('get'); - call_integration_hook('integrate_remove_buddy', array(Profile::$member->id)); + IntegrationHook::call('integrate_remove_buddy', array(Profile::$member->id)); $_SESSION['prf-save'] = Lang::$txt['could_not_remove_person']; @@ -192,7 +193,7 @@ public function buddies(): void } } - call_integration_hook('integrate_add_buddies', array(Profile::$member->id, &$new_buddies)); + IntegrationHook::call('integrate_add_buddies', array(Profile::$member->id, &$new_buddies)); $_SESSION['prf-save'] = Lang::$txt['could_not_add_person']; @@ -358,7 +359,7 @@ public function buddies(): void unset($_SESSION['prf-save']); } - call_integration_hook('integrate_view_buddies', array(Profile::$member->id)); + IntegrationHook::call('integrate_view_buddies', array(Profile::$member->id)); } /** diff --git a/Sources/Actions/Profile/Main.php b/Sources/Actions/Profile/Main.php index 4f0e5a49688..57ccb6a7480 100644 --- a/Sources/Actions/Profile/Main.php +++ b/Sources/Actions/Profile/Main.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\Profile; @@ -637,7 +638,7 @@ public function execute(): void $password = Utils::htmlspecialcharsDecode($password); // Does the integration want to check passwords? - $good_password = in_array(true, call_integration_hook('integrate_verify_password', array(Profile::$member->username, $password, false)), true); + $good_password = in_array(true, IntegrationHook::call('integrate_verify_password', array(Profile::$member->username, $password, false)), true); // Bad password!!! if (!$good_password && !Security::hashVerifyPassword(Profile::$member->username, $password, Profile::$member->passwd)) @@ -862,7 +863,7 @@ function(&$value, $key) $this->profile_areas['profile_action']['areas']['logout']['enabled'] = !empty($_REQUEST['area']) && $_REQUEST['area'] === 'popup'; // Give mods access to the menu. - call_integration_hook('integrate_profile_areas', array(&$this->profile_areas)); + IntegrationHook::call('integrate_profile_areas', array(&$this->profile_areas)); // Do some cleaning ready for the menu function. Utils::$context['password_areas'] = array(); diff --git a/Sources/Actions/Profile/Notification.php b/Sources/Actions/Profile/Notification.php index e67db1694d5..bce8dc97930 100644 --- a/Sources/Actions/Profile/Notification.php +++ b/Sources/Actions/Profile/Notification.php @@ -19,6 +19,7 @@ use SMF\Alert; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Menu; @@ -426,7 +427,7 @@ function configuration($defaultSettings = false) // Now, now, we could pass this through global but we should really get into the habit of // passing content to hooks, not expecting hooks to splatter everything everywhere. - call_integration_hook('integrate_alert_types', array(&$this->alert_types, &$this->group_options)); + IntegrationHook::call('integrate_alert_types', array(&$this->alert_types, &$this->group_options)); // Now we have to do some permissions testing - but only if we're not loading this from the admin center if (!empty(Profile::$member->id)) diff --git a/Sources/Actions/Profile/Popup.php b/Sources/Actions/Profile/Popup.php index 180ffb6e013..3a9636ebd96 100644 --- a/Sources/Actions/Profile/Popup.php +++ b/Sources/Actions/Profile/Popup.php @@ -17,6 +17,7 @@ use SMF\Actions\ActionInterface; use SMF\Config; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\Utils; @@ -138,7 +139,7 @@ public function execute(): void // We only want to output our little layer here. Utils::$context['template_layers'] = array(); - call_integration_hook('integrate_profile_popup', array(&$this->profile_items)); + IntegrationHook::call('integrate_profile_popup', array(&$this->profile_items)); // Now check if these items are available Utils::$context['profile_items'] = array(); diff --git a/Sources/Actions/Profile/ShowPosts.php b/Sources/Actions/Profile/ShowPosts.php index b6d62f1747f..989bb76b5c7 100644 --- a/Sources/Actions/Profile/ShowPosts.php +++ b/Sources/Actions/Profile/ShowPosts.php @@ -20,6 +20,7 @@ use SMF\Board; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Logging; @@ -1027,7 +1028,7 @@ protected function loadPosts($is_topics = false): void } // Allow last minute changes. - call_integration_hook('integrate_profile_showPosts'); + IntegrationHook::call('integrate_profile_showPosts'); foreach (Utils::$context['posts'] as $key => $post) { diff --git a/Sources/Actions/Profile/StatPanel.php b/Sources/Actions/Profile/StatPanel.php index bf00f917395..d9b60b855a4 100644 --- a/Sources/Actions/Profile/StatPanel.php +++ b/Sources/Actions/Profile/StatPanel.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\Profile; @@ -275,7 +276,7 @@ public function execute(): void ); // Custom stats (just add a template_layer to add it to the template!) - call_integration_hook('integrate_profile_stats', array(Profile::$member->id, &Utils::$context['text_stats'])); + IntegrationHook::call('integrate_profile_stats', array(Profile::$member->id, &Utils::$context['text_stats'])); } /*********************** diff --git a/Sources/Actions/Profile/ThemeOptions.php b/Sources/Actions/Profile/ThemeOptions.php index f40eaaa34bc..7c4cbbebe19 100644 --- a/Sources/Actions/Profile/ThemeOptions.php +++ b/Sources/Actions/Profile/ThemeOptions.php @@ -16,6 +16,7 @@ use SMF\BackwardCompatibility; use SMF\Actions\ActionInterface; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Profile; use SMF\Theme; @@ -66,7 +67,7 @@ public function execute(): void Theme::loadSubTemplate('options'); // Let mods hook into the theme options. - call_integration_hook('integrate_theme_options'); + IntegrationHook::call('integrate_theme_options'); Profile::$member->loadThemeOptions(); diff --git a/Sources/Actions/QuickModeration.php b/Sources/Actions/QuickModeration.php index 03bb3c01a9d..c20beae2a66 100644 --- a/Sources/Actions/QuickModeration.php +++ b/Sources/Actions/QuickModeration.php @@ -17,6 +17,7 @@ use SMF\Board; use SMF\Config; +use SMF\IntegrationHook; use SMF\Logging; use SMF\Mail; use SMF\Msg; @@ -269,11 +270,11 @@ public static function getActions(bool $search = false): array // Approve isn't applicable when viewing search results. self::$known_actions = array_diff(self::$known_actions, array('approve')); - call_integration_hook('integrate_quick_mod_actions_search', array(self::$known_actions)); + IntegrationHook::call('integrate_quick_mod_actions_search', array(self::$known_actions)); } else { - call_integration_hook('integrate_quick_mod_actions', array(self::$known_actions)); + IntegrationHook::call('integrate_quick_mod_actions', array(self::$known_actions)); } return self::$known_actions; diff --git a/Sources/Actions/Recent.php b/Sources/Actions/Recent.php index ab2d1b5ec45..6566ef713f1 100644 --- a/Sources/Actions/Recent.php +++ b/Sources/Actions/Recent.php @@ -19,6 +19,7 @@ use SMF\Board; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Msg; use SMF\PageIndex; @@ -149,7 +150,7 @@ public function execute(): void $this->buildQuickButtons(); // Allow last minute changes. - call_integration_hook('integrate_recent_RecentPosts'); + IntegrationHook::call('integrate_recent_RecentPosts'); } /*********************** diff --git a/Sources/Actions/Register2.php b/Sources/Actions/Register2.php index 9cdeabef951..85984e6f8db 100644 --- a/Sources/Actions/Register2.php +++ b/Sources/Actions/Register2.php @@ -19,6 +19,7 @@ use SMF\Cookie; use SMF\ErrorHandler; use SMF\Group; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Logging; use SMF\Profile; @@ -460,7 +461,7 @@ function (&$value, $key) } else { - call_integration_hook('integrate_activate', array($reg_options['username'])); + IntegrationHook::call('integrate_activate', array($reg_options['username'])); Cookie::setLoginCookie(60 * Config::$modSettings['cookieTime'], $member_id, Cookie::encrypt($reg_options['register_vars']['passwd'], $reg_options['register_vars']['password_salt'])); @@ -616,7 +617,7 @@ public static function registerMember(&$reg_options, $return_errors = false) Db::$db->free_result($request); // Perhaps someone else wants to check this user. - call_integration_hook('integrate_register_check', array(&$reg_options, &$reg_errors)); + IntegrationHook::call('integrate_register_check', array(&$reg_options, &$reg_errors)); // If we found any errors we need to do something about it right away! foreach ($reg_errors as $key => $error) @@ -776,7 +777,7 @@ public static function registerMember(&$reg_options, $return_errors = false) ); // Call an optional function to validate the users' input. - call_integration_hook('integrate_register', array(&$reg_options, &$theme_vars, &$known_ints, &$known_floats)); + IntegrationHook::call('integrate_register', array(&$reg_options, &$theme_vars, &$known_ints, &$known_floats)); $column_names = array(); $values = array(); @@ -816,7 +817,7 @@ public static function registerMember(&$reg_options, $return_errors = false) ); // Call an optional function as notification of registration. - call_integration_hook('integrate_post_register', array(&$reg_options, &$theme_vars, &$member_id)); + IntegrationHook::call('integrate_post_register', array(&$reg_options, &$theme_vars, &$member_id)); // Update the number of members and latest member's info - and pass the name, but remove the 's. if ($reg_options['register_vars']['is_activated'] == 1) @@ -960,7 +961,7 @@ public static function registerMember(&$reg_options, $return_errors = false) $_SESSION['just_registered'] = 1; // If they are for sure registered, let other people to know about it - call_integration_hook('integrate_register_after', array($reg_options, $member_id)); + IntegrationHook::call('integrate_register_after', array($reg_options, $member_id)); return $member_id; } diff --git a/Sources/Actions/Reminder.php b/Sources/Actions/Reminder.php index 65f9066682f..593d9b6143d 100644 --- a/Sources/Actions/Reminder.php +++ b/Sources/Actions/Reminder.php @@ -17,6 +17,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Mail; use SMF\Security; @@ -274,7 +275,7 @@ public function setPassword2() // User validated. Update the database! User::updateMemberData($this->member->id, array('validation_code' => '', 'passwd' => Security::hashPassword($this->member->username, $_POST['passwrd1']))); - call_integration_hook('integrate_reset_pass', array($this->member->username, $this->member->username, $_POST['passwrd1'])); + IntegrationHook::call('integrate_reset_pass', array($this->member->username, $this->member->username, $_POST['passwrd1'])); Theme::loadTemplate('Login'); Utils::$context += array( @@ -392,7 +393,7 @@ public function secretAnswer2() // Alright, so long as 'yer sure. User::updateMemberData($this->member->id_member, array('passwd' => Security::hashPassword($this->member->username, $_POST['passwrd1']))); - call_integration_hook('integrate_reset_pass', array($this->member->username, $this->member->username, $_POST['passwrd1'])); + IntegrationHook::call('integrate_reset_pass', array($this->member->username, $this->member->username, $_POST['passwrd1'])); // Tell them it went fine. Theme::loadTemplate('Login'); diff --git a/Sources/Actions/Search.php b/Sources/Actions/Search.php index 259a90bf773..761d1cdb7c4 100644 --- a/Sources/Actions/Search.php +++ b/Sources/Actions/Search.php @@ -18,6 +18,7 @@ use SMF\Category; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Theme; use SMF\User; @@ -297,7 +298,7 @@ public function execute(): void Utils::$context['page_title'] = Lang::$txt['set_parameters']; - call_integration_hook('integrate_search'); + IntegrationHook::call('integrate_search'); } /*********************** diff --git a/Sources/Actions/Search2.php b/Sources/Actions/Search2.php index 246aec9c485..526a5111fad 100644 --- a/Sources/Actions/Search2.php +++ b/Sources/Actions/Search2.php @@ -18,6 +18,7 @@ use SMF\Category; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\PageIndex; use SMF\Security; @@ -203,7 +204,7 @@ public function prepareSearchContext($reset = false) $counter++; - call_integration_hook('integrate_search_message_context', array(&$output, &$message, $counter)); + IntegrationHook::call('integrate_search_message_context', array(&$output, &$message, $counter)); return $output; } @@ -298,7 +299,7 @@ protected function preventPrefetch(): void */ protected function errorCheck(): bool { - call_integration_hook('integrate_search_errors'); + IntegrationHook::call('integrate_search_errors'); // One or more search errors? Go back to the first search screen. if (!empty(Utils::$context['search_errors'])) @@ -551,7 +552,7 @@ protected function initSearchContext() // Load the posters... $this->getPosters(); - call_integration_hook('integrate_search_message_list', array(&$this->messages, &$this->posters)); + IntegrationHook::call('integrate_search_message_list', array(&$this->messages, &$this->posters)); if (!empty($this->posters)) User::load(array_unique($this->posters)); diff --git a/Sources/Actions/Stats.php b/Sources/Actions/Stats.php index 3488a0e3c1f..b645888d09b 100644 --- a/Sources/Actions/Stats.php +++ b/Sources/Actions/Stats.php @@ -17,6 +17,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Theme; use SMF\Time; @@ -777,7 +778,7 @@ public function execute(): void } // Custom stats (just add a template_layer to add it to the template!) - call_integration_hook('integrate_forum_stats'); + IntegrationHook::call('integrate_forum_stats'); if (empty($_SESSION['expanded_stats'])) return; diff --git a/Sources/Actions/TopicMerge.php b/Sources/Actions/TopicMerge.php index caf4422c99c..b1fe234785a 100644 --- a/Sources/Actions/TopicMerge.php +++ b/Sources/Actions/TopicMerge.php @@ -21,6 +21,7 @@ use SMF\Board; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Logging; use SMF\Msg; @@ -1004,7 +1005,7 @@ public function merge(): void 'subject' => $target_subject, ); - call_integration_hook('integrate_merge_topic', array($merged_topic, $updated_topics, $deleted_topics, $deleted_polls)); + IntegrationHook::call('integrate_merge_topic', array($merged_topic, $updated_topics, $deleted_topics, $deleted_polls)); // Send them to the all done page. Utils::redirectexit('action=mergetopics;sa=done;to=' . $id_topic . ';targetboard=' . $target_board); diff --git a/Sources/Actions/TopicMove2.php b/Sources/Actions/TopicMove2.php index 9158d10c2e3..a7c5a998643 100644 --- a/Sources/Actions/TopicMove2.php +++ b/Sources/Actions/TopicMove2.php @@ -18,6 +18,7 @@ use SMF\Board; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Logging; use SMF\MessageIndex; @@ -327,7 +328,7 @@ public function execute(): void // Notify people that this topic has been moved? Mail::sendNotifications(Topic::$topic_id, 'move'); - call_integration_hook('integrate_movetopic2_end'); + IntegrationHook::call('integrate_movetopic2_end'); // Why not go back to the original board in case they want to keep moving? if (!isset($_REQUEST['goback'])) diff --git a/Sources/Actions/TopicSplit.php b/Sources/Actions/TopicSplit.php index 0fd809cc46d..fd7e14fa106 100644 --- a/Sources/Actions/TopicSplit.php +++ b/Sources/Actions/TopicSplit.php @@ -21,6 +21,7 @@ use SMF\Board; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Logging; use SMF\MessageIndex; @@ -973,7 +974,7 @@ public static function splitTopic($split1_ID_TOPIC, $splitMessages, $new_subject 'id_topic' => $split2_ID_TOPIC, ); - call_integration_hook('integrate_split_topic', array($split1, $split2, $new_subject, $id_board)); + IntegrationHook::call('integrate_split_topic', array($split1, $split2, $new_subject, $id_board)); // Return the ID of the newly created topic. return $split2_ID_TOPIC; diff --git a/Sources/Actions/TrackIP.php b/Sources/Actions/TrackIP.php index 107aca8b6f1..596871f2e6f 100644 --- a/Sources/Actions/TrackIP.php +++ b/Sources/Actions/TrackIP.php @@ -18,6 +18,7 @@ use SMF\Config; use SMF\ErrorHandler; use SMF\Lang; +use SMF\IntegrationHook; use SMF\IP; use SMF\ItemList; use SMF\Profile; @@ -331,7 +332,7 @@ public function execute(): void // Allow 3rd party integrations to add in their own lists or whatever. Utils::$context['additional_track_lists'] = array(); - call_integration_hook('integrate_profile_trackip', array($ip_string, $ip_var)); + IntegrationHook::call('integrate_profile_trackip', array($ip_string, $ip_var)); Utils::$context['single_ip'] = ($ip_var['low'] === $ip_var['high']); diff --git a/Sources/Actions/Unread.php b/Sources/Actions/Unread.php index eb572d4c9ae..232bc716415 100644 --- a/Sources/Actions/Unread.php +++ b/Sources/Actions/Unread.php @@ -18,6 +18,7 @@ use SMF\Board; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\PageIndex; use SMF\Theme; @@ -253,7 +254,7 @@ public function execute(): void Utils::$context['no_topic_listing'] = empty(Utils::$context['topics']); // Allow helpdesks and bug trackers and what not to add their own unread data (just add a template_layer to show custom stuff in the template!) - call_integration_hook('integrate_unread_list'); + IntegrationHook::call('integrate_unread_list'); } /*********************** @@ -1066,7 +1067,7 @@ protected function buildButtons() } // Allow mods to add additional buttons here - call_integration_hook('integrate_recent_buttons'); + IntegrationHook::call('integrate_recent_buttons'); } } diff --git a/Sources/Actions/ViewQuery.php b/Sources/Actions/ViewQuery.php index 9e044832fa2..eb6ab75ad95 100644 --- a/Sources/Actions/ViewQuery.php +++ b/Sources/Actions/ViewQuery.php @@ -17,6 +17,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Theme; use SMF\User; @@ -92,7 +93,7 @@ public function execute(): void } } - call_integration_hook('integrate_egg_nog'); + IntegrationHook::call('integrate_egg_nog'); $query_id = isset($_REQUEST['qq']) ? (int) $_REQUEST['qq'] - 1 : -1; diff --git a/Sources/Actions/Who.php b/Sources/Actions/Who.php index 52187667669..f31558d6e6d 100644 --- a/Sources/Actions/Who.php +++ b/Sources/Actions/Who.php @@ -17,6 +17,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\IP; use SMF\Lang; use SMF\PageIndex; @@ -422,7 +423,7 @@ public static function determineActions($urls, $preferred_prefix = false) Lang::load('Who'); - call_integration_hook('who_allowed', array(&self::$allowedActions)); + IntegrationHook::call('who_allowed', array(&self::$allowedActions)); if (!is_array($urls)) { @@ -612,7 +613,7 @@ public static function determineActions($urls, $preferred_prefix = false) } // Maybe the action is integrated into another system? - if (count($integrate_actions = call_integration_hook('integrate_whos_online', array($actions))) > 0) + if (count($integrate_actions = IntegrationHook::call('integrate_whos_online', array($actions))) > 0) { foreach ($integrate_actions as $integrate_action) { @@ -724,7 +725,7 @@ public static function determineActions($urls, $preferred_prefix = false) Db::$db->free_result($result); } - call_integration_hook('whos_online_after', array(&$urls, &$data)); + IntegrationHook::call('whos_online_after', array(&$urls, &$data)); if (!is_array($urls)) { diff --git a/Sources/Actions/XmlHttp.php b/Sources/Actions/XmlHttp.php index 2b9cd79d69e..bc34a2625e6 100644 --- a/Sources/Actions/XmlHttp.php +++ b/Sources/Actions/XmlHttp.php @@ -20,6 +20,7 @@ use SMF\Config; use SMF\Editor; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Msg; use SMF\Profile; @@ -465,7 +466,7 @@ protected function __construct() Theme::loadTemplate('Xml'); // Easy adding of sub actions. - call_integration_hook('integrate_XMLhttpMain_subActions', array(&self::$subactions)); + IntegrationHook::call('integrate_XMLhttpMain_subActions', array(&self::$subactions)); if (!empty($_REQUEST['sa']) && isset(self::$subactions[$_REQUEST['sa']])) $this->subaction = $_REQUEST['sa']; diff --git a/Sources/Alert.php b/Sources/Alert.php index 92f929e0946..05a5aa1e3f2 100644 --- a/Sources/Alert.php +++ b/Sources/Alert.php @@ -948,7 +948,7 @@ public static function fetch(int $memID, bool|array $to_fetch = false, int $limi // Hooks might want to do something snazzy with their own content types, // including enforcing permissions if appropriate. - call_integration_hook('integrate_fetch_alerts', array(&$loaded, &self::$link_formats)); + IntegrationHook::call('integrate_fetch_alerts', array(&$loaded, &self::$link_formats)); // Did a hook remove some of the alerts we loaded? if ($loaded_ids !== array_keys($loaded)) @@ -1345,7 +1345,7 @@ protected function setIcon(): void $this->icon = ''; } - call_integration_hook('integrate_alert_icon', array(&$this->icon, (array) $this)); + IntegrationHook::call('integrate_alert_icon', array(&$this->icon, (array) $this)); } /************************* * Internal static methods diff --git a/Sources/Attachment.php b/Sources/Attachment.php index 59732d74b1f..bbe7fc712a6 100644 --- a/Sources/Attachment.php +++ b/Sources/Attachment.php @@ -541,7 +541,7 @@ public static function load(array|int $ids, int $approval_status = self::APPROVE $joins[] = 'LEFT JOIN {db_prefix}attachments AS thumb ON (a.id_thumb = thumb.id_attach)'; } - call_integration_hook('integrate_attachment_load', array(&$selects, &$params, &$from, &$joins, &$where, &$order, &$limit)); + IntegrationHook::call('integrate_attachment_load', array(&$selects, &$params, &$from, &$joins, &$where, &$order, &$limit)); foreach (self::queryData($selects, $params, $from, $joins, $where, $order, $limit) as $props) { @@ -614,7 +614,7 @@ public static function loadByMsg(array|int $msgs, int $approval_status = self::A $joins[] = 'LEFT JOIN {db_prefix}attachments AS thumb ON (a.id_thumb = thumb.id_attach)'; } - call_integration_hook('integrate_attachment_loadbymsg', array(&$selects, &$params, &$from, &$joins, &$where, &$order, &$limit)); + IntegrationHook::call('integrate_attachment_loadbymsg', array(&$selects, &$params, &$from, &$joins, &$where, &$order, &$limit)); foreach (self::queryData($selects, $params, $from, $joins, $where, $order, $limit) as $props) { @@ -679,7 +679,7 @@ public static function loadByMember(array|int $members, int $approval_status = s $joins[] = 'LEFT JOIN {db_prefix}attachments AS thumb ON (a.id_thumb = thumb.id_attach)'; } - call_integration_hook('integrate_attachment_loadbymember', array(&$selects, &$params, &$from, &$joins, &$where, &$order, &$limit)); + IntegrationHook::call('integrate_attachment_loadbymember', array(&$selects, &$params, &$from, &$joins, &$where, &$order, &$limit)); foreach (self::queryData($selects, $params, $from, $joins, $where, $order, $limit) as $props) { @@ -1168,7 +1168,7 @@ public static function process() // id_folder => Config::$modSettings['currentAttachmentUploadDir'] // errors => An array of errors (use the index of the Lang::$txt variable for that error). // Template changes can be done using "integrate_upload_template". - call_integration_hook('integrate_attachment_upload', array()); + IntegrationHook::call('integrate_attachment_upload', array()); } /** @@ -1456,7 +1456,7 @@ public static function create(&$attachmentOptions) ); // Last chance to change stuff! - call_integration_hook('integrate_createAttachment', array(&$attachmentOptions, &$attachmentInserts)); + IntegrationHook::call('integrate_createAttachment', array(&$attachmentOptions, &$attachmentInserts)); // Make sure the folder is valid... $tmp = is_array(Config::$modSettings['attachmentUploadDir']) ? Config::$modSettings['attachmentUploadDir'] : Utils::jsonDecode(Config::$modSettings['attachmentUploadDir'], true); @@ -1667,7 +1667,7 @@ public static function assign($attachIDs = array(), $msgID = 0) return false; // "I see what is right and approve, but I do what is wrong." - call_integration_hook('integrate_assign_attachments', array(&$attachIDs, &$msgID)); + IntegrationHook::call('integrate_assign_attachments', array(&$attachIDs, &$msgID)); // One last check if (empty($attachIDs)) @@ -1769,7 +1769,7 @@ public static function approve($attachments): bool ) ); - call_integration_hook('integrate_approve_attachments', array($attachments)); + IntegrationHook::call('integrate_approve_attachments', array($attachments)); return true; } @@ -1947,7 +1947,7 @@ public static function remove($condition, $query_type = '', $return_affected_mes ); } - call_integration_hook('integrate_remove_attachments', array($attach)); + IntegrationHook::call('integrate_remove_attachments', array($attach)); if ($return_affected_messages) return array_unique($msgs); @@ -1975,7 +1975,7 @@ public static function parseAttachBBC($attachID = 0) $msgID = !empty($_REQUEST['msg']) ? (int) $_REQUEST['msg'] : 0; // Perhaps someone else wants to do the honors? Yes, this also includes dealing with previews ;) - $externalParse = call_integration_hook('integrate_pre_parseAttachBBC', array($attachID, $msgID)); + $externalParse = IntegrationHook::call('integrate_pre_parseAttachBBC', array($attachID, $msgID)); // "I am innocent of the blood of this just person: see ye to it." if (!empty($externalParse) && (is_string($externalParse) || is_array($externalParse))) @@ -2077,7 +2077,7 @@ public static function parseAttachBBC($attachID = 0) } // Last minute changes? - call_integration_hook('integrate_post_parseAttachBBC', array(&$attachContext)); + IntegrationHook::call('integrate_post_parseAttachBBC', array(&$attachContext)); // Don't do any logic with the loaded data, leave it to whoever called this function. return $attachContext; diff --git a/Sources/Autoloader.php b/Sources/Autoloader.php index 3bf2845a004..65e6c21a1da 100644 --- a/Sources/Autoloader.php +++ b/Sources/Autoloader.php @@ -32,14 +32,6 @@ 'SMF\\' => '', ); - // Do any third-party scripts want in on the fun? - if (function_exists('call_integration_hook') && $level === 0) - { - $level++; - call_integration_hook('integrate_autoload', array(&$class_map)); - $level--; - } - // Ensure $sourcedir is set to something valid. if (class_exists('SMF\\Config', false) && isset(Config::$sourcedir)) $sourcedir = Config::$sourcedir; @@ -47,6 +39,22 @@ if (empty($sourcedir) || !is_dir($sourcedir)) $sourcedir = __DIR__; + // Do any third-party scripts want in on the fun? + if ($level === 0) + { + $level++; + + if (!class_exists('SMF\\IntegrationHook', false) && is_file($sourcedir . '/IntegrationHook.php')) + { + require $sourcedir . '/IntegrationHook.php'; + } + + if (class_exists('SMF\\IntegrationHook', false)) + IntegrationHook::call('integrate_autoload', array(&$class_map)); + + $level--; + } + foreach ($class_map as $prefix => $dirname) { // Does the class use the namespace prefix? diff --git a/Sources/BBCodeParser.php b/Sources/BBCodeParser.php index 7f9d1d84020..d6d34e39e83 100644 --- a/Sources/BBCodeParser.php +++ b/Sources/BBCodeParser.php @@ -1121,7 +1121,7 @@ function($a, $b) self::$domain_label_chars = '0-9A-Za-z\-'; // In case a mod wants to control behaviour for a special URI scheme. - call_integration_hook('integrate_autolinker_schemes', array(&self::$schemes)); + IntegrationHook::call('integrate_autolinker_schemes', array(&self::$schemes)); /************************* * Set up smileys parsing. @@ -1134,7 +1134,7 @@ function($a, $b) // (e.g. emojis instead of images) if ($this->smiley_set !== 'none') { - call_integration_hook('integrate_smileys', array(&$this->smiley_preg_search, &$this->smiley_preg_replacements)); + IntegrationHook::call('integrate_smileys', array(&$this->smiley_preg_search, &$this->smiley_preg_replacements)); } /************************ @@ -1188,7 +1188,7 @@ public function parse(string $message, bool $smileys = true, string $cache_id = } // Allow mods access before entering $this->parseMessage. - call_integration_hook('integrate_pre_parsebbc', array(&$this->message, &$this->smileys, &$cache_id, &$this->parse_tags, &$this->cache_key_extras)); + IntegrationHook::call('integrate_pre_parsebbc', array(&$this->message, &$this->smileys, &$cache_id, &$this->parse_tags, &$this->cache_key_extras)); // If no cache id was given, make a generic one. $cache_id = strval($cache_id) !== '' ? $cache_id : 'str' . substr(md5($this->message), 0, 7); @@ -1235,7 +1235,7 @@ public function parse(string $message, bool $smileys = true, string $cache_id = $this->parseMessage(); // Allow mods access to what $this->parseMessage created. - call_integration_hook('integrate_post_parsebbc', array(&$this->message, &$this->smileys, &$cache_id, &$this->parse_tags)); + IntegrationHook::call('integrate_post_parsebbc', array(&$this->message, &$this->smileys, &$cache_id, &$this->parse_tags)); // Cache the output if it took some time... if (!empty(CacheApi::$enable) && microtime(true) - $cache_t > pow(50, -CacheApi::$enable)) @@ -2569,7 +2569,7 @@ public static function attachValidate(&$tag, &$data, $disabled, $params): void // If you want to work with the attachment data itself, use one of these: // - integrate_pre_parseAttachBBC // - integrate_post_parseAttachBBC - call_integration_hook('integrate_attach_bbc_validate', array(&$return_context, $current_attachment, $tag, $data, $disabled, $params)); + IntegrationHook::call('integrate_attach_bbc_validate', array(&$return_context, $current_attachment, $tag, $data, $disabled, $params)); // Gotta append what we just did. $data = $return_context; @@ -3215,7 +3215,7 @@ protected function setDisabled(): void } // Maybe some custom BBC need to be disabled for printing. - call_integration_hook('integrate_bbc_print', array(&$this->disabled)); + IntegrationHook::call('integrate_bbc_print', array(&$this->disabled)); } } @@ -5063,7 +5063,7 @@ protected static function integrateBBC(): void // Only do this once. if (self::$integrate_bbc_codes_done !== true) { - call_integration_hook('integrate_bbc_codes', array(&self::$codes, &self::$no_autolink_tags)); + IntegrationHook::call('integrate_bbc_codes', array(&self::$codes, &self::$no_autolink_tags)); // Prevent duplicates. $temp = array(); diff --git a/Sources/Board.php b/Sources/Board.php index 379ce3b31fd..41c23f02ad4 100644 --- a/Sources/Board.php +++ b/Sources/Board.php @@ -630,7 +630,7 @@ public function save(array $boardOptions = array()): void ); // Do any hooks want to add or adjust anything? - call_integration_hook('integrate_modify_board', array($this->id, $boardOptions, &$set, &$params)); + IntegrationHook::call('integrate_modify_board', array($this->id, $boardOptions, &$set, &$params)); Db::$db->query('', ' UPDATE {db_prefix}boards @@ -1528,7 +1528,7 @@ public static function modify(int $board_id, array &$boardOptions): void ErrorHandler::fatalLang('no_board'); } - call_integration_hook('integrate_pre_modify_board', array($board_id, &$boardOptions)); + IntegrationHook::call('integrate_pre_modify_board', array($board_id, &$boardOptions)); $board = self::$loaded[$board_id]; @@ -1713,7 +1713,7 @@ public static function create(array $boardOptions): int '', ); - call_integration_hook('integrate_create_board', array(&$boardOptions, &$board_columns, &$board_parameters)); + IntegrationHook::call('integrate_create_board', array(&$boardOptions, &$board_columns, &$board_parameters)); // Make a new instance and save it. $board = new self(0, array_combine(array_keys($board_columns), $board_parameters)); @@ -1761,7 +1761,7 @@ public static function delete(array $boards_to_remove, int $moveChildrenTo = nul Category::getTree(); - call_integration_hook('integrate_delete_board', array($boards_to_remove, &$moveChildrenTo)); + IntegrationHook::call('integrate_delete_board', array($boards_to_remove, &$moveChildrenTo)); // If $moveChildrenTo is set to null, include the children in the removal. if ($moveChildrenTo === null) @@ -2560,7 +2560,7 @@ protected function loadBoardInfo(): void } // Do any mods want to add some custom stuff to the query? - call_integration_hook('integrate_load_board', array(&$selects, &$params, &$joins, &$where, &$order)); + IntegrationHook::call('integrate_load_board', array(&$selects, &$params, &$joins, &$where, &$order)); $selects = array_unique($selects); $params = array_unique($params); @@ -2610,7 +2610,7 @@ protected function loadBoardInfo(): void 'deny_groups' => $row['deny_member_groups'] == '' ? array() : array_filter(explode(',', $row['deny_member_groups']), 'strlen'), ); - call_integration_hook('integrate_board_info', array(&$props, $row)); + IntegrationHook::call('integrate_board_info', array(&$props, $row)); } // This row included an individual moderator. diff --git a/Sources/Cache/CacheApi.php b/Sources/Cache/CacheApi.php index 34aff436762..d3ce966f52d 100644 --- a/Sources/Cache/CacheApi.php +++ b/Sources/Cache/CacheApi.php @@ -14,7 +14,9 @@ namespace SMF\Cache; use SMF\BackwardCompatibility; + use SMF\Config; +use SMF\IntegrationHook; use SMF\Utils; abstract class CacheApi @@ -447,7 +449,7 @@ final public static function detect() $loadedApis[$class_name] = $cache_api; } - call_integration_hook('integrate_load_cache_apis', array(&$loadedApis)); + IntegrationHook::call('integrate_load_cache_apis', array(&$loadedApis)); return $loadedApis; } @@ -473,7 +475,7 @@ final public static function clean($type = '') // Ask the API to do the heavy lifting. cleanCache also calls invalidateCache to be sure. self::$loadedApi->cleanCache($type); - call_integration_hook('integrate_clean_cache'); + IntegrationHook::call('integrate_clean_cache'); clearstatcache(); } @@ -490,8 +492,8 @@ final public static function clean($type = '') */ final public static function quickGet($key, $file, $function, $params, $level = 1) { - if (function_exists('call_integration_hook')) - call_integration_hook('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); + if (class_exists('SMF\\IntegrationHook', false)) + IntegrationHook::call('pre_cache_quick_get', array(&$key, &$file, &$function, &$params, &$level)); /* Refresh the cache if either: 1. Caching is disabled. @@ -515,8 +517,8 @@ final public static function quickGet($key, $file, $function, $params, $level = if (!empty($cache_block['post_retri_eval'])) eval($cache_block['post_retri_eval']); - if (function_exists('call_integration_hook')) - call_integration_hook('post_cache_quick_get', array(&$cache_block)); + if (class_exists('SMF\\IntegrationHook', false)) + IntegrationHook::call('post_cache_quick_get', array(&$cache_block)); return $cache_block['data']; } @@ -552,8 +554,8 @@ final public static function put($key, $value, $ttl = 120) $value = $value === null ? null : Utils::jsonEncode($value); self::$loadedApi->putData($key, $value, $ttl); - if (function_exists('call_integration_hook')) - call_integration_hook('cache_put_data', array(&$key, &$value, &$ttl)); + if (class_exists('SMF\\IntegrationHook', false)) + IntegrationHook::call('cache_put_data', array(&$key, &$value, &$ttl)); if (isset(Config::$db_show_debug) && Config::$db_show_debug === true) self::$hits[self::$count_hits]['t'] = microtime(true) - $st; @@ -596,8 +598,8 @@ final public static function get($key, $ttl = 120) } } - if (function_exists('call_integration_hook') && isset($value)) - call_integration_hook('cache_get_data', array(&$key, &$ttl, &$value)); + if (class_exists('SMF\\IntegrationHook', false) && isset($value)) + IntegrationHook::call('cache_get_data', array(&$key, &$ttl, &$value)); return empty($value) ? null : Utils::jsonDecode($value, true); } diff --git a/Sources/Category.php b/Sources/Category.php index 84d01292d3b..69a6462fb62 100644 --- a/Sources/Category.php +++ b/Sources/Category.php @@ -356,7 +356,7 @@ public static function modify(int $category_id, array $catOptions): void $catParameters = array(); $cat_id = $category_id; - call_integration_hook('integrate_pre_modify_category', array($cat_id, &$catOptions)); + IntegrationHook::call('integrate_pre_modify_category', array($cat_id, &$catOptions)); // Wanna change the categories position? if (isset($catOptions['move_after'])) @@ -433,7 +433,7 @@ public static function modify(int $category_id, array $catOptions): void } $cat_id = $category_id; - call_integration_hook('integrate_modify_category', array($cat_id, &$catUpdates, &$catParameters)); + IntegrationHook::call('integrate_modify_category', array($cat_id, &$catUpdates, &$catParameters)); // Do the updates (if any). if (!empty($catUpdates)) @@ -498,7 +498,7 @@ public static function create(array $catOptions): int $catOptions['cat_desc'], ); - call_integration_hook('integrate_create_category', array(&$catOptions, &$cat_columns, &$cat_parameters)); + IntegrationHook::call('integrate_create_category', array(&$catOptions, &$cat_columns, &$cat_parameters)); // Add the category to the database. $category_id = Db::$db->insert('', @@ -533,7 +533,7 @@ public static function delete(array $categories, int $moveBoardsTo = null): void { self::getTree(); - call_integration_hook('integrate_delete_category', array($categories, &$moveBoardsTo)); + IntegrationHook::call('integrate_delete_category', array($categories, &$moveBoardsTo)); // With no category set to move the boards to, delete them all. if ($moveBoardsTo === null) @@ -687,7 +687,7 @@ public static function getTree(): void $order = array('c.cat_order', 'b.child_level', 'b.board_order'); // Let mods add extra columns, parameters, etc., to the SELECT query - call_integration_hook('integrate_pre_boardtree', array(&$selects, &$params, &$joins, &$where, &$order)); + IntegrationHook::call('integrate_pre_boardtree', array(&$selects, &$params, &$joins, &$where, &$order)); $selects = array_unique($selects); $params = array_unique($params); @@ -766,7 +766,7 @@ public static function getTree(): void } // If mods want to do anything with this board before we move on, now's the time - call_integration_hook('integrate_boardtree_board', array($row)); + IntegrationHook::call('integrate_boardtree_board', array($row)); } // Get a list of all the boards in each category (using recursion). diff --git a/Sources/Config.php b/Sources/Config.php index c2f3cb8c79e..c7b2010156e 100644 --- a/Sources/Config.php +++ b/Sources/Config.php @@ -1165,7 +1165,7 @@ public static function reloadModSettings(): void if (!empty(self::$modSettings['load_average']) || self::$modSettings['load_average'] === 0.0) { - call_integration_hook('integrate_load_average', array(self::$modSettings['load_average'])); + IntegrationHook::call('integrate_load_average', array(self::$modSettings['load_average'])); } if (!empty(self::$modSettings['loadavg_forum']) && !empty(self::$modSettings['load_average']) && self::$modSettings['load_average'] >= self::$modSettings['loadavg_forum']) @@ -1209,7 +1209,7 @@ public static function reloadModSettings(): void $integration_settings = Utils::jsonDecode(SMF_INTEGRATION_SETTINGS, true); foreach ($integration_settings as $hook => $function) - add_integration_function($hook, $function, false); + IntegrationHook::add($hook, $function, false); } // Any files to pre include? @@ -1229,7 +1229,7 @@ public static function reloadModSettings(): void Utils::load(); // Call pre load integration functions. - call_integration_hook('integrate_pre_load'); + IntegrationHook::call('integrate_pre_load'); } /** @@ -1384,9 +1384,9 @@ public static function getSettingsDefs(): array self::$settings_defs = $class_vars['settings_defs']; // Allow mods the option to define comments, defaults, etc., for their settings. - // Check if function exists, in case we are calling from installer or upgrader. - if (function_exists('call_integration_hook')) - call_integration_hook('integrate_update_settings_file', array(&self::$settings_defs)); + // Check if IntegrationHook exists, in case we are calling from installer or upgrader. + if (class_exists('SMF\\IntegrationHook', false)) + IntegrationHook::call('integrate_update_settings_file', array(&self::$settings_defs)); // Return the setting definitions, including any added by mods. return self::$settings_defs; diff --git a/Sources/Cookie.php b/Sources/Cookie.php index 65f0e6aa1f4..c73936b22fe 100644 --- a/Sources/Cookie.php +++ b/Sources/Cookie.php @@ -208,7 +208,7 @@ public function __construct( $this->path, ); - call_integration_hook('integrate_cookie_data', array($data, &$this->custom_data)); + IntegrationHook::call('integrate_cookie_data', array($data, &$this->custom_data)); } /** @@ -241,7 +241,7 @@ public function set() // MOD AUTHORS: This hook just informs you about the cookie. If you want // to change the cookie data, use integrate_cookie_data instead. - call_integration_hook('integrate_cookie', array($this->name, $value, $this->expires, $this->path, $this->domain, $this->secure, $this->httponly, $this->samesite)); + IntegrationHook::call('integrate_cookie', array($this->name, $value, $this->expires, $this->path, $this->domain, $this->secure, $this->httponly, $this->samesite)); return setcookie($this->name, $value, array( 'expires' => $this->expires, diff --git a/Sources/Editor.php b/Sources/Editor.php index adba5ada989..576f6b7518c 100644 --- a/Sources/Editor.php +++ b/Sources/Editor.php @@ -346,7 +346,7 @@ public static function getMessageIcons(int $board_id): array } } - call_integration_hook('integrate_load_message_icons', array(&$icons)); + IntegrationHook::call('integrate_load_message_icons', array(&$icons)); return array_values($icons); } @@ -643,7 +643,7 @@ protected function buildBbcToolbar(): void ); // Allow mods to modify BBC buttons. - call_integration_hook('integrate_bbc_buttons', array(&self::$bbc_tags, &$editor_tag_map, &self::$disabled_tags)); + IntegrationHook::call('integrate_bbc_buttons', array(&self::$bbc_tags, &$editor_tag_map, &self::$disabled_tags)); // Generate a list of buttons that shouldn't be shown - this should be the fastest way to do this. $disabled_bbc = !empty(Config::$modSettings['disabledBBC']) ? explode(',', Config::$modSettings['disabledBBC']) : array(); @@ -887,7 +887,7 @@ protected function setSCEditorOptions() // Allow mods to change $this->sce_options. // Usful if, e.g., a mod wants to add an SCEditor plugin. - call_integration_hook('integrate_sceditor_options', array(&$this->sce_options)); + IntegrationHook::call('integrate_sceditor_options', array(&$this->sce_options)); } } diff --git a/Sources/ErrorHandler.php b/Sources/ErrorHandler.php index d5468f7b941..cec8881e5cf 100644 --- a/Sources/ErrorHandler.php +++ b/Sources/ErrorHandler.php @@ -120,7 +120,7 @@ public function __construct(int $error_level, string $error_string, string $file $message = self::log($error_level . ': ' . $error_string, $error_type, $file, $line); // Let's give integrations a chance to output a bit differently - call_integration_hook('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); + IntegrationHook::call('integrate_output_error', array($message, $error_type, $error_level, $file, $line)); // Dying on these errors only causes MORE problems (blank pages!) if ($file == 'Unknown') @@ -250,7 +250,7 @@ public static function log(string $error_message, string|bool $error_type = 'gen $tried_hook = true; // Allow the hook to change the error_type and know about the error. - call_integration_hook('integrate_error_types', array(&$other_error_types, &$error_type, $error_message, $file, $line)); + IntegrationHook::call('integrate_error_types', array(&$other_error_types, &$error_type, $error_message, $file, $line)); $known_error_types = array_merge($known_error_types, $other_error_types); } diff --git a/Sources/Event.php b/Sources/Event.php index 043580dfd0d..cc361fcd00f 100644 --- a/Sources/Event.php +++ b/Sources/Event.php @@ -302,7 +302,7 @@ public function save(): void $params[] = $this->start->format('e'); } - call_integration_hook('integrate_create_event', array((array) $this, &$columns, &$params)); + IntegrationHook::call('integrate_create_event', array((array) $this, &$columns, &$params)); $this->id = Db::$db->insert('', '{db_prefix}calendar', @@ -355,7 +355,7 @@ public function save(): void } // Why pass `$this->id` if we're also passing `$this`, you ask? For historical reasons. - call_integration_hook('integrate_modify_event', array($this->id, $this, &$set, &$params)); + IntegrationHook::call('integrate_modify_event', array($this->id, $this, &$set, &$params)); Db::$db->query('', ' UPDATE {db_prefix}calendar @@ -991,7 +991,7 @@ public static function get(string $low_date, string $high_date, bool $use_permis if ($use_permissions) $where[] = '(cal.id_board = {int:no_board_link} OR {query_wanna_see_board})'; - call_integration_hook('integrate_query_event', array(&$selects, &$params, &$joins, &$where, &$order, &$limit)); + IntegrationHook::call('integrate_query_event', array(&$selects, &$params, &$joins, &$where, &$order, &$limit)); foreach(self::queryData($selects, $params, $joins, $where, $order, $limit) as $row) { @@ -1097,7 +1097,7 @@ public static function remove(int $id): void ) ); - call_integration_hook('integrate_remove_event', array($id)); + IntegrationHook::call('integrate_remove_event', array($id)); Config::updateModSettings(array( 'calendar_updated' => time(), diff --git a/Sources/Forum.php b/Sources/Forum.php index ea6248083e9..4f992507b50 100644 --- a/Sources/Forum.php +++ b/Sources/Forum.php @@ -241,13 +241,13 @@ public function __construct() // Why three different hooks? For historical reasons. // Allow modifying $actions easily. - call_integration_hook('integrate_actions', array(&self::$actions)); + IntegrationHook::call('integrate_actions', array(&self::$actions)); // Allow modifying $unlogged_actions easily. - call_integration_hook('integrate_pre_log_stats', array(&self::$unlogged_actions)); + IntegrationHook::call('integrate_pre_log_stats', array(&self::$unlogged_actions)); // Allow modifying $guest_access_actions easily. - call_integration_hook('integrate_guest_actions', array(&self::$guest_access_actions)); + IntegrationHook::call('integrate_guest_actions', array(&self::$guest_access_actions)); } /** diff --git a/Sources/Group.php b/Sources/Group.php index 9d6ede01c23..8bfcaff3830 100644 --- a/Sources/Group.php +++ b/Sources/Group.php @@ -443,7 +443,7 @@ public function save(): void // Saving a new group. if (empty($this->id)) { - call_integration_hook('integrate_pre_add_membergroup', array()); + IntegrationHook::call('integrate_pre_add_membergroup', array()); $columns = array( 'group_name' => 'string-80', @@ -481,7 +481,7 @@ public function save(): void self::$loaded[$this->id] = $this; - call_integration_hook('integrate_add_membergroup', array($this->id, $this->min_posts > -1)); + IntegrationHook::call('integrate_add_membergroup', array($this->id, $this->min_posts > -1)); } // Updating an existing group. else @@ -520,7 +520,7 @@ public function save(): void $params ); - call_integration_hook('integrate_save_membergroup', array($this->id)); + IntegrationHook::call('integrate_save_membergroup', array($this->id)); } // Update membership for post groups, hidden groups, and the moderator group. @@ -1112,7 +1112,7 @@ public function addMembers(int|array $members, string $type = 'auto', bool $perm // For historical reasons, the hook expects an array rather than just the name string. $group_names = array($this->id => $this->name); - call_integration_hook('integrate_add_members_to_group', array($members, $this->id, &$group_names)); + IntegrationHook::call('integrate_add_members_to_group', array($members, $this->id, &$group_names)); // Update their postgroup statistics. Logging::updateStats('postgroups', $members); @@ -2330,7 +2330,7 @@ public static function getCachedList() $groupCache[$row['id_group']] = '' . $row['group_name'] . ''; } - call_integration_hook('integrate_getMembergroupList', array(&$groupCache, $group)); + IntegrationHook::call('integrate_getMembergroupList', array(&$groupCache, $group)); return array( 'data' => $groupCache, diff --git a/Sources/IntegrationHook.php b/Sources/IntegrationHook.php new file mode 100644 index 00000000000..e0f7873e9ac --- /dev/null +++ b/Sources/IntegrationHook.php @@ -0,0 +1,342 @@ + array( + 'load' => false, + 'call' => 'call_integration_hook', + 'add' => 'add_integration_function', + 'remove' => 'remove_integration_function', + ), + ); + + /******************* + * Public properties + *******************/ + + /** + * @var array + * + * The name of this integration hook. + */ + public array $name; + + /** + * @var bool + * + * If true, silently skip hooked functions that are not callable. + */ + public bool $ignore_errors = false; + + /** + * @var array + * + * The results from executing this hook. + */ + public array $results = array(); + + /********************* + * Internal properties + *********************/ + + /** + * @var array + * + * The callables to execute for this hook. + */ + private array $callables = array(); + + /**************** + * Public methods + ****************/ + + /** + * Constructor. + * + * @param string $name The name of the integration hook. + * @param bool $ignore_errors If true, silently skip hooked functions that + * are not callable. Defaults to Utils::$context['ignore_hook_errors']. + */ + public function __construct(string $name, bool $ignore_errors = null) + { + if (!class_exists('SMF\\Config', false) || !class_exists('SMF\\Utils', false)) + return; + + $this->ignore_errors = $ignore_errors ?? !empty(Utils::$context['ignore_hook_errors']); + + if (Config::$db_show_debug === true) + Utils::$context['debug']['hooks'][] = $name; + + if (empty(Config::$modSettings[$name])) + return; + + $func_strings = explode(',', Config::$modSettings[$name]); + + // Loop through each one to get the callable for it. + foreach ($func_strings as $func_string) + { + // Hook has been marked as disabled. Skip it! + if (strpos($func_string, '!') !== false) + continue; + + $this->callables[$func_string] = call_helper($func_string, true); + } + } + + /** + * Executes all the callables in $this->callables, passing the $parameters + * to each one. + * + * @param array $parameters Parameters to pass to the hooked callables. + * @return array The results returned by all the hooked callables. + */ + public function execute(array $parameters = array()): array + { + if (empty($this->callables)) + return $this->results; + + // Loop through each callable. + foreach ($this->callables as $func_string => $callable) + { + // Is it valid? + if (is_callable($callable)) + { + $this->results[$func_string] = call_user_func_array($callable, $parameters); + } + // This failed, but we want to do so silently. + elseif ($this->ignore_errors) + { + // return $this->results; + continue; + } + // Whatever it was supposed to call, it failed :( + else + { + Lang::load('Errors'); + + // Get a full path to show on error. + if (strpos($func_string, '|') !== false) + { + list($file, $func) = explode('|', $func_string); + + $path = strtr($file, array( + '$boarddir' => Config::$boarddir, + '$sourcedir' => Config::$sourcedir, + )); + + if (strpos($path, '$themedir') !== false && class_exists('SMF\\Theme', false) && !empty(Theme::$current->settings['theme_dir'])) + { + $path = strtr($path, array( + '$themedir' => Theme::$current->settings['theme_dir'], + )); + } + + ErrorHandler::log(sprintf(Lang::$txt['hook_fail_call_to'], $func, $path), 'general'); + } + // Assume the file resides on Config::$boarddir somewhere... + else + { + ErrorHandler::log(sprintf(Lang::$txt['hook_fail_call_to'], $func_string, Config::$boarddir), 'general'); + } + } + } + + return $this->results; + } + + /*********************** + * Public static methods + ***********************/ + + /** + * Convenience method to create and execute an instance of this class. + * + * @param string $name The name of the integration hook. + * @param array $parameters Parameters to pass to the hooked callables. + * @return array The results returned by all the hooked callables. + */ + public static function call($name, $parameters = array()): array + { + $hook = new self($name); + return $hook->execute($parameters); + } + + /** + * Adds a function or method to an integration hook. + * + * Does nothing if the function is already added. + * Cleans up enabled/disabled variants before taking requested action. + * + * @param string $name The complete hook name. + * @param string $function The function name. Can be a call to a method via + * Class::method. + * @param bool $permanent If true, updates the value in settings table. + * @param string $file The filename. Must include one of the following + * wildcards: $boarddir, $sourcedir, $themedir. + * Example: $sourcedir/Test.php + * @param bool $object Indicates if your class will be instantiated when its + * respective hook is called. If true, your function must be a method. + */ + public static function add(string $name, string $function, bool $permanent = true, string $file = '', bool $object = false): void + { + // Any objects? + if ($object) + $function = $function . '#'; + + // Any files to load? + if (!empty($file) && is_string($file)) + $function = $file . (!empty($function) ? '|' . $function : ''); + + // Get the correct string. + $integration_call = $function; + $enabled_call = rtrim($function, '!'); + $disabled_call = $enabled_call . '!'; + + // Is it going to be permanent? + if ($permanent) + { + $request = Db::$db->query('', ' + SELECT value + FROM {db_prefix}settings + WHERE variable = {string:variable}', + array( + 'variable' => $name, + ) + ); + list($current_functions) = Db::$db->fetch_row($request); + Db::$db->free_result($request); + + if (!empty($current_functions)) + { + $current_functions = explode(',', $current_functions); + + // Cleanup enabled/disabled variants before taking action. + $current_functions = array_diff($current_functions, array($enabled_call, $disabled_call)); + + $permanent_functions = array_unique(array_merge($current_functions, array($integration_call))); + } + else + { + $permanent_functions = array($integration_call); + } + + Config::updateModSettings(array($name => implode(',', $permanent_functions))); + } + + // Make current function list usable. + $functions = empty(Config::$modSettings[$name]) ? array() : explode(',', Config::$modSettings[$name]); + + // Cleanup enabled/disabled variants before taking action. + $functions = array_diff($functions, array($enabled_call, $disabled_call)); + $functions = array_unique(array_merge($functions, array($integration_call))); + + Config::$modSettings[$name] = implode(',', $functions); + + // It is handy to be able to know which hooks are temporary... + if ($permanent !== true) + { + if (!isset(Utils::$context['integration_hooks_temporary'])) + Utils::$context['integration_hooks_temporary'] = array(); + + Utils::$context['integration_hooks_temporary'][$name][$function] = true; + } + } + + /** + * Removes an integration hook function. + * + * Removes the given function from the given hook. + * Does nothing if the function is not available. + * Cleans up enabled/disabled variants before taking requested action. + * + * @see IntegrationHook:add + * + * @param string $name The complete hook name. + * @param string $function The function name. Can be a call to a method via + * Class::method. + * @param bool $permanent Irrelevant for the function itself but need to + * declare it to match. + * @param string $file The filename. Must include one of the following + * wildcards: $boarddir, $sourcedir, $themedir. + * Example: $sourcedir/Test.php + * @param bool $object Indicates if your class will be instantiated when its + * respective hook is called. If true, your function must be a method. + */ + public static function remove(string $name, string $function, bool $permanent = true, string $file = '', bool $object = false): void + { + // Any objects? + if ($object) + $function = $function . '#'; + + // Any files to load? + if (!empty($file) && is_string($file)) + $function = $file . '|' . $function; + + // Get the correct string. + $integration_call = $function; + $enabled_call = rtrim($function, '!'); + $disabled_call = $enabled_call . '!'; + + // Get the permanent functions. + $request = Db::$db->query('', ' + SELECT value + FROM {db_prefix}settings + WHERE variable = {string:variable}', + array( + 'variable' => $name, + ) + ); + list($current_functions) = Db::$db->fetch_row($request); + Db::$db->free_result($request); + + if (!empty($current_functions)) + { + $current_functions = explode(',', $current_functions); + + // Cleanup enabled and disabled variants. + $current_functions = array_unique(array_diff($current_functions, array($enabled_call, $disabled_call))); + + Config::updateModSettings(array($name => implode(',', $current_functions))); + } + + // Turn the function list into something usable. + $functions = empty(Config::$modSettings[$name]) ? array() : explode(',', Config::$modSettings[$name]); + + // Cleanup enabled and disabled variants. + $functions = array_unique(array_diff($functions, array($enabled_call, $disabled_call))); + + Config::$modSettings[$name] = implode(',', $functions); + } +} + +// Export public static functions and properties to global namespace for backward compatibility. +if (is_callable(__NAMESPACE__ . '\IntegrationHook::exportStatic')) + IntegrationHook::exportStatic(); + +?> \ No newline at end of file diff --git a/Sources/ItemList.php b/Sources/ItemList.php index 60bf40e3784..6faf58efd70 100644 --- a/Sources/ItemList.php +++ b/Sources/ItemList.php @@ -195,7 +195,7 @@ public function __construct(array $options) if (!$this->checkOptions($options)) return; - call_integration_hook('integrate_' . $options['id'], array(&$options)); + IntegrationHook::call('integrate_' . $options['id'], array(&$options)); // Check again just in case a mod screwed up. if (!$this->checkOptions($options)) diff --git a/Sources/Lang.php b/Sources/Lang.php index c57e51f7779..cec1ad957c6 100644 --- a/Sources/Lang.php +++ b/Sources/Lang.php @@ -458,7 +458,7 @@ public static function censorText(&$text, $force = false) if ((!empty(Theme::$current->options['show_no_censored']) && !empty(Config::$modSettings['allow_no_censored']) && !$force) || empty(Config::$modSettings['censor_vulgar']) || !is_string($text) || trim($text) === '') return $text; - call_integration_hook('integrate_word_censor', array(&$text)); + IntegrationHook::call('integrate_word_censor', array(&$text)); // If they haven't yet been loaded, load them. if ($censor_vulgar == null) diff --git a/Sources/Logging.php b/Sources/Logging.php index d59eb088908..09f321ba4e1 100644 --- a/Sources/Logging.php +++ b/Sources/Logging.php @@ -90,7 +90,7 @@ public static function logActions(array $logs): int ); $always_log = array('agreement_accepted', 'policy_accepted', 'agreement_updated', 'policy_updated'); - call_integration_hook('integrate_log_types', array(&$log_types, &$always_log)); + IntegrationHook::call('integrate_log_types', array(&$log_types, &$always_log)); foreach ($logs as $log) { @@ -784,7 +784,7 @@ public static function getMembersOnlineStats($membersOnlineOptions) // Hidden and non-hidden members make up all online members. $membersOnlineStats['num_users_online'] = count($membersOnlineStats['users_online']) + $membersOnlineStats['num_users_hidden'] - (isset(Config::$modSettings['show_spider_online']) && Config::$modSettings['show_spider_online'] > 1 ? count($spider_finds) : 0); - call_integration_hook('integrate_online_stats', array(&$membersOnlineStats)); + IntegrationHook::call('integrate_online_stats', array(&$membersOnlineStats)); return $membersOnlineStats; } diff --git a/Sources/Mail.php b/Sources/Mail.php index 9fca65c9a10..53df88b51dc 100644 --- a/Sources/Mail.php +++ b/Sources/Mail.php @@ -137,7 +137,7 @@ public static function send($to, $subject, $message, $from = null, $message_id = $headers .= 'X-Mailer: SMF' . $line_break; // Pass this to the integration before we start modifying the output -- it'll make it easier later. - if (in_array(false, call_integration_hook('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) + if (in_array(false, IntegrationHook::call('integrate_outgoing_email', array(&$subject, &$message, &$headers, &$to_array)), true)) return false; // Save the original message... diff --git a/Sources/Mentions.php b/Sources/Mentions.php index bb017b42cd7..4f704860fb9 100644 --- a/Sources/Mentions.php +++ b/Sources/Mentions.php @@ -89,15 +89,17 @@ public static function getMentionsByContent($content_type, $content_id, array $m */ public static function insertMentions($content_type, $content_id, array $members, $id_member) { - call_integration_hook('mention_insert_' . $content_type, array($content_id, &$members)); + IntegrationHook::call('mention_insert_' . $content_type, array($content_id, &$members)); foreach ($members as $member) + { Db::$db->insert('ignore', '{db_prefix}mentions', array('content_id' => 'int', 'content_type' => 'string', 'id_member' => 'int', 'id_mentioned' => 'int', 'time' => 'int'), array((int) $content_id, $content_type, $id_member, $member['id'], time()), array('content_id', 'content_type', 'id_mentioned') ); + } } /** diff --git a/Sources/Menu.php b/Sources/Menu.php index bc703139552..aa7014e0e2f 100644 --- a/Sources/Menu.php +++ b/Sources/Menu.php @@ -312,7 +312,7 @@ public function __construct(array $data, array $options = array()) */ if (!empty($this->current_action) && empty($this->options['disable_hook_call'])) { - call_integration_hook('integrate_' . $this->current_action . '_areas', array(&$this->data)); + IntegrationHook::call('integrate_' . $this->current_action . '_areas', array(&$this->data)); } // Should we use a custom base url, or use the default? diff --git a/Sources/Msg.php b/Sources/Msg.php index 97f9f0bdc75..1c4fdd00c29 100644 --- a/Sources/Msg.php +++ b/Sources/Msg.php @@ -513,7 +513,7 @@ public function format(int $counter = 0, array $format_options = array()): array } } - call_integration_hook('integrate_format_msg', array(&$this->formatted, $this->id)); + IntegrationHook::call('integrate_format_msg', array(&$this->formatted, $this->id)); return $this->formatted; } @@ -600,7 +600,7 @@ public static function get($ids, array $query_customizations = array()) // Just FYI, for historical reasons the order in which the arguments are // passed to this hook is different than the order in which they are // passed to the queryData() method. - call_integration_hook('integrate_query_message', array(&$selects, &$joins, &$params, &$where, &$order, &$limit)); + IntegrationHook::call('integrate_query_message', array(&$selects, &$joins, &$params, &$where, &$order, &$limit)); foreach(self::queryData($selects, $params, $joins, $where, $order, $limit) as $row) { @@ -923,7 +923,7 @@ function($m) $message = strtr($message, array('[]' => '[]', '['' => '['')); // Any hooks want to work here? - call_integration_hook('integrate_preparsecode', array(&$message, $previewing)); + IntegrationHook::call('integrate_preparsecode', array(&$message, $previewing)); } /** @@ -935,7 +935,7 @@ function($m) public static function un_preparsecode($message): string { // Any hooks want to work here? - call_integration_hook('integrate_unpreparsecode', array(&$message)); + IntegrationHook::call('integrate_unpreparsecode', array(&$message)); $parts = preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i', $message, -1, PREG_SPLIT_DELIM_CAPTURE); @@ -1419,7 +1419,7 @@ public static function create(&$msgOptions, &$topicOptions, &$posterOptions): bo ); // What if we want to do anything with posts? - call_integration_hook('integrate_create_post', array(&$msgOptions, &$topicOptions, &$posterOptions, &$message_columns, &$message_parameters)); + IntegrationHook::call('integrate_create_post', array(&$msgOptions, &$topicOptions, &$posterOptions, &$message_columns, &$message_parameters)); // Insert the post. $msgOptions['id'] = Db::$db->insert('', @@ -1449,7 +1449,7 @@ public static function create(&$msgOptions, &$topicOptions, &$posterOptions): bo } // What if we want to export new posts out to a CMS? - call_integration_hook('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); + IntegrationHook::call('integrate_after_create_post', array($msgOptions, $topicOptions, $posterOptions, $message_columns, $message_parameters)); // Insert a new topic (if the topicID was left empty.) if ($new_topic) @@ -1468,7 +1468,7 @@ public static function create(&$msgOptions, &$topicOptions, &$posterOptions): bo $topicOptions['redirect_expires'] === null ? 0 : $topicOptions['redirect_expires'], $topicOptions['redirect_topic'] === null ? 0 : $topicOptions['redirect_topic'], ); - call_integration_hook('integrate_before_create_topic', array(&$msgOptions, &$topicOptions, &$posterOptions, &$topic_columns, &$topic_parameters)); + IntegrationHook::call('integrate_before_create_topic', array(&$msgOptions, &$topicOptions, &$posterOptions, &$topic_columns, &$topic_parameters)); $topicOptions['id'] = Db::$db->insert('', '{db_prefix}topics', @@ -1511,7 +1511,7 @@ public static function create(&$msgOptions, &$topicOptions, &$posterOptions): bo Logging::updateStats('subject', $topicOptions['id'], $msgOptions['subject']); // What if we want to export new topics out to a CMS? - call_integration_hook('integrate_create_topic', array(&$msgOptions, &$topicOptions, &$posterOptions)); + IntegrationHook::call('integrate_create_topic', array(&$msgOptions, &$topicOptions, &$posterOptions)); } // The topic already exists, it only needs a little updating. else @@ -1546,7 +1546,7 @@ public static function create(&$msgOptions, &$topicOptions, &$posterOptions): bo if ($topicOptions['sticky_mode'] !== null) $topics_columns[] = 'is_sticky = {int:is_sticky}'; - call_integration_hook('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); + IntegrationHook::call('integrate_modify_topic', array(&$topics_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions)); // Update the number of replies and the lock/sticky status. Db::$db->query('', ' @@ -1843,7 +1843,7 @@ public static function modify(&$msgOptions, &$topicOptions, &$posterOptions): bo $msgOptions['send_notifications'] = isset($msgOptions['send_notifications']) ? (bool) $msgOptions['send_notifications'] : true; // Maybe a mod wants to make some changes? - call_integration_hook('integrate_modify_post', array(&$messages_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions, &$messageInts)); + IntegrationHook::call('integrate_modify_post', array(&$messages_columns, &$update_parameters, &$msgOptions, &$topicOptions, &$posterOptions, &$messageInts)); foreach ($messages_columns as $var => $val) { @@ -2268,7 +2268,7 @@ public static function approve($msgs, $approve = true, $notify = true): bool } // In case an external CMS needs to know about this approval/unapproval. - call_integration_hook('integrate_after_approve_posts', array($approve, $msgs, $topic_changes, $member_post_changes)); + IntegrationHook::call('integrate_after_approve_posts', array($approve, $msgs, $topic_changes, $member_post_changes)); return true; } @@ -2509,7 +2509,7 @@ public static function remove($message, $decreasePostCount = true) Db::$db->free_result($request); // Give mods a heads-up before we do anything. - call_integration_hook('integrate_pre_remove_message', array($message, $decreasePostCount, $row)); + IntegrationHook::call('integrate_pre_remove_message', array($message, $decreasePostCount, $row)); if (empty(Board::$info->id) || $row['id_board'] != Board::$info->id) { @@ -2934,7 +2934,7 @@ public static function remove($message, $decreasePostCount = true) } // Allow mods to remove message related data of their own (likes, maybe?) - call_integration_hook('integrate_remove_message', array($message, $row, $recycle)); + IntegrationHook::call('integrate_remove_message', array($message, $row, $recycle)); // Update the pesky statistics. Logging::updateStats('message'); diff --git a/Sources/PackageManager/PackageManager.php b/Sources/PackageManager/PackageManager.php index ac2be2e9a5a..d1118f4f260 100644 --- a/Sources/PackageManager/PackageManager.php +++ b/Sources/PackageManager/PackageManager.php @@ -16,6 +16,7 @@ use SMF\BBCodeParser; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\ItemList; use SMF\Lang; use SMF\Logging; @@ -1137,9 +1138,13 @@ public function install() Utils::$context['ignore_hook_errors'] = true; if ($action['reverse']) - remove_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); + { + IntegrationHook::remove($action['hook'], $action['function'], true, $action['include_file'], $action['object']); + } else - add_integration_function($action['hook'], $action['function'], true, $action['include_file'], $action['object']); + { + IntegrationHook::add($action['hook'], $action['function'], true, $action['include_file'], $action['object']); + } } // Only do the database changes on uninstall if requested. elseif ($action['type'] == 'database' && !empty($action['filename']) && (!Utils::$context['uninstalling'] || !empty($_POST['do_db_changes']))) @@ -1493,7 +1498,7 @@ public function browse() Utils::$context['available_packages'] = 0; Utils::$context['modification_types'] = array('modification', 'avatar', 'language', 'unknown', 'smiley'); - call_integration_hook('integrate_modification_types'); + IntegrationHook::call('integrate_modification_types'); foreach (Utils::$context['modification_types'] as $type) { @@ -2907,7 +2912,7 @@ public function download() Utils::$context['package']['install']['link'] = '[ ' . (isset(Lang::$txt['install_' . Utils::$context['package']['type']]) ? Lang::$txt['install_' . Utils::$context['package']['type']] : Lang::$txt['install_unknown']) . ' ]'; // Does a 3rd party hook want to do some additional changes? - call_integration_hook('integrate_package_download'); + IntegrationHook::call('integrate_package_download'); Utils::$context['package']['list_files']['link'] = '[ ' . Lang::$txt['list_files'] . ' ]'; @@ -2993,7 +2998,7 @@ public function upload() Utils::$context['package']['install']['link'] = '[ ' . (isset(Lang::$txt['install_' . Utils::$context['package']['type']]) ? Lang::$txt['install_' . Utils::$context['package']['type']] : Lang::$txt['install_unknown']) . ' ]'; // Does a 3rd party hook want to do some additional changes? - call_integration_hook('integrate_package_upload'); + IntegrationHook::call('integrate_package_upload'); Utils::$context['package']['list_files']['link'] = '[ ' . Lang::$txt['list_files'] . ' ]'; @@ -3129,7 +3134,7 @@ public function list_getPackages($start, $items_per_page, $sort, $params) 'unknown' => 1, 'smiley' => 1, ); - call_integration_hook('integrate_packages_sort_id', array(&$sort_id, &$packages)); + IntegrationHook::call('integrate_packages_sort_id', array(&$sort_id, &$packages)); while ($package = readdir($dir)) { @@ -3313,7 +3318,7 @@ protected function __construct() // Backward compatibility for deprecated integrate_package_get hook. $temp = array_map(function($sa) {return $this->subactions[$sa];}, $this->packageget_subactions); - call_integration_hook('integrate_package_get', array(&$temp)); + IntegrationHook::call('integrate_package_get', array(&$temp)); foreach ($temp as $sa => $func) $this->subactions[isset($this->packageget_subactions[$sa]) ? $this->packageget_subactions[$sa] : $sa] = $func; } @@ -3323,7 +3328,7 @@ protected function __construct() } // Give mods access to the sub-actions. - call_integration_hook('integrate_manage_packages', array(&$this->subactions)); + IntegrationHook::call('integrate_manage_packages', array(&$this->subactions)); } /** diff --git a/Sources/PersonalMessage/Folder.php b/Sources/PersonalMessage/Folder.php index 4855df148e9..c4314d0115e 100644 --- a/Sources/PersonalMessage/Folder.php +++ b/Sources/PersonalMessage/Folder.php @@ -15,6 +15,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\PageIndex; use SMF\Theme; @@ -247,7 +248,7 @@ public function prepareMessageContext($type = 'subject', $check = false) $output = $message->format($counter++, $format_options); - call_integration_hook('integrate_prepare_pm_context', array(&$output, &$message, $counter)); + IntegrationHook::call('integrate_prepare_pm_context', array(&$output, &$message, $counter)); return $output; } @@ -526,7 +527,7 @@ protected function showConversation(): array ); // Allow mods to add additional buttons here - call_integration_hook('integrate_conversation_buttons'); + IntegrationHook::call('integrate_conversation_buttons'); return array_keys($conversation->pms); } diff --git a/Sources/PersonalMessage/PM.php b/Sources/PersonalMessage/PM.php index 75204745805..26ef4178d8b 100644 --- a/Sources/PersonalMessage/PM.php +++ b/Sources/PersonalMessage/PM.php @@ -20,6 +20,7 @@ use SMF\Config; use SMF\Editor; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Group; use SMF\Lang; use SMF\Mail; @@ -848,7 +849,7 @@ public static function compose(): void if (Utils::$context['require_verification']) $verifier = new Verifier(array('id' => 'pm')); - call_integration_hook('integrate_pm_post'); + IntegrationHook::call('integrate_pm_post'); // Register this form and get a sequence number in Utils::$context. Security::checkSubmitOnce('register'); @@ -1229,7 +1230,7 @@ public static function send($recipients, $subject, $message, $store_outbox = fal $recipients = array($recipients); // Integrated PMs - call_integration_hook('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message)); + IntegrationHook::call('integrate_personal_message', array(&$recipients, &$from, &$subject, &$message)); // Get a list of usernames and convert them to IDs. $usernames = array(); @@ -1632,7 +1633,7 @@ public static function send($recipients, $subject, $message, $store_outbox = fal } // Integrated After PMs - call_integration_hook('integrate_personal_message_after', array(&$id_pm, &$log, &$recipients, &$from, &$subject, &$message)); + IntegrationHook::call('integrate_personal_message_after', array(&$id_pm, &$log, &$recipients, &$from, &$subject, &$message)); // Back to what we were on before! Lang::load('index+PersonalMessage'); @@ -2238,7 +2239,7 @@ public static function reportErrors(array $error_types, array $named_recipients, Utils::$context['bcc_value'] = empty($named_recipients['bcc']) ? '' : '"' . implode('", "', $named_recipients['bcc']) . '"'; - call_integration_hook('integrate_pm_error'); + IntegrationHook::call('integrate_pm_error'); // No check for the previous submission is needed. Security::checkSubmitOnce('free'); diff --git a/Sources/PersonalMessage/Search.php b/Sources/PersonalMessage/Search.php index f64a34411b2..15edeb8f20a 100644 --- a/Sources/PersonalMessage/Search.php +++ b/Sources/PersonalMessage/Search.php @@ -16,6 +16,7 @@ use SMF\Category; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Menu; use SMF\PageIndex; @@ -335,7 +336,7 @@ public function performSearch(): void // If mods want access to the general context values, let them do that now. // MOD AUTHORS: If you need access to the messages themselves, use the // integrate_pm_search_result hook. - call_integration_hook('integrate_search_pm_context'); + IntegrationHook::call('integrate_search_pm_context'); // Set up our generator so that the template can loop through the results. Utils::$context['personal_messages'] = SearchResult::getFormatted(Utils::$context['messages']); diff --git a/Sources/PersonalMessage/SearchResult.php b/Sources/PersonalMessage/SearchResult.php index 382af8912a0..e605cded1ee 100644 --- a/Sources/PersonalMessage/SearchResult.php +++ b/Sources/PersonalMessage/SearchResult.php @@ -13,6 +13,7 @@ namespace SMF\PersonalMessage; +use SMF\IntegrationHook; use SMF\Search\SearchResult as SR; /** @@ -39,7 +40,7 @@ public static function getFormatted($ids, array $query_customizations = array()) unset($output['quickbuttons']['quickmod']); - call_integration_hook('integrate_pm_search_result', array(&$output)); + IntegrationHook::call('integrate_pm_search_result', array(&$output)); yield $output; } diff --git a/Sources/Poll.php b/Sources/Poll.php index 380dcd03b05..c6138b97bb5 100644 --- a/Sources/Poll.php +++ b/Sources/Poll.php @@ -526,7 +526,7 @@ public function format(array $format_options = array()): array } // Allow mods to add additional buttons here - call_integration_hook('integrate_poll_buttons'); + IntegrationHook::call('integrate_poll_buttons'); return $this->formatted; } @@ -670,7 +670,7 @@ public function save(): void } // Let mods know that this poll has been added or edited. - call_integration_hook('integrate_poll_add_edit', array($this->id, $is_edit)); + IntegrationHook::call('integrate_poll_add_edit', array($this->id, $is_edit)); } /** @@ -1065,7 +1065,7 @@ public static function vote(): void ); // Let mods know about this vote. - call_integration_hook('integrate_poll_vote', array($poll->id, $choices)); + IntegrationHook::call('integrate_poll_vote', array($poll->id, $choices)); // Return to the post... Utils::redirectexit('topic=' . Topic::$topic_id . '.' . (int) ($_REQUEST['start'] ?? 0)); @@ -1407,7 +1407,7 @@ public static function remove() ); // Let mods know that this poll has been removed. - call_integration_hook('integrate_poll_remove', array($poll->id)); + IntegrationHook::call('integrate_poll_remove', array($poll->id)); // Log this! Logging::logAction('remove_poll', array('topic' => Topic::$topic_id)); diff --git a/Sources/Profile.php b/Sources/Profile.php index 165b94da302..702f059e6c5 100644 --- a/Sources/Profile.php +++ b/Sources/Profile.php @@ -608,7 +608,7 @@ public function loadStandardFields(bool $force_reload = false) User::updateMemberData($this->id, array('member_name' => $value)); // Call this here so any integrated systems will know about the name change (resetPassword() takes care of this if we're letting SMF generate the password) - call_integration_hook('integrate_reset_pass', array($this->username, $value, $_POST['passwrd1'])); + IntegrationHook::call('integrate_reset_pass', array($this->username, $value, $_POST['passwrd1'])); } } return false; @@ -1021,7 +1021,7 @@ public function loadStandardFields(bool $force_reload = false) ), ); - call_integration_hook('integrate_load_profile_fields', array(&$this->standard_fields)); + IntegrationHook::call('integrate_load_profile_fields', array(&$this->standard_fields)); $disabled_fields = !empty(Config::$modSettings['disabled_profile_fields']) ? explode(',', Config::$modSettings['disabled_profile_fields']) : array(); @@ -1207,7 +1207,7 @@ public function loadCustomFields(string $area = 'summary'): void Utils::$context['custom_fields'] = &$this->custom_fields; Utils::$context['custom_fields_required'] = &$this->custom_fields_required; - call_integration_hook('integrate_load_custom_profile_fields', array($this->id, $area)); + IntegrationHook::call('integrate_load_custom_profile_fields', array($this->id, $area)); } /** @@ -1469,7 +1469,7 @@ public function setupContext(array $fields): void Utils::$context['profile_javascript'] = ''; Utils::$context['profile_onsubmit_javascript'] = ''; - call_integration_hook('integrate_setup_profile_context', array(&$fields)); + IntegrationHook::call('integrate_setup_profile_context', array(&$fields)); // Make sure we have this! $this->loadStandardFields(true); @@ -1601,7 +1601,7 @@ public function save() $this->prepareToSaveCustomFields($_REQUEST['sa'] ?? null); // Give hooks some access to the save data. - call_integration_hook('integrate_profile_save', array(&Profile::$member->new_data, &Profile::$member->save_errors, Profile::$member->id, Profile::$member->data, Menu::$loaded['profile']->current_area)); + IntegrationHook::call('integrate_profile_save', array(&Profile::$member->new_data, &Profile::$member->save_errors, Profile::$member->id, Profile::$member->data, Menu::$loaded['profile']->current_area)); // There was a problem. Let them try again. if (!empty($this->save_errors)) @@ -1619,7 +1619,7 @@ public function save() // If we've changed the password, notify any integration that may be listening in. if (isset($this->new_data['passwd'])) { - call_integration_hook('integrate_reset_pass', array($this->username, $this->username, $_POST['passwrd2'])); + IntegrationHook::call('integrate_reset_pass', array($this->username, $this->username, $_POST['passwrd2'])); } parent::updateMemberData($this->id, $this->new_data); @@ -1822,7 +1822,7 @@ public function validateGroups(int &$value, array $additional_groups = array()): } // Announce to any hooks that we have changed groups, but don't allow them to change it. - call_integration_hook('integrate_profile_profileSaveGroups', array($value, $additional_groups)); + IntegrationHook::call('integrate_profile_profileSaveGroups', array($value, $additional_groups)); return true; } @@ -1841,7 +1841,7 @@ public function validateAvatarData(string &$value): bool|string if (empty($this->id) && !empty(Utils::$context['password_auth_failed'])) return false; - call_integration_hook('before_profile_save_avatar', array(&$value)); + IntegrationHook::call('before_profile_save_avatar', array(&$value)); switch ($value) { @@ -1873,7 +1873,7 @@ public function validateAvatarData(string &$value): bool|string // Setup the profile variables so it shows things right on display! $this->data['avatar'] = $this->new_data['avatar']; - call_integration_hook('after_profile_save_avatar'); + IntegrationHook::call('after_profile_save_avatar'); return false; } @@ -2654,7 +2654,7 @@ protected function prepareToSaveCustomFields(string $area = null): void // The true in the hook params replaces an obsolete $returnErrors variable. // The !self::$member->post_sanitized replaces an obsolete $sanitize variable. - $hook_errors = call_integration_hook('integrate_save_custom_profile_fields', array( + $hook_errors = IntegrationHook::call('integrate_save_custom_profile_fields', array( &$this->new_cf_data['updates'], &$this->log_changes, &$this->cf_save_errors, @@ -3202,7 +3202,7 @@ protected function resetPassword(string $username = null): void User::updateMemberData($this->id, array('passwd' => $new_password_sha1)); } - call_integration_hook('integrate_reset_pass', array($this->username, $username, $new_password)); + IntegrationHook::call('integrate_reset_pass', array($this->username, $username, $new_password)); $replacements = array( 'USERNAME' => $username, diff --git a/Sources/Search/SearchApi.php b/Sources/Search/SearchApi.php index bcd2677d2e5..ea80fff9866 100644 --- a/Sources/Search/SearchApi.php +++ b/Sources/Search/SearchApi.php @@ -16,6 +16,7 @@ use SMF\BackwardCompatibility; use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\User; use SMF\Utils; @@ -866,7 +867,7 @@ final public static function detect(): array ); } - call_integration_hook('integrate_load_search_apis', array(&$loadedApis)); + IntegrationHook::call('integrate_load_search_apis', array(&$loadedApis)); return $loadedApis; } @@ -883,7 +884,7 @@ final public static function detect(): array */ protected function calculateWeight(): void { - call_integration_hook('integrate_search_weights', array(&self::$weight_factors)); + IntegrationHook::call('integrate_search_weights', array(&self::$weight_factors)); foreach (self::$weight_factors as $weight_factor => $value) { @@ -904,7 +905,7 @@ protected function calculateWeight(): void */ protected function setBlacklistedWords(): void { - call_integration_hook('integrate_search_blacklisted_words', array(&$this->blacklisted_words)); + IntegrationHook::call('integrate_search_blacklisted_words', array(&$this->blacklisted_words)); } /** @@ -995,7 +996,7 @@ protected function setParams(): void $this->ageRecentMsg = Config::$modSettings['maxMsgID'] - $this->ageMinMsg; // *** Parse the search query - call_integration_hook('integrate_search_params', array(&$this->params)); + IntegrationHook::call('integrate_search_params', array(&$this->params)); // What are we searching for? if (empty($this->params['search'])) @@ -1472,7 +1473,7 @@ protected function setBoardQuery(): void */ protected function setSort(): void { - call_integration_hook('integrate_search_sort_columns', array(&$this->sort_columns)); + IntegrationHook::call('integrate_search_sort_columns', array(&$this->sort_columns)); if (empty($this->params['sort']) && !empty($_REQUEST['sort'])) { @@ -1584,7 +1585,7 @@ protected function searchSubjectOnly(): void } } - call_integration_hook('integrate_subject_only_search_query', array(&$subject_query, &$subject_query_params)); + IntegrationHook::call('integrate_subject_only_search_query', array(&$subject_query, &$subject_query_params)); $relevance = '1000 * ('; @@ -1883,7 +1884,7 @@ protected function searchSubjectAndMessage() } } - call_integration_hook('integrate_subject_search_query', array(&$subject_query)); + IntegrationHook::call('integrate_subject_search_query', array(&$subject_query)); // Nothing to search for? if (empty($subject_query['where'])) @@ -2143,7 +2144,7 @@ protected function searchSubjectAndMessage() } } - call_integration_hook('integrate_main_search_query', array(&$main_query)); + IntegrationHook::call('integrate_main_search_query', array(&$main_query)); // Did we either get some indexed results, or otherwise did not do an indexed query? if (!empty($indexedResults) || !$this->supportsMethod('indexedWordQuery', $this->getQueryParams())) diff --git a/Sources/Security.php b/Sources/Security.php index 45fefb7e3cd..45c0b1aaffb 100644 --- a/Sources/Security.php +++ b/Sources/Security.php @@ -206,7 +206,7 @@ public static function spamProtection(string $error_type, bool $only_return_resu 'search' => !empty(Config::$modSettings['search_floodcontrol_time']) ? Config::$modSettings['search_floodcontrol_time'] : 1, ); - call_integration_hook('integrate_spam_protection', array(&$timeOverrides)); + IntegrationHook::call('integrate_spam_protection', array(&$timeOverrides)); // Moderators are free... if (!User::$me->allowedTo('moderate_board')) diff --git a/Sources/ServerSideIncludes.php b/Sources/ServerSideIncludes.php index f719234540b..7d32ce4d5d1 100644 --- a/Sources/ServerSideIncludes.php +++ b/Sources/ServerSideIncludes.php @@ -528,7 +528,7 @@ public static function queryPosts($query_where = '', $query_where_params = array Db::$db->free_result($request); // If mods want to do something with this list of posts, let them do that now. - call_integration_hook('integrate_ssi_queryPosts', array(&$posts)); + IntegrationHook::call('integrate_ssi_queryPosts', array(&$posts)); // Just return it. if ($output_method != 'echo' || empty($posts)) @@ -699,7 +699,7 @@ public static function recentTopics($num_recent = 8, $exclude_boards = null, $in Db::$db->free_result($request); // If mods want to do something with this list of topics, let them do that now. - call_integration_hook('integrate_ssi_recentTopics', array(&$posts)); + IntegrationHook::call('integrate_ssi_recentTopics', array(&$posts)); // Just return it. if ($output_method != 'echo' || empty($posts)) @@ -761,7 +761,7 @@ public static function topPoster($topNumber = 1, $output_method = 'echo') Db::$db->free_result($request); // If mods want to do something with this list of members, let them do that now. - call_integration_hook('integrate_ssi_topPoster', array(&$return)); + IntegrationHook::call('integrate_ssi_topPoster', array(&$return)); // Just return all the top posters. if ($output_method != 'echo') @@ -819,7 +819,7 @@ public static function topBoards($num_top = 10, $output_method = 'echo') Db::$db->free_result($request); // If mods want to do something with this list of boards, let them do that now. - call_integration_hook('integrate_ssi_topBoards', array(&$boards)); + IntegrationHook::call('integrate_ssi_topBoards', array(&$boards)); // If we shouldn't output or have nothing to output, just jump out. if ($output_method != 'echo' || empty($boards)) @@ -916,7 +916,7 @@ public static function topTopics($type = 'replies', $num_topics = 10, $output_me Db::$db->free_result($request); // If mods want to do something with this list of topics, let them do that now. - call_integration_hook('integrate_ssi_topTopics', array(&$topics, $type)); + IntegrationHook::call('integrate_ssi_topTopics', array(&$topics, $type)); if ($output_method != 'echo' || empty($topics)) return $topics; @@ -1153,7 +1153,7 @@ public static function queryMembers($query_where = null, $query_where_params = a return array(); // If mods want to do something with this list of members, let them do that now. - call_integration_hook('integrate_ssi_queryMembers', array(&$members)); + IntegrationHook::call('integrate_ssi_queryMembers', array(&$members)); // Load the members. User::load($members); @@ -1235,7 +1235,7 @@ public static function boardStats($output_method = 'echo') Db::$db->free_result($result); // If mods want to do something with the board stats, let them do that now. - call_integration_hook('integrate_ssi_boardStats', array(&$totals)); + IntegrationHook::call('integrate_ssi_boardStats', array(&$totals)); if ($output_method != 'echo') return $totals; @@ -1267,7 +1267,7 @@ public static function whosOnline($output_method = 'echo') $return = Logging::getMembersOnlineStats($membersOnlineOptions); // If mods want to do something with the list of who is online, let them do that now. - call_integration_hook('integrate_ssi_whosOnline', array(&$return)); + IntegrationHook::call('integrate_ssi_whosOnline', array(&$return)); // Add some redundancy for backwards compatibility reasons. if ($output_method != 'echo') @@ -1420,7 +1420,7 @@ public static function recentPoll($topPollInstead = false, $output_method = 'ech $return = $poll->format(); // If mods want to do something with this poll, let them do that now. - call_integration_hook('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); + IntegrationHook::call('integrate_ssi_recentPoll', array(&$return, $topPollInstead)); if ($output_method != 'echo') return $return; @@ -1505,7 +1505,7 @@ public static function showPoll($topic = null, $output_method = 'echo') $return = $poll->format(); // If mods want to do something with this poll, let them do that now. - call_integration_hook('integrate_ssi_showPoll', array(&$return)); + IntegrationHook::call('integrate_ssi_showPoll', array(&$return)); if ($output_method != 'echo') return $return; @@ -1716,7 +1716,7 @@ public static function news($output_method = 'echo') Utils::$context['random_news_line'] = !empty(Utils::$context['news_lines']) ? Utils::$context['news_lines'][mt_rand(0, count(Utils::$context['news_lines']) - 1)] : ''; // If mods want to do somthing with the news, let them do that now. Don't need to pass the news line itself, since it is already in Utils::$context. - call_integration_hook('integrate_ssi_news'); + IntegrationHook::call('integrate_ssi_news'); if ($output_method != 'echo') return Utils::$context['random_news_line']; @@ -1748,7 +1748,7 @@ public static function todaysBirthdays($output_method = 'echo') $return = CacheApi::quickGet('calendar_index_offset_' . User::$me->time_offset, 'Actions/Calendar.php', 'SMF\\Actions\\Calendar::cache_getRecentEvents', array($eventOptions)); // The self::todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary - call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); + IntegrationHook::call('integrate_ssi_calendar', array(&$return, $eventOptions)); if ($output_method != 'echo') return $return['calendar_birthdays']; @@ -1781,7 +1781,7 @@ public static function todaysHolidays($output_method = 'echo') $return = CacheApi::quickGet('calendar_index_offset_' . User::$me->time_offset, 'Actions/Calendar.php', 'SMF\\Actions\\Calendar::cache_getRecentEvents', array($eventOptions)); // The self::todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary - call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); + IntegrationHook::call('integrate_ssi_calendar', array(&$return, $eventOptions)); if ($output_method != 'echo') return $return['calendar_holidays']; @@ -1813,7 +1813,7 @@ public static function todaysEvents($output_method = 'echo') $return = CacheApi::quickGet('calendar_index_offset_' . User::$me->time_offset, 'Actions/Calendar.php', 'SMF\\Actions\\Calendar::cache_getRecentEvents', array($eventOptions)); // The self::todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary - call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); + IntegrationHook::call('integrate_ssi_calendar', array(&$return, $eventOptions)); if ($output_method != 'echo') return $return['calendar_events']; @@ -1853,7 +1853,7 @@ public static function todaysCalendar($output_method = 'echo') $return = CacheApi::quickGet('calendar_index_offset_' . User::$me->time_offset, 'Actions/Calendar.php', 'SMF\\Actions\\Calendar::cache_getRecentEvents', array($eventOptions)); // The self::todaysCalendar variants all use the same hook and just pass on $eventOptions so the hooked code can distinguish different cases if necessary - call_integration_hook('integrate_ssi_calendar', array(&$return, $eventOptions)); + IntegrationHook::call('integrate_ssi_calendar', array(&$return, $eventOptions)); if ($output_method != 'echo') return $return; @@ -2080,7 +2080,7 @@ public static function boardNews($board = null, $limit = null, $start = null, $l $return[count($return) - 1]['is_last'] = true; // If mods want to do something with this list of posts, let them do that now. - call_integration_hook('integrate_ssi_boardNews', array(&$return)); + IntegrationHook::call('integrate_ssi_boardNews', array(&$return)); if ($output_method != 'echo') return $return; @@ -2223,7 +2223,7 @@ public static function recentEvents($max_events = 7, $output_method = 'echo') $return[$mday][count($array) - 1]['is_last'] = true; // If mods want to do something with this list of events, let them do that now. - call_integration_hook('integrate_ssi_recentEvents', array(&$return)); + IntegrationHook::call('integrate_ssi_recentEvents', array(&$return)); if ($output_method != 'echo' || empty($return)) return $return; @@ -2378,7 +2378,7 @@ public static function recentAttachments($num_attachments = 10, $attachment_ext Db::$db->free_result($request); // If mods want to do something with this list of attachments, let them do that now. - call_integration_hook('integrate_ssi_recentAttachments', array(&$attachments)); + IntegrationHook::call('integrate_ssi_recentAttachments', array(&$attachments)); // So you just want an array? Here you can have it. if ($output_method == 'array' || empty($attachments)) @@ -2548,7 +2548,7 @@ public function __construct() $_SESSION['USER_AGENT'] = $_SERVER['HTTP_USER_AGENT']; // Have the ability to easily add functions to SSI. - call_integration_hook('integrate_SSI'); + IntegrationHook::call('integrate_SSI'); self::$setup_done = true; } diff --git a/Sources/Session.php b/Sources/Session.php index ea28fe20bf8..963cc5507d3 100644 --- a/Sources/Session.php +++ b/Sources/Session.php @@ -199,7 +199,7 @@ public static function load(): void @ini_set('arg_separator.output', '&'); // Allows mods to change/add PHP settings - call_integration_hook('integrate_load_session'); + IntegrationHook::call('integrate_load_session'); if (!empty(Config::$modSettings['globalCookies'])) { @@ -248,7 +248,7 @@ public static function load(): void // Use cache setting sessions? if (empty(Config::$modSettings['databaseSession_enable']) && !empty(CacheApi::$enable) && php_sapi_name() != 'cli') { - call_integration_hook('integrate_session_handlers'); + IntegrationHook::call('integrate_session_handlers'); } session_start(); diff --git a/Sources/Subs.php b/Sources/Subs.php index 80486c7e0f0..df8cb933afd 100644 --- a/Sources/Subs.php +++ b/Sources/Subs.php @@ -38,6 +38,7 @@ class_exists('SMF\\Attachment'); class_exists('SMF\\BBCodeParser'); +class_exists('SMF\\IntegrationHook'); class_exists('SMF\\Image'); class_exists('SMF\\Logging'); class_exists('SMF\\PageIndex'); @@ -84,200 +85,6 @@ function permute($array) return $orders; } -/** - * Process functions of an integration hook. - * calls all functions of the given hook. - * supports static class method calls. - * - * @param string $hook The hook name - * @param array $parameters An array of parameters this hook implements - * @return array The results of the functions - */ -function call_integration_hook($hook, $parameters = array()) -{ - if (!class_exists('SMF\\Utils', false)) - return; - - if (Config::$db_show_debug === true) - Utils::$context['debug']['hooks'][] = $hook; - - // Need to have some control. - if (!isset(Utils::$context['instances'])) - Utils::$context['instances'] = array(); - - $results = array(); - if (empty(Config::$modSettings[$hook])) - return $results; - - $functions = explode(',', Config::$modSettings[$hook]); - // Loop through each function. - foreach ($functions as $function) - { - // Hook has been marked as "disabled". Skip it! - if (strpos($function, '!') !== false) - continue; - - $call = call_helper($function, true); - - // Is it valid? - if (!empty($call)) - $results[$function] = call_user_func_array($call, $parameters); - // This failed, but we want to do so silently. - elseif (!empty($function) && !empty(Utils::$context['ignore_hook_errors'])) - return $results; - // Whatever it was suppose to call, it failed :( - elseif (!empty($function)) - { - Lang::load('Errors'); - - // Get a full path to show on error. - if (strpos($function, '|') !== false) - { - list ($file, $string) = explode('|', $function); - $absPath = empty(Theme::$current->settings['theme_dir']) ? (strtr(trim($file), array('$boarddir' => Config::$boarddir, '$sourcedir' => Config::$sourcedir))) : (strtr(trim($file), array('$boarddir' => Config::$boarddir, '$sourcedir' => Config::$sourcedir, '$themedir' => Theme::$current->settings['theme_dir']))); - ErrorHandler::log(sprintf(Lang::$txt['hook_fail_call_to'], $string, $absPath), 'general'); - } - // "Assume" the file resides on Config::$boarddir somewhere... - else - ErrorHandler::log(sprintf(Lang::$txt['hook_fail_call_to'], $function, Config::$boarddir), 'general'); - } - } - - return $results; -} - -/** - * Add a function for integration hook. - * Does nothing if the function is already added. - * Cleans up enabled/disabled variants before taking requested action. - * - * @param string $hook The complete hook name. - * @param string $function The function name. Can be a call to a method via Class::method. - * @param bool $permanent If true, updates the value in settings table. - * @param string $file The file. Must include one of the following wildcards: $boarddir, $sourcedir, $themedir, example: $sourcedir/Test.php - * @param bool $object Indicates if your class will be instantiated when its respective hook is called. If true, your function must be a method. - */ -function add_integration_function($hook, $function, $permanent = true, $file = '', $object = false) -{ - // Any objects? - if ($object) - $function = $function . '#'; - - // Any files to load? - if (!empty($file) && is_string($file)) - $function = $file . (!empty($function) ? '|' . $function : ''); - - // Get the correct string. - $integration_call = $function; - $enabled_call = rtrim($function, '!'); - $disabled_call = $enabled_call . '!'; - - // Is it going to be permanent? - if ($permanent) - { - $request = Db::$db->query('', ' - SELECT value - FROM {db_prefix}settings - WHERE variable = {string:variable}', - array( - 'variable' => $hook, - ) - ); - list ($current_functions) = Db::$db->fetch_row($request); - Db::$db->free_result($request); - - if (!empty($current_functions)) - { - $current_functions = explode(',', $current_functions); - - // Cleanup enabled/disabled variants before taking action. - $current_functions = array_diff($current_functions, array($enabled_call, $disabled_call)); - - $permanent_functions = array_unique(array_merge($current_functions, array($integration_call))); - } - else - $permanent_functions = array($integration_call); - - Config::updateModSettings(array($hook => implode(',', $permanent_functions))); - } - - // Make current function list usable. - $functions = empty(Config::$modSettings[$hook]) ? array() : explode(',', Config::$modSettings[$hook]); - - // Cleanup enabled/disabled variants before taking action. - $functions = array_diff($functions, array($enabled_call, $disabled_call)); - - $functions = array_unique(array_merge($functions, array($integration_call))); - Config::$modSettings[$hook] = implode(',', $functions); - - // It is handy to be able to know which hooks are temporary... - if ($permanent !== true) - { - if (!isset(Utils::$context['integration_hooks_temporary'])) - Utils::$context['integration_hooks_temporary'] = array(); - Utils::$context['integration_hooks_temporary'][$hook][$function] = true; - } -} - -/** - * Remove an integration hook function. - * Removes the given function from the given hook. - * Does nothing if the function is not available. - * Cleans up enabled/disabled variants before taking requested action. - * - * @param string $hook The complete hook name. - * @param string $function The function name. Can be a call to a method via Class::method. - * @param boolean $permanent Irrelevant for the function itself but need to declare it to match - * @param string $file The filename. Must include one of the following wildcards: $boarddir, $sourcedir, $themedir, example: $sourcedir/Test.php - * @param boolean $object Indicates if your class will be instantiated when its respective hook is called. If true, your function must be a method. - * @see add_integration_function - */ -function remove_integration_function($hook, $function, $permanent = true, $file = '', $object = false) -{ - // Any objects? - if ($object) - $function = $function . '#'; - - // Any files to load? - if (!empty($file) && is_string($file)) - $function = $file . '|' . $function; - - // Get the correct string. - $integration_call = $function; - $enabled_call = rtrim($function, '!'); - $disabled_call = $enabled_call . '!'; - - // Get the permanent functions. - $request = Db::$db->query('', ' - SELECT value - FROM {db_prefix}settings - WHERE variable = {string:variable}', - array( - 'variable' => $hook, - ) - ); - list ($current_functions) = Db::$db->fetch_row($request); - Db::$db->free_result($request); - - if (!empty($current_functions)) - { - $current_functions = explode(',', $current_functions); - - // Cleanup enabled and disabled variants. - $current_functions = array_unique(array_diff($current_functions, array($enabled_call, $disabled_call))); - - Config::updateModSettings(array($hook => implode(',', $current_functions))); - } - - // Turn the function list into something usable. - $functions = empty(Config::$modSettings[$hook]) ? array() : explode(',', Config::$modSettings[$hook]); - - // Cleanup enabled and disabled variants. - $functions = array_unique(array_diff($functions, array($enabled_call, $disabled_call))); - - Config::$modSettings[$hook] = implode(',', $functions); -} - /** * Receives a string and tries to figure it out if it's a method or a function. * If a method is found, it looks for a "#" which indicates SMF should create a new instance of the given class. diff --git a/Sources/TaskRunner.php b/Sources/TaskRunner.php index ed4c918835a..402f1e8f2bf 100644 --- a/Sources/TaskRunner.php +++ b/Sources/TaskRunner.php @@ -715,7 +715,7 @@ protected function scheduleTask(): void protected function getScheduledTaskDetails(int $id, string $task, bool $is_callable = false): array { // Allow mods to easily add scheduled tasks. - call_integration_hook('integrate_scheduled_tasks', array(&self::$scheduled_tasks)); + IntegrationHook::call('integrate_scheduled_tasks', array(&self::$scheduled_tasks)); if ($is_callable) { diff --git a/Sources/Theme.php b/Sources/Theme.php index 594c58b2ab9..d4dbb61fbc3 100644 --- a/Sources/Theme.php +++ b/Sources/Theme.php @@ -265,7 +265,7 @@ public static function load($id = 0, $initialize = true) } // Allow mod authors the option to override the theme id for custom page themes - call_integration_hook('integrate_pre_load_theme', array(&$id)); + IntegrationHook::call('integrate_pre_load_theme', array(&$id)); // If not already loaded, load it now. if (!isset(self::$loaded[$id])) @@ -950,7 +950,7 @@ public static function setupContext($forceload = false) Utils::$context['meta_tags'][] = array('name' => 'description', 'content' => Utils::$context['page_title_html_safe']); } - call_integration_hook('integrate_theme_context'); + IntegrationHook::call('integrate_theme_context'); } /** @@ -1160,7 +1160,7 @@ public static function setupMenuContext() ); // Allow editing menu buttons easily. - call_integration_hook('integrate_menu_buttons', array(&$buttons)); + IntegrationHook::call('integrate_menu_buttons', array(&$buttons)); // Now we put the buttons in the context so the theme can use them. $menu_buttons = array(); @@ -1331,7 +1331,7 @@ public static function setupMenuContext() } // Not all actions are simple. - call_integration_hook('integrate_current_action', array(&$current_action)); + IntegrationHook::call('integrate_current_action', array(&$current_action)); if (isset(Utils::$context['menu_buttons'][$current_action])) Utils::$context['menu_buttons'][$current_action]['active_button'] = true; @@ -1393,7 +1393,7 @@ public static function template_header() $securityFiles = array('install.php', 'upgrade.php', 'convert.php', 'repair_paths.php', 'repair_settings.php', 'Settings.php~', 'Settings_bak.php~'); // Add your own files. - call_integration_hook('integrate_security_files', array(&$securityFiles)); + IntegrationHook::call('integrate_security_files', array(&$securityFiles)); foreach ($securityFiles as $i => $securityFile) { @@ -1539,7 +1539,7 @@ public static function template_footer() public static function template_javascript($do_deferred = false) { // Use this hook to minify/optimize Javascript files and vars - call_integration_hook('integrate_pre_javascript_output', array(&$do_deferred)); + IntegrationHook::call('integrate_pre_javascript_output', array(&$do_deferred)); $toMinify = array( 'standard' => array(), @@ -1671,7 +1671,7 @@ public static function template_javascript($do_deferred = false) public static function template_css() { // Use this hook to minify/optimize CSS files - call_integration_hook('integrate_pre_css_output'); + IntegrationHook::call('integrate_pre_css_output'); $toMinify = array(); $normal = array(); @@ -2028,9 +2028,9 @@ public static function wrapAction() if (!isset(self::$current->settings['catch_action']['filename'])) self::$current->settings['catch_action']['filename'] = ''; - add_integration_function('integrate_wrap_action', $hook, false, self::$current->settings['catch_action']['filename'], false); + IntegrationHook::add('integrate_wrap_action', $hook, false, self::$current->settings['catch_action']['filename'], false); - call_integration_hook('integrate_wrap_action'); + IntegrationHook::call('integrate_wrap_action'); } // And finally, the main sub template ;). @@ -2629,7 +2629,7 @@ protected function initialize() } // Call load theme integration functions. - call_integration_hook('integrate_load_theme'); + IntegrationHook::call('integrate_load_theme'); // We are ready to go. Utils::$context['theme_loaded'] = true; @@ -2798,7 +2798,7 @@ protected function loadTemplatesAndLangFiles() // This allows sticking some HTML on the page output - useful for controls. Utils::$context['insert_after_template'] = ''; - call_integration_hook('integrate_simple_actions', array(&$this->simpleActions, &$this->simpleAreas, &$this->simpleSubActions, &$this->extraParams, &$this->xmlActions)); + IntegrationHook::call('integrate_simple_actions', array(&$this->simpleActions, &$this->simpleAreas, &$this->simpleSubActions, &$this->extraParams, &$this->xmlActions)); Utils::$context['simple_action'] = ( in_array(Utils::$context['current_action'], $this->simpleActions) diff --git a/Sources/TimeZone.php b/Sources/TimeZone.php index 29370cdc9de..c3feebd085b 100644 --- a/Sources/TimeZone.php +++ b/Sources/TimeZone.php @@ -2376,7 +2376,7 @@ public static function getTzidMetazones(int|string $when = 'now'): array list($when, $later) = self::getTimeRange($when); - call_integration_hook('integrate_metazones', array(&self::$metazones, $when)); + IntegrationHook::call('integrate_metazones', array(&self::$metazones, $when)); // Fallbacks in case the server has an old version of the TZDB. $tzid_fallbacks = self::getTzidFallbacks(array_keys(self::$metazones), $when); @@ -2423,7 +2423,7 @@ public static function getSortedTzidsForCountry(string $country_code, int|string // Avoid unnecessary repetition. if (!isset($country_tzids[$country_code])) { - call_integration_hook('integrate_country_timezones', array(&self::$sorted_tzids, $country_code, $when)); + IntegrationHook::call('integrate_country_timezones', array(&self::$sorted_tzids, $country_code, $when)); $country_tzids[$country_code] = isset(self::$sorted_tzids[$country_code]) ? self::$sorted_tzids[$country_code] : array(); @@ -2473,7 +2473,7 @@ public static function getTzidFallbacks(array $tzids, int|string $when = 'now'): $missing = array_diff($tzids, timezone_identifiers_list(\DateTimeZone::ALL_WITH_BC)); - call_integration_hook('integrate_timezone_fallbacks', array(&self::$fallbacks, &$missing, $tzids, $when)); + IntegrationHook::call('integrate_timezone_fallbacks', array(&self::$fallbacks, &$missing, $tzids, $when)); $replacements = array(); diff --git a/Sources/Topic.php b/Sources/Topic.php index fadff11673d..207c47ce1d8 100644 --- a/Sources/Topic.php +++ b/Sources/Topic.php @@ -1119,7 +1119,7 @@ public static function remove($topics, $decreasePostCount = true, $ignoreRecycli $recycle_board = !empty(Config::$modSettings['recycle_enable']) && !empty(Config::$modSettings['recycle_board']) ? (int) Config::$modSettings['recycle_board'] : 0; // Do something before? - call_integration_hook('integrate_remove_topics_before', array($topics, $recycle_board)); + IntegrationHook::call('integrate_remove_topics_before', array($topics, $recycle_board)); // Decrease the post counts. if ($decreasePostCount) @@ -1421,7 +1421,7 @@ public static function remove($topics, $decreasePostCount = true, $ignoreRecycli ); // Maybe there's a mod that wants to delete topic related data of its own - call_integration_hook('integrate_remove_topics', array($topics)); + IntegrationHook::call('integrate_remove_topics', array($topics)); // Update the totals... Logging::updateStats('message'); @@ -1493,7 +1493,7 @@ protected function loadTopicInfo(): void $topic_joins[] = 'LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = t.id_board AND lmr.id_member = {int:current_member})'; } - call_integration_hook('integrate_display_topic', array(&$topic_selects, &$topic_joins, &$topic_parameters)); + IntegrationHook::call('integrate_display_topic', array(&$topic_selects, &$topic_joins, &$topic_parameters)); // @todo Why isn't this cached? // @todo if we get id_board in this query and cache it, we can save a query on posting diff --git a/Sources/Url.php b/Sources/Url.php index d95c9f98a6b..896682a6ad7 100644 --- a/Sources/Url.php +++ b/Sources/Url.php @@ -468,7 +468,7 @@ public function proxied(): object // Allow mods to easily implement an alternative proxy. // MOD AUTHORS: To add settings UI for your proxy, use the integrate_general_settings hook. - call_integration_hook('integrate_proxy', array($this->url, &$proxied->url)); + IntegrationHook::call('integrate_proxy', array($this->url, &$proxied->url)); return $proxied; } diff --git a/Sources/User.php b/Sources/User.php index f84dbbeb208..a0781a06aed 100644 --- a/Sources/User.php +++ b/Sources/User.php @@ -1297,7 +1297,7 @@ public function format(bool $display_custom_fields = false): array } } - call_integration_hook('integrate_member_context', array(&$this->formatted, $this->id, $display_custom_fields)); + IntegrationHook::call('integrate_member_context', array(&$this->formatted, $this->id, $display_custom_fields)); $this->custom_fields_displayed = !empty($this->custom_fields_displayed) | $display_custom_fields; @@ -1587,7 +1587,7 @@ public function rebuildModCache(): void 'mq' => $mod_query, ); - call_integration_hook('integrate_mod_cache'); + IntegrationHook::call('integrate_mod_cache'); $this->mod_cache = $_SESSION['mc']; @@ -2015,7 +2015,7 @@ public function adjustPermissions(): void // Okay, well, you can watch, but don't touch a thing. elseif (isset($_SESSION['ban']['cannot_post']) || (!empty(Config::$modSettings['warning_mute']) && Config::$modSettings['warning_mute'] <= $this->warning)) { - call_integration_hook('integrate_post_ban_permissions', array(&self::$post_ban_permissions)); + IntegrationHook::call('integrate_post_ban_permissions', array(&self::$post_ban_permissions)); $this->permissions = array_diff($this->permissions, self::$post_ban_permissions); } @@ -2023,7 +2023,7 @@ public function adjustPermissions(): void elseif (!empty(Config::$modSettings['warning_moderate']) && Config::$modSettings['warning_moderate'] <= $this->warning) { // Work out what permissions should change... - call_integration_hook('integrate_warn_permissions', array(&self::$warn_permissions)); + IntegrationHook::call('integrate_warn_permissions', array(&self::$warn_permissions)); foreach (self::$warn_permissions as $old => $new) { @@ -2096,7 +2096,7 @@ public function validateSession(string $type = 'admin', bool $force = false): st // Validate what type of session check this is. $types = array(); - call_integration_hook('integrate_validateSession', array(&$types)); + IntegrationHook::call('integrate_validateSession', array(&$types)); $type = in_array($type, $types) || $type == 'moderate' ? $type : 'admin'; // If we're using XML give an additional ten minutes grace as an admin @@ -2138,7 +2138,7 @@ public function validateSession(string $type = 'admin', bool $force = false): st $this->checkSession(); - $good_password = in_array(true, call_integration_hook('integrate_verify_password', array($this->username, $_POST[$type . '_pass'], false)), true); + $good_password = in_array(true, IntegrationHook::call('integrate_verify_password', array($this->username, $_POST[$type . '_pass'], false)), true); // Password correct? if ($good_password || Security::hashVerifyPassword($this->username, $_POST[$type . '_pass'], $this->passwd)) @@ -2358,7 +2358,7 @@ public function allowedTo(string|array $permission, int|array $boards = null, bo $user_permissions = (array) $this->permissions; // Allow temporary overrides for general permissions? - call_integration_hook('integrate_allowed_to_general', array(&$user_permissions, $permission)); + IntegrationHook::call('integrate_allowed_to_general', array(&$user_permissions, $permission)); return array_intersect($permission, $user_permissions) != array(); } @@ -2425,7 +2425,7 @@ public function allowedTo(string|array $permission, int|array $boards = null, bo } // Allow temporary overrides for board permissions? - call_integration_hook('integrate_allowed_to_board', array(&$return, $permission, $boards, $any)); + IntegrationHook::call('integrate_allowed_to_board', array(&$return, $permission, $boards, $any)); $this->perm_cache[$cache_key] = $return; @@ -2466,7 +2466,7 @@ public function isAllowedTo(string|array $permission, int|array $boards = null, $permission = (array) $permission; $boards = (array) $boards; - call_integration_hook('integrate_heavy_permissions_session', array(&self::$heavy_permissions)); + IntegrationHook::call('integrate_heavy_permissions_session', array(&self::$heavy_permissions)); // Check the permission and return an error... if (!$this->allowedTo($permission, $boards, $any)) @@ -2616,7 +2616,7 @@ public function boardsAllowedTo(string|array $permissions, bool $check_access = } // Maybe a mod needs to tweak the list of allowed boards on the fly? - call_integration_hook('integrate_boards_allowed_to', array(&$boards, $deny_boards, $permissions, $check_access, $simple)); + IntegrationHook::call('integrate_boards_allowed_to', array(&$boards, $deny_boards, $permissions, $check_access, $simple)); return $boards; } @@ -2962,7 +2962,7 @@ public static function setAvatarData(array $data = array()): array } } - call_integration_hook('integrate_set_avatar_data', array(&$image, &$data)); + IntegrationHook::call('integrate_set_avatar_data', array(&$image, &$data)); // At this point in time $image has to be filled unless you chose to force gravatar and the user doesn't have the needed data to retrieve it... thus a check for !empty() is still needed. if (!empty($image)) @@ -3090,7 +3090,7 @@ public static function updateMemberData($members, array $data): void { foreach ($vars_to_integrate as $var) { - call_integration_hook('integrate_change_member_data', array($member_names, $var, &$data[$var], &self::$knownInts, &self::$knownFloats)); + IntegrationHook::call('integrate_change_member_data', array($member_names, $var, &$data[$var], &self::$knownInts, &self::$knownFloats)); } } } @@ -3663,7 +3663,7 @@ public static function delete(int|array $users, bool $check_not_admin = false): )); // Integration rocks! - call_integration_hook('integrate_delete_members', array($users)); + IntegrationHook::call('integrate_delete_members', array($users)); Logging::updateStats('member'); @@ -3697,7 +3697,7 @@ public static function validatePassword(string $password, string $username, arra // Maybe we need some more fancy password checks. $pass_error = ''; - call_integration_hook('integrate_validatePassword', array($password, $username, $restrict_in, &$pass_error)); + IntegrationHook::call('integrate_validatePassword', array($password, $username, $restrict_in, &$pass_error)); if (!empty($pass_error)) return $pass_error; @@ -3774,7 +3774,7 @@ public static function validateUsername(int $memID, string $username, bool $retu } // Maybe a mod wants to perform more checks? - call_integration_hook('integrate_validate_username', array($username, &$errors)); + IntegrationHook::call('integrate_validate_username', array($username, &$errors)); if ($return_error) return $errors; @@ -3905,7 +3905,7 @@ public static function isReservedName(string $name, int $current_id_member = 0, $is_reserved = false; // Maybe a mod wants to perform further checks? - call_integration_hook('integrate_check_name', array($checkName, &$is_reserved, $current_id_member, $is_name)); + IntegrationHook::call('integrate_check_name', array($checkName, &$is_reserved, $current_id_member, $is_name)); return $is_reserved; } @@ -4295,7 +4295,7 @@ public static function groupsAllowedTo(array|string $permissions, ?int $board_id $member_groups[$permission][$k] = array_unique($member_groups[$permission][$k]); // Maybe a mod needs to tweak the list of allowed groups on the fly? - call_integration_hook('integrate_groups_allowed_to', array(&$member_groups[$permission], $permission, $board_id)); + IntegrationHook::call('integrate_groups_allowed_to', array(&$member_groups[$permission], $permission, $board_id)); // Denied is never allowed. $member_groups[$permission]['allowed'] = array_diff($member_groups[$permission]['allowed'], $member_groups[$permission]['denied']); @@ -4695,7 +4695,7 @@ protected function __construct(int $id = null, string|null $dataset = null) // Alternatively, consider the integrate_user_properties hook in // the setProperties() method, which lets you work with the // properties of any instance of this class. - call_integration_hook('integrate_user_info'); + IntegrationHook::call('integrate_user_info'); } } // Reloading the current user requires special handling. @@ -4850,7 +4850,7 @@ protected function setProperties(): void $this->dataset = $profile['dataset']; // An easy way for mods to add or adjust properties. - call_integration_hook('integrate_user_properties', array($this)); + IntegrationHook::call('integrate_user_properties', array($this)); } /** @@ -4859,7 +4859,7 @@ protected function setProperties(): void */ protected function integrateVerifyUser(): void { - if (count($integration_ids = call_integration_hook('integrate_verify_user')) === 0) + if (count($integration_ids = IntegrationHook::call('integrate_verify_user')) === 0) return; foreach ($integration_ids as $integration_id) @@ -5028,7 +5028,7 @@ protected function verifyTfa(): void $force_tfasetup = false; } - call_integration_hook('integrate_force_tfasetup', array(&$force_tfasetup)); + IntegrationHook::call('integrate_force_tfasetup', array(&$force_tfasetup)); } // Validate for Two Factor Authentication @@ -5037,7 +5037,7 @@ protected function verifyTfa(): void $tfacookie = Config::$cookiename . '_tfa'; $tfasecret = null; - $verified = call_integration_hook('integrate_verify_tfa', array(self::$my_id, self::$profiles[self::$my_id])); + $verified = IntegrationHook::call('integrate_verify_tfa', array(self::$my_id, self::$profiles[self::$my_id])); if (empty($verified) || !in_array(true, $verified)) { @@ -5596,7 +5596,7 @@ protected static function loadUserData(array $users, int $type = self::LOAD_BY_I } // Allow mods to easily add to the selected member data - call_integration_hook('integrate_load_member_data', array(&$select_columns, &$select_tables, &$dataset)); + IntegrationHook::call('integrate_load_member_data', array(&$select_columns, &$select_tables, &$dataset)); // Load the members' data. $request = Db::$db->query('', ' @@ -5662,7 +5662,7 @@ protected static function loadUserData(array $users, int $type = self::LOAD_BY_I self::loadOptions($loaded_ids); // This hook's name is due to historical reasons. - call_integration_hook('integrate_load_min_user_settings', array(&self::$profiles)); + IntegrationHook::call('integrate_load_min_user_settings', array(&self::$profiles)); if ($type === self::LOAD_BY_ID && !empty(CacheApi::$enable)) { diff --git a/Sources/Utils.php b/Sources/Utils.php index 9154bf365d8..8a159d78e31 100644 --- a/Sources/Utils.php +++ b/Sources/Utils.php @@ -1980,7 +1980,7 @@ public static function emitFile(\ArrayAccess|array $file, bool $show_thumb = fal // Allow customizations to hook in here before we send anything to // modify any headers needed or to change the process of how we output. - call_integration_hook('integrate_download_headers'); + IntegrationHook::call('integrate_download_headers'); // Try to buy some time... @set_time_limit(600); @@ -2197,7 +2197,7 @@ function($m) } // Maybe integrations want to change where we are heading? - call_integration_hook('integrate_redirect', array(&$setLocation, &$refresh, &$permanent)); + IntegrationHook::call('integrate_redirect', array(&$setLocation, &$refresh, &$permanent)); // Set the header. header('location: ' . str_replace(' ', '%20', $setLocation), true, $permanent ? 301 : 302); @@ -2320,7 +2320,7 @@ public static function obExit(bool $header = null, bool $do_footer = null, bool $_SESSION['USER_AGENT'] = empty($_SERVER['HTTP_USER_AGENT']) ? '' : $_SERVER['HTTP_USER_AGENT']; // Hand off the output to the portal, etc. we're integrated with. - call_integration_hook('integrate_exit', array($do_footer)); + IntegrationHook::call('integrate_exit', array($do_footer)); // Don't exit if we're coming from index.php; that will pass through normally. if (!$from_index) diff --git a/Sources/Verifier.php b/Sources/Verifier.php index 2dee3b5b402..00d14e90368 100644 --- a/Sources/Verifier.php +++ b/Sources/Verifier.php @@ -194,7 +194,7 @@ class Verifier implements \ArrayAccess public function __construct(array $options, bool $do_test = false) { // Add a verification hook, pre-setup. - call_integration_hook('integrate_create_control_verification_pre', array(&$options, $do_test)); + IntegrationHook::call('integrate_create_control_verification_pre', array(&$options, $do_test)); // Always need an ID. If someone forgot to provide it, fall back to the // current action (but trim off any trailing '2' in the action name). @@ -280,7 +280,7 @@ public function __construct(array $options, bool $do_test = false) $_SESSION[$this->id . '_vv']['count']++; // Let our hooks know that we are done with the verification process. - call_integration_hook('integrate_create_control_verification_post', array(&$this->errors, $do_test)); + IntegrationHook::call('integrate_create_control_verification_post', array(&$this->errors, $do_test)); // Return errors if we have them. if (!empty($this->errors)) @@ -497,7 +497,7 @@ protected function test(): void } // Do ay hooks have something to say about this verification? - call_integration_hook('integrate_create_control_verification_test', array($this, &$this->errors)); + IntegrationHook::call('integrate_create_control_verification_test', array($this, &$this->errors)); } /** @@ -617,7 +617,7 @@ protected function refresh(): void } // Hooks may need to know about this. - call_integration_hook('integrate_create_control_verification_refresh', array($this)); + IntegrationHook::call('integrate_create_control_verification_refresh', array($this)); } /** diff --git a/Sources/tasks/DailyMaintenance.php b/Sources/tasks/DailyMaintenance.php index 28eae2b74bf..5bb75e40f92 100644 --- a/Sources/tasks/DailyMaintenance.php +++ b/Sources/tasks/DailyMaintenance.php @@ -15,6 +15,7 @@ use SMF\Alert; use SMF\Config; +use SMF\IntegrationHook; use SMF\ProxyServer; use SMF\Actions\Admin\SearchEngines; use SMF\Cache\CacheApi; @@ -151,7 +152,7 @@ public function execute() } // Anyone else have something to do? - call_integration_hook('integrate_daily_maintenance'); + IntegrationHook::call('integrate_daily_maintenance'); return true; } diff --git a/Sources/tasks/ExportProfileData.php b/Sources/tasks/ExportProfileData.php index 8ce3dca2653..8e3a4b39046 100644 --- a/Sources/tasks/ExportProfileData.php +++ b/Sources/tasks/ExportProfileData.php @@ -15,6 +15,7 @@ use SMF\Config; use SMF\ErrorHandler; +use SMF\IntegrationHook; use SMF\Lang; use SMF\TaskRunner; use SMF\Theme; @@ -913,7 +914,7 @@ public function execute() ); foreach ($hook_methods as $hook => $method) - add_integration_function('integrate_' . $hook, __CLASS__ . '::' . $method, false); + IntegrationHook::add('integrate_' . $hook, __CLASS__ . '::' . $method, false); // Perform the export. if ($this->_details['format'] == 'XML') @@ -1366,7 +1367,7 @@ protected function exportXmlXslt() Utils::$context['export_dlfilename'] = $this->_details['dlfilename']; // Embedded XSLT requires adding a special DTD and processing instruction in the main XML document. - add_integration_function('integrate_xml_data', __CLASS__ . '::add_dtd', false); + IntegrationHook::add('integrate_xml_data', __CLASS__ . '::add_dtd', false); // Make sure the stylesheet is set. $this->buildStylesheet(); @@ -1525,7 +1526,7 @@ protected function buildStylesheet(): void ); // Let mods adjust the XSLT variables. - call_integration_hook('integrate_export_xslt_variables', array(&$xslt_variables, $this->_details['format'])); + IntegrationHook::call('integrate_export_xslt_variables', array(&$xslt_variables, $this->_details['format'])); $idhash = hash_hmac('sha1', $this->_details['uid'], Config::getAuthSecret()); $xslt_variables['dltoken'] = array( @@ -1674,7 +1675,7 @@ protected function buildStylesheet(): void } // Let mods adjust the XSLT stylesheet. - call_integration_hook('integrate_export_xslt_stylesheet', array(&$this->xslt_stylesheet, $this->_details['format'])); + IntegrationHook::call('integrate_export_xslt_stylesheet', array(&$this->xslt_stylesheet, $this->_details['format'])); $this->stylesheet = implode("\n\n", $this->xslt_stylesheet); @@ -1748,7 +1749,7 @@ protected function loadCssJs() Theme::loadCSSFile('rtl.css', array('order_pos' => 4000), 'smf_rtl'); // In case any mods added relevant CSS. - call_integration_hook('integrate_pre_css_output'); + IntegrationHook::call('integrate_pre_css_output'); // This next chunk mimics some of Theme::template_css() $css_to_minify = array(); @@ -1790,8 +1791,8 @@ function ($a, $b) Theme::loadJavaScriptFile('https://ajax.googleapis.com/ajax/libs/jquery/' . JQUERY_VERSION . '/jquery.min.js', array('external' => true, 'seed' => false), 'smf_jquery'); // There might be JavaScript that we need to add in order to support custom BBC or something. - call_integration_hook('integrate_pre_javascript_output', array(false)); - call_integration_hook('integrate_pre_javascript_output', array(true)); + IntegrationHook::call('integrate_pre_javascript_output', array(false)); + IntegrationHook::call('integrate_pre_javascript_output', array(true)); $js_to_minify = array(); $all_js_files = array(); diff --git a/Sources/tasks/Likes_Notify.php b/Sources/tasks/Likes_Notify.php index 4fc375834d4..e2793f41c97 100644 --- a/Sources/tasks/Likes_Notify.php +++ b/Sources/tasks/Likes_Notify.php @@ -15,6 +15,7 @@ use SMF\Alert; use SMF\Config; +use SMF\IntegrationHook; use SMF\User; use SMF\Utils; use SMF\Actions\Notify; @@ -66,7 +67,7 @@ public function execute() else { // This isn't something we know natively how to support. Call the hooks, if they're dealing with it, return false, otherwise return the user id. - $hook_results = call_integration_hook('integrate_find_like_author', array($this->_details['content_type'], $this->_details['content_id'])); + $hook_results = IntegrationHook::call('integrate_find_like_author', array($this->_details['content_type'], $this->_details['content_id'])); foreach ($hook_results as $result) if (!empty($result)) { diff --git a/Sources/tasks/SendDigests.php b/Sources/tasks/SendDigests.php index 68ef856961c..c62d725a2ba 100644 --- a/Sources/tasks/SendDigests.php +++ b/Sources/tasks/SendDigests.php @@ -14,6 +14,7 @@ namespace SMF\Tasks; use SMF\Config; +use SMF\IntegrationHook; use SMF\Lang; use SMF\Mail; use SMF\Theme; @@ -211,7 +212,7 @@ public function execute() 'bye' => sprintf(Lang::$txt['regards_team'], Utils::$context['forum_name']), ); - call_integration_hook('integrate_daily_digest_lang', array(&$langtxt, $lang)); + IntegrationHook::call('integrate_daily_digest_lang', array(&$langtxt, $lang)); } // The preferred way... @@ -323,7 +324,7 @@ public function execute() } } - call_integration_hook('integrate_daily_digest_email', array(&$email, $types, $notify_types, $langtxt)); + IntegrationHook::call('integrate_daily_digest_email', array(&$email, $types, $notify_types, $langtxt)); if ($titled) $email['body'] .= "\n"; diff --git a/Sources/tasks/WeeklyMaintenance.php b/Sources/tasks/WeeklyMaintenance.php index 7467e48c75c..aa0455b7a26 100644 --- a/Sources/tasks/WeeklyMaintenance.php +++ b/Sources/tasks/WeeklyMaintenance.php @@ -14,6 +14,7 @@ namespace SMF\Tasks; use SMF\Config; +use SMF\IntegrationHook; use SMF\Theme; use SMF\Cache\CacheApi; use SMF\Db\DatabaseApi as Db; @@ -268,7 +269,7 @@ public function execute() Theme::deleteAllMinified(); // Maybe there's more to do. - call_integration_hook('integrate_weekly_maintenance'); + IntegrationHook::call('integrate_weekly_maintenance'); return true; } diff --git a/Themes/default/index.template.php b/Themes/default/index.template.php index 38058ba71cc..a2f85e68bc4 100644 --- a/Themes/default/index.template.php +++ b/Themes/default/index.template.php @@ -12,6 +12,7 @@ use SMF\Config; use SMF\Lang; +use SMF\IntegrationHook; use SMF\Theme; use SMF\Time; use SMF\Utils; @@ -682,7 +683,7 @@ function template_quickbuttons($list_items, $list_class = null, $output_method = { // Enable manipulation with hooks if (!empty($list_class)) - call_integration_hook('integrate_' . $list_class . '_quickbuttons', array(&$list_items)); + IntegrationHook::call('integrate_' . $list_class . '_quickbuttons', array(&$list_items)); // Make sure the list has at least one shown item foreach ($list_items as $key => $li)