Skip to content

Commit

Permalink
Add new hook callback for extend_bulk_user_actions #50
Browse files Browse the repository at this point in the history
  • Loading branch information
bwalkerl committed Nov 13, 2024
1 parent 3f914f5 commit fc1b42c
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
42 changes: 42 additions & 0 deletions classes/hook_callbacks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

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')
));
}
}
}
34 changes: 34 additions & 0 deletions db/hooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* 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,
],
];
2 changes: 2 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit fc1b42c

Please sign in to comment.