From b48e755affc865547ab148340f586ae9a297c8f5 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 24 Apr 2018 15:54:00 +0200 Subject: [rebootcontrol] Try clients first that are known to be online This prevents long delays if a large amount of clients is selected where the majority is offline. --- modules-available/rebootcontrol/page.inc.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'modules-available/rebootcontrol/page.inc.php') diff --git a/modules-available/rebootcontrol/page.inc.php b/modules-available/rebootcontrol/page.inc.php index 041ae74f..675c94f8 100644 --- a/modules-available/rebootcontrol/page.inc.php +++ b/modules-available/rebootcontrol/page.inc.php @@ -49,7 +49,13 @@ class Page_RebootControl extends Page Message::addError('no-clients-selected'); Util::redirect(); } - + usort($actualClients, function($a, $b) { + $a = ($a['state'] === 'IDLE' || $a['state'] === 'OCCUPIED'); + $b = ($b['state'] === 'IDLE' || $b['state'] === 'OCCUPIED'); + if ($a === $b) + return 0; + return $a ? -1 : 1; + }); $task = RebootControl::execute($actualClients, $this->action === 'shutdown', $minutes, $locationId); Util::redirect("?do=rebootcontrol&taskid=".$task["id"]); } -- cgit v1.2.3-55-g7522