From 59f6f89a2b7950e7b5fb4bdb0e2cdaf4998f1e9e Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 11 Jan 2019 16:49:58 +0100 Subject: [locations] Show current boot menu per location, add edit button --- .../locations/lang/de/template-tags.json | 1 + .../locations/lang/en/template-tags.json | 1 + modules-available/locations/page.inc.php | 60 ++++++++++++++++------ .../locations/templates/locations.html | 17 +++++- 4 files changed, 61 insertions(+), 18 deletions(-) diff --git a/modules-available/locations/lang/de/template-tags.json b/modules-available/locations/lang/de/template-tags.json index 43142555..96273ce4 100644 --- a/modules-available/locations/lang/de/template-tags.json +++ b/modules-available/locations/lang/de/template-tags.json @@ -3,6 +3,7 @@ "lang_areYouSureNoUndo": "Sind Sie sicher? Diese Aktion kann nicht r\u00fcckg\u00e4ngig gemacht werden.", "lang_assignSubnetExplanation": "Rechner, die in einen der hier aufgef\u00fchrten Adressbereiche fallen, werden diesem Ort zugeschrieben und erhalten damit z.B. f\u00fcr diesen Raum angepasste Veranstaltungslisten.", "lang_assignedSubnets": "Zugeordnete Subnetze bzw. IP-Bereiche", + "lang_bootMenu": "Bootmen\u00fc", "lang_deleteChildLocations": "Untergeordnete Orte ebenfalls l\u00f6schen", "lang_deleteLocation": "Ort l\u00f6schen", "lang_deleteSubnet": "Bereich l\u00f6schen", diff --git a/modules-available/locations/lang/en/template-tags.json b/modules-available/locations/lang/en/template-tags.json index 41261726..64211e27 100644 --- a/modules-available/locations/lang/en/template-tags.json +++ b/modules-available/locations/lang/en/template-tags.json @@ -3,6 +3,7 @@ "lang_areYouSureNoUndo": "Are you sure? This cannot be undone!", "lang_assignSubnetExplanation": "Client machines which fall into an IP range listed below will be assigned to this location and will see an according lecture list (e.g. they will see lectures that are exclusively assigned to this location).", "lang_assignedSubnets": "Assigned subnets \/ IP ranges", + "lang_bootMenu": "Boot menu", "lang_deleteChildLocations": "Delete child locations aswell", "lang_deleteLocation": "Delete location", "lang_deleteSubnet": "Delete range", diff --git a/modules-available/locations/page.inc.php b/modules-available/locations/page.inc.php index 9beae163..2d8f5ff9 100644 --- a/modules-available/locations/page.inc.php +++ b/modules-available/locations/page.inc.php @@ -375,6 +375,11 @@ class Page_Locations extends Page } else { $locationList[$lid]['havestatistics'] = false; } + if (User::hasPermission('.serversetup.ipxe.menu.assign', $lid)) { + $visibleLocationIds[] = $lid; + } else { + $locationList[$lid]['haveipxe'] = false; + } if (!in_array($lid, $visibleLocationIds)) { unset($locationList[$lid]); } elseif (!in_array($lid, $allowedLocationIds)) { @@ -440,22 +445,7 @@ class Page_Locations extends Page $locationList[$locId] += array('configName' => $conf['title'], 'configClass' => 'slx-bold'); } } - $depth = array(); - foreach ($locationList as &$loc) { - $d = $loc['depth']; - if (!isset($loc['configName'])) { - // Has no explicit config assignment - if ($d === 0) { - $loc['configName'] = $defaultConfig; - } else { - $loc['configName'] = $depth[$d - 1]; - } - $loc['configClass'] = 'gray'; - } - $depth[$d] = $loc['configName']; - unset($depth[$d + 1]); - } - unset($loc); + $this->propagateFields($locationList, $defaultConfig, 'configName', 'configClass'); } // Count overridden config vars if (Module::get('baseconfig') !== false) { @@ -467,6 +457,24 @@ class Page_Locations extends Page $locationList[$lid]['overriddenVars'] = $row['cnt']; } } + // Confusing because the count might be inaccurate within a branch + //$this->propagateFields($locationList, '', 'overriddenVars', 'overriddenClass'); + } + // Show ipxe menu + if (Module::get('serversetup') !== false) { + $res = Database::simpleQuery("SELECT ml.locationid, m.title, ml.defaultentryid FROM serversetup_menu m + INNER JOIN serversetup_menu_location ml USING (menuid) + WHERE locationid IN (:allowedLocationIds) GROUP BY locationid", compact('allowedLocationIds')); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $lid = (int)$row['locationid']; + if (isset($locationList[$lid])) { + if ($row['defaultentryid'] !== null) { + $row['title'] .= '(*)'; + } + $locationList[$lid]['customMenu'] = $row['title']; + } + } + $this->propagateFields($locationList, '', 'customMenu', 'customMenuClass'); } $addAllowedLocs = User::getAllowedLocations("location.add"); @@ -484,6 +492,7 @@ class Page_Locations extends Page 'havestatistics' => Module::get('statistics') !== false, 'havebaseconfig' => Module::get('baseconfig') !== false, 'havesysconfig' => Module::get('sysconfig') !== false, + 'haveipxe' => Module::get('serversetup') !== false, 'overlapSelf' => $overlapSelf, 'overlapOther' => $overlapOther, 'haveOverlapSelf' => !empty($overlapSelf), @@ -637,4 +646,23 @@ class Page_Locations extends Page return $result; } + private function propagateFields(&$locationList, $defaultValue, $name, $class) + { + $depth = array(); + foreach ($locationList as &$loc) { + $d = $loc['depth']; + if (!isset($loc[$name])) { + // Has no explicit config assignment + if ($d === 0) { + $loc[$name] = $defaultValue; + } else { + $loc[$name] = $depth[$d - 1]; + } + $loc[$class] = 'gray'; + } + $depth[$d] = $loc[$name]; + unset($depth[$d + 1]); + } + } + } diff --git a/modules-available/locations/templates/locations.html b/modules-available/locations/templates/locations.html index 67f22744..06d32020 100644 --- a/modules-available/locations/templates/locations.html +++ b/modules-available/locations/templates/locations.html @@ -37,6 +37,9 @@ {{#havesysconfig}}{{lang_sysConfig}}{{/havesysconfig}} + + {{#haveipxe}}{{lang_bootMenu}}{{/haveipxe}} + {{#list}} @@ -67,7 +70,7 @@ {{clientLoad}} {{/havestatistics}} - + {{#havebaseconfig}}
@@ -87,6 +90,16 @@ {{/havesysconfig}} + + {{#haveipxe}} +
+ +
+ + {{customMenu}}   + + {{/haveipxe}} + {{/list}} {{#unassignedCount}} @@ -170,7 +183,7 @@ function slxOpenLocation(e, lid) { } return; } - var td = $('').attr('colspan', '5').css('padding', '0px 0px 12px'); + var td = $('').attr('colspan', '6').css('padding', '0px 0px 12px'); var tr = $('').attr('id', 'location-details-' + lid); tr.append(td); $(e).closest('tr').addClass('active slx-bold').after(tr); -- cgit v1.2.3-55-g7522