summaryrefslogtreecommitdiffstats
path: root/modules-available/passthrough/page.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/passthrough/page.inc.php')
-rw-r--r--modules-available/passthrough/page.inc.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/modules-available/passthrough/page.inc.php b/modules-available/passthrough/page.inc.php
index b36b45ac..2db2525e 100644
--- a/modules-available/passthrough/page.inc.php
+++ b/modules-available/passthrough/page.inc.php
@@ -94,6 +94,7 @@ class Page_Passthrough extends Page
/**
* Show all the hardware that is known. Start with video adapters.
+ * @return void
*/
private function showHardwareList()
{
@@ -157,13 +158,26 @@ class Page_Passthrough extends Page
private function showLocationMapping()
{
$locationId = Request::get('locationid', Request::REQUIRED, 'int');
- $res = Database::queryAll("SELECT g.groupid, g.title, gxl.locationid AS enabled FROM passthrough_group g
- LEFT JOIN passthrough_group_x_location gxl ON (g.groupid = gxl.groupid AND gxl.locationid = :locationid)
- ORDER BY gxl.locationid ASC",
- ['locationid' => $locationId]);
+ $locationIds = Location::getLocationRootChain($locationId);
+ $res = Database::queryAll("SELECT g.groupid, g.title, GROUP_CONCAT(gxl.locationid) AS lids FROM passthrough_group g
+ LEFT JOIN passthrough_group_x_location gxl ON (g.groupid = gxl.groupid AND gxl.locationid IN (:lids))
+ GROUP BY groupid, title
+ ORDER BY lids ASC",
+ ['lids' => $locationIds]);
+ foreach ($res as &$item) {
+ if ($item['lids'] === null)
+ continue;
+ $item['checked'] = 'checked';
+ $list = explode(',', $item['lids']);
+ if (!in_array($locationId, $list)) {
+ $item['disabled'] = true;
+ $item['parent_location'] = Location::getName($list[0]);
+ }
+ }
Render::addTemplate('location-assign', [
'list' => array_reverse($res),
'locationid' => $locationId,
+ 'locationname' => Location::getName($locationId),
]);
}