Merge pull request #130 from catalyst/issue129-outage-not-finished

Fixes #129 - Stop maintenance after stoptime.
This commit is contained in:
Daniel Thee Roperto
2018-04-26 16:31:12 +10:00
committed by GitHub
2 changed files with 5 additions and 5 deletions

View File

@@ -250,7 +250,7 @@ class outagelib {
$code = <<<'EOT'
<?php
if (time() >= {{STARTTIME}}) {
if ((time() >= {{STARTTIME}}) && (time() < {{STOPTIME}})) {
define('MOODLE_INTERNAL', true);
require_once($CFG->dirroot.'/lib/moodlelib.php');
if (!remoteip_in_list('{{ALLOWEDIPS}}')) {
@@ -278,8 +278,8 @@ if (time() >= {{STARTTIME}}) {
}
}
EOT;
$search = ['{{STARTTIME}}', '{{ALLOWEDIPS}}', '{{YOURIP}}'];
$replace = [$starttime, $allowedips, getremoteaddr('n/a')];
$search = ['{{STARTTIME}}', '{{STOPTIME}}', '{{ALLOWEDIPS}}', '{{YOURIP}}'];
$replace = [$starttime, $stoptime, $allowedips, getremoteaddr('n/a')];
return str_replace($search, $replace, $code);
}

View File

@@ -290,7 +290,7 @@ class outagelib_test extends advanced_testcase {
public function test_createmaintenancephpcode() {
$expected = <<<'EOT'
<?php
if (time() >= 123) {
if ((time() >= 123) && (time() < 456)) {
define('MOODLE_INTERNAL', true);
require_once($CFG->dirroot.'/lib/moodlelib.php');
if (!remoteip_in_list('heyyou
@@ -330,7 +330,7 @@ EOT;
$expected = <<<'EOT'
<?php
if (time() >= 123) {
if ((time() >= 123) && (time() < 456)) {
define('MOODLE_INTERNAL', true);
require_once($CFG->dirroot.'/lib/moodlelib.php');
if (!remoteip_in_list('127.0.0.1')) {