WIP Issue #17 - Settings page done, missing forms and other references to warning duration and stop time.

This commit is contained in:
Daniel Thee Roperto
2016-09-08 17:25:28 +10:00
parent 07ee61f4f3
commit 4e46e934d0
9 changed files with 56 additions and 26 deletions

View File

@@ -45,7 +45,7 @@ class edit extends \moodleform {
$mform->addElement('date_time_selector', 'starttime', get_string('starttime', 'auth_outage'));
$mform->addElement('date_time_selector', 'stoptime', get_string('stoptime', 'auth_outage'));
$mform->addElement('duration', 'outageduration', get_string('outageduration', 'auth_outage'));
$mform->addElement('duration', 'warningduration', get_string('warningduration', 'auth_outage'));
@@ -59,6 +59,8 @@ class edit extends \moodleform {
$mform->addElement('editor', 'description', get_string('description', 'auth_outage'));
$mform->addElement('static', 'usagehints', '', get_string('textplaceholdershint', 'auth_outage'));
$this->add_action_buttons();
}

View File

@@ -44,9 +44,9 @@ class outage {
public $stoptime = null;
/**
* @var int Amount of minutes before outage starts to show the warning message.
* @var int Warning start timestamp.
*/
public $warningduration = null;
public $warntime = null;
/**
* @var string Short description of the outage (no HTML).
@@ -85,8 +85,8 @@ class outage {
if (is_object($data) || is_array($data)) {
outagelib::data2object($data, $this);
// FIXME types are wrong. Is this behaving as expected?
$fields = ['createdby', 'id', 'lastmodified', 'modifiedby', 'starttime', 'stoptime', 'warningduration'];
// Adjust field types as needed.
$fields = ['createdby', 'id', 'lastmodified', 'modifiedby', 'starttime', 'stoptime', 'warntime'];
foreach ($fields as $f) {
$this->$f = ($this->$f === null) ? null : (int)$this->$f;
}

View File

@@ -158,7 +158,7 @@ class outagedb {
// Gets only one record if available, the one that starts(ed) first and that stops last.
$data = $DB->get_records_select(
'auth_outage',
'(starttime - warningduration <= :datetime1 AND stoptime >= :datetime2)',
'(warntime <= :datetime1 AND stoptime >= :datetime2)',
['datetime1' => $time, 'datetime2' => $time],
'starttime ASC, stoptime DESC, title ASC',
'*',