diff --git a/classes/hook_callbacks.php b/classes/hook_callbacks.php new file mode 100644 index 0000000..c6688e6 --- /dev/null +++ b/classes/hook_callbacks.php @@ -0,0 +1,41 @@ +. + +namespace auth_outage; + +use auth_outage\local\outagelib; +use core\hook\output\before_standard_top_of_body_html_generation; + +/** + * Hook callbacks for auth_outage. + * + * @package auth_outage + * @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 { + + /** + * Inject the warning bar into the page if there is currently an outage. + * + * @param before_standard_top_of_body_html_generation $hook + */ + public static function before_standard_top_of_body_html_generation(before_standard_top_of_body_html_generation $hook): void { + // Get code to inject. + $hook->add_html(outagelib::get_inject_code()); + } +} diff --git a/db/hooks.php b/db/hooks.php new file mode 100644 index 0000000..087e3f9 --- /dev/null +++ b/db/hooks.php @@ -0,0 +1,34 @@ +. + +/** + * Hook callbacks for auth_outage + * + * @package auth_outage + * @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\hook\output\before_standard_top_of_body_html_generation::class, + 'callback' => [\auth_outage\hook_callbacks::class, 'before_standard_top_of_body_html_generation'], + 'priority' => 0, + ], +]; diff --git a/lib.php b/lib.php index cc95564..91d6eb1 100644 --- a/lib.php +++ b/lib.php @@ -68,6 +68,9 @@ function auth_outage_get_climaintenance_resource_file($file) { /** * Inject the warning bar into the page if there is currently an outage. * + * This is a legacy callback that is used for compatibility with older Moodle versions. + * Moodle 4.4+ will use auth_outage\hook_callbacks::before_standard_top_of_body_html_generation instead. + * * @return string|void */ function auth_outage_before_standard_top_of_body_html() { diff --git a/version.php b/version.php index 801be6d..84dc160 100644 --- a/version.php +++ b/version.php @@ -28,8 +28,8 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = "auth_outage"; -$plugin->version = 2023012700; // The current plugin version (Date: YYYYMMDDXX). -$plugin->release = 2023012700; // Human-readable release information. +$plugin->version = 2024052000; // The current plugin version (Date: YYYYMMDDXX). +$plugin->release = 2024052000; // Human-readable release information. $plugin->requires = 2017111309; // 2017111309 = T13, but this really requires 3.9 and higher. $plugin->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments! -$plugin->supported = [39, 401]; // A range of branch numbers of supported moodle versions. +$plugin->supported = [39, 404]; // A range of branch numbers of supported moodle versions.