diff --git a/auth.php b/auth.php
index 4bf8c85..e937086 100644
--- a/auth.php
+++ b/auth.php
@@ -32,7 +32,7 @@ use auth_outage\local\outagelib;
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir.'/authlib.php');
+require_once($CFG->libdir . '/authlib.php');
/**
* auth_plugin_outage class.
diff --git a/bootstrap.php b/bootstrap.php
index 415c9ea..7d74105 100644
--- a/bootstrap.php
+++ b/bootstrap.php
@@ -40,7 +40,7 @@ if (!isset($CFG->dataroot)) {
// 1) Make sure we replace the configurations for behat as we have not ran 'lib/setup.php' yet.
if (!empty($CFG->behat_wwwroot) || !empty($CFG->behat_dataroot) || !empty($CFG->behat_prefix)) {
- require_once(__DIR__.'/../../lib/behat/lib.php');
+ require_once(__DIR__ . '/../../lib/behat/lib.php');
behat_update_vars_for_process();
if (behat_is_test_site()) {
$beforebehatcfg = $CFG;
@@ -74,11 +74,11 @@ if (!empty($_SERVER['REQUEST_URI'])) {
if (array_key_exists('path', $rooturl) && !empty($rooturl['path'])) {
$path = $rooturl['path'];
}
- $url = $path.'/auth/outage/info.php';
+ $url = $path . '/auth/outage/info.php';
$outageinfo = strpos($_SERVER['REQUEST_URI'], $url) === 0 ? true : false;
}
-$allowed = !file_exists($CFG->dataroot.'/climaintenance.php') // Not in maintenance mode.
+$allowed = !file_exists($CFG->dataroot . '/climaintenance.php') // Not in maintenance mode.
|| (defined('ABORT_AFTER_CONFIG') && ABORT_AFTER_CONFIG) // Only config requested.
|| (defined('CLI_SCRIPT') && CLI_SCRIPT) // Allow CLI scripts.
|| $outageinfo // Allow outage info requests.
@@ -87,7 +87,7 @@ if (!$allowed) {
// Call the climaintenance.php which will check for the conditions
// that have been baked into it from the frontend (ip, accesskey, etc...).
$CFG->dirroot = dirname(dirname(dirname(__FILE__))); // It is not defined yet but the script below needs it.
- require($CFG->dataroot.'/climaintenance.php'); // This call may terminate the script here or not.
+ require($CFG->dataroot . '/climaintenance.php'); // This call may terminate the script here or not.
}
// 4) Set flag this file was loaded.
diff --git a/checkfinished.php b/checkfinished.php
index f7e15b9..684b8ee 100644
--- a/checkfinished.php
+++ b/checkfinished.php
@@ -31,7 +31,7 @@ header('Cache-Control: public, max-age=10,s-maxage=10');
// @codingStandardsIgnoreEnd
define('NO_AUTH_OUTAGE', true);
-require_once(__DIR__.'/../../config.php');
+require_once(__DIR__ . '/../../config.php');
$active = outagedb::get_active();
diff --git a/classes/calendar/calendar.php b/classes/calendar/calendar.php
index d2ae3f0..3cea7a0 100644
--- a/classes/calendar/calendar.php
+++ b/classes/calendar/calendar.php
@@ -20,7 +20,7 @@ use auth_outage\local\outage;
use calendar_event;
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->dirroot.'/calendar/lib.php');
+require_once($CFG->dirroot . '/calendar/lib.php');
/**
* calendar class.
@@ -53,7 +53,7 @@ class calendar {
$event = self::load($outage->id);
if (is_null($event)) {
- debugging('Cannot update calendar entry for outage #'.$outage->id.', event not found. Creating it...');
+ debugging('Cannot update calendar entry for outage #' . $outage->id . ', event not found. Creating it...');
self::create($outage);
} else {
$event->update(self::create_data($outage), false);
@@ -69,7 +69,7 @@ class calendar {
// If not found (was not created before) ignore it.
if (is_null($event)) {
- debugging('Cannot delete calendar entry for outage #'.$outageid.', event not found. Ignoring it...');
+ debugging('Cannot delete calendar entry for outage #' . $outageid . ', event not found. Ignoring it...');
} else {
$event->delete();
}
diff --git a/classes/dml/outagedb.php b/classes/dml/outagedb.php
index 6582669..9126159 100644
--- a/classes/dml/outagedb.php
+++ b/classes/dml/outagedb.php
@@ -26,7 +26,7 @@ use coding_exception;
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->dirroot.'/calendar/lib.php');
+require_once($CFG->dirroot . '/calendar/lib.php');
/**
* outagedb class.
@@ -118,7 +118,6 @@ class outagedb {
// Create calendar entry.
calendar::create($outage);
} else {
-
$other = (array) $outage;
$other['title'] = $outage->get_title();
$event = outage_updated::create([
@@ -208,8 +207,10 @@ class outagedb {
$outagecache = new outage(json_decode($outageinfo));
}
- if ($outagecache && $outagecache->warntime <= $time && $outagecache->stoptime >= $time
- && (!$outagecache->finished || $outagecache->finished >= $time)) {
+ if (
+ $outagecache && $outagecache->warntime <= $time && $outagecache->stoptime >= $time
+ && (!$outagecache->finished || $outagecache->finished >= $time)
+ ) {
return $outagecache;
}
return null;
@@ -238,7 +239,8 @@ class outagedb {
':datetime1 < stoptime AND (finished IS NULL OR :datetime2 < finished)',
['datetime1' => $time, 'datetime2' => $time],
'starttime ASC, stoptime DESC, title ASC',
- '*');
+ '*'
+ );
foreach ($rs as $r) {
$outages[] = new outage($r);
}
@@ -270,7 +272,8 @@ class outagedb {
'NOT (:datetime1 < stoptime AND (finished IS NULL OR :datetime2 < finished))',
['datetime1' => $time, 'datetime2' => $time],
'stoptime DESC, starttime DESC, title ASC',
- '*');
+ '*'
+ );
foreach ($rs as $r) {
$outages[] = new outage($r);
}
@@ -295,12 +298,12 @@ class outagedb {
$outage = self::get_by_id($id);
if (is_null($outage)) {
- debugging('Cannot finish outage #'.$id.': outage not found.');
+ debugging('Cannot finish outage #' . $id . ': outage not found.');
return;
}
if (!$outage->is_ongoing($time)) {
- debugging('Cannot finish outage #'.$id.': outage not ongoing.');
+ debugging('Cannot finish outage #' . $id . ': outage not ongoing.');
return;
}
diff --git a/classes/form/outage/delete.php b/classes/form/outage/delete.php
index 0d65da5..7994526 100644
--- a/classes/form/outage/delete.php
+++ b/classes/form/outage/delete.php
@@ -17,7 +17,7 @@
namespace auth_outage\form\outage;
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir.'/formslib.php');
+require_once($CFG->libdir . '/formslib.php');
/**
* delete class.
diff --git a/classes/form/outage/edit.php b/classes/form/outage/edit.php
index d830cf3..60e3276 100644
--- a/classes/form/outage/edit.php
+++ b/classes/form/outage/edit.php
@@ -22,7 +22,7 @@ use moodleform;
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir.'/formslib.php');
+require_once($CFG->libdir . '/formslib.php');
/**
* edit class.
@@ -64,7 +64,7 @@ class edit extends moodleform {
'text',
'title',
get_string('title', 'auth_outage'),
- 'maxlength="'.self::TITLE_MAX_CHARS.'" size="60"'
+ 'maxlength="' . self::TITLE_MAX_CHARS . '" size="60"'
);
$mform->setType('title', PARAM_TEXT);
$mform->addHelpButton('title', 'title', 'auth_outage');
@@ -75,8 +75,13 @@ class edit extends moodleform {
$mform->addElement('static', 'usagehints', '', get_string('textplaceholdershint', 'auth_outage'));
$mform->addElement('static', 'warningreenablemaintenancemode', '');
- $mform->addElement('advcheckbox', 'useaccesskey', get_string('useaccesskey', 'auth_outage'),
- get_string('useaccesskey:desc', 'auth_outage'), 0);
+ $mform->addElement(
+ 'advcheckbox',
+ 'useaccesskey',
+ get_string('useaccesskey', 'auth_outage'),
+ get_string('useaccesskey:desc', 'auth_outage'),
+ 0
+ );
$mform->addElement('text', 'accesskey', get_string('accesskey', 'auth_outage'));
$mform->setType('accesskey', PARAM_TEXT);
@@ -125,7 +130,7 @@ class edit extends moodleform {
return null;
}
if ($data->description['format'] != '1') {
- debugging('Not implemented for format '.$data->description['format'], DEBUG_DEVELOPER);
+ debugging('Not implemented for format ' . $data->description['format'], DEBUG_DEVELOPER);
return null;
}
$outagedata = [
@@ -165,8 +170,10 @@ class edit extends moodleform {
]);
// If the default_autostart is configured in config, then force autostart to be the default value.
- if (array_key_exists('auth_outage', $CFG->forced_plugin_settings)
- && array_key_exists('default_autostart', $CFG->forced_plugin_settings['auth_outage'])) {
+ if (
+ array_key_exists('auth_outage', $CFG->forced_plugin_settings)
+ && array_key_exists('default_autostart', $CFG->forced_plugin_settings['auth_outage'])
+ ) {
$this->_form->setDefaults([
'autostart' => $CFG->forced_plugin_settings['auth_outage']['default_autostart'],
]);
@@ -175,8 +182,10 @@ class edit extends moodleform {
if (!empty($outage->id) && $outage->autostart && $outage->starttime < time() && $outage->stoptime > time()) {
$warning = $mform->getElement('warningreenablemaintenancemode');
- $warning->setValue($OUTPUT->notification(get_string('warningreenablemaintenancemode', 'auth_outage'),
- 'notifywarning'));
+ $warning->setValue($OUTPUT->notification(
+ get_string('warningreenablemaintenancemode', 'auth_outage'),
+ 'notifywarning'
+ ));
}
} else {
throw new coding_exception('$outage must be an outage object.', $outage);
diff --git a/classes/form/outage/finish.php b/classes/form/outage/finish.php
index 473ea60..32ef0bb 100644
--- a/classes/form/outage/finish.php
+++ b/classes/form/outage/finish.php
@@ -20,7 +20,7 @@ use moodleform;
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir.'/formslib.php');
+require_once($CFG->libdir . '/formslib.php');
/**
* finish class.
diff --git a/classes/hook_callbacks.php b/classes/hook_callbacks.php
index c6688e6..bbd0223 100644
--- a/classes/hook_callbacks.php
+++ b/classes/hook_callbacks.php
@@ -28,7 +28,6 @@ use core\hook\output\before_standard_top_of_body_html_generation;
* @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.
*
diff --git a/classes/local/cli/cli_exception.php b/classes/local/cli/cli_exception.php
index 16926de..ee871d0 100644
--- a/classes/local/cli/cli_exception.php
+++ b/classes/local/cli/cli_exception.php
@@ -79,6 +79,6 @@ class cli_exception extends Exception {
* @param Exception|null $previous Another exception as reference or null.
*/
public function __construct($message, $code = 1, ?Exception $previous = null) {
- parent::__construct('*ERROR* '.$message, $code, $previous = null);
+ parent::__construct('*ERROR* ' . $message, $code, $previous = null);
}
}
diff --git a/classes/local/cli/clibase.php b/classes/local/cli/clibase.php
index 699e87b..a1cbc3a 100644
--- a/classes/local/cli/clibase.php
+++ b/classes/local/cli/clibase.php
@@ -46,7 +46,7 @@ abstract class clibase {
*/
public function __construct(?array $options = null) {
global $CFG;
- require_once($CFG->libdir.'/clilib.php');
+ require_once($CFG->libdir . '/clilib.php');
$warning = outagelib::generate_plugin_configuration_warning();
if ($warning) {
@@ -57,11 +57,13 @@ abstract class clibase {
if (is_null($options)) {
// Using Moodle CLI API to read the parameters.
- list($options, $unrecognized) = cli_get_params($this->generate_options(), $this->generate_shortcuts());
+ [$options, $unrecognized] = cli_get_params($this->generate_options(), $this->generate_shortcuts());
if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
- throw new cli_exception(get_string('cliunknowoption', 'admin', $unrecognized),
- cli_exception::ERROR_PARAMETER_UNKNOWN);
+ throw new cli_exception(
+ get_string('cliunknowoption', 'admin', $unrecognized),
+ cli_exception::ERROR_PARAMETER_UNKNOWN
+ );
}
} else {
// If not using Moodle CLI API to read parameters, ensure all keys exist.
@@ -129,13 +131,13 @@ abstract class clibase {
$options = $this->generate_options();
$shorts = array_flip($this->generate_shortcuts());
- printf("%s\n\n", get_string('cli'.$cliname.'help', 'auth_outage'));
+ printf("%s\n\n", get_string('cli' . $cliname . 'help', 'auth_outage'));
foreach (array_keys($options) as $long) {
- $text = get_string('cli'.$cliname.'param'.$long, 'auth_outage');
- $short = isset($shorts[$long]) ? ('-'.$shorts[$long].',') : '';
- $long = '--'.$long;
+ $text = get_string('cli' . $cliname . 'param' . $long, 'auth_outage');
+ $short = isset($shorts[$long]) ? ('-' . $shorts[$long] . ',') : '';
+ $long = '--' . $long;
printf(" %-4s %-20s %s\n", $short, $long, $text);
}
- printf("\n%s\n\n", get_string('cli'.$cliname.'examples', 'auth_outage'));
+ printf("\n%s\n\n", get_string('cli' . $cliname . 'examples', 'auth_outage'));
}
}
diff --git a/classes/local/cli/create.php b/classes/local/cli/create.php
index 8ac8bbf..62234f3 100644
--- a/classes/local/cli/create.php
+++ b/classes/local/cli/create.php
@@ -83,7 +83,7 @@ class create extends clibase {
// Check if any extra parameter was given.
foreach (array_keys($defaults) as $key) {
if (!array_key_exists($key, $missing)) {
- throw new coding_exception('$default['.$key.'] is not valid.');
+ throw new coding_exception('$default[' . $key . '] is not valid.');
}
unset($missing[$key]);
}
@@ -91,7 +91,7 @@ class create extends clibase {
// Check if any required parameter is missing.
foreach (array_keys($missing) as $k => $v) {
if (is_null($v)) {
- throw new coding_exception('$default[] missing: '.$k);
+ throw new coding_exception('$default[] missing: ' . $k);
}
}
@@ -110,8 +110,10 @@ class create extends clibase {
// If not help mode, 'start' is required and cannot use default.
if (is_null($this->options['start'])) {
- throw new cli_exception(get_string('clierrormissingparamaters', 'auth_outage'),
- cli_exception::ERROR_PARAMETER_MISSING);
+ throw new cli_exception(
+ get_string('clierrormissingparamaters', 'auth_outage'),
+ cli_exception::ERROR_PARAMETER_MISSING
+ );
}
// If cloning, set defaults to outage being cloned.
@@ -189,8 +191,10 @@ class create extends clibase {
private function clone_defaults() {
$id = $this->options['clone'];
if (!is_number($id) || ($id <= 0)) {
- throw new cli_exception(get_string('clierrorinvalidvaluenotid', 'auth_outage', ['param' => 'clone']),
- cli_exception::ERROR_PARAMETER_INVALID);
+ throw new cli_exception(
+ get_string('clierrorinvalidvaluenotid', 'auth_outage', ['param' => 'clone']),
+ cli_exception::ERROR_PARAMETER_INVALID
+ );
}
$outage = outagedb::get_by_id((int)$id);
@@ -234,13 +238,17 @@ class create extends clibase {
*/
private function merge_options_check_parameters_int_nonnegative($option, $param) {
if (!is_number($option)) {
- throw new cli_exception(get_string('clierrorinvalidvaluenotnumber', 'auth_outage', ['param' => $param]),
- cli_exception::ERROR_PARAMETER_INVALID);
+ throw new cli_exception(
+ get_string('clierrorinvalidvaluenotnumber', 'auth_outage', ['param' => $param]),
+ cli_exception::ERROR_PARAMETER_INVALID
+ );
}
$option = (int)$option;
if ($option < 0) {
- throw new cli_exception(get_string('clierrorinvalidvaluenegativenumber', 'auth_outage', ['param' => $param]),
- cli_exception::ERROR_PARAMETER_INVALID);
+ throw new cli_exception(
+ get_string('clierrorinvalidvaluenegativenumber', 'auth_outage', ['param' => $param]),
+ cli_exception::ERROR_PARAMETER_INVALID
+ );
}
return $option;
}
@@ -254,13 +262,17 @@ class create extends clibase {
*/
private function merge_options_check_parameters_string_nonempty($option, $param) {
if (!is_string($option)) {
- throw new cli_exception(get_string('clierrorinvalidvaluenotstring', 'auth_outage', ['param' => $param]),
- cli_exception::ERROR_PARAMETER_INVALID);
+ throw new cli_exception(
+ get_string('clierrorinvalidvaluenotstring', 'auth_outage', ['param' => $param]),
+ cli_exception::ERROR_PARAMETER_INVALID
+ );
}
$option = trim($option);
if (strlen($option) == 0) {
- throw new cli_exception(get_string('clierrorinvalidvalueemptystring', 'auth_outage', ['param' => $param]),
- cli_exception::ERROR_PARAMETER_INVALID);
+ throw new cli_exception(
+ get_string('clierrorinvalidvalueemptystring', 'auth_outage', ['param' => $param]),
+ cli_exception::ERROR_PARAMETER_INVALID
+ );
}
return $option;
}
@@ -287,7 +299,9 @@ class create extends clibase {
}
}
- throw new cli_exception(get_string('clierrorinvalidvaluenotbool', 'auth_outage', ['param' => $param]),
- cli_exception::ERROR_PARAMETER_INVALID);
+ throw new cli_exception(
+ get_string('clierrorinvalidvaluenotbool', 'auth_outage', ['param' => $param]),
+ cli_exception::ERROR_PARAMETER_INVALID
+ );
}
}
diff --git a/classes/local/cli/finish.php b/classes/local/cli/finish.php
index 9eeee37..cc4a9a8 100644
--- a/classes/local/cli/finish.php
+++ b/classes/local/cli/finish.php
@@ -66,16 +66,20 @@ class finish extends clibase {
// Cannot run during CLI_MAINTENANCE mode.
if (CLI_MAINTENANCE) {
- throw new cli_exception(get_string('cliinmaintenancemode', 'auth_outage'),
- cli_exception::ERROR_MAINTENANCE_MODE);
+ throw new cli_exception(
+ get_string('cliinmaintenancemode', 'auth_outage'),
+ cli_exception::ERROR_MAINTENANCE_MODE
+ );
}
// Requires outageid or active but not both at the same time.
$byid = !is_null($this->options['outageid']);
$byactive = $this->options['active'];
if ($byid == $byactive) {
- throw new cli_exception(get_string('cliwaitforiterroridxoractive', 'auth_outage'),
- cli_exception::ERROR_PARAMETER_MISSING);
+ throw new cli_exception(
+ get_string('cliwaitforiterroridxoractive', 'auth_outage'),
+ cli_exception::ERROR_PARAMETER_MISSING
+ );
}
$outage = $this->get_outage();
@@ -97,8 +101,10 @@ class finish extends clibase {
} else {
$id = $this->options['outageid'];
if (!is_number($id) || ($id <= 0)) {
- throw new cli_exception(get_string('clierrorinvalidvalue', 'auth_outage', ['param' => 'outageid']),
- cli_exception::ERROR_PARAMETER_INVALID);
+ throw new cli_exception(
+ get_string('clierrorinvalidvalue', 'auth_outage', ['param' => 'outageid']),
+ cli_exception::ERROR_PARAMETER_INVALID
+ );
}
$outage = outagedb::get_by_id((int)$id);
}
diff --git a/classes/local/cli/waitforit.php b/classes/local/cli/waitforit.php
index 0ae7c2a..dd95103 100644
--- a/classes/local/cli/waitforit.php
+++ b/classes/local/cli/waitforit.php
@@ -90,8 +90,10 @@ class waitforit extends clibase {
$byid = !is_null($this->options['outageid']);
$byactive = $this->options['active'];
if ($byid == $byactive) {
- throw new cli_exception(get_string('cliwaitforiterroridxoractive', 'auth_outage'),
- cli_exception::ERROR_PARAMETER_INVALID);
+ throw new cli_exception(
+ get_string('cliwaitforiterroridxoractive', 'auth_outage'),
+ cli_exception::ERROR_PARAMETER_INVALID
+ );
}
$this->verbose('Verbose mode activated.');
@@ -100,11 +102,11 @@ class waitforit extends clibase {
while ($sleep = $this->wait_for_outage_to_start($outage)) {
if (is_null($this->sleepcallback)) {
- $this->verbose('Sleeping for '.$sleep.' second(s).');
+ $this->verbose('Sleeping for ' . $sleep . ' second(s).');
sleep($sleep);
$this->time = time();
} else {
- $this->verbose('Calling callback to sleep '.$sleep.' second(s).');
+ $this->verbose('Calling callback to sleep ' . $sleep . ' second(s).');
$callback = $this->sleepcallback;
$this->time = $callback($sleep);
}
@@ -136,10 +138,12 @@ class waitforit extends clibase {
} else {
$id = $this->options['outageid'];
if (!is_number($id) || ($id <= 0)) {
- throw new cli_exception(get_string('clierrorinvalidvalue', 'auth_outage', ['param' => 'outageid']),
- cli_exception::ERROR_PARAMETER_INVALID);
+ throw new cli_exception(
+ get_string('clierrorinvalidvalue', 'auth_outage', ['param' => 'outageid']),
+ cli_exception::ERROR_PARAMETER_INVALID
+ );
}
- $this->verbose('Querying database for outage #'.$id.'...');
+ $this->verbose('Querying database for outage #' . $id . '...');
$outage = outagedb::get_by_id((int)$id);
}
@@ -147,7 +151,7 @@ class waitforit extends clibase {
throw new cli_exception(get_string('clierroroutagenotfound', 'auth_outage'), cli_exception::ERROR_OUTAGE_NOT_FOUND);
}
- $this->verbose('Found outage #'.$outage->id.': '.$outage->get_title());
+ $this->verbose('Found outage #' . $outage->id . ': ' . $outage->get_title());
return $outage;
}
diff --git a/classes/local/controllers/infopage.php b/classes/local/controllers/infopage.php
index fcdf051..a812b7c 100644
--- a/classes/local/controllers/infopage.php
+++ b/classes/local/controllers/infopage.php
@@ -114,7 +114,7 @@ class infopage {
'admin' => is_siteadmin(),
'outage' => $this->outage,
];
- require($CFG->dirroot.'/auth/outage/views/info/content.php');
+ require($CFG->dirroot . '/auth/outage/views/info/content.php');
// Moodle 2.7 did not check for CLI mode, which was fixed later.
if (!($CFG->branch == '27' && CLI_SCRIPT)) {
@@ -133,7 +133,7 @@ class infopage {
}
if (!is_null($params['id']) && !is_null($params['outage']) && ($params['id'] !== $params['outage']->id)) {
- throw new coding_exception('Provided id and outage->id do not match.', $params['id'].'/'.$params['outage']->id);
+ throw new coding_exception('Provided id and outage->id do not match.', $params['id'] . '/' . $params['outage']->id);
}
if (is_null($params['id']) && is_null($params['outage'])) {
diff --git a/classes/local/controllers/maintenance_static_page.php b/classes/local/controllers/maintenance_static_page.php
index b2a6858..485d640 100644
--- a/classes/local/controllers/maintenance_static_page.php
+++ b/classes/local/controllers/maintenance_static_page.php
@@ -50,7 +50,8 @@ class maintenance_static_page {
$html = '';
} else {
$data = maintenance_static_page_io::file_get_data(
- $CFG->wwwroot.'/auth/outage/info.php?auth_outage_hide_warning=1&static=1&id='.$outage->id);
+ $CFG->wwwroot . '/auth/outage/info.php?auth_outage_hide_warning=1&static=1&id=' . $outage->id
+ );
$html = $data['contents'];
}
diff --git a/classes/local/controllers/maintenance_static_page_generator.php b/classes/local/controllers/maintenance_static_page_generator.php
index f9a0cd9..820e5e5 100644
--- a/classes/local/controllers/maintenance_static_page_generator.php
+++ b/classes/local/controllers/maintenance_static_page_generator.php
@@ -74,7 +74,6 @@ class maintenance_static_page_generator {
$this->io->cleanup();
if (!is_null($this->dom)) {
-
// This can take a while to process using repeated curls.
core_php_time_limit::raise();
@@ -184,9 +183,9 @@ class maintenance_static_page_generator {
$fullurl = $originalurl;
} else if ($originalurl[0] == '/') {
$rooturl = parse_url($CFG->wwwroot);
- $fullurl = $rooturl['scheme'].'://'.$rooturl['host'].$originalurl;
+ $fullurl = $rooturl['scheme'] . '://' . $rooturl['host'] . $originalurl;
} else {
- $fullurl = $baseref.'/'.$originalurl;
+ $fullurl = $baseref . '/' . $originalurl;
}
$saved = $this->io->save_url_file($fullurl);
@@ -253,7 +252,7 @@ class maintenance_static_page_generator {
$fullurl = (string) new moodle_url($matches[1]);
}
$newurl = $this->io->generate_file_url($fullurl);
- $updated = preg_replace(self::PATTERN, ' url('.$newurl.') ', $style);
+ $updated = preg_replace(self::PATTERN, ' url(' . $newurl . ') ', $style);
$element->setAttribute('style', $updated);
}
}
diff --git a/classes/local/controllers/maintenance_static_page_io.php b/classes/local/controllers/maintenance_static_page_io.php
index 239c3fd..abfed21 100644
--- a/classes/local/controllers/maintenance_static_page_io.php
+++ b/classes/local/controllers/maintenance_static_page_io.php
@@ -61,7 +61,7 @@ class maintenance_static_page_io {
}
if ($result['contents'] === false) {
- debugging('Cannot fetch: '.$file);
+ debugging('Cannot fetch: ' . $file);
$result = ['contents' => '', 'mime' => 'unknown'];
}
return $result;
@@ -85,9 +85,9 @@ class maintenance_static_page_io {
public function get_template_file() {
global $CFG;
if ($this->preview) {
- return $this->get_resources_folder().'/climaintenance.html';
+ return $this->get_resources_folder() . '/climaintenance.html';
} else {
- return $CFG->dataroot.'/climaintenance.template.html';
+ return $CFG->dataroot . '/climaintenance.template.html';
}
}
@@ -102,10 +102,10 @@ class maintenance_static_page_io {
global $CFG;
// If you change the path, also change file auth/outage/bootstrap.php as it does not use this reference.
- $dir = $CFG->dataroot.'/auth_outage/climaintenance';
+ $dir = $CFG->dataroot . '/auth_outage/climaintenance';
if ($this->preview) {
- $dir = $dir.'/preview';
+ $dir = $dir . '/preview';
}
return $dir;
}
@@ -155,18 +155,18 @@ class maintenance_static_page_io {
$dir = realpath($dir);
$safedir = $this->get_resources_folder();
if (substr($dir, 0, strlen($safedir)) !== $safedir) {
- throw new invalid_parameter_exception('Unsafe to delete: '.$dir);
+ throw new invalid_parameter_exception('Unsafe to delete: ' . $dir);
}
if (!is_dir($dir)) {
- throw new coding_exception('Not a directory: '.$dir);
+ throw new coding_exception('Not a directory: ' . $dir);
}
$files = scandir($dir);
foreach ($files as $file) {
if (($file == '.') || ($file == '..')) {
continue;
}
- $file = $dir.'/'.$file;
+ $file = $dir . '/' . $file;
if (is_file($file)) {
unlink($file);
continue;
@@ -175,7 +175,7 @@ class maintenance_static_page_io {
$this->delete_directory_recursively($file);
continue;
}
- throw new coding_exception('Not a file or directory: '.$file);
+ throw new coding_exception('Not a file or directory: ' . $file);
}
rmdir($dir);
}
@@ -211,7 +211,7 @@ class maintenance_static_page_io {
global $CFG;
if (!self::is_url($url)) {
- debugging('Found a relative url ('.$url.') -- is it using moodle_url()?');
+ debugging('Found a relative url (' . $url . ') -- is it using moodle_url()?');
return null; // Leave hardcoded URLs as it is.
}
@@ -227,12 +227,12 @@ class maintenance_static_page_io {
$data = self::file_get_data($url);
$mime = trim(base64_encode($data['mime']), '=');
- $url = sha1($data['contents']).'.'.$mime;
- $filepath = $this->get_resources_folder().'/'.$url;
+ $url = sha1($data['contents']) . '.' . $mime;
+ $filepath = $this->get_resources_folder() . '/' . $url;
file_put_contents($filepath, $data['contents']);
if ($this->preview) {
- $url = 'preview/'.$url;
+ $url = 'preview/' . $url;
}
return ['file' => $filepath, 'url' => $url];
diff --git a/classes/local/outagelib.php b/classes/local/outagelib.php
index ffcc254..7e42885 100644
--- a/classes/local/outagelib.php
+++ b/classes/local/outagelib.php
@@ -26,7 +26,7 @@ use invalid_parameter_exception;
use stdClass;
defined('MOODLE_INTERNAL') || die();
-require_once(__DIR__.'/../../lib.php');
+require_once(__DIR__ . '/../../lib.php');
/**
* outagelib class.
@@ -37,7 +37,6 @@ require_once(__DIR__.'/../../lib.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class outagelib {
-
/** Outage start. */
const OUTAGE_START = '';
@@ -135,7 +134,7 @@ class outagelib {
$renderer = $PAGE->get_renderer('auth_outage');
return $renderer->render_warningbar($active, $time, false, $preview);
} catch (Exception $e) {
- debugging('Exception occured while injecting our code: '.$e->getMessage());
+ debugging('Exception occured while injecting our code: ' . $e->getMessage());
debugging($e->getTraceAsString(), DEBUG_DEVELOPER);
}
}
@@ -230,7 +229,7 @@ class outagelib {
$message = get_config('moodle', 'maintenance_message');
if ($message) {
debugging('Disabling $CFG->maintenance_message to allow our template page to take place.');
- debugging('Previous value: '.$message);
+ debugging('Previous value: ' . $message);
// We cannot do much if forced config, but the logs will show the error.
unset_config('maintenance_message');
}
@@ -253,7 +252,7 @@ class outagelib {
self::$injectcalled = true;
// Do not inject into admin/settings.php.
- if ($_SERVER['SCRIPT_NAME'] == '/'.$CFG->admin.'/settings.php') {
+ if ($_SERVER['SCRIPT_NAME'] == '/' . $CFG->admin . '/settings.php') {
if (optional_param('section', '', PARAM_RAW) === 'additionalhtml') {
return false;
}
@@ -293,6 +292,10 @@ class outagelib {
// single-quotes (and double for the sake of it) are present otherwise it would break the code.
$allowedips = addslashes($allowedips);
+ // Escape the access key before substitution into the PHP literal to prevent
+ // code injection via a maliciously crafted access key value.
+ $accesskey = addslashes((string)$accesskey);
+
$cookiesecure = is_moodle_cookie_secure();
// Since Moodle 4.3 cookiehttponly is default to true and this CFG is not set.
@@ -381,7 +384,7 @@ EOT;
*/
public static function update_climaintenance_code($outage) {
global $CFG;
- $file = $CFG->dataroot.'/climaintenance.php';
+ $file = $CFG->dataroot . '/climaintenance.php';
if (!is_null($outage) && !($outage instanceof outage)) {
throw new coding_exception('$outage must be null or an outage object.');
@@ -401,7 +404,7 @@ EOT;
$dir = dirname($file);
if (!file_exists($dir) || !is_dir($dir)) {
- throw new file_exception('Directory must exists: '.$dir);
+ throw new file_exception('Directory must exists: ' . $dir);
}
file_put_contents($file, $code);
}
@@ -417,8 +420,10 @@ EOT;
$message = [];
- if (trim(self::get_config()->allowedips) != ''
- && (!isset($CFG->auth_outage_bootstrap_loaded) || !$CFG->auth_outage_bootstrap_loaded)) {
+ if (
+ trim(self::get_config()->allowedips) != ''
+ && (!isset($CFG->auth_outage_bootstrap_loaded) || !$CFG->auth_outage_bootstrap_loaded)
+ ) {
$message[] = get_string('configurationwarning', 'auth_outage');
}
diff --git a/classes/output/manage/base_table.php b/classes/output/manage/base_table.php
index 3f2fd31..4223470 100644
--- a/classes/output/manage/base_table.php
+++ b/classes/output/manage/base_table.php
@@ -22,7 +22,7 @@ use html_writer;
use moodle_url;
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir.'/tablelib.php');
+require_once($CFG->libdir . '/tablelib.php');
/**
* base_table class.
@@ -58,7 +58,7 @@ class base_table extends flexible_table {
global $PAGE;
$id = (is_null($id) ? self::$autoid++ : $id);
- parent::__construct('auth_outage_manage_'.$id);
+ parent::__construct('auth_outage_manage_' . $id);
$this->define_baseurl($PAGE->url);
$this->set_attribute('class', 'generaltable admintable');
@@ -77,7 +77,7 @@ class base_table extends flexible_table {
// View button.
$buttons .= html_writer::link(
new moodle_url('/auth/outage/info.php', ['id' => $outage->id]),
- $OUTPUT->pix_icon('t/preview', get_string('view'), 'moodle', array('class' => 'iconsmall')),
+ $OUTPUT->pix_icon('t/preview', get_string('view'), 'moodle', ['class' => 'iconsmall']),
[
'title' => get_string('view'),
'target' => '_blank',
@@ -88,7 +88,7 @@ class base_table extends flexible_table {
if ($editdelete) {
$buttons .= html_writer::link(
new moodle_url('/auth/outage/edit.php', ['edit' => $outage->id]),
- $OUTPUT->pix_icon('t/edit', get_string('edit'), 'moodle', array('class' => 'iconsmall')),
+ $OUTPUT->pix_icon('t/edit', get_string('edit'), 'moodle', ['class' => 'iconsmall']),
['title' => get_string('edit')]
);
}
@@ -96,7 +96,7 @@ class base_table extends flexible_table {
// Clone button.
$buttons .= html_writer::link(
new moodle_url('/auth/outage/edit.php', ['clone' => $outage->id]),
- $OUTPUT->pix_icon('t/copy', get_string('clone', 'auth_outage'), 'moodle', array('class' => 'iconsmall')),
+ $OUTPUT->pix_icon('t/copy', get_string('clone', 'auth_outage'), 'moodle', ['class' => 'iconsmall']),
['title' => get_string('clone', 'auth_outage')]
);
@@ -104,7 +104,7 @@ class base_table extends flexible_table {
if ($outage->is_ongoing()) {
$buttons .= html_writer::link(
new moodle_url('/auth/outage/finish.php', ['id' => $outage->id]),
- $OUTPUT->pix_icon('t/check', get_string('finish', 'auth_outage'), 'moodle', array('class' => 'iconsmall')),
+ $OUTPUT->pix_icon('t/check', get_string('finish', 'auth_outage'), 'moodle', ['class' => 'iconsmall']),
['title' => get_string('finish', 'auth_outage')]
);
}
@@ -113,7 +113,7 @@ class base_table extends flexible_table {
if ($editdelete) {
$buttons .= html_writer::link(
new moodle_url('/auth/outage/delete.php', ['id' => $outage->id]),
- $OUTPUT->pix_icon('t/delete', get_string('delete'), 'moodle', array('class' => 'iconsmall')),
+ $OUTPUT->pix_icon('t/delete', get_string('delete'), 'moodle', ['class' => 'iconsmall']),
['title' => get_string('delete')]
);
}
diff --git a/classes/output/manage/history_table.php b/classes/output/manage/history_table.php
index 3b3e8bc..2514a6d 100644
--- a/classes/output/manage/history_table.php
+++ b/classes/output/manage/history_table.php
@@ -19,7 +19,7 @@ namespace auth_outage\output\manage;
use auth_outage\local\outage;
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir.'/tablelib.php');
+require_once($CFG->libdir . '/tablelib.php');
/**
* history_table class.
@@ -45,8 +45,7 @@ class history_table extends base_table {
get_string('tableheaderdurationactual', 'auth_outage'),
get_string('tableheadertitle', 'auth_outage'),
get_string('actions'),
- ]
- );
+ ]);
$this->setup();
}
diff --git a/classes/output/manage/planned_table.php b/classes/output/manage/planned_table.php
index 2f302ff..6c78aef 100644
--- a/classes/output/manage/planned_table.php
+++ b/classes/output/manage/planned_table.php
@@ -21,7 +21,7 @@ use html_writer;
use moodle_url;
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->libdir.'/tablelib.php');
+require_once($CFG->libdir . '/tablelib.php');
/**
* planned_table class.
diff --git a/classes/output/renderer.php b/classes/output/renderer.php
index 03900f0..4fce37b 100644
--- a/classes/output/renderer.php
+++ b/classes/output/renderer.php
@@ -45,7 +45,7 @@ class renderer extends plugin_renderer_base {
$viewbag['viewfile'] = $view;
unset($view);
- require($CFG->dirroot.'/auth/outage/views/'.$viewbag['viewfile']);
+ require($CFG->dirroot . '/auth/outage/views/' . $viewbag['viewfile']);
}
/**
@@ -88,8 +88,8 @@ class renderer extends plugin_renderer_base {
* @return string HTML for the page.
*/
public function renderdeleteconfirmation(outage $outage) {
- return $this->rendersubtitle('outagedelete').
- html_writer::tag('p', get_string('outagedeletewarning', 'auth_outage')).
+ return $this->rendersubtitle('outagedelete') .
+ html_writer::tag('p', get_string('outagedeletewarning', 'auth_outage')) .
$this->renderoutage($outage, false);
}
@@ -99,8 +99,8 @@ class renderer extends plugin_renderer_base {
* @return string HTML for the page.
*/
public function renderfinishconfirmation(outage $outage) {
- return $this->rendersubtitle('outagefinish').
- html_writer::tag('p', get_string('outagefinishwarning', 'auth_outage')).
+ return $this->rendersubtitle('outagefinish') .
+ html_writer::tag('p', get_string('outagefinishwarning', 'auth_outage')) .
$this->renderoutage($outage, false);
}
@@ -147,7 +147,7 @@ class renderer extends plugin_renderer_base {
$created = core_user::get_user($outage->createdby, 'firstname,lastname', MUST_EXIST);
$created = html_writer::link(
new moodle_url('/user/profile.php', ['id' => $outage->createdby]),
- trim($created->firstname.' '.$created->lastname)
+ trim($created->firstname . ' ' . $created->lastname)
);
}
@@ -157,7 +157,7 @@ class renderer extends plugin_renderer_base {
$modified = core_user::get_user($outage->modifiedby, 'firstname,lastname', MUST_EXIST);
$modified = html_writer::link(
new moodle_url('/user/profile.php', ['id' => $outage->modifiedby]),
- trim($modified->firstname.' '.$modified->lastname)
+ trim($modified->firstname . ' ' . $modified->lastname)
);
}
@@ -185,33 +185,35 @@ class renderer extends plugin_renderer_base {
$start = outagelib::OUTAGE_START;
$end = outagelib::OUTAGE_END;
$outagehtml = html_writer::div(
- html_writer::tag('blockquote',
- html_writer::div(html_writer::tag('b', $outage->get_title(), ['data-id' => $outage->id])).
- html_writer::div(html_writer::tag('i', $outage->get_description())).
+ html_writer::tag(
+ 'blockquote',
+ html_writer::div(html_writer::tag('b', $outage->get_title(), ['data-id' => $outage->id])) .
+ html_writer::div(html_writer::tag('i', $outage->get_description())) .
html_writer::div(
- html_writer::tag('b', get_string('tableheaderwarnbefore', 'auth_outage').': ').
+ html_writer::tag('b', get_string('tableheaderwarnbefore', 'auth_outage') . ': ') .
format_time($outage->get_warning_duration())
- ).
+ ) .
html_writer::div(
- html_writer::tag('b', get_string('tableheaderstarttime', 'auth_outage').': ').
+ html_writer::tag('b', get_string('tableheaderstarttime', 'auth_outage') . ': ') .
userdate($outage->starttime, get_string('datetimeformat', 'auth_outage'))
- ).
+ ) .
html_writer::div(
- html_writer::tag('b', get_string('tableheaderdurationplanned', 'auth_outage').': ').
+ html_writer::tag('b', get_string('tableheaderdurationplanned', 'auth_outage') . ': ') .
format_time($outage->get_duration_planned())
- ).
+ ) .
html_writer::div(
- html_writer::tag('b', get_string('tableheaderdurationactual', 'auth_outage').': ').
+ html_writer::tag('b', get_string('tableheaderdurationactual', 'auth_outage') . ': ') .
$finished
- ).
+ ) .
html_writer::div(
- html_writer::tag('small',
- 'Created by '.$created.
- ', modified by '.$modified.' on '.
+ html_writer::tag(
+ 'small',
+ 'Created by ' . $created .
+ ', modified by ' . $modified . ' on ' .
userdate($outage->lastmodified, get_string('datetimeformat', 'auth_outage'))
)
- ).
- ($buttons ? html_writer::div($linkedit.$linkdelete) : '')
+ ) .
+ ($buttons ? html_writer::div($linkedit . $linkdelete) : '')
)
);
return $start . $outagehtml . $end;
diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php
index a562d8d..5e4cce3 100644
--- a/classes/privacy/provider.php
+++ b/classes/privacy/provider.php
@@ -25,7 +25,6 @@ namespace auth_outage\privacy;
*/
class provider implements
\core_privacy\local\metadata\null_provider {
-
/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
@@ -38,5 +37,4 @@ class provider implements
public static function get_reason(): string {
return 'privacy:no_data_reason';
}
-
}
diff --git a/cli/create.php b/cli/create.php
index 9764321..cad53bd 100644
--- a/cli/create.php
+++ b/cli/create.php
@@ -28,8 +28,8 @@ use auth_outage\local\cli\create;
use auth_outage\local\outagelib;
define('CLI_SCRIPT', true);
-require_once(__DIR__.'/../../../config.php');
-require_once($CFG->libdir.'/clilib.php');
+require_once(__DIR__ . '/../../../config.php');
+require_once($CFG->libdir . '/clilib.php');
try {
$cli = new create();
diff --git a/cli/finish.php b/cli/finish.php
index d3e0fb0..d233d4a 100644
--- a/cli/finish.php
+++ b/cli/finish.php
@@ -27,8 +27,8 @@ use auth_outage\local\cli\cli_exception;
use auth_outage\local\cli\finish;
define('CLI_SCRIPT', true);
-require_once(__DIR__.'/../../../config.php');
-require_once($CFG->libdir.'/clilib.php');
+require_once(__DIR__ . '/../../../config.php');
+require_once($CFG->libdir . '/clilib.php');
try {
$cli = new finish();
@@ -36,4 +36,3 @@ try {
} catch (cli_exception $e) {
cli_error($e->getMessage());
}
-
diff --git a/cli/waitforit.php b/cli/waitforit.php
index c9859c9..90e4b7f 100644
--- a/cli/waitforit.php
+++ b/cli/waitforit.php
@@ -27,8 +27,8 @@ use auth_outage\local\cli\cli_exception;
use auth_outage\local\cli\waitforit;
define('CLI_SCRIPT', true);
-require_once(__DIR__.'/../../../config.php');
-require_once($CFG->libdir.'/clilib.php');
+require_once(__DIR__ . '/../../../config.php');
+require_once($CFG->libdir . '/clilib.php');
try {
$cli = new waitforit();
@@ -36,4 +36,3 @@ try {
} catch (cli_exception $e) {
cli_error($e->getMessage());
}
-
diff --git a/db/upgrade.php b/db/upgrade.php
index 4e46ec9..8673f61 100644
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -48,7 +48,6 @@ function xmldb_auth_outage_upgrade($oldversion) {
}
if ($oldversion < 2024081900) {
-
// Define field accesskey to be added to auth_outage.
$table = new xmldb_table('auth_outage');
$field = new xmldb_field('accesskey', XMLDB_TYPE_CHAR, '16', null, null, null, null, 'finished');
diff --git a/delete.php b/delete.php
index b3a9713..1c5042b 100644
--- a/delete.php
+++ b/delete.php
@@ -27,9 +27,9 @@ use auth_outage\dml\outagedb;
use auth_outage\form\outage\delete;
use auth_outage\output\renderer;
-require_once(__DIR__.'/../../config.php');
-require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir.'/formslib.php');
+require_once(__DIR__ . '/../../config.php');
+require_once($CFG->libdir . '/adminlib.php');
+require_once($CFG->libdir . '/formslib.php');
admin_externalpage_setup('auth_outage_manage');
$PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
@@ -46,7 +46,7 @@ if ($mform->is_cancelled()) {
$id = required_param('id', PARAM_INT);
$outage = outagedb::get_by_id($id);
if ($outage == null) {
- throw new invalid_parameter_exception('Outage #'.$id.' not found.');
+ throw new invalid_parameter_exception('Outage #' . $id . ' not found.');
}
$dataid = new stdClass();
diff --git a/edit.php b/edit.php
index eebb285..5d97a2e 100644
--- a/edit.php
+++ b/edit.php
@@ -29,9 +29,9 @@ use auth_outage\local\outage;
use auth_outage\local\outagelib;
use auth_outage\output\renderer;
-require_once(__DIR__.'/../../config.php');
-require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir.'/formslib.php');
+require_once(__DIR__ . '/../../config.php');
+require_once($CFG->libdir . '/adminlib.php');
+require_once($CFG->libdir . '/formslib.php');
admin_externalpage_setup('auth_outage_manage');
$output = $PAGE->get_renderer('auth_outage');
@@ -83,7 +83,7 @@ if ($outage == null) {
$mform->set_data($outage);
-$PAGE->navbar->add(get_string($action.'crumb', 'auth_outage'));
+$PAGE->navbar->add(get_string($action . 'crumb', 'auth_outage'));
echo $output->header();
echo $output->rendersubtitle($action);
$mform->display();
diff --git a/file.php b/file.php
index e41884d..6056de2 100644
--- a/file.php
+++ b/file.php
@@ -45,13 +45,13 @@ if (count($parts) != 2) {
$mime = base64_decode($parts[1]);
// Detect type, we only support css or PNG images.
-header('Content-Type: '.$mime);
+header('Content-Type: ' . $mime);
// Use cache.
$lifetime = 60 * 60 * 24; // 1 day.
-header('Expires: '.gmdate('D, d M Y H:i:s', time() + $lifetime).' GMT');
+header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT');
header('Pragma: ');
-header('Cache-Control: public, max-age='.$lifetime);
+header('Cache-Control: public, max-age=' . $lifetime);
header('Accept-Ranges: none');
@@ -60,7 +60,7 @@ header('Accept-Ranges: none');
*/
function auth_outage_bootstrap_callback() {
// Not using classes as classloader has not been initialized yet. Keep it minimalist.
- require_once(__DIR__.'/lib.php');
+ require_once(__DIR__ . '/lib.php');
$file = auth_outage_get_climaintenance_resource_file($_GET['file']);
if (is_null($file)) {
// @codingStandardsIgnoreStart
@@ -79,5 +79,5 @@ require_once(__DIR__.'/../../config.php');
// We should never reach here if config.php and auth/outage/bootstrap.php intercepted it correctly.
// If config.php did not execute the callback function we can use the debugging function here.
-debugging('Your config.php is not properly configured for auth/outage plugin. '.
+debugging('Your config.php is not properly configured for auth/outage plugin. ' .
'Please check the plugin settings for information.');
diff --git a/finish.php b/finish.php
index 868b1bf..944db6a 100644
--- a/finish.php
+++ b/finish.php
@@ -27,9 +27,9 @@ use auth_outage\dml\outagedb;
use auth_outage\form\outage\finish;
use auth_outage\output\renderer;
-require_once(__DIR__.'/../../config.php');
-require_once($CFG->libdir.'/adminlib.php');
-require_once($CFG->libdir.'/formslib.php');
+require_once(__DIR__ . '/../../config.php');
+require_once($CFG->libdir . '/adminlib.php');
+require_once($CFG->libdir . '/formslib.php');
admin_externalpage_setup('auth_outage_manage');
$PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
@@ -46,7 +46,7 @@ if ($mform->is_cancelled()) {
$id = required_param('id', PARAM_INT);
$outage = outagedb::get_by_id($id);
if ($outage == null) {
- throw new invalid_parameter_exception('Outage #'.$id.' not found.');
+ throw new invalid_parameter_exception('Outage #' . $id . ' not found.');
}
$dataid = new stdClass();
diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php
index 8eb74f5..470c44e 100644
--- a/lang/en/auth_outage.php
+++ b/lang/en/auth_outage.php
@@ -23,13 +23,19 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+$string['accesskey'] = 'Access key';
+$string['accesskey_help'] = 'Testers should pass the access key initially in the url parameters e.g. ?accesskey=xyz. This will then be stored in a cookie for 24 hours, during which the url parameter will not be necessary.
Note: the access key is in addition to any IP restrictions setup.';
+$string['allowedipsempty'] = 'No one will be blocked by IP because the list is empty. You can add your own IP address ({$a->ip}) and block all other IPs. IP blocking is in addition to access key blocking (if setup in outage)';
+$string['allowedipshasmyip'] = 'Your IP ({$a->ip}) is in the list and your IP will not be blocked out during an Outage.';
+$string['allowedipshasntmyip'] = 'Your IP ({$a->ip}) is not in the list and your IP will be blocked out during an outage.';
+$string['allowedipsnoconfig'] = 'Your config.php does not have the extra setup to allow blocking via IP.
Please refer to our README.md file for more information.';
$string['auth_outagedescription'] = 'Auxiliary plugin that warns users about a future outage and prevents them from logging in once the outage starts.';
$string['autostart'] = 'Auto start maintenance mode.';
$string['autostart_help'] = 'If selected, when the outage starts it will automatically turn on Moodle maintenance mode.';
$string['builtinallowediplist'] = 'Builtin Allowed IP List';
$string['builtinallowediplist_desc'] = 'A second allowed IP list which makes it easier to have some IPs forced in config.php and others editable in the UI';
-$string['clicreatehelp'] = 'Creates a new outage.';
$string['clicreateexamples'] = "Create an outage starting in 10 seconds\n\n> php create.php -s=10";
+$string['clicreatehelp'] = 'Creates a new outage.';
$string['clicreateparamautostart'] = 'must be Y or N, sets if the outage automatically triggers maintenance mode.';
$string['clicreateparamblock'] = 'blocks until outage starts.';
$string['clicreateparamclone'] = 'clone another outage except for the start time.';
@@ -40,16 +46,28 @@ $string['clicreateparamonlyid'] = 'only outputs the new outage id, useful for sc
$string['clicreateparamstart'] = 'in how many seconds should this outage start or unix time to start outage. Required.';
$string['clicreateparamtitle'] = 'the title of the outage.';
$string['clicreateparamwarn'] = 'how many seconds before it starts to display a warning.';
-$string['clifinishhelp'] = 'Finishes an ongoing outage.';
+$string['clierrorinvalidvalue'] = 'Invalid value for parameter: {$a->param}';
+$string['clierrorinvalidvalueemptystring'] = 'Param --{$a->param} must not be an empty string';
+$string['clierrorinvalidvaluenegativenumber'] = 'Param --{$a->param} must be a positive number';
+$string['clierrorinvalidvaluenotbool'] = 'Param --{$a->param} must be set to either Y or N';
+$string['clierrorinvalidvaluenotid'] = 'Param --{$a->param} must be an id number';
+$string['clierrorinvalidvaluenotnumber'] = 'Param --{$a->param} must be a number';
+$string['clierrorinvalidvaluenotstring'] = 'Param --{$a->param} must be a string';
+$string['clierrormissingparamaters'] = 'You must specify the start time, use --help for more information.';
+$string['clierroroutagechanged'] = 'Outage was changed while waiting.';
+$string['clierroroutageended'] = 'Outage has already ended.';
+$string['clierroroutagenotfound'] = 'Outage not found.';
$string['clifinishexamples'] = '';
+$string['clifinishhelp'] = 'Finishes an ongoing outage.';
$string['clifinishnotongoing'] = 'Outage is not ongoing.';
-$string['clifinishparamhelp'] = 'shows parameters help.';
$string['clifinishparamactive'] = 'finishes the currently active outage.';
+$string['clifinishparamhelp'] = 'shows parameters help.';
$string['clifinishparamoutageid'] = 'the id of the outage to finish.';
$string['cliinmaintenancemode'] = 'Moodle maintenance mode is on. Use "php admin/cli/maintenance.php --disable" to disable it before finishing the outage.';
+$string['clioutagecreated'] = 'Outage created, id: {$a->id}';
$string['cliwaitforiterroridxoractive'] = 'You must use --outageid=# or --active parameter but not both.';
-$string['cliwaitforithelp'] = 'Waits until an outage starts.';
$string['cliwaitforitexamples'] = '';
+$string['cliwaitforithelp'] = 'Waits until an outage starts.';
$string['cliwaitforitoutagestarted'] = 'Outage started!';
$string['cliwaitforitoutagestartingin'] = 'Outage starting in {$a->countdown}.';
$string['cliwaitforitparamactive'] = 'wait for the currently active outage.';
@@ -57,39 +75,27 @@ $string['cliwaitforitparamhelp'] = 'shows parameters help.';
$string['cliwaitforitparamoutageid'] = 'the id of the outage to wait until it starts.';
$string['cliwaitforitparamsleep'] = 'maximum amount of seconds before status output.';
$string['cliwaitforitparamverbose'] = 'enable verbose mode.';
-$string['clierrorinvalidvalue'] = 'Invalid value for parameter: {$a->param}';
-$string['clierrorinvalidvaluenotid'] = 'Param --{$a->param} must be an id number';
-$string['clierrorinvalidvaluenotbool'] = 'Param --{$a->param} must be set to either Y or N';
-$string['clierrorinvalidvaluenotnumber'] = 'Param --{$a->param} must be a number';
-$string['clierrorinvalidvaluenegativenumber'] = 'Param --{$a->param} must be a positive number';
-$string['clierrorinvalidvaluenotstring'] = 'Param --{$a->param} must be a string';
-$string['clierrorinvalidvalueemptystring'] = 'Param --{$a->param} must not be an empty string';
-$string['clierrormissingparamaters'] = 'You must specify the start time, use --help for more information.';
-$string['clierroroutagechanged'] = 'Outage was changed while waiting.';
-$string['clierroroutageended'] = 'Outage has already ended.';
-$string['clierroroutagenotfound'] = 'Outage not found.';
-$string['clioutagecreated'] = 'Outage created, id: {$a->id}';
$string['clone'] = 'Clone';
-$string['configurationwarning'] = 'The outage plugin is not properly configured, please refer to README.md for more information.';
$string['configurationdisabled'] = 'The authentication plugin \'Outage\' is disabled. Please enable it in the site administration it and try again.';
$string['configurationinaccessiblewwwroot'] = 'Could not access {$a->wwwroot} from the server, creation of outages may fail.';
+$string['configurationwarning'] = 'The outage plugin is not properly configured, please refer to README.md for more information.';
$string['datetimeformat'] = '%a %d %h %Y at %I:%M%P %Z';
+$string['defaultdescription'] = 'Description';
+$string['defaultdescriptiondescription'] = 'Default warning message for outages. Use {{start}} and {{stop}} placeholders as required.';
+$string['defaultdescriptionvalue'] = 'There is maintenance scheduled from {{start}} to {{stop}} and our system will not be available during that time.';
$string['defaultlayoutcss'] = 'Layout CSS';
$string['defaultlayoutcssdescription'] = 'This CSS code can be used to override the Outage Warning Bar CSS.';
$string['defaultoutageautostart'] = 'Outage auto start';
$string['defaultoutageautostartdescription'] = 'If the outage should automatically trigger maintenance mode once it starts, locking down the whole site.';
$string['defaultoutageduration'] = 'Outage duration';
$string['defaultoutagedurationdescription'] = 'Default duration (in minutes) of an outage.';
-$string['defaultwarningduration'] = 'Warning duration';
-$string['defaultwarningdurationdescription'] = 'Default warning time (in minutes) for outages.';
$string['defaulttime'] = 'Default time';
$string['defaulttimedescription'] = 'The default time for the next outage, expressed in natural language eg "next Thursday 7pm". See PHP relative dates';
$string['defaulttitle'] = 'Title';
$string['defaulttitledescription'] = 'Default title for outages. Use {{start}} and {{stop}} placeholders as required.';
$string['defaulttitlevalue'] = 'System down from {{start}} for {{duration}}';
-$string['defaultdescription'] = 'Description';
-$string['defaultdescriptiondescription'] = 'Default warning message for outages. Use {{start}} and {{stop}} placeholders as required.';
-$string['defaultdescriptionvalue'] = 'There is maintenance scheduled from {{start}} to {{stop}} and our system will not be available during that time.';
+$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['finish'] = 'Finish';
@@ -97,29 +103,24 @@ $string['info15secondsbefore'] = '15 seconds before';
$string['infoendofoutage'] = 'end of outage';
$string['infofrom'] = 'From:';
$string['infohidewarning'] = 'no warning bar';
-$string['infountil'] = 'Until:';
+$string['infopagestaticgenerated'] = 'This warning was generated on {$a->time}.';
$string['infostart'] = 'start';
$string['infostartofwarning'] = 'start of warning';
$string['infostaticpage'] = 'static page';
-$string['infopagestaticgenerated'] = 'This warning was generated on {$a->time}.';
+$string['infountil'] = 'Until:';
$string['ips_combine'] = 'The IPs listed above will be combined with the IPs listed below.';
-$string['allowedipsempty'] = 'No one will be blocked by IP because the list is empty. You can add your own IP address ({$a->ip}) and block all other IPs. IP blocking is in addition to access key blocking (if setup in outage)';
-$string['allowedipshasmyip'] = 'Your IP ({$a->ip}) is in the list and your IP will not be blocked out during an Outage.';
-$string['allowedipshasntmyip'] = 'Your IP ({$a->ip}) is not in the list and your IP will be blocked out during an outage.';
-$string['allowedipsnoconfig'] = 'Your config.php does not have the extra setup to allow blocking via IP.
Please refer to our README.md file for more information.';
$string['logformaintmodeconfig'] = 'Update maintenance mode configuration.';
$string['logformaintmodeconfigcomplete'] = 'Updating maintenance mode configuration complete.';
-$string['menusettings'] = 'Settings';
$string['menumanage'] = 'Manage outages';
+$string['menusettings'] = 'Settings';
$string['messageoutagebackonline'] = 'We are back online!';
$string['messageoutagebackonlinedescription'] = 'You may resume browsing safely.';
$string['messageoutageongoing'] = 'Back online at {$a->stop}.';
$string['messageoutagewarning'] = 'Shutting down in {{countdown}}';
$string['na'] = 'n/a';
$string['notfound'] = 'No outages found.';
+$string['outage:updatenotify'] = '';
$string['outage:viewinfo'] = 'View outage info';
-$string['outageedit'] = 'Edit outage';
-$string['outageeditcrumb'] = 'Edit';
$string['outageclone'] = 'Clone outage';
$string['outageclonecrumb'] = 'Clone';
$string['outagecreate'] = 'Create outage';
@@ -127,13 +128,14 @@ $string['outagecreatecrumb'] = 'Create';
$string['outagedelete'] = 'Delete outage';
$string['outagedeletewarning'] = 'You are about to permanently delete the outage below. This cannot be undone.';
$string['outageduration'] = 'Outage duration';
-$string['outagedurationerrorinvalid'] = 'Outage duration must be positive.';
$string['outageduration_help'] = 'How long the outage lasts after it starts.';
+$string['outagedurationerrorinvalid'] = 'Outage duration must be positive.';
+$string['outageedit'] = 'Edit outage';
+$string['outageeditcrumb'] = 'Edit';
$string['outagefinish'] = 'Finish outage';
$string['outagefinishwarning'] = 'You are about to mark this outage as finished. The system will be immediately back online.';
$string['outageslistfuture'] = 'Planned outages';
$string['outageslistpast'] = 'Outage history';
-$string['outage:updatenotify'] = '';
$string['pluginname'] = 'Outage manager';
$string['removeselectors'] = 'Remove selectors';
$string['removeselectorsdescription'] = 'CSS selectors to remove when rendering a static themed maintenance page. One selector per line.';
@@ -144,28 +146,26 @@ $string['settingssectionplugindescription'] = 'General outage management plugin
$string['starttime'] = 'Start date and time';
$string['starttime_help'] = 'At which date and time the outage starts, preventing general access to the system.';
$string['tableheaderduration'] = 'Duration';
-$string['tableheaderdurationplanned'] = 'Planned duration';
$string['tableheaderdurationactual'] = 'Actual duration';
-$string['tableheaderstarttime'] = 'Starts on';
+$string['tableheaderdurationplanned'] = 'Planned duration';
$string['tableheaderstartedtime'] = 'Started on';
-$string['tableheaderwarnbefore'] = 'Warns before';
+$string['tableheaderstarttime'] = 'Starts on';
$string['tableheadertitle'] = 'Title';
+$string['tableheaderwarnbefore'] = 'Warns before';
$string['tablestarttimefutureformat'] = '{$a->absolute}
In {$a->relative}';
$string['tablestarttimepastformat'] = '{$a->absolute}
{$a->relative} ago';
$string['taskupdatestaticpage'] = 'Update static outage page';
$string['textplaceholdershint'] = 'You can use {{start}}, {{stop}} and {{duration}} as placeholders on the title and description.';
-$string['titleerrorinvalid'] = 'Title cannot be left blank.';
-$string['titleerrortoolong'] = 'Title cannot have more than {$a} characters.';
$string['title'] = 'Title';
$string['title_help'] = 'A short title to for this outage. It will be displayed on the warning bar and on the calendar.';
-$string['warningdurationerrorinvalid'] = 'Warning duration must be positive.';
-$string['warningduration'] = 'Warning duration';
-$string['warningduration_help'] = 'How long before the start of the outage should the warning be displayed.';
-$string['warningreenablemaintenancemode'] = 'Please note that saving this outage will re-enable maintenance mode.
Untick "Auto start maintenance mode" if you want to prevent this.';
-$string['accesskey'] = 'Access key';
-$string['accesskey_help'] = 'Testers should pass the access key initially in the url parameters e.g. ?accesskey=xyz. This will then be stored in a cookie for 24 hours, during which the url parameter will not be necessary.
Note: the access key is in addition to any IP restrictions setup.';
+$string['titleerrorinvalid'] = 'Title cannot be left blank.';
+$string['titleerrortoolong'] = 'Title cannot have more than {$a} characters.';
$string['useaccesskey'] = 'Use access key';
$string['useaccesskey:desc'] = 'Require testers to access site during outage by providing the access key below';
+$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.
Untick "Auto start maintenance mode" if you want to prevent this.';
/*
* Privacy provider (GDPR)
diff --git a/lib.php b/lib.php
index 91d6eb1..dc2104c 100644
--- a/lib.php
+++ b/lib.php
@@ -48,7 +48,7 @@ function auth_outage_get_climaintenance_resource_file($file) {
// We are not using any external libraries or references in this file (we have not gully loaded config.php yet).
// If you change the path below maybe you need to change maintenance_static_page::get_resources_folder() as well.
$resourcedir = rtrim($CFG->dataroot, '/'); // In case the configuration has a trailing slash.
- $resourcedir = $resourcedir.'/auth_outage/climaintenance';
+ $resourcedir = $resourcedir . '/auth_outage/climaintenance';
// Protect against path traversal attacks.
$basename = basename($file);
@@ -61,7 +61,7 @@ function auth_outage_get_climaintenance_resource_file($file) {
return null;
}
- $realpath = realpath($resourcedir.'/'.$file);
+ $realpath = realpath($resourcedir . '/' . $file);
return ($realpath == false) ? null : $realpath;
}
diff --git a/manage.php b/manage.php
index 582438d..217b61f 100644
--- a/manage.php
+++ b/manage.php
@@ -27,8 +27,8 @@ use auth_outage\dml\outagedb;
use auth_outage\output\renderer;
use auth_outage\local\outagelib;
-require_once(__DIR__.'/../../config.php');
-require_once($CFG->libdir.'/adminlib.php');
+require_once(__DIR__ . '/../../config.php');
+require_once($CFG->libdir . '/adminlib.php');
admin_externalpage_setup('auth_outage_manage');
$PAGE->set_url(new moodle_url('/auth/outage/manage.php'));
diff --git a/settings.php b/settings.php
index 068986c..870dba6 100644
--- a/settings.php
+++ b/settings.php
@@ -89,7 +89,8 @@ if ($hassiteconfig) {
$settings->add(new admin_setting_heading(
'plugin',
get_string('settingssectionplugin', 'auth_outage'),
- get_string('settingssectionplugindescription', 'auth_outage')));
+ get_string('settingssectionplugindescription', 'auth_outage')
+ ));
$settings->add(new admin_setting_configtextarea(
'auth_outage/css',
@@ -152,7 +153,8 @@ if ($hassiteconfig) {
// Clear '$settings' to prevent adding again outsite category.
$settings = null;
// Add options.
- $ADMIN->add('auth_outage',
+ $ADMIN->add(
+ 'auth_outage',
new admin_externalpage(
'auth_outage_manage',
get_string('menumanage', 'auth_outage'),
diff --git a/tests/behat/behat_auth_outage.php b/tests/behat/behat_auth_outage.php
index fb166e0..4fc33b4 100644
--- a/tests/behat/behat_auth_outage.php
+++ b/tests/behat/behat_auth_outage.php
@@ -30,7 +30,7 @@ use auth_outage\local\outage;
use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Exception\ExpectationException;
-require_once(__DIR__.'/../../../../lib/behat/behat_base.php');
+require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');
/**
* Steps definitions related to auth_outage.
@@ -90,8 +90,8 @@ class behat_auth_outage extends behat_base {
$data = [
'autostart' => false,
'finished' => null,
- 'title' => 'Example of '.$type.' outage',
- 'description' => 'An outage: '.$type,
+ 'title' => 'Example of ' . $type . ' outage',
+ 'description' => 'An outage: ' . $type,
];
switch ($type) {
case 'waiting':
@@ -121,7 +121,7 @@ class behat_auth_outage extends behat_base {
$data['stoptime'] = time() - (60 * 60 * 2); // Stopped 1 hour ago.
break;
default:
- throw new InvalidArgumentException('$type='.$type.' is not valid.');
+ throw new InvalidArgumentException('$type=' . $type . ' is not valid.');
}
outagedb::save(new outage($data));
}
@@ -136,8 +136,8 @@ class behat_auth_outage extends behat_base {
$expected = ($action == 'Edit') ? 2 : 1; // Edit is an action through the title or button.
$found = $this->how_many_times_can_i_see_action($action);
if ($found != $expected) {
- throw new ExpectationException('"'.$action.'" action not found, expected '.$expected.
- ' but found '.$found.'.', $this->getSession());
+ throw new ExpectationException('"' . $action . '" action not found, expected ' . $expected .
+ ' but found ' . $found . '.', $this->getSession());
}
}
@@ -149,7 +149,7 @@ class behat_auth_outage extends behat_base {
*/
public function i_should_not_see_the_action($action) {
if ($this->how_many_times_can_i_see_action($action) != 0) {
- throw new ExpectationException('"'.$action.'" action was found', $this->getSession());
+ throw new ExpectationException('"' . $action . '" action was found', $this->getSession());
}
}
@@ -159,7 +159,7 @@ class behat_auth_outage extends behat_base {
* @param string $name
*/
public function i_should_see_an_empty_settings_text_area($name) {
- $this->assertSession()->fieldValueEquals('s_auth_outage_'.$name, '');
+ $this->assertSession()->fieldValueEquals('s_auth_outage_' . $name, '');
}
/**
@@ -177,7 +177,7 @@ class behat_auth_outage extends behat_base {
*/
private function how_many_times_can_i_see_action($action) {
$selector = 'css';
- $locator = "div[role='main'] a[title='".$action."']";
+ $locator = "div[role='main'] a[title='" . $action . "']";
$items = $this->getSession()->getPage()->findAll($selector, $locator);
return count($items);
}
@@ -188,7 +188,7 @@ class behat_auth_outage extends behat_base {
* @param string $action Action button to click.
*/
public function i_click_on_the_action_button($action) {
- $node = $this->get_selected_node('css_element', "div[role='main'] table nobr a[title='".$action."']");
+ $node = $this->get_selected_node('css_element', "div[role='main'] table nobr a[title='" . $action . "']");
$this->ensure_node_is_visible($node);
$node->click();
}
@@ -205,7 +205,7 @@ class behat_auth_outage extends behat_base {
$count = count($this->getSession()->getWindowNames());
if ($count != 2) {
- throw new ExpectationException('Number of windows: '.$count, $this->getSession());
+ throw new ExpectationException('Number of windows: ' . $count, $this->getSession());
}
}
@@ -220,17 +220,17 @@ class behat_auth_outage extends behat_base {
$container = $this->getSession()->getPage()->findAll('css', $element);
if (count($container) == 0) {
- throw new ExpectationException('"'.$element.'" element not found', $this->getSession());
+ throw new ExpectationException('"' . $element . '" element not found', $this->getSession());
}
$container = $container[0];
$xpathliteral = $this->getSession()->getSelectorsHandler()->xpathLiteral($text);
- $xpath = "/descendant-or-self::*[contains(., $xpathliteral)]".
+ $xpath = "/descendant-or-self::*[contains(., $xpathliteral)]" .
"[count(descendant::*[contains(., $xpathliteral)]) = 0]";
$found = $this->find_all('xpath', $xpath, false, $container);
if (count($found) == 0) {
- throw new ExpectationException('"'.$text.'" text was not found in the "'.$element.'" element', $this->getSession());
+ throw new ExpectationException('"' . $text . '" text was not found in the "' . $element . '" element', $this->getSession());
}
foreach ($found as $node) {
@@ -238,8 +238,10 @@ class behat_auth_outage extends behat_base {
return;
}
}
- throw new ExpectationException('"'.$text.'" text was found in the "'.$element.'" element but was not visible',
- $this->getSession());
+ throw new ExpectationException(
+ '"' . $text . '" text was found in the "' . $element . '" element but was not visible',
+ $this->getSession()
+ );
}
/**
@@ -252,7 +254,7 @@ class behat_auth_outage extends behat_base {
$locator = "#auth_outage_warningbar_box";
$items = $this->getSession()->getPage()->findAll($selector, $locator);
if (count($items) > 0) {
- throw new ExpectationException($locator.' found, not expected.', $this->getSession());
+ throw new ExpectationException($locator . ' found, not expected.', $this->getSession());
}
}
@@ -280,7 +282,7 @@ class behat_auth_outage extends behat_base {
$row
);
if (($row['autostart'] != 'yes') && ($row['autostart'] != 'no')) {
- throw new Exception('autostart must be yes or no, found: '.$row['autostart']);
+ throw new Exception('autostart must be yes or no, found: ' . $row['autostart']);
}
if ($row['finished'] == '') {
$row['finished'] = null;
@@ -318,7 +320,7 @@ class behat_auth_outage extends behat_base {
$seconds += 5; // Give it some extra time to pool the server.
break;
default:
- throw new Exception('Invalid $what='.$what);
+ throw new Exception('Invalid $what=' . $what);
}
if ($seconds >= 0) {
$seconds++; // Give one extra second for things to happen.
@@ -332,7 +334,7 @@ class behat_auth_outage extends behat_base {
*/
private function is_behat_3() {
global $version;
- list($behat) = explode('.', $version);
+ [$behat] = explode('.', $version);
return ($behat >= 3);
}
}
diff --git a/tests/calendar_test.php b/tests/calendar_test.php
index 74afa73..8e88e49 100644
--- a/tests/calendar_test.php
+++ b/tests/calendar_test.php
@@ -38,7 +38,7 @@ use auth_outage\calendar\calendar;
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \auth_outage\calendar\calendar
*/
-class calendar_test extends \core_phpunit\testcase {
+final class calendar_test extends \core_phpunit\testcase {
/**
* @var outage|null The calendar entry owner.
*/
@@ -47,7 +47,7 @@ class calendar_test extends \core_phpunit\testcase {
/**
* Creates an outage and checks if its in the calendar.
*/
- public function test_create() {
+ public function test_create(): void {
$this->resetAfterTest(true);
self::setAdminUser();
@@ -68,7 +68,7 @@ class calendar_test extends \core_phpunit\testcase {
/**
* Updates an outage and checks the calendar.
*/
- public function test_update() {
+ public function test_update(): void {
$this->resetAfterTest(true);
self::setAdminUser();
@@ -92,7 +92,7 @@ class calendar_test extends \core_phpunit\testcase {
/**
* Deletes an outage and checks the calendar.
*/
- public function test_delete() {
+ public function test_delete(): void {
$this->resetAfterTest(true);
self::setAdminUser();
@@ -117,7 +117,7 @@ class calendar_test extends \core_phpunit\testcase {
/**
* Try to update a non existing outage.
*/
- public function test_update_notfound() {
+ public function test_update_notfound(): void {
$this->resetAfterTest(true);
self::setAdminUser();
@@ -140,7 +140,7 @@ class calendar_test extends \core_phpunit\testcase {
/**
* Try to delete a non existing outage.
*/
- public function test_delete_notfound() {
+ public function test_delete_notfound(): void {
$this->resetAfterTest(true);
self::setAdminUser();
diff --git a/tests/cli_create_test.php b/tests/cli_create_test.php
index aefeff4..babf3c9 100644
--- a/tests/cli_create_test.php
+++ b/tests/cli_create_test.php
@@ -29,7 +29,7 @@ use auth_outage\local\cli\create;
use auth_outage\local\cli\cli_exception;
defined('MOODLE_INTERNAL') || die();
-require_once(__DIR__.'/cli_testcase.php');
+require_once(__DIR__ . '/cli_testcase.php');
/**
* create_test test class.
@@ -40,8 +40,7 @@ require_once(__DIR__.'/cli_testcase.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \auth_outage\local\cli\create
*/
-class cli_create_test extends cli_testcase {
-
+final class cli_create_test extends cli_testcase {
public function tearDown(): void {
parent::tearDown();
}
@@ -49,7 +48,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests without any arguments.
*/
- public function test_noarguments() {
+ public function test_noarguments(): void {
$cli = new create();
$this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_MISSING);
$this->execute($cli);
@@ -58,7 +57,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests when the start time is not a valid number.
*/
- public function test_invalidparam_notanumber() {
+ public function test_invalidparam_notanumber(): void {
$cli = new create(['start' => 'some day']);
$cli->set_defaults([
'warn' => 50,
@@ -74,7 +73,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests when providing a negative start time.
*/
- public function test_invalidparam_negative() {
+ public function test_invalidparam_negative(): void {
$cli = new create(['start' => -1]);
$cli->set_defaults([
'warn' => 50,
@@ -90,7 +89,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests providing an empty title.
*/
- public function test_invalidparam_emptystring() {
+ public function test_invalidparam_emptystring(): void {
$cli = new create(['start' => 0, 'title' => '']);
$cli->set_defaults([
'warn' => 50,
@@ -106,7 +105,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests if not providing the title (it will be send as true).
*/
- public function test_invalidparam_notastring() {
+ public function test_invalidparam_notastring(): void {
$cli = new create(['start' => 0, 'title' => true]);
$cli->set_defaults([
'warn' => 50,
@@ -122,7 +121,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests the help.
*/
- public function test_help() {
+ public function test_help(): void {
$this->set_parameters(['--help']);
$cli = new create();
$output = $this->execute($cli);
@@ -133,7 +132,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests the options and shortcuts.
*/
- public function test_options() {
+ public function test_options(): void {
$cli = new create();
$options = $cli->generate_options();
@@ -150,7 +149,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests creating with all given options.
*/
- public function test_create_withoptions() {
+ public function test_create_withoptions(): void {
$this->set_parameters([
'--autostart=true',
'--warn=10',
@@ -179,7 +178,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests creating with the onlyid parameter.
*/
- public function test_create_onlyid() {
+ public function test_create_onlyid(): void {
$this->set_parameters([
'--onlyid',
'--autostart=N',
@@ -210,7 +209,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests creating using some default values.
*/
- public function test_create_withdefaults() {
+ public function test_create_withdefaults(): void {
$this->set_parameters([
'--warn=100',
'--start=50',
@@ -243,7 +242,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests creating with clone.
*/
- public function test_create_withclone() {
+ public function test_create_withclone(): void {
self::setAdminUser();
$now = time();
// Create the outage to clone.
@@ -260,7 +259,7 @@ class cli_create_test extends cli_testcase {
$this->set_parameters([
'--onlyid',
'--start=60',
- '--clone='.$id,
+ '--clone=' . $id,
]);
$cli = new create();
$cli->set_referencetime($now);
@@ -277,7 +276,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests creating with an invalid clone id.
*/
- public function test_create_withclone_invalid() {
+ public function test_create_withclone_invalid(): void {
$this->set_parameters([
'--start=60',
'--clone=-1',
@@ -290,7 +289,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests creating with the block flag.
*/
- public function test_create_withblock() {
+ public function test_create_withblock(): void {
// Not an extensive test in the blocking API, cliwaitforit tests should cover them deeper.
$this->set_parameters([
'--autostart=N',
@@ -312,7 +311,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests providing an invalid option as default.
*/
- public function test_setdefaults_extra() {
+ public function test_setdefaults_extra(): void {
$cli = new create([]);
$this->set_expected_exception('coding_exception');
$cli->set_defaults(['aninvalidparameter' => 'value']);
@@ -321,7 +320,7 @@ class cli_create_test extends cli_testcase {
/**
* Tests with an invalud autostart bool value.
*/
- public function test_invalid_bool() {
+ public function test_invalid_bool(): void {
$this->set_parameters([
'--autostart=maybe',
'--warn=60',
diff --git a/tests/cli_finish_test.php b/tests/cli_finish_test.php
index e872d85..cba43fa 100644
--- a/tests/cli_finish_test.php
+++ b/tests/cli_finish_test.php
@@ -29,7 +29,7 @@ use auth_outage\local\cli\finish;
use auth_outage\local\cli\cli_exception;
defined('MOODLE_INTERNAL') || die();
-require_once(__DIR__.'/cli_testcase.php');
+require_once(__DIR__ . '/cli_testcase.php');
/**
* finish_test test class.
@@ -40,8 +40,7 @@ require_once(__DIR__.'/cli_testcase.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \auth_outage\local\cli\finish
*/
-class cli_finish_test extends cli_testcase {
-
+final class cli_finish_test extends cli_testcase {
public function tearDown(): void {
parent::tearDown();
}
@@ -49,7 +48,7 @@ class cli_finish_test extends cli_testcase {
/**
* Tests the constructor.
*/
- public function test_constructor() {
+ public function test_constructor(): void {
$cli = new finish();
self::assertNotNull($cli);
}
@@ -57,7 +56,7 @@ class cli_finish_test extends cli_testcase {
/**
* Tests the generated options and shortcuts.
*/
- public function test_options() {
+ public function test_options(): void {
$cli = new finish();
$options = $cli->generate_options();
@@ -74,7 +73,7 @@ class cli_finish_test extends cli_testcase {
/**
* Tests the help.
*/
- public function test_help() {
+ public function test_help(): void {
$this->set_parameters(['--help']);
$cli = new finish();
$text = $this->execute($cli);
@@ -85,7 +84,7 @@ class cli_finish_test extends cli_testcase {
/**
* Tests if running without arguments.
*/
- public function test_noarguments() {
+ public function test_noarguments(): void {
$cli = new finish();
$this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_MISSING);
$this->execute($cli);
@@ -94,7 +93,7 @@ class cli_finish_test extends cli_testcase {
/**
* Tests finishing an already ended outage.
*/
- public function test_endedoutage() {
+ public function test_endedoutage(): void {
self::setAdminUser();
$now = time();
$id = outagedb::save(new outage([
@@ -105,7 +104,7 @@ class cli_finish_test extends cli_testcase {
'title' => 'Title',
'description' => 'Description',
]));
- $this->set_parameters(['-id='.$id]);
+ $this->set_parameters(['-id=' . $id]);
$cli = new finish();
$cli->set_referencetime($now);
$this->set_expected_cli_exception(cli_exception::ERROR_OUTAGE_INVALID);
@@ -115,7 +114,7 @@ class cli_finish_test extends cli_testcase {
/**
* Tests finishing an outage.
*/
- public function test_finish() {
+ public function test_finish(): void {
self::setAdminUser();
$now = time();
$id = outagedb::save(new outage([
@@ -126,7 +125,7 @@ class cli_finish_test extends cli_testcase {
'title' => 'Title',
'description' => 'Description',
]));
- $this->set_parameters(['-id='.$id]);
+ $this->set_parameters(['-id=' . $id]);
$cli = new finish();
$cli->set_referencetime($now);
$this->execute($cli);
@@ -135,7 +134,7 @@ class cli_finish_test extends cli_testcase {
/**
* Tests finishing an active outage when it does not exists.
*/
- public function test_activenotfound() {
+ public function test_activenotfound(): void {
self::setAdminUser();
$this->set_parameters(['-a']);
$cli = new finish();
@@ -146,7 +145,7 @@ class cli_finish_test extends cli_testcase {
/**
* Tests providing an invalid outage id.
*/
- public function test_invalidid() {
+ public function test_invalidid(): void {
self::setAdminUser();
$this->set_parameters(['-id=theid']);
$cli = new finish();
@@ -157,7 +156,7 @@ class cli_finish_test extends cli_testcase {
/**
* Tests when the outage is not found.
*/
- public function test_idnotfound() {
+ public function test_idnotfound(): void {
self::setAdminUser();
$this->set_parameters(['-id=99999']);
$cli = new finish();
diff --git a/tests/cli_test.php b/tests/cli_test.php
index d821e74..cfb5682 100644
--- a/tests/cli_test.php
+++ b/tests/cli_test.php
@@ -27,7 +27,7 @@ use auth_outage\local\cli\cli_exception;
use auth_outage\local\cli\create;
defined('MOODLE_INTERNAL') || die();
-require_once(__DIR__.'/cli_testcase.php');
+require_once(__DIR__ . '/cli_testcase.php');
/**
* cli_test test class.
@@ -38,8 +38,7 @@ require_once(__DIR__.'/cli_testcase.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \auth_outage\local\cli\create
*/
-class cli_test extends cli_testcase {
-
+final class cli_test extends cli_testcase {
public function tearDown(): void {
parent::tearDown();
}
@@ -47,7 +46,7 @@ class cli_test extends cli_testcase {
/**
* Tests providing an unknown parameter.
*/
- public function test_invalidargumentparam() {
+ public function test_invalidargumentparam(): void {
$this->set_parameters(['--aninvalidparameter']);
$this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_UNKNOWN);
new create();
@@ -56,7 +55,7 @@ class cli_test extends cli_testcase {
/**
* Tests providing another unknow parameter (without --).
*/
- public function test_invalidargumentgiven() {
+ public function test_invalidargumentgiven(): void {
$this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_UNKNOWN);
new create(['anotherinvalidparameter']);
}
@@ -64,7 +63,7 @@ class cli_test extends cli_testcase {
/**
* Tests setting reference times.
*/
- public function test_setreferencetime() {
+ public function test_setreferencetime(): void {
$cli = new create(['start' => 0]);
$cli->set_referencetime(1);
$cli->set_referencetime(60 * 60 * 24 * 7);
@@ -73,7 +72,7 @@ class cli_test extends cli_testcase {
/**
* Tests setting an invalid reference time.
*/
- public function test_setreferencetime_invalid() {
+ public function test_setreferencetime_invalid(): void {
$this->set_parameters(['--start=60']);
$cli = new create();
$this->set_expected_exception('coding_exception');
@@ -83,7 +82,7 @@ class cli_test extends cli_testcase {
/**
* Tests the help.
*/
- public function test_help() {
+ public function test_help(): void {
$this->set_parameters(['-h']);
$cli = new create();
$output = $this->execute($cli);
@@ -94,7 +93,7 @@ class cli_test extends cli_testcase {
/**
* Tests the cli_exception.
*/
- public function test_exception() {
+ public function test_exception(): void {
$this->set_expected_cli_exception(cli_exception::ERROR_UNDEFINED);
throw new cli_exception('An CLI exception.');
}
@@ -102,7 +101,7 @@ class cli_test extends cli_testcase {
/**
* Tests with the auth_outage plugin disabled.
*/
- public function test_authdisabled() {
+ public function test_authdisabled(): void {
// Disable all auth plugins.
set_config('auth', '');
\core\session\manager::gc(); // Remove stale sessions.
diff --git a/tests/cli_testcase.php b/tests/cli_testcase.php
index c449293..2012b5c 100644
--- a/tests/cli_testcase.php
+++ b/tests/cli_testcase.php
@@ -24,7 +24,7 @@
*/
defined('MOODLE_INTERNAL') || die();
-require_once(__DIR__.'/base_testcase.php');
+require_once(__DIR__ . '/base_testcase.php');
/**
* cli_testcase class.
@@ -35,7 +35,6 @@ require_once(__DIR__.'/base_testcase.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class cli_testcase extends base_testcase {
-
public function tearDown(): void {
parent::tearDown();
}
diff --git a/tests/cli_waitforit_test.php b/tests/cli_waitforit_test.php
index fd9c354..32e4d5b 100644
--- a/tests/cli_waitforit_test.php
+++ b/tests/cli_waitforit_test.php
@@ -29,7 +29,7 @@ use auth_outage\local\cli\waitforit;
use auth_outage\local\cli\cli_exception;
defined('MOODLE_INTERNAL') || die();
-require_once(__DIR__.'/cli_testcase.php');
+require_once(__DIR__ . '/cli_testcase.php');
/**
* waitforit_test test class.
@@ -40,8 +40,7 @@ require_once(__DIR__.'/cli_testcase.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \auth_outage\local\cli\waitforit
*/
-class cli_waitforit_test extends cli_testcase {
-
+final class cli_waitforit_test extends cli_testcase {
public function tearDown(): void {
parent::tearDown();
}
@@ -49,7 +48,7 @@ class cli_waitforit_test extends cli_testcase {
/**
* Tests the constructor.
*/
- public function test_constructor() {
+ public function test_constructor(): void {
$cli = new waitforit();
self::assertNotNull($cli);
}
@@ -57,7 +56,7 @@ class cli_waitforit_test extends cli_testcase {
/**
* Tests the generated options.
*/
- public function test_generateoptions() {
+ public function test_generateoptions(): void {
$cli = new waitforit();
$options = $cli->generate_options();
foreach (array_keys($options) as $k) {
@@ -68,7 +67,7 @@ class cli_waitforit_test extends cli_testcase {
/**
* Tests the generated shortcut options.
*/
- public function test_generateshortcuts() {
+ public function test_generateshortcuts(): void {
$cli = new waitforit();
$options = $cli->generate_options();
$shorts = $cli->generate_shortcuts();
@@ -80,7 +79,7 @@ class cli_waitforit_test extends cli_testcase {
/**
* Tests if help works.
*/
- public function test_help() {
+ public function test_help(): void {
$this->set_parameters(['--help']);
$cli = new waitforit();
$text = $this->execute($cli);
@@ -91,7 +90,7 @@ class cli_waitforit_test extends cli_testcase {
/**
* Checks if providing an outageid and active parameter.
*/
- public function test_bothparams() {
+ public function test_bothparams(): void {
$this->set_parameters(['--outageid=1', '--active']);
$cli = new waitforit();
$this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_INVALID);
@@ -101,7 +100,7 @@ class cli_waitforit_test extends cli_testcase {
/**
* Tests with an invalid outage id
*/
- public function test_invalidoutageid() {
+ public function test_invalidoutageid(): void {
$this->set_parameters(['-id=-1']);
$cli = new waitforit();
$this->set_expected_cli_exception(cli_exception::ERROR_PARAMETER_INVALID);
@@ -111,7 +110,7 @@ class cli_waitforit_test extends cli_testcase {
/**
* Tests with an active outage when it does not exists.
*/
- public function test_outagenotfound() {
+ public function test_outagenotfound(): void {
$this->set_parameters(['-a']);
$cli = new waitforit();
$this->set_expected_cli_exception(cli_exception::ERROR_OUTAGE_NOT_FOUND);
@@ -121,7 +120,7 @@ class cli_waitforit_test extends cli_testcase {
/**
* Tests with an outage that already ended.
*/
- public function test_endedoutage() {
+ public function test_endedoutage(): void {
self::setAdminUser();
$now = time();
$id = outagedb::save(new outage([
@@ -132,7 +131,7 @@ class cli_waitforit_test extends cli_testcase {
'title' => 'Title',
'description' => 'Description',
]));
- $this->set_parameters(['-id='.$id]);
+ $this->set_parameters(['-id=' . $id]);
$cli = new waitforit();
$cli->set_referencetime($now);
$this->set_expected_cli_exception(cli_exception::ERROR_OUTAGE_INVALID);
@@ -142,7 +141,7 @@ class cli_waitforit_test extends cli_testcase {
/**
* Tests waiting for an existing active outage, verbose mode.
*/
- public function test_activeverbose() {
+ public function test_activeverbose(): void {
self::setAdminUser();
$now = time();
outagedb::save(new outage([
diff --git a/tests/controllers_infopage_test.php b/tests/controllers_infopage_test.php
index 5ca176c..be43566 100644
--- a/tests/controllers_infopage_test.php
+++ b/tests/controllers_infopage_test.php
@@ -27,7 +27,7 @@ use auth_outage\local\outage;
use auth_outage\local\controllers\infopage;
defined('MOODLE_INTERNAL') || die();
-require_once(__DIR__.'/base_testcase.php');
+require_once(__DIR__ . '/base_testcase.php');
/**
* Tests performed on infopage controller class and update_static_page task class.
@@ -38,8 +38,7 @@ require_once(__DIR__.'/base_testcase.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \auth_outage\local\controllers\infopage
*/
-class controllers_infopage_test extends base_testcase {
-
+final class controllers_infopage_test extends base_testcase {
public function tearDown(): void {
parent::tearDown();
}
@@ -47,7 +46,7 @@ class controllers_infopage_test extends base_testcase {
/**
* Tests the constructor.
*/
- public function test_constructor() {
+ public function test_constructor(): void {
$this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance()));
new infopage();
@@ -56,7 +55,7 @@ class controllers_infopage_test extends base_testcase {
/**
* Tests the constructor with given parameters.
*/
- public function test_constructor_withparams() {
+ public function test_constructor_withparams(): void {
$this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance()));
$_GET = ['id' => 1, 'static' => 'true'];
@@ -66,7 +65,7 @@ class controllers_infopage_test extends base_testcase {
/**
* Tests the constructor with different id and outage id.
*/
- public function test_constructor_idmismatch() {
+ public function test_constructor_idmismatch(): void {
$this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance()));
$outage = $this->get_dummy_outage();
@@ -77,7 +76,7 @@ class controllers_infopage_test extends base_testcase {
/**
* Tests the constructor with an invalid outage.
*/
- public function test_constructor_invalidoutage() {
+ public function test_constructor_invalidoutage(): void {
$this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance()));
$this->set_expected_exception('coding_exception', 'Provided outage is not a valid outage object. (My outage)');
@@ -87,7 +86,7 @@ class controllers_infopage_test extends base_testcase {
/**
* Checks the output of the info page.
*/
- public function test_output() {
+ public function test_output(): void {
$this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance()));
$outage = $this->get_dummy_outage();
@@ -100,7 +99,7 @@ class controllers_infopage_test extends base_testcase {
/**
* Checks the output of the info page.
*/
- public function test_output_without_permission() {
+ public function test_output_without_permission(): void {
$this->revoke_info_page_permissions();
$this->assertFalse(has_capability('auth/outage:viewinfo', context_system::instance()));
@@ -114,7 +113,7 @@ class controllers_infopage_test extends base_testcase {
/**
* Checks the output of the info page.
*/
- public function test_output_without_permission_but_static() {
+ public function test_output_without_permission_but_static(): void {
$this->revoke_info_page_permissions();
$this->assertFalse(has_capability('auth/outage:viewinfo', context_system::instance()));
@@ -128,7 +127,7 @@ class controllers_infopage_test extends base_testcase {
/**
* Checks the output of the info page.
*/
- public function test_output_with_forcelogin() {
+ public function test_output_with_forcelogin(): void {
$this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance()));
set_config('forcelogin', true);
@@ -143,7 +142,7 @@ class controllers_infopage_test extends base_testcase {
/**
* Checks the output of the info page.
*/
- public function test_output_with_forcelogin_if_static() {
+ public function test_output_with_forcelogin_if_static(): void {
$this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance()));
set_config('forcelogin', true);
@@ -159,7 +158,7 @@ class controllers_infopage_test extends base_testcase {
/**
* Tests the constructor enables SVG support.
*/
- public function test_svgicons_is_true() {
+ public function test_svgicons_is_true(): void {
global $CFG;
$this->assertTrue(has_capability('auth/outage:viewinfo', context_system::instance()));
diff --git a/tests/controllers_maintenance_static_page_test.php b/tests/controllers_maintenance_static_page_test.php
index def7166..858d83d 100644
--- a/tests/controllers_maintenance_static_page_test.php
+++ b/tests/controllers_maintenance_static_page_test.php
@@ -29,7 +29,7 @@ use auth_outage\local\controllers\maintenance_static_page_io;
use auth_outage\local\controllers\maintenance_static_page_generator;
defined('MOODLE_INTERNAL') || die();
-require_once(__DIR__.'/base_testcase.php');
+require_once(__DIR__ . '/base_testcase.php');
/**
* maintenance_static_page_test class.
@@ -40,8 +40,7 @@ require_once(__DIR__.'/base_testcase.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \auth_outage\local\controllers\maintenance_static_page_generator
*/
-class controllers_maintenance_static_page_test extends base_testcase {
-
+final class controllers_maintenance_static_page_test extends base_testcase {
public function tearDown(): void {
parent::tearDown();
}
@@ -49,39 +48,41 @@ class controllers_maintenance_static_page_test extends base_testcase {
/**
* Test template file.
*/
- public function test_templatefile() {
+ public function test_templatefile(): void {
global $CFG;
$page = maintenance_static_page::create_from_html('');
- self::assertSame($CFG->dataroot.'/climaintenance.template.html', $page->get_io()->get_template_file());
+ self::assertSame($CFG->dataroot . '/climaintenance.template.html', $page->get_io()->get_template_file());
$page->get_io()->set_preview(true);
- self::assertSame($CFG->dataroot.'/auth_outage/climaintenance/preview/climaintenance.html',
- $page->get_io()->get_template_file());
+ self::assertSame(
+ $CFG->dataroot . '/auth_outage/climaintenance/preview/climaintenance.html',
+ $page->get_io()->get_template_file()
+ );
}
/**
* Test resources folder.
*/
- public function test_resourcesfolder() {
+ public function test_resourcesfolder(): void {
global $CFG;
$page = maintenance_static_page::create_from_html('');
- self::assertSame($CFG->dataroot.'/auth_outage/climaintenance', $page->get_io()->get_resources_folder());
+ self::assertSame($CFG->dataroot . '/auth_outage/climaintenance', $page->get_io()->get_resources_folder());
$page->get_io()->set_preview(true);
- self::assertSame($CFG->dataroot.'/auth_outage/climaintenance/preview', $page->get_io()->get_resources_folder());
+ self::assertSame($CFG->dataroot . '/auth_outage/climaintenance/preview', $page->get_io()->get_resources_folder());
}
/**
* Test create from outage.
*/
- public function test_createfromoutage() {
+ public function test_createfromoutage(): void {
// How to fetch a page from PHPUnit environment?
}
/**
* Test create from HTML.
*/
- public function test_createfromhtml() {
+ public function test_createfromhtml(): void {
$html = "\n
- + show_data($viewbag['unended']); @@ -65,7 +65,7 @@ echo $viewbag['warning']; $urlnew->param('starttime', $next); echo $output->single_button($urlnew, get_string('outagecreate', 'auth_outage')); if ($default) { - echo ' ' . userdate( $next, get_string('datetimeformat', 'auth_outage')); + echo ' ' . userdate($next, get_string('datetimeformat', 'auth_outage')); } } endif; ?> @@ -73,11 +73,11 @@ echo $viewbag['warning'];
- + show_data($viewbag['ended']); diff --git a/views/warningbar/warningbar.php b/views/warningbar/warningbar.php index 43047a6..cfded85 100644 --- a/views/warningbar/warningbar.php +++ b/views/warningbar/warningbar.php @@ -49,19 +49,19 @@ if (!$viewbag['static']) { if (is_siteadmin()) { $link = html_writer::link( new moodle_url('/auth/outage/finish.php', ['id' => $viewbag['outage']->id]), - $OUTPUT->pix_icon('t/check', get_string('finish', 'auth_outage'), 'moodle', array('class' => 'iconsmall')) . get_string('finish', 'auth_outage'), + $OUTPUT->pix_icon('t/check', get_string('finish', 'auth_outage'), 'moodle', ['class' => 'iconsmall']) . get_string('finish', 'auth_outage'), [ 'title' => get_string('finish', 'auth_outage'), 'class' => 'auth_outage_warningbar_box_finish', ] ); - $title .= ' '.html_writer::span($link, '', ['id' => 'auth_outage_warningbar_button']); + $title .= ' ' . html_writer::span($link, '', ['id' => 'auth_outage_warningbar_button']); } } ?> @@ -73,11 +73,11 @@ if (!$viewbag['static']) { - +