diff options
author | Simon Rettberg | 2017-02-13 15:48:30 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-02-13 15:48:30 +0100 |
commit | f508096e53c631a124bda1de8f154ac8977d8cfc (patch) | |
tree | d3367152c7b178ec2af88f4d1bc86abd3b5009f4 | |
parent | added "Cancel" to branding-check template (diff) | |
download | slx-admin-f508096e53c631a124bda1de8f154ac8977d8cfc.tar.gz slx-admin-f508096e53c631a124bda1de8f154ac8977d8cfc.tar.xz slx-admin-f508096e53c631a124bda1de8f154ac8977d8cfc.zip |
[roomplanner] Make hiding of rooms in api more clever
Don't hide a non-leaf room if at least one its leafs doesn't
have a valid room plan (but the non-leaf in question does).
-rw-r--r-- | modules-available/roomplanner/inc/pvsgenerator.inc.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/modules-available/roomplanner/inc/pvsgenerator.inc.php b/modules-available/roomplanner/inc/pvsgenerator.inc.php index c00d5439..d61e826b 100644 --- a/modules-available/roomplanner/inc/pvsgenerator.inc.php +++ b/modules-available/roomplanner/inc/pvsgenerator.inc.php @@ -16,6 +16,8 @@ class PvsGenerator /* get all rooms */ $rooms = array(); + // Use left joins everywhere so we still have the complete list of locations below + // for figuring out which locations are leafs and which aren't $ret = Database::simpleQuery( 'SELECT l.locationid, l.parentlocationid, l.locationname, lr.locationid AS notnull, lr.managerip, lr.tutoruuid, m.clientip as tutorip ' . 'FROM location l ' @@ -27,12 +29,27 @@ class PvsGenerator settype($row['parentlocationid'], 'int'); $rooms[$row['locationid']] = $row; } + // Mark all non-leafs as skip foreach ($rooms as &$room) { if ($room['parentlocationid'] > 0 && isset($rooms[$room['parentlocationid']])) { $rooms[$room['parentlocationid']]['skip'] = true; // Don't just unset, might be wrong order } } - unset($room); // refd! + // Now un-mark all where there's at least one child without valid room plan + foreach ($rooms as &$room) { + if (!isset($room['skip']) && (is_null($room['notnull']) || empty($room['managerip']))) { + $room['skip'] = true; + $r2 =& $room; + while ($r2['parentlocationid'] > 0) { + $r2 =& $rooms[$r2['parentlocationid']]; + if (!(is_null($room['notnull']) || empty($room['managerip']))) { + unset($r2['skip']); + break; + } + } + } + } + unset($room, $r2); // refd! /* collect names and build room blocks - filter empty rooms while at it */ $roomNames = array(); |