Compare commits

..

38 Commits

Author SHA1 Message Date
Tomo Tsuyuki 40fccef237 Revert "Fix URL is blocked message when not behind a proxy/load balancer"
This reverts commit 51db933862.
2026-06-18 12:00:11 +10:00
Tomo Tsuyuki dbc8e75092 issue #405: fix unit test failure 2026-06-18 10:02:04 +10: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
12 changed files with 36 additions and 113 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
--------
+13 -5
View File
@@ -56,7 +56,7 @@ class outagelib {
global $CFG;
require_once($CFG->libdir . '/filelib.php');
$curl = new curl(['ignoresecurity' => true]);
$curl = new curl();
$contents = $curl->get($file);
$info = $curl->get_info();
if (!empty($info['content_type'])) {
@@ -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);
}
-35
View File
@@ -64,41 +64,6 @@ class base_table extends flexible_table {
$this->set_attribute('class', 'generaltable admintable');
}
/**
* Displays a user by their fullname with a link to a profile.
* @param int $userid
* @return string HTML link to user profile
*/
private function format_user(int $userid): string {
if ($userid == 0 || !$user = \core_user::get_user($userid)) {
return get_string('na', 'auth_outage');
}
$url = new moodle_url('/user/profile.php', ['id' => $userid]);
return html_writer::link($url, fullname($user));
}
/**
* Formats created by column.
* @param outage $outage
* @return string The user who created the outage.
*/
protected function format_created(outage $outage): string {
return $this->format_user($outage->createdby);
}
/**
* Formats modified by column.
* @param outage $outage
* @return string The user who last modiifed the outage and the last modified time.
*/
protected function format_modified(outage $outage): string {
$timestamp = html_writer::div(
userdate($outage->lastmodified, get_string('datetimeformat', 'auth_outage')),
'small text-muted'
);
return $this->format_user($outage->modifiedby) . $timestamp;
}
/**
* Create the action buttons HTML code for a specific outage.
* @param outage $outage The outage to generate the buttons.
+1 -5
View File
@@ -36,7 +36,7 @@ class history_table extends base_table {
public function __construct() {
parent::__construct();
$this->define_columns(['warning', 'starts', 'duration', 'durationactual', 'title', 'created', 'modified', 'actions']);
$this->define_columns(['warning', 'starts', 'durationplanned', 'durationactual', 'title', 'actions']);
$this->define_headers([
get_string('tableheaderwarnbefore', 'auth_outage'),
@@ -44,8 +44,6 @@ class history_table extends base_table {
get_string('tableheaderdurationplanned', 'auth_outage'),
get_string('tableheaderdurationactual', 'auth_outage'),
get_string('tableheadertitle', 'auth_outage'),
get_string('tableheadercreatedby', 'auth_outage'),
get_string('tableheadermodifiedby', 'auth_outage'),
get_string('actions'),
]);
@@ -66,8 +64,6 @@ class history_table extends base_table {
format_time($outage->get_duration_planned()),
$finished,
$outage->get_title(),
$this->format_created($outage),
$this->format_modified($outage),
$this->create_data_buttons($outage, false),
]);
}
+1 -5
View File
@@ -38,15 +38,13 @@ class planned_table extends base_table {
public function __construct() {
parent::__construct();
$this->define_columns(['warning', 'starts', 'duration', 'title', 'created', 'modified', 'actions']);
$this->define_columns(['warning', 'starts', 'duration', 'title', 'actions']);
$this->define_headers([
get_string('tableheaderwarnbefore', 'auth_outage'),
get_string('tableheaderstarttime', 'auth_outage'),
get_string('tableheaderduration', 'auth_outage'),
get_string('tableheadertitle', 'auth_outage'),
get_string('tableheadercreatedby', 'auth_outage'),
get_string('tableheadermodifiedby', 'auth_outage'),
get_string('actions'),
]);
@@ -70,8 +68,6 @@ class planned_table extends base_table {
self::create_starttime_string($outage->starttime),
format_time($outage->get_duration_planned()),
$title,
$this->format_created($outage),
$this->format_modified($outage),
$this->create_data_buttons($outage, true),
]);
}
+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');
+1 -7
View File
@@ -141,6 +141,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';
@@ -149,11 +150,9 @@ $string['settingssectionplugin'] = 'Plugin Configuration';
$string['settingssectionplugindescription'] = 'General outage management plugin settings.';
$string['starttime'] = 'Start date and time';
$string['starttime_help'] = 'At which date and time the outage starts, preventing general access to the system.';
$string['tableheadercreatedby'] = 'Created by';
$string['tableheaderduration'] = 'Duration';
$string['tableheaderdurationactual'] = 'Actual duration';
$string['tableheaderdurationplanned'] = 'Planned duration';
$string['tableheadermodifiedby'] = 'Last modified by';
$string['tableheaderstartedtime'] = 'Started on';
$string['tableheaderstarttime'] = 'Starts on';
$string['tableheadertitle'] = 'Title';
@@ -172,8 +171,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([
@@ -431,39 +431,6 @@ final class maintenance_static_page_test extends \auth_outage\base_testcase {
maintenance_static_page_io::file_get_data(200);
}
/**
* Test file_get_data with curlsecurityblockedhosts.
* We will use an external URL to test passing ignoresecurity inside of file_get_data works,
* ideally in real code we should only be calling file_get_data with internal URLs.
*/
public function test_file_get_data_curlsecurityblockedhosts(): void {
global $CFG, $USER;
$testhtml = $this->getExternalTestFileUrl('/test.html');
$url = new \moodle_url($testhtml);
$host = $url->get_host();
set_config('curlsecurityblockedhosts', $host); // Blocks $host.
// Test a regular curl with the default security enabled does in fact get blocked.
$curl = new \curl();
$contents = $curl->get($testhtml);
$expected = $curl->get_security()->get_blocked_url_string();
self::assertSame($expected, $contents);
self::assertSame(0, $curl->get_errno());
if ($CFG->branch >= 403) {
self::assertDebuggingCalled(
"Blocked $testhtml: The URL is blocked. [user {$USER->id}]",
DEBUG_NONE
);
}
// Test file_get_data does return the page and isn't blocked by security.
$found = maintenance_static_page_io::file_get_data($url->out());
$expected = '47250a973d1b88d9445f94db4ef2c97a';
self::assertSame($expected, md5($found['contents']));
self::assertSame('text/html', $found['mime']);
}
/**
* Test remove css selector.
*/
@@ -583,7 +550,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 +560,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);
}
+5 -6
View File
@@ -28,9 +28,8 @@
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!
$plugin->supported = [501, 501]; // A range of branch numbers of supported moodle versions.
+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',