mirror of
https://github.com/catalyst/moodle-auth_outage.git
synced 2026-05-17 05:48:43 +02:00
Merge branch 'master' into issue16-hidemenu
This commit is contained in:
@@ -154,20 +154,21 @@ final class outagedb {
|
||||
throw new \InvalidArgumentException('$time must be null or an int.');
|
||||
}
|
||||
|
||||
// TODO Is there a way to use Moodle API instead of writing SQL (conditions not equals)?
|
||||
// TODO Query not fully using indexes (starttime + 90)
|
||||
// Gets any active outage (already started or during warning period).
|
||||
// Gets only one record if available, the one that starts(ed) first and that stops last.
|
||||
$data = $DB->get_record_sql('
|
||||
SELECT *
|
||||
FROM {auth_outage}
|
||||
WHERE (starttime - warningduration <= :datetime1 AND stoptime >= :datetime2)
|
||||
ORDER BY starttime ASC, stoptime DESC, title ASC
|
||||
LIMIT 1
|
||||
',
|
||||
['datetime1' => $time, 'datetime2' => $time]
|
||||
$data = $DB->get_records_select(
|
||||
'auth_outage',
|
||||
'(starttime - warningduration <= :datetime1 AND stoptime >= :datetime2)',
|
||||
['datetime1' => $time, 'datetime2' => $time],
|
||||
'starttime ASC, stoptime DESC, title ASC',
|
||||
'*',
|
||||
0,
|
||||
1
|
||||
);
|
||||
|
||||
return ($data === false) ? null : new \auth_outage\models\outage($data);
|
||||
// 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 \auth_outage\models\outage(array_shift($data));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
.auth_outage_warningbar {
|
||||
box-sizing: content-box;
|
||||
position: fixed;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
|
||||
Reference in New Issue
Block a user