From fc1b42c67d2ee9c2ad2b5efaa6a4db16d475671b Mon Sep 17 00:00:00 2001 From: Benjamin Walker Date: Wed, 13 Nov 2024 15:16:35 +1000 Subject: [PATCH] Add new hook callback for extend_bulk_user_actions #50 --- classes/hook_callbacks.php | 42 ++++++++++++++++++++++++++++++++++++++ db/hooks.php | 34 ++++++++++++++++++++++++++++++ lib.php | 2 ++ version.php | 4 ++-- 4 files changed, 80 insertions(+), 2 deletions(-) create mode 100644 classes/hook_callbacks.php create mode 100644 db/hooks.php diff --git a/classes/hook_callbacks.php b/classes/hook_callbacks.php new file mode 100644 index 0000000..87b399f --- /dev/null +++ b/classes/hook_callbacks.php @@ -0,0 +1,42 @@ +. + +namespace tool_emailutils; + +/** + * Hook callbacks for tool_emailutils. + * + * @package tool_emailutils + * @author Benjamin Walker (benjaminwalker@catalyst-au.net) + * @copyright 2024 Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ +class hook_callbacks { + + /** + * This adds a new bulk user action to reset a persons bounce count. + * + * @param \core_user\hook\extend_bulk_user_actions $hook + */ + public static function extend_bulk_user_actions(\core_user\hook\extend_bulk_user_actions $hook): void { + if (has_capability('moodle/site:config', \context_system::instance())) { + $hook->add_action('tool_ses_reset_bounces', new \action_link( + new \moodle_url('/admin/tool/emailutils/reset_bounces.php'), + get_string('resetbounces', 'tool_emailutils') + )); + } + } +} diff --git a/db/hooks.php b/db/hooks.php new file mode 100644 index 0000000..5057bc3 --- /dev/null +++ b/db/hooks.php @@ -0,0 +1,34 @@ +. + +/** + * Hook callbacks for tool_emailutils + * + * @package tool_emailutils + * @author Benjamin Walker (benjaminwalker@catalyst-au.net) + * @copyright 2024 Catalyst IT + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +defined('MOODLE_INTERNAL') || die(); + +$callbacks = [ + [ + 'hook' => \core_user\hook\extend_bulk_user_actions::class, + 'callback' => '\tool_emailutils\hook_callbacks::extend_bulk_user_actions', + 'priority' => 0, + ], +]; diff --git a/lib.php b/lib.php index f8a0974..9ce5b6a 100644 --- a/lib.php +++ b/lib.php @@ -25,6 +25,8 @@ /** * This adds a new bulk user action to reset a persons bounce count + * This is a legacy callback that is used for compatibility with older Moodle versions. + * Moodle 4.4+ will use tool_emailutils\hook_callbacks::extend_bulk_user_actions instead. */ function tool_emailutils_bulk_user_actions() { return [ diff --git a/version.php b/version.php index 593dd9f..d62cfe2 100644 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2024111300; -$plugin->release = 2024111300; +$plugin->version = 2024111301; +$plugin->release = 2024111301; $plugin->requires = 2020061500; $plugin->component = 'tool_emailutils'; $plugin->dependencies = ['local_aws' => 2020061500];