summaryrefslogtreecommitdiffstats
path: root/modules-available/locations
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/locations')
-rw-r--r--modules-available/locations/page.inc.php10
-rw-r--r--modules-available/locations/templates/locations.html23
2 files changed, 18 insertions, 15 deletions
diff --git a/modules-available/locations/page.inc.php b/modules-available/locations/page.inc.php
index d9bc7130..0cfa5b90 100644
--- a/modules-available/locations/page.inc.php
+++ b/modules-available/locations/page.inc.php
@@ -69,7 +69,7 @@ class Page_Locations extends Page
private function addLocations()
{
$names = Request::post('newlocation', false);
- $parents = Request::post('newparent', false);
+ $parents = Request::post('newparent', []);
if (!is_array($names) || !is_array($parents)) {
Message::addError('main.empty-field');
Util::redirect('?do=Locations');
@@ -198,6 +198,7 @@ class Page_Locations extends Page
}
}
}
+ // TODO: Check permissions for new parent (only if changed)
$ret = Database::exec('UPDATE location SET parentlocationid = :parent, locationname = :name'
. ' WHERE locationid = :lid', array(
'lid' => $locationId,
@@ -318,13 +319,13 @@ class Page_Locations extends Page
$res = Database::simpleQuery("SELECT subnetid, startaddr, endaddr, locationid FROM subnet
WHERE locationid IN (:locations) ORDER BY startaddr ASC",
array("locations" => User::getAllowedLocations("location.view")));
+ $allowedLocs = User::getAllowedLocations("subnet.add");
$rows = array();
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
$row['startaddr'] = long2ip($row['startaddr']);
$row['endaddr'] = long2ip($row['endaddr']);
$row['locations'] = Location::getLocations($row['locationid']);
- $allowedLocs = User::getAllowedLocations("subnet.add");
foreach ($row['locations'] as &$loc) {
if (!(in_array($loc["locationid"], $allowedLocs) || $loc["locationid"] == $row['locationid'])) {
$loc["disabled"] = "disabled";
@@ -376,6 +377,7 @@ class Page_Locations extends Page
unset($loc);
foreach ($locs as $loc) {
foreach ($loc['parents'] as $pid) {
+ $locs[(int)$pid]['hasChild'] = true;
$locs[(int)$pid]['clientCountSum'] += $loc['clientCount'];
}
}
@@ -444,7 +446,8 @@ class Page_Locations extends Page
}
$addAllowedLocs = User::getAllowedLocations("location.add");
- $addAllowedList = Location::getLocations(0, 0, True);
+ $addAllowedLocs[] = 0;
+ $addAllowedList = Location::getLocations(0, 0, true);
foreach ($addAllowedList as &$loc) {
if (!in_array($loc["locationid"], $addAllowedLocs)) {
$loc["disabled"] = "disabled";
@@ -514,6 +517,7 @@ class Page_Locations extends Page
);
$allowedLocs = User::getAllowedLocations("location.edit");
+ $allowedLocs[] = 0;
foreach ($data['parents'] as &$parent) {
if (!(in_array($parent["locationid"], $allowedLocs) || $parent["locationid"] == $loc['parentlocationid'])) {
$parent["disabled"] = "disabled";
diff --git a/modules-available/locations/templates/locations.html b/modules-available/locations/templates/locations.html
index 02428323..be3d5115 100644
--- a/modules-available/locations/templates/locations.html
+++ b/modules-available/locations/templates/locations.html
@@ -41,12 +41,12 @@
<td class="text-nowrap" align="right">
{{^linkClass}}
{{#havestatistics}}
- {{clientCount}}
- <span class="text-muted">
- /
- <span style="display:inline-block;width:3ex">{{clientCountSum}}</span>
+ <a href="?do=Statistics&amp;show=list&amp;filters=location={{locationid}}">&nbsp;{{clientCount}}&nbsp;</a>
+ <span style="display:inline-block;width:5ex">
+ {{#hasChild}}
+ (<a href="?do=Statistics&amp;show=list&amp;filters=location~{{locationid}}">&downarrow;{{clientCountSum}}</a>)
+ {{/hasChild}}
</span>
- <a class="btn btn-default btn-xs" href="?do=Statistics&amp;show=list&amp;filters=location={{locationid}}"><span class="glyphicon glyphicon-eye-open"></span></a>
{{/havestatistics}}
{{/linkClass}}
</td>
@@ -87,9 +87,8 @@
<tr>
<td>{{lang_unassignedMachines}}</td>
<td class="text-nowrap" align="right">
- {{unassignedCount}}
- <a class="btn btn-default btn-xs" href="?do=Statistics&amp;show=list&amp;filters=location=0">
- <span class="glyphicon glyphicon-eye-open"></span>
+ <a href="?do=Statistics&amp;show=list&amp;filters=location=0">
+ &nbsp;{{unassignedCount}}&nbsp;
</a>
</td>
<td class="text-nowrap" align="right">
@@ -103,16 +102,16 @@
<form method="post" action="?do=Locations">
<input type="hidden" name="token" value="{{token}}">
<input type="hidden" name="action" value="addlocations">
- <table class="table table-condensed table-hover">
+ <table class="table table-condensed">
<tr id="lasttr">
<td width="60%">&emsp;</td>
<td class="text-right" colspan="2">
- <button id="saveLocationRows" type="submit" class="btn btn-primary" style="display: none">
- <span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}
- </button>
<button {{^addAllowed}}disabled{{/addAllowed}} class="btn btn-success" type="button" onclick="slxAddLocationRow()">
<span class="glyphicon glyphicon-plus"></span> {{lang_location}}
</button>
+ <button id="saveLocationRows" type="submit" class="btn btn-primary collapse">
+ <span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}
+ </button>
</td>
</tr>
</table>