Skip to content

Commit

Permalink
Implements SMF\IntegrationHook
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Stovell <[email protected]>
  • Loading branch information
Sesquipedalian committed Nov 4, 2023
1 parent 87e9a7c commit 27bf405
Show file tree
Hide file tree
Showing 126 changed files with 907 additions and 651 deletions.
3 changes: 2 additions & 1 deletion Sources/Actions/Activate.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

use SMF\Config;
use SMF\ErrorHandler;
use SMF\IntegrationHook;
use SMF\Lang;
use SMF\Logging;
use SMF\Mail;
Expand Down Expand Up @@ -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' => ''));
Expand Down
7 changes: 4 additions & 3 deletions Sources/Actions/Admin/ACP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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));
}

/*************************
Expand Down
5 changes: 3 additions & 2 deletions Sources/Actions/Admin/AntiSpam.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use SMF\Actions\ActionInterface;

use SMF\Config;
use SMF\IntegrationHook;
use SMF\Lang;
use SMF\Menu;
use SMF\Theme;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down
17 changes: 9 additions & 8 deletions Sources/Actions/Admin/Attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use SMF\Attachment;
use SMF\Config;
use SMF\IntegrationHook;
use SMF\ItemList;
use SMF\Lang;
use SMF\Menu;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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']);
Expand Down
19 changes: 10 additions & 9 deletions Sources/Actions/Admin/Bans.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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'];
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()));
Expand All @@ -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'),
Expand Down Expand Up @@ -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']))
Expand Down Expand Up @@ -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('', '
Expand Down
13 changes: 7 additions & 6 deletions Sources/Actions/Admin/Boards.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
}

/**
Expand Down Expand Up @@ -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');
}

/**
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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');
Expand Down
7 changes: 4 additions & 3 deletions Sources/Actions/Admin/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use SMF\Board;
use SMF\Config;
use SMF\IntegrationHook;
use SMF\ItemList;
use SMF\Lang;
use SMF\Menu;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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'];
Expand Down
Loading

0 comments on commit 27bf405

Please sign in to comment.