mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-17 05:48:43 +02:00
Modified unit tests to remove autostart, and quickstart guide and readme.
This commit is contained in:
committed by
Brendan Heywood
parent
ffda33329c
commit
ac29a02402
@@ -100,11 +100,6 @@ class outagedb {
|
||||
$outage->modifiedby = $USER->id;
|
||||
$outage->lastmodified = time();
|
||||
|
||||
// Setting autostart to false if the default autostart is configured to "Force off".
|
||||
if (get_config('default_autostart', 'auth_outage') === '2') {
|
||||
$outage->autostart = 0;
|
||||
}
|
||||
|
||||
if ($outage->id === null) {
|
||||
// If new outage, set its creator.
|
||||
$outage->createdby = $USER->id;
|
||||
@@ -347,37 +342,6 @@ class outagedb {
|
||||
return (count($data) == 0) ? null : new outage(array_shift($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the next outage which has not started yet and has the autostart flag set to true.
|
||||
* @param null $time Timestamp reference for current time.
|
||||
* @return outage|null The outage or null if not found.
|
||||
* @throws coding_exception
|
||||
*/
|
||||
public static function get_next_autostarting($time = null) {
|
||||
global $DB;
|
||||
|
||||
if ($time === null) {
|
||||
$time = time();
|
||||
}
|
||||
if (!is_int($time) || ($time <= 0)) {
|
||||
throw new coding_exception('$time must be null or a positive int.', $time);
|
||||
}
|
||||
|
||||
$data = $DB->get_records_select(
|
||||
'auth_outage',
|
||||
'(:datetime <= starttime) AND (autostart = 1)',
|
||||
['datetime' => $time],
|
||||
'starttime ASC',
|
||||
'*',
|
||||
0,
|
||||
1
|
||||
);
|
||||
|
||||
// Not using $DB->get_record_select instead because there is no 'limit' parameter.
|
||||
// Allowing multiple records still raises an internal error.
|
||||
return (count($data) == 0) ? null : new outage(array_shift($data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an ongoing outage (between start and stop time but not finished).
|
||||
* @param int|null $time Timestamp considered to check for outages, null for current date/time.
|
||||
|
||||
@@ -136,7 +136,6 @@ class edit extends moodleform {
|
||||
}
|
||||
$outagedata = [
|
||||
'id' => ($data->id === 0) ? null : $data->id,
|
||||
'autostart' => (isset($data->autostart) && ($data->autostart == 1)),
|
||||
'starttime' => $data->starttime,
|
||||
'stoptime' => $data->starttime + $data->outageduration,
|
||||
'warntime' => $data->starttime - $data->warningduration,
|
||||
@@ -161,7 +160,6 @@ class edit extends moodleform {
|
||||
if ($outage instanceof outage) {
|
||||
$this->_form->setDefaults([
|
||||
'id' => $outage->id,
|
||||
'autostart' => $outage->autostart,
|
||||
'starttime' => $outage->starttime,
|
||||
'outageduration' => $outage->get_duration_planned(),
|
||||
'warningduration' => $outage->get_warning_duration(),
|
||||
|
||||
@@ -43,7 +43,6 @@ class create extends clibase {
|
||||
return [
|
||||
'help' => false,
|
||||
'clone' => null,
|
||||
'autostart' => null,
|
||||
'warn' => null,
|
||||
'start' => null,
|
||||
'duration' => null,
|
||||
@@ -60,7 +59,6 @@ class create extends clibase {
|
||||
*/
|
||||
public function generate_shortcuts() {
|
||||
return [
|
||||
'a' => 'autostart',
|
||||
'b' => 'block',
|
||||
'c' => 'clone',
|
||||
'd' => 'duration',
|
||||
@@ -165,7 +163,6 @@ class create extends clibase {
|
||||
// an outage 47 years in advance.
|
||||
$start = $options['start'] > 1500000000 ? $options['start'] : $this->time + $options['start'];
|
||||
$outage = new outage([
|
||||
'autostart' => $options['autostart'],
|
||||
'warntime' => $start - $options['warn'],
|
||||
'starttime' => $start,
|
||||
'stoptime' => $start + $options['duration'],
|
||||
@@ -199,7 +196,6 @@ class create extends clibase {
|
||||
|
||||
$outage = outagedb::get_by_id((int)$id);
|
||||
$this->set_defaults([
|
||||
'autostart' => $outage->autostart,
|
||||
'warn' => $outage->get_warning_duration(),
|
||||
'duration' => $outage->get_duration_planned(),
|
||||
'title' => $outage->title,
|
||||
@@ -222,10 +218,6 @@ class create extends clibase {
|
||||
$options[$param] = $this->merge_options_check_parameters_string_nonempty($options[$param], $param);
|
||||
}
|
||||
|
||||
foreach (['autostart'] as $param) {
|
||||
$options[$param] = $this->merge_options_check_parameters_bool($options[$param], $param);
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,11 +58,6 @@ class outage {
|
||||
*/
|
||||
public $id = null;
|
||||
|
||||
/**
|
||||
* @var bool|null Maintenance mode auto start flag.
|
||||
*/
|
||||
public $autostart = null;
|
||||
|
||||
/**
|
||||
* @var int|null Start Time timestamp.
|
||||
*/
|
||||
@@ -294,9 +289,6 @@ class outage {
|
||||
foreach ($fs as $f) {
|
||||
$this->$f = ($this->$f === null) ? null : (int)$this->$f;
|
||||
}
|
||||
|
||||
// Adjust bool fields.
|
||||
$this->autostart = ($this->autostart === null) ? null : (bool)$this->autostart;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -173,7 +173,6 @@ class outagelib {
|
||||
'allowedips' => '',
|
||||
'css' => '',
|
||||
'default_time' => '',
|
||||
'default_autostart' => '0',
|
||||
'default_duration' => (string)(60 * 60),
|
||||
'default_warning_duration' => (string)(60 * 60),
|
||||
'default_title' => get_string('defaulttitlevalue', 'auth_outage'),
|
||||
@@ -223,7 +222,7 @@ class outagelib {
|
||||
* @param outage|null $outage Outage or null if no scheduled outage.
|
||||
*/
|
||||
private static function update_maintenance_later($outage) {
|
||||
if (is_null($outage) || !$outage->autostart || get_config('default_autostart', 'auth_outage') === '2') {
|
||||
if (is_null($outage)) {
|
||||
unset_config('maintenance_later');
|
||||
} else {
|
||||
$message = get_config('moodle', 'maintenance_message');
|
||||
|
||||
Reference in New Issue
Block a user