summaryrefslogtreecommitdiffstats
path: root/modules-available/rebootcontrol/pages/task.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/rebootcontrol/pages/task.inc.php')
-rw-r--r--modules-available/rebootcontrol/pages/task.inc.php23
1 files changed, 10 insertions, 13 deletions
diff --git a/modules-available/rebootcontrol/pages/task.inc.php b/modules-available/rebootcontrol/pages/task.inc.php
index 691fd9e2..7db2a90b 100644
--- a/modules-available/rebootcontrol/pages/task.inc.php
+++ b/modules-available/rebootcontrol/pages/task.inc.php
@@ -26,6 +26,8 @@ class SubPage
private static function showTask()
{
+ // No permission check here - user had to guess the UUID, not very likely,
+ // but this way we can still link to some implicitly triggered job
$taskid = Request::get("taskid", Request::REQUIRED, 'string');
$type = Request::get('type', false, 'string');
if ($type === 'checkhost') {
@@ -93,8 +95,9 @@ class SubPage
} elseif ($type === RebootControl::TASK_WOL) {
// Nothing (yet)
} else {
- Util::traceError('oopsie');
+ ErrorHandler::traceError('oopsie');
}
+ $job['timestamp_s'] = Util::prettyTime($job['timestamp']);
Render::addTemplate('status-' . $template, $job);
}
@@ -103,6 +106,9 @@ class SubPage
Render::addTemplate('task-header');
// Append list of active reboot/shutdown tasks
$allowedLocs = User::getAllowedLocations("action.*");
+ if (empty($allowedLocs)) {
+ User::assertPermission('action.*');
+ }
$active = RebootControl::getActiveTasks($allowedLocs);
if (empty($active)) {
Message::addInfo('no-current-tasks');
@@ -112,8 +118,10 @@ class SubPage
if (isset($entry['clients'])) {
$entry['clients'] = count($entry['clients']);
}
+ $entry['timestamp_s'] = Util::prettyTime($entry['timestamp']);
}
unset($entry);
+ ArrayUtil::sortByColumn($active, 'timestamp', SORT_ASC, SORT_NUMERIC);
Render::addTemplate('task-list', ['list' => $active]);
}
}
@@ -121,7 +129,7 @@ class SubPage
private static function expandLocationIds(&$lids)
{
foreach ($lids as &$locid) {
- if ($locid === 0) {
+ if ($locid === null || $locid === 0) {
$name = '-';
} else {
$name = Location::getName($locid);
@@ -137,14 +145,3 @@ class SubPage
}
}
-
-
-// Remove when we require >= 7.3.0
-if (!function_exists('array_key_first')) {
- function array_key_first(array $arr) {
- foreach($arr as $key => $unused) {
- return $key;
- }
- return NULL;
- }
-}