Compare commits

..

38 Commits

Author SHA1 Message Date
Brendan Heywood 5756583514 Added admin notifications #185 2026-06-05 12:14:17 +10:00
Benjamin Walker 1fa22a4ea3 Display creation info on manage outage page 2026-01-25 13:44:11 +11:00
abhinavgandham 54eca9e3a1 Fixed examples table syntax in default settings behat file. 2026-01-22 19:48:35 +11:00
abhinavgandham e4be98f482 Removed more tests that are not needed. 2026-01-22 19:48:35 +11:00
abhinavgandham 2e2692facd Removed maintanance mode tests. 2026-01-22 19:48:35 +11:00
abhinavgandham e653bc4365 Removed maintenance later code in outagelib so that site does not go into hard cli mode when outage starts. 2026-01-22 19:48:35 +11:00
abhinavgandham 74de81ef7c Fixed PHPUnit test errors and failures. 2026-01-22 19:48:35 +11:00
abhinavgandham 990152f439 Fixed upgrade step. 2026-01-22 19:48:35 +11:00
abhinavgandham 5e0a3c015d Modified unit tests to remove autostart, and quickstart guide and readme. 2026-01-22 19:48:35 +11:00
abhinavgandham bf51ff6de9 Version bump and codechecker fixes. 2026-01-22 19:48:35 +11:00
abhinavgandham 6ca7cb6d7e Issue #390: Reverted new 'Force off' option and dropdown conversion. 2026-01-22 19:48:35 +11:00
Matthew Hilton 83cb36660b Merge pull request #400 from catalyst/issue-387-m501
Issue 387: Add metadata header to outage pages
2026-01-19 14:09:47 +10:00
Peter Burnett 2a7556eb75 chore: ci Fixes 2026-01-19 13:56:09 +10:00
Peter Burnett 425ef963fb Issue 387: Add metadata header to outage pages 2026-01-19 13:26:06 +10:00
Brendan Heywood b63af0465e Merge pull request #398 from catalyst/MOODLE_501_issue390
Issue #390: Changed outage auto-start default parameter from checkbox to dropdown with option to fully disable.
2026-01-15 20:17:37 +11:00
abhinavgandham a8d496121f Fixed default parameter in configselect and updated 'Force off' lang string. 2026-01-15 16:32:39 +10:00
abhinavgandham fdd5569324 Formatting fixes. 2026-01-15 14:10:23 +10:00
abhinavgandham a32c923aaa Included logic for 'Force off' setting. 2026-01-15 14:00:45 +10:00
abhinavgandham a96035be92 Issue #390: Changed outage auto-start default parameter from checkbox to dropdown with option to fully disable. 2026-01-14 13:36:54 +10:00
Brendan Heywood 0105891b2e Update README.md 2026-01-13 14:34:46 +10:00
Brendan Heywood 3fca6fe0af Merge pull request #396 from catalyst/MOODLE_501_branchtablefix
Issue #390: Fixed branch table formatting and github actions ci link to point to 5.1 in `README.md`.
2026-01-13 15:33:55 +11:00
abhinavgandham 79b7a0fa59 Issue #390: Fixed branch table formatting and github actions ci link to point to 5.1 in readme. 2026-01-13 14:06:55 +10:00
Brendan Heywood 59b6c63252 Fixed code standards 2026-01-13 14:48:59 +11:00
Brendan Heywood 8a204a9b25 Merge pull request #395 from catalyst/MOODLE_501_versionfix
Issue #390: fixed version.php plugin version, release and required moodle version.
2026-01-13 13:14:32 +11:00
abhinavgandham 245bc347d4 Added new line at the end of version.php. 2026-01-13 12:03:06 +10:00
abhinavgandham cc09171e82 Fixed comments indentation. 2026-01-13 11:47:11 +10:00
abhinavgandham c0ea1c1261 Issue #390: fixed version.php plugin version, release and required moodle version. 2026-01-13 11:31:09 +10:00
Brendan Heywood 2c25292a40 Merge pull request #393 from catalyst/MOODLE_501_codecleanup
Issue #390: Code cleanup to fix code standards codesniffer errors.
2026-01-12 17:56:13 +11:00
abhinavgandham 2b30fca670 Changed require_once path in behat_auth_outage.php 2026-01-12 16:23:44 +10:00
abhinavgandham 1183420b3b Issue #390: Code cleanup to fix code standards codesniffer errors. 2026-01-12 15:08:32 +10:00
Guillaume 845a370d6f Fix #314: Switch optional_param starttime to optional_param_array (#384)
* Fix #314: Switch optional_param starttime to optional_param_array

* convert default startime to timestamp

* fix error debug warning
2025-12-03 17:40:42 +11:00
Brendan Heywood 329c635b3a Merge pull request #385 from catalyst/fix-define-5-1
Fix bootstrap define #352
2025-11-29 16:46:26 +11:00
Brendan Heywood b932792cb0 Fix bootstrap define #352 2025-11-29 15:53:06 +11:00
Brendan Heywood 8bdfa9e222 Merge pull request #381 from catalyst/tweak-comment
Improve comments when blocked
2025-10-22 15:08:20 +10:00
Brendan Heywood 77ee908aed Improve comments when blocked 2025-10-22 14:19:54 +11:00
Dan Marsden 1e40a209b0 Merge pull request #380 from aspark21/patch-1
5.1+ path has changed due to MDL-83424
2025-09-22 02:45:37 +01:00
Dan Marsden 361250ed49 Moodle 5.1 branch. 2025-09-22 13:36:28 +12:00
Alistair Spark 0fd6a20e8e 5.1+ path has changed due to MDL-83424 2025-09-21 18:47:19 +01:00
15 changed files with 226 additions and 34 deletions
+5 -4
View File
@@ -1,4 +1,4 @@
[![ci](https://github.com/catalyst/moodle-auth_outage/actions/workflows/ci.yml/badge.svg?branch=MOODLE_39_STABLE)](https://github.com/catalyst/moodle-auth_outage/actions/workflows/ci.yml?branch=MOODLE_39_STABLE)
[![ci](https://github.com/catalyst/moodle-auth_outage/actions/workflows/ci.yml/badge.svg?branch=MOODLE_501_STABLE)](https://github.com/catalyst/moodle-auth_outage/actions/workflows/ci.yml?branch=MOODLE_501_STABLE)
# Moodle Outage manager plugin
- [Moodle Outage manager plugin](#moodle-outage-manager-plugin)
@@ -42,9 +42,10 @@ need to manually add one extra plugin, please check:
Moodle supported branches
--------
| Version | Branch | PHP |
|-------------|-------------------|------|
| Moodle 3.9+ | MOODLE_39_STABLE | 7.2+ |
| Version | Branch | PHP |
|----------------|---------------------|------|
| Moodle 5.1 | MOODLE_501_STABLE | 8.2 |
| Moodle 3.9-5.0 | MOODLE_39_STABLE | 7.2+ |
Totara supported branches
--------
+79
View File
@@ -84,6 +84,82 @@ class outagedb {
return new outage($outage);
}
/**
* Also sends all admins the event as a message
*
* @param $outage
* @param $event
*/
private static function notify($outage, $event) {
$admins = get_admins();
foreach ($admins as $admin) {
self::notify_user($outage, $event, $admin);
}
}
/**
* Send outage info to one user
*
* @param $outage outage
* @param $event event
* @param $to user object
*/
private static function notify_user($outage, $event, $to) {
global $SITE, $CFG;
$from = \core_user::get_user($event->userid);
if (!$from) {
return;
}
$fields = [
'site_shortname' => $SITE->shortname,
'site_fullname' => $SITE->fullname,
'site_wwwroot' => $CFG->wwwroot,
'outage_id' => $outage->id,
'outage_title' => $outage->get_title(),
'outage_desc' => clean_text($outage->get_description(), FORMAT_HTML),
'outage_start' => userdate($outage->starttime, get_string('datetimeformat', 'auth_outage')),
'outage_stop' => userdate($outage->stoptime, get_string('datetimeformat', 'auth_outage')),
'outage_duration' => format_time($outage->get_duration_planned()),
'event_name' => $event->get_name(),
'event_desc' => $event->get_description(),
'event_link' => $event->get_url()->out(),
'from_name' => fullname($from),
'to_name' => fullname($to),
'prefs_link' => (new \moodle_url('/message/notificationpreferences.php'))->out(),
];
$message = new \core\message\message();
$message->component = 'auth_outage';
$message->name = 'updatenotify';
$message->userto = $to;
$message->subject = get_string('messagesubject', 'auth_outage', $fields);
$message->fullmessage = get_string('messagetext', 'auth_outage', $fields);
$message->fullmessagehtml = get_string('messagehtml', 'auth_outage', $fields);
$message->fullmessageformat = FORMAT_HTML;
$threadid = generate_email_messageid('outage' . $outage->id);
$message->userfrom = $from;
$message->userfrom->customheaders = [
"In-Reply-To: $threadid",
"References: $threadid",
"Thread-Topic: " . $message->subject,
"Thread-Index: $threadid",
];
$message->notification = 1;
message_send($message);
}
/**
* Saves an outage to the database.
*
@@ -114,6 +190,7 @@ class outagedb {
]);
$event->add_record_snapshot('auth_outage', (object)(array) $outage);
$event->trigger();
self::notify($outage, $event);
// Create calendar entry.
calendar::create($outage);
@@ -127,6 +204,7 @@ class outagedb {
$event->add_record_snapshot('auth_outage', (object)(array) $outage);
$event->trigger();
self::notify($outage, $event);
// Remove the createdby field so it does not get updated.
unset($outage->createdby);
@@ -170,6 +248,7 @@ class outagedb {
$event->add_record_snapshot('auth_outage', $previous);
$event->trigger();
self::notify($outage, $event);
// Delete it and remove from calendar.
$DB->delete_records('auth_outage', ['id' => $id]);
+11 -1
View File
@@ -28,13 +28,23 @@ use moodle_url;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class outage_created extends base {
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventoutagecreated', 'auth_outage');
}
/**
* Returns non-localised event description with id's for admin use only.
*
* @return string
*/
public function get_description() {
return "The user with the id '{$this->userid}' created outage {$this->other['id']} '{$this->other['title']}'";
return "The user with the id '{$this->userid}' scheduled outage {$this->other['id']} '{$this->other['title']}'";
}
/**
+10
View File
@@ -28,6 +28,16 @@ use moodle_url;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class outage_deleted extends base {
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventoutagedeleted', 'auth_outage');
}
/**
* Returns non-localised event description with id's for admin use only.
*
+10
View File
@@ -28,6 +28,16 @@ use moodle_url;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class outage_updated extends base {
/**
* Return localised event name.
*
* @return string
*/
public static function get_name() {
return get_string('eventoutageupdated', 'auth_outage');
}
/**
* Returns non-localised event description with id's for admin use only.
*
+12 -4
View File
@@ -253,7 +253,7 @@ class outagelib {
* @param int $stoptime Outage stop time.
* @param string $allowedips List of IPs allowed.
* @param string|null $accesskey access key, or null if no access key set.
* @param string|null $metadata metadata to be added to the outage headers, or null if none.
* @param string|null $metadata Metadata to set in headers, or null if none.
*
* @return string
* @throws invalid_parameter_exception
@@ -345,9 +345,17 @@ EOT;
$search = ['{{STARTTIME}}', '{{STOPTIME}}', '{{USEALLOWEDIPS}}', '{{ALLOWEDIPS}}', '{{USEACCESSKEY}}', '{{ACCESSKEY}}',
'{{YOURIP}}', '{{COOKIESECURE}}', '{{COOKIEHTTPONLY}}', '{{METADATA}}'];
// Note that var_export is required because (string) false == '', not 'false'.
$replace = [$starttime, $stoptime, var_export(!empty($allowedips), true), $allowedips, var_export(!empty($accesskey), true),
$accesskey, getremoteaddr('n/a'), var_export($cookiesecure, true),
var_export($cookiehttponly, true), var_export($metadata, true)];
$replace = [
$starttime,
$stoptime,
var_export(!empty($allowedips), true),
$allowedips,
var_export(!empty($accesskey), true),
$accesskey,
getremoteaddr('n/a'),
var_export($cookiesecure, true),
var_export($cookiehttponly, true),
var_export($metadata, true)];
return str_replace($search, $replace, $code);
}
+9
View File
@@ -34,4 +34,13 @@ $capabilities = [
'user' => CAP_ALLOW,
],
],
'auth/outage:updatenotify' => [
'captype' => 'write',
'riskbitmask' => RISK_XSS,
'contextlevel' => CONTEXT_SYSTEM,
'archetypes' => [
'manager' => CAP_ALLOW,
]
],
];
+32
View File
@@ -0,0 +1,32 @@
<?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/>.
/**
* Defines message providers for outage
*
* @package auth_outage
* @copyright 2020 Brendan Heywood <brendan@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
$messageproviders = [
'updatenotify' => [
'capability' => 'auth/outage:updatenotify',
]
];
+4 -4
View File
@@ -61,7 +61,7 @@ function xmldb_auth_outage_upgrade($oldversion) {
upgrade_plugin_savepoint(true, 2024081900, 'auth', 'outage');
}
if ($oldversion < 2024081901) {
if ($oldversion < 2026011301) {
// Define field metadata to be added to auth_outage.
$table = new xmldb_table('auth_outage');
$field = new xmldb_field('metadata', XMLDB_TYPE_TEXT, null, null, null, null, null, 'accesskey');
@@ -72,10 +72,10 @@ function xmldb_auth_outage_upgrade($oldversion) {
}
// Outage savepoint reached.
upgrade_plugin_savepoint(true, 2024081901, 'auth', 'outage');
upgrade_plugin_savepoint(true, 2026011301, 'auth', 'outage');
}
if ($oldversion < 2024081902) {
if ($oldversion < 2026011302) {
// Getting the table auth_outage and target field to remove from the table.
$table = new xmldb_table('auth_outage');
$field = new xmldb_field('autostart');
@@ -89,7 +89,7 @@ function xmldb_auth_outage_upgrade($oldversion) {
unset_config('default_autostart', 'auth_outage');
// Outage savepoint reached.
upgrade_plugin_savepoint(true, 2024081902, 'auth', 'outage');
upgrade_plugin_savepoint(true, 2026011302, 'auth', 'outage');
}
return true;
-1
View File
@@ -28,7 +28,6 @@ use auth_outage\form\outage\edit;
use auth_outage\local\outage;
use auth_outage\local\outagelib;
require_once(__DIR__ . '/../../config.php');
require_once($CFG->libdir . '/adminlib.php');
require_once($CFG->libdir . '/formslib.php');
+44 -6
View File
@@ -100,6 +100,9 @@ $string['defaultwarningduration'] = 'Warning duration';
$string['defaultwarningdurationdescription'] = 'Default warning time (in minutes) for outages.';
$string['description'] = 'Public Description';
$string['description_help'] = 'A full description of the outage, publicly visible by all users.';
$string['eventoutagecreated'] = 'Outage scheduled';
$string['eventoutagedeleted'] = 'Outage cancelled';
$string['eventoutageupdated'] = 'Outage updated';
$string['finish'] = 'Finish';
$string['info15secondsbefore'] = '15 seconds before';
$string['infoendofoutage'] = 'end of outage';
@@ -121,9 +124,48 @@ $string['messageoutageongoing'] = 'Back online at {$a->stop}.';
$string['messageoutagewarning'] = 'Shutting down in {{countdown}}';
$string['metadata'] = 'Outage metadata';
$string['metadata_help'] = 'Data here will be output in the outage page as a meta tag in the header of the outage page.';
$string['messageprovider:updatenotify'] = 'Changes to planned outages';
$string['messagesubject'] = '[{$a->site_shortname}] {$a->event_name} #{$a->outage_id}: {$a->outage_start}';
$string['messagetext'] = '{$a->event_name}
{$a->site_fullname} ({$a->site_wwwroot})
{$a->event_link}
ID: {$a->outage_id}
NAME: {$a->outage_title}
START: {$a->outage_start}
DURATION: {$a->outage_duration}
DESCRIPTION:
{$a->outage_desc}
--
To unsubscribe visit:
{$a->prefs_link}';
$string['messagehtml'] = '
<h3>{$a->event_name}</h3>
<p>{$a->site_fullname} (<a href="{$a->site_wwwroot}">{$a->site_wwwroot}</a>)</p>
<p><a href="{$a->event_link}">{$a->event_link}</a></p>
<h4>Name:</h4>
<p>{$a->outage_title}</p>
<h4>Start:</h4>
<p>{$a->outage_start}</p>
<h4>Duration:</h4>
<p>{$a->outage_duration}</p>
<h4>Description:</h4>
<p>{$a->outage_desc}</p>
<hr>
<p>To unsubscribe visit:<br>
<a href="{$a->prefs_link}">{$a->prefs_link}</a></p>
';
$string['na'] = 'n/a';
$string['notfound'] = 'No outages found.';
$string['outage:updatenotify'] = '';
$string['outage:updatenotify'] = 'Receive outage update notifications';
$string['outage:viewinfo'] = 'View outage info';
$string['outageclone'] = 'Clone outage';
$string['outageclonecrumb'] = 'Clone';
@@ -141,6 +183,7 @@ $string['outagefinishwarning'] = 'You are about to mark this outage as finished.
$string['outageslistfuture'] = 'Planned outages';
$string['outageslistpast'] = 'Outage history';
$string['pluginname'] = 'Outage manager';
$string["privacy:no_data_reason"] = "The Outage authentication plugin does not store any personal data.";
$string['removeselectors'] = 'Remove selectors';
$string['removeselectorsdescription'] = 'CSS selectors to remove when rendering a static themed maintenance page. One selector per line.';
$string['settingssectiondefaults'] = 'Default Outage Parameters';
@@ -172,8 +215,3 @@ $string['warningduration'] = 'Warning duration';
$string['warningduration_help'] = 'How long before the start of the outage should the warning be displayed.';
$string['warningdurationerrorinvalid'] = 'Warning duration must be positive.';
$string['warningreenablemaintenancemode'] = 'Please note that saving this outage will re-enable maintenance mode.<br />Untick "Auto start maintenance mode" if you want to prevent this.';
/*
* Privacy provider (GDPR)
*/
$string["privacy:no_data_reason"] = "The Outage authentication plugin does not store any personal data.";
+2 -2
View File
@@ -158,7 +158,7 @@ final class waitforit_test extends cli_testcase {
/**
* Tests the countdown.
*/
public function test_countdown() {
public function test_countdown(): void {
self::setAdminUser();
$now = time();
outagedb::save(new outage([
@@ -186,7 +186,7 @@ final class waitforit_test extends cli_testcase {
/**
* Tests if the outage changed while waiting.
*/
public function test_outagechanged() {
public function test_outagechanged(): void {
self::setAdminUser();
$now = time();
$id = outagedb::save(new outage([
@@ -583,7 +583,7 @@ final class maintenance_static_page_test extends \auth_outage\base_testcase {
/**
* Test meta refresh maximum 5 minutes.
*/
public function test_meta_refresh_maximum_5seconds() {
public function test_meta_refresh_maximum_5seconds(): void {
$this->resetAfterTest(true);
$html = "<!DOCTYPE html>\n" .
'<html><head><title>Title</title></head>' .
@@ -593,7 +593,6 @@ final class maintenance_static_page_test extends \auth_outage\base_testcase {
$page->set_max_refresh_time(5);
$page->generate();
$generated = trim(file_get_contents($page->get_io()->get_template_file()));
return $generated;
self::assertStringContainsString('<meta http-equiv="refresh" content="5">', $generated);
}
+4 -6
View File
@@ -28,9 +28,7 @@
defined('MOODLE_INTERNAL') || die();
$plugin->component = "auth_outage";
$plugin->version = 2024081903; // The current plugin version (Date: YYYYMMDDXX).
$plugin->release = 2024081903; // 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, 405]; // A range of branch numbers of supported moodle versions.
$plugin->incompatible = 501;
$plugin->version = 2026011304; // The current plugin version (Date: YYYYMMDDXX).
$plugin->release = 2026011304; // Human-readable release information.
$plugin->requires = 2025100600; // Moodle 5.1.
$plugin->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments!
+3 -4
View File
@@ -44,14 +44,13 @@ defined('MOODLE_INTERNAL') || die();
<?php if ($viewbag['admin']) : ?>
<?php
$adminlinks = [];
foreach (
[
$params = [
'startofwarning' => -$viewbag['outage']->get_warning_duration(),
'15secondsbefore' => -15,
'start' => 0,
'endofoutage' => $viewbag['outage']->get_duration_planned() - 1,
] as $title => $delta
) {
];
foreach ($params as $title => $delta) {
$adminlinks[] = html_writer::link(
new moodle_url(
'/auth/outage/info.php',