summaryrefslogtreecommitdiffstats
path: root/modules-available/roomplanner/hooks/client-update.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/roomplanner/hooks/client-update.inc.php')
-rw-r--r--modules-available/roomplanner/hooks/client-update.inc.php19
1 files changed, 19 insertions, 0 deletions
diff --git a/modules-available/roomplanner/hooks/client-update.inc.php b/modules-available/roomplanner/hooks/client-update.inc.php
new file mode 100644
index 00000000..a8ffd555
--- /dev/null
+++ b/modules-available/roomplanner/hooks/client-update.inc.php
@@ -0,0 +1,19 @@
+<?php
+
+// Either poweron or user logged in
+if ($type === '~poweron' || ($type === '~runstate' && $used === 1 && $old['state'] !== 'OCCUPIED')) {
+ // Get all the clients that are managers for rooms this client is a tutor for.
+ // Start in the machine table aliased tut, map $ip to client uuid, then look this
+ // up in the location_roomplan table as tutoruuid, get the according managerip,
+ // look this one up again in machine table aliased mgr to finally get the according
+ // mac address of that manager. We need that for WOL.
+ $managers = Database::queryAll('SELECT mgr.machineuuid, mgr.clientip, mgr.macaddr
+ FROM machine tut
+ INNER JOIN location_roomplan lr ON (tut.machineuuid = lr.tutoruuid)
+ INNER JOIN machine mgr ON (lr.managerip = mgr.clientip)
+ WHERE tut.clientip = :tutorip', ['tutorip' => $ip]);
+ if (!empty($managers) && Module::isAvailable('rebootcontrol')) {
+ // Create WOL job
+ RebootControl::wakeMachines($managers);
+ }
+} \ No newline at end of file