summaryrefslogtreecommitdiffstats
path: root/modules-available/permissionmanager
diff options
context:
space:
mode:
authorUdo Walter2017-11-21 17:24:44 +0100
committerUdo Walter2017-11-21 17:24:44 +0100
commit3d88bb5a4223d3fdc9084eee3e75defc8da674b0 (patch)
tree9d15a1ccafa5ec3ee97f991637145e524e70e37c /modules-available/permissionmanager
parent[dozmod] implemented new permission system to module for: deleting expired vm... (diff)
downloadslx-admin-3d88bb5a4223d3fdc9084eee3e75defc8da674b0.tar.gz
slx-admin-3d88bb5a4223d3fdc9084eee3e75defc8da674b0.tar.xz
slx-admin-3d88bb5a4223d3fdc9084eee3e75defc8da674b0.zip
[permissionmanager] added key relationships to install script;
changed nested php for loops to sql code; standardized sql column naming; small bugfixes;
Diffstat (limited to 'modules-available/permissionmanager')
-rw-r--r--modules-available/permissionmanager/clientscript.js4
-rw-r--r--modules-available/permissionmanager/inc/getpermissiondata.inc.php84
-rw-r--r--modules-available/permissionmanager/inc/permissiondbupdate.inc.php62
-rw-r--r--modules-available/permissionmanager/inc/permissionutil.inc.php10
-rw-r--r--modules-available/permissionmanager/install.inc.php83
-rw-r--r--modules-available/permissionmanager/page.inc.php28
-rw-r--r--modules-available/permissionmanager/style.css2
-rw-r--r--modules-available/permissionmanager/templates/_page.html6
-rw-r--r--modules-available/permissionmanager/templates/locationstable.html10
-rw-r--r--modules-available/permissionmanager/templates/roleeditor.html6
-rw-r--r--modules-available/permissionmanager/templates/rolestable.html10
-rw-r--r--modules-available/permissionmanager/templates/userstable.html16
12 files changed, 173 insertions, 148 deletions
diff --git a/modules-available/permissionmanager/clientscript.js b/modules-available/permissionmanager/clientscript.js
index 1881c70d..700ebc11 100644
--- a/modules-available/permissionmanager/clientscript.js
+++ b/modules-available/permissionmanager/clientscript.js
@@ -19,7 +19,7 @@ document.addEventListener("DOMContentLoaded", function() {
$('.dataTable tbody').find('tr').hide();
}
// Find all rows which shall be shown and increase their counter by 1
- $(".roleId-" + value).closest("tr").each(function () {
+ $(".roleid-" + value).closest("tr").each(function () {
$(this).data("selectizeCount", $(this).data("selectizeCount") + 1);
$(this).show();
});
@@ -31,7 +31,7 @@ document.addEventListener("DOMContentLoaded", function() {
$('.dataTable tbody').find('tr').show();
} else {
// Find all rows which have the delete role, decrease their counter by 1
- $(".roleId-" + value).closest("tr").each(function () {
+ $(".roleid-" + value).closest("tr").each(function () {
$(this).data("selectizeCount", $(this).data("selectizeCount") - 1);
// If counter is 0, hide the row (no filter given to show the row anymore)
if ($(this).data("selectizeCount") === 0) {
diff --git a/modules-available/permissionmanager/inc/getpermissiondata.inc.php b/modules-available/permissionmanager/inc/getpermissiondata.inc.php
index 5114f4ef..9d69c722 100644
--- a/modules-available/permissionmanager/inc/getpermissiondata.inc.php
+++ b/modules-available/permissionmanager/inc/getpermissiondata.inc.php
@@ -8,8 +8,8 @@ class GetPermissionData {
$userdata= array();
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
$userdata[$row['userid'].' '.$row['login']][] = array(
- 'roleId' => $row['roleId'],
- 'roleName' => $row['roleName']
+ 'roleid' => $row['roleid'],
+ 'rolename' => $row['rolename']
);
}
$data = array();
@@ -26,60 +26,51 @@ class GetPermissionData {
// get LocationIDs, Location Names, Roles of each Location
public static function getLocationData() {
- $res = self::queryLocationData();
- $locdata = array();
+ $res = Database::simpleQuery("SELECT role.roleid as roleid, rolename, GROUP_CONCAT(locationid) as locationids FROM role
+ LEFT JOIN (SELECT roleid, COALESCE(locationid, 0) AS locationid FROM role_x_location) rxl
+ ON role.roleid = rxl.roleid GROUP BY roleid ORDER BY rolename ASC");
+ $locations = Location::getLocations(0, 0, false, true);
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $locdata[$row['locid'].' '.$row['locname']][] = array(
- 'roleId' => $row['roleId'],
- 'roleName' => $row['roleName']
- );
+ $locationids = explode(",", $row['locationids']);
+ if (in_array("0", $locationids)) {
+ $locationids = array_map("intval", Location::extractIds(Location::getTree()));
+ } else {
+ $locationids = PermissionUtil::getSublocations(Location::getTree(), $locationids);
+ }
+ foreach ($locationids as $locationid) {
+ $locations[$locationid]['roles'][] = array(
+ 'roleid' => $row['roleid'],
+ 'rolename' => $row['rolename']
+ );
+ }
}
- $data = array();
- foreach($locdata AS $loc => $roles) {
- $loc = explode(" ", $loc, 2);
- $data[] = array(
- 'locid' => $loc[0],
- 'locname' => $loc[1],
- 'roles' => $roles
- );
- }
- return $data;
+ return array_values($locations);
}
// get all roles from database (id and name)
public static function getRoles() {
- $res = Database::simpleQuery("SELECT id, name FROM role ORDER BY name ASC");
+ $res = Database::simpleQuery("SELECT roleid, rolename FROM role ORDER BY rolename ASC");
$data = array();
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
$data[] = array(
- 'roleId' => $row['id'],
- 'roleName' => $row['name']
+ 'roleid' => $row['roleid'],
+ 'rolename' => $row['rolename']
);
}
return $data;
}
- public static function getLocations($selected) {
- $res = Database::simplequery("SELECT locationid, locationname FROM location");
- $data = array();
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $data[] = array('locid' => $row['locationid'], 'locName' => $row['locationname'],
- 'selected' => in_array($row['locationid'], $selected) ? "selected" : "");
- }
- return $data;
- }
-
- public static function getRoleData($roleId) {
- $query = "SELECT id, name FROM role WHERE id = :roleId";
- $data = Database::queryFirst($query, array("roleId" => $roleId));
- $query = "SELECT roleid, locid FROM role_x_location WHERE roleid = :roleId";
- $res = Database::simpleQuery($query, array("roleId" => $roleId));
+ public static function getRoleData($roleid) {
+ $query = "SELECT roleid, rolename FROM role WHERE roleid = :roleid";
+ $data = Database::queryFirst($query, array("roleid" => $roleid));
+ $query = "SELECT roleid, locationid FROM role_x_location WHERE roleid = :roleid";
+ $res = Database::simpleQuery($query, array("roleid" => $roleid));
$data["locations"] = array();
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
- $data["locations"][] = $row['locid'];
+ $data["locations"][] = $row['locationid'];
}
- $query = "SELECT roleid, permissionid FROM role_x_permission WHERE roleid = :roleId";
- $res = Database::simpleQuery($query, array("roleId" => $roleId));
+ $query = "SELECT roleid, permissionid FROM role_x_permission WHERE roleid = :roleid";
+ $res = Database::simpleQuery($query, array("roleid" => $roleid));
$data["permissions"] = array();
while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
$data["permissions"][] = $row['permissionid'];
@@ -89,21 +80,10 @@ class GetPermissionData {
// UserID, User Login Name, Roles of each User
private static function queryUserData() {
- $res = Database::simpleQuery("SELECT user.userid AS userid, user.login AS login, role.name AS roleName, role.id AS roleId
+ $res = Database::simpleQuery("SELECT user.userid AS userid, user.login AS login, role.rolename AS rolename, role.roleid AS roleid
FROM user
LEFT JOIN user_x_role ON user.userid = user_x_role.userid
- LEFT JOIN role ON user_x_role.roleid = role.id
- ");
- return $res;
- }
-
- // LocationID, Location Name, Roles of each Location
- private static function queryLocationData() {
- $res = Database::simpleQuery("SELECT location.locationid AS locid, location.locationname AS locname, role.name AS roleName, role.id AS roleId
- FROM location
- LEFT JOIN role_x_location ON location.locationid = role_x_location.locid
- LEFT JOIN role ON role_x_location.roleid = role.id
- ORDER BY location.locationname
+ LEFT JOIN role ON user_x_role.roleid = role.roleid
");
return $res;
}
diff --git a/modules-available/permissionmanager/inc/permissiondbupdate.inc.php b/modules-available/permissionmanager/inc/permissiondbupdate.inc.php
index 87c989fa..f144b35e 100644
--- a/modules-available/permissionmanager/inc/permissiondbupdate.inc.php
+++ b/modules-available/permissionmanager/inc/permissiondbupdate.inc.php
@@ -4,53 +4,49 @@ class PermissionDbUpdate {
// insert new user_x_role to database. "ignore" to ignore duplicate entry try
public static function addRoleToUser($users, $roles) {
- foreach($users AS $user) {
- foreach ($roles AS $role) {
- $query = "INSERT IGNORE INTO user_x_role (userid, roleid) VALUES (:user, :role)";
- Database::exec($query, array("user" => $user, "role" => $role));
+ $query = "INSERT IGNORE INTO user_x_role (userid, roleid) VALUES (:userid, :roleid)";
+ foreach($users AS $userid) {
+ foreach ($roles AS $roleid) {
+ Database::exec($query, array("userid" => $userid, "roleid" => $roleid));
}
}
}
// remove user_x_role entry from database
public static function removeRoleFromUser($users, $roles) {
- foreach($users AS $user) {
- foreach ($roles AS $role) {
- $query = "DELETE FROM user_x_role WHERE userid = :user AND roleid = :role";
- Database::exec($query, array("user" => $user, "role" => $role));
- }
- }
+ $query = "DELETE FROM user_x_role WHERE userid IN (:users) AND roleid IN (:roles)";
+ Database::exec($query, array("users" => $users, "roles" => $roles));
}
// delete role, delete user_x_role relationships, delete role_x_location relationships, delete role_x_permission relationships
- public static function deleteRole($id) {
- $query = "DELETE FROM role WHERE id = :id";
- Database::exec($query, array("id" => $id));
- $query = "DELETE FROM user_x_role WHERE roleid = :id";
- Database::exec($query, array("id" => $id));
- $query = "DELETE FROM role_x_location WHERE roleid = :id";
- Database::exec($query, array("id" => $id));
- $query = "DELETE FROM role_x_permission WHERE roleid = :id";
- Database::exec($query, array("id" => $id));
+ public static function deleteRole($roleid) {
+ $query = "DELETE FROM role WHERE roleid = :roleid";
+ Database::exec($query, array("roleid" => $roleid));
+ $query = "DELETE FROM user_x_role WHERE roleid = :roleid";
+ Database::exec($query, array("roleid" => $roleid));
+ $query = "DELETE FROM role_x_location WHERE roleid = :roleid";
+ Database::exec($query, array("roleid" => $roleid));
+ $query = "DELETE FROM role_x_permission WHERE roleid = :roleid";
+ Database::exec($query, array("roleid" => $roleid));
}
- public static function saveRole($roleName, $locations, $permissions, $role = NULL) {
- if ($role) {
- Database::exec("UPDATE role SET name = :roleName WHERE id = :role",
- array("roleName" => $roleName, "role" => $role));
- Database::exec("DELETE FROM role_x_location WHERE roleid = :role", array("role" => $role));
- Database::exec("DELETE FROM role_x_permission WHERE roleid = :role", array("role" => $role));
+ public static function saveRole($rolename, $locations, $permissions, $roleid = NULL) {
+ if ($roleid) {
+ Database::exec("UPDATE role SET rolename = :rolename WHERE roleid = :roleid",
+ array("rolename" => $rolename, "roleid" => $roleid));
+ Database::exec("DELETE FROM role_x_location WHERE roleid = :roleid", array("roleid" => $roleid));
+ Database::exec("DELETE FROM role_x_permission WHERE roleid = :roleid", array("roleid" => $roleid));
} else {
- Database::exec("INSERT INTO role (name) VALUES (:roleName)", array("roleName" => $roleName));
- $role = Database::lastInsertId();
+ Database::exec("INSERT INTO role (rolename) VALUES (:rolename)", array("rolename" => $rolename));
+ $roleid = Database::lastInsertId();
}
- foreach ($locations as $locID) {
- Database::exec("INSERT INTO role_x_location (roleid, locid) VALUES (:role, :locid)",
- array("role" => $role, "locid" => $locID));
+ foreach ($locations as $locationid) {
+ Database::exec("INSERT INTO role_x_location (roleid, locationid) VALUES (:roleid, :locationid)",
+ array("roleid" => $roleid, "locationid" => $locationid));
}
- foreach ($permissions as $permission) {
- Database::exec("INSERT INTO role_x_permission (roleid, permissionid) VALUES (:role, :permission)",
- array("role" => $role, "permission" => $permission));
+ foreach ($permissions as $permissionid) {
+ Database::exec("INSERT INTO role_x_permission (roleid, permissionid) VALUES (:roleid, :permissionid)",
+ array("roleid" => $roleid, "permissionid" => $permissionid));
}
}
diff --git a/modules-available/permissionmanager/inc/permissionutil.inc.php b/modules-available/permissionmanager/inc/permissionutil.inc.php
index 5c3eef58..17257eec 100644
--- a/modules-available/permissionmanager/inc/permissionutil.inc.php
+++ b/modules-available/permissionmanager/inc/permissionutil.inc.php
@@ -11,7 +11,7 @@ class PermissionUtil
}
$res = Database::simpleQuery("SELECT role_x_permission.permissionid as 'permissionid',
- role_x_location.locid as 'locationid'
+ role_x_location.locationid as 'locationid'
FROM user_x_role
INNER JOIN role_x_permission ON user_x_role.roleid = role_x_permission.roleid
LEFT JOIN role_x_location ON role_x_permission.roleid = role_x_location.roleid
@@ -29,11 +29,11 @@ class PermissionUtil
public static function getAllowedLocations($userid, $permissionid) {
- $res = Database::simpleQuery("SELECT role_x_permission.permissionid as 'permissionid',
- role_x_location.locid as 'locationid'
+ $res = Database::simpleQuery("SELECT role_x_permission.permissionid, rxl.locationid
FROM user_x_role
INNER JOIN role_x_permission ON user_x_role.roleid = role_x_permission.roleid
- LEFT JOIN role_x_location ON role_x_permission.roleid = role_x_location.roleid
+ LEFT JOIN (SELECT roleid, COALESCE(locationid, 0) AS locationid FROM role_x_location) rxl
+ ON role_x_permission.roleid = rxl.roleid
WHERE user_x_role.userid = :userid", array("userid" => $userid));
$allowedLocations = array();
@@ -53,7 +53,7 @@ class PermissionUtil
return $allowedLocations;
}
- private static function getSublocations($tree, $locations) {
+ public static function getSublocations($tree, $locations) {
$result = array_flip($locations);
foreach ($tree as $location) {
if (array_key_exists("children", $location)) {
diff --git a/modules-available/permissionmanager/install.inc.php b/modules-available/permissionmanager/install.inc.php
index 8c882498..71ee7a1e 100644
--- a/modules-available/permissionmanager/install.inc.php
+++ b/modules-available/permissionmanager/install.inc.php
@@ -3,25 +3,84 @@
$res = array();
$res[] = tableCreate('role', "
- `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
- `name` varchar(200) NOT NULL,
- PRIMARY KEY (`id`)
+ roleid int(10) unsigned NOT NULL AUTO_INCREMENT,
+ rolename varchar(200) NOT NULL,
+ PRIMARY KEY (roleid)
");
$res[] = tableCreate('user_x_role', "
- `userid` int(10) unsigned NOT NULL,
- `roleid` int(10) unsigned NOT NULL,
- PRIMARY KEY (`userid`, `roleid`)
+ userid int(10) unsigned NOT NULL,
+ roleid int(10) unsigned NOT NULL,
+ PRIMARY KEY (userid, roleid)
");
$res[] = tableCreate('role_x_location', "
- `roleid` int(10) unsigned NOT NULL,
- `locid` int(10) unsigned NOT NULL,
- PRIMARY KEY (`roleid`, `locid`)
+ id int(10) unsigned NOT NULL AUTO_INCREMENT,
+ roleid int(10) unsigned NOT NULL,
+ locationid int(11),
+ PRIMARY KEY (id)
");
$res[] = tableCreate('role_x_permission', "
- `roleid` int(10) unsigned NOT NULL,
- `permissionid` varchar(200) NOT NULL,
- PRIMARY KEY (`roleid`, `permissionid`)
+ roleid int(10) unsigned NOT NULL,
+ permissionid varchar(200) NOT NULL,
+ PRIMARY KEY (roleid, permissionid)
");
+
+if (!tableExists('user') || !tableExists('location')) {
+ finalResponse(UPDATE_RETRY, 'Cannot add constraint yet. Please retry.');
+} else {
+ $c = tableGetContraints('user_x_role', 'userid', 'user', 'userid');
+ if ($c === false)
+ finalResponse(UPDATE_FAILED, 'Cannot get constraints of user table: ' . Database::lastError());
+ if (empty($c)) {
+ $alter = Database::exec('ALTER TABLE user_x_role ADD FOREIGN KEY (userid) REFERENCES user (userid) ON DELETE CASCADE ON UPDATE CASCADE');
+ if ($alter === false)
+ finalResponse(UPDATE_FAILED, 'Cannot add userid constraint referencing user table: ' . Database::lastError());
+ $res[] = UPDATE_DONE;
+ }
+
+ $c = tableGetContraints('user_x_role', 'roleid', 'role', 'roleid');
+ if ($c === false)
+ finalResponse(UPDATE_FAILED, 'Cannot get constraints of role table: ' . Database::lastError());
+ if (empty($c)) {
+ $alter = Database::exec('ALTER TABLE user_x_role ADD FOREIGN KEY (roleid) REFERENCES role (roleid) ON DELETE CASCADE ON UPDATE CASCADE');
+ if ($alter === false)
+ finalResponse(UPDATE_FAILED, 'Cannot add roleid constraint referencing role table: ' . Database::lastError());
+ $res[] = UPDATE_DONE;
+ }
+
+ $c = tableGetContraints('role_x_location', 'roleid', 'role', 'roleid');
+ if ($c === false)
+ finalResponse(UPDATE_FAILED, 'Cannot get constraints of role table: ' . Database::lastError());
+ if (empty($c)) {
+ $alter = Database::exec('ALTER TABLE role_x_location ADD FOREIGN KEY (roleid) REFERENCES role (roleid) ON DELETE CASCADE ON UPDATE CASCADE');
+ if ($alter === false)
+ finalResponse(UPDATE_FAILED, 'Cannot add roleid constraint referencing role table: ' . Database::lastError());
+ $res[] = UPDATE_DONE;
+ }
+
+ $c = tableGetContraints('role_x_location', 'locationid', 'location', 'locationid');
+ if ($c === false)
+ finalResponse(UPDATE_FAILED, 'Cannot get constraints of location table: ' . Database::lastError());
+ if (empty($c)) {
+ $alter = Database::exec('ALTER TABLE role_x_location ADD FOREIGN KEY (locationid) REFERENCES location (locationid) ON DELETE CASCADE ON UPDATE CASCADE');
+ if ($alter === false)
+ finalResponse(UPDATE_FAILED, 'Cannot add locationid constraint referencing location table: ' . Database::lastError());
+ $res[] = UPDATE_DONE;
+ }
+
+ $c = tableGetContraints('role_x_permission', 'roleid', 'role', 'roleid');
+ if ($c === false)
+ finalResponse(UPDATE_FAILED, 'Cannot get constraints of role table: ' . Database::lastError());
+ if (empty($c)) {
+ $alter = Database::exec('ALTER TABLE role_x_permission ADD FOREIGN KEY (roleid) REFERENCES role (roleid) ON DELETE CASCADE ON UPDATE CASCADE');
+ if ($alter === false)
+ finalResponse(UPDATE_FAILED, 'Cannot add roleid constraint referencing role table: ' . Database::lastError());
+ $res[] = UPDATE_DONE;
+ }
+}
+if (in_array(UPDATE_DONE, $res)) {
+ finalResponse(UPDATE_DONE, 'Tables created successfully');
+}
+finalResponse(UPDATE_NOOP, 'Everything already up to date');
diff --git a/modules-available/permissionmanager/page.inc.php b/modules-available/permissionmanager/page.inc.php
index 7f288fd9..20e8ad3a 100644
--- a/modules-available/permissionmanager/page.inc.php
+++ b/modules-available/permissionmanager/page.inc.php
@@ -29,10 +29,10 @@ class Page_PermissionManager extends Page
PermissionDbUpdate::deleteRole($id);
} elseif ($action === 'saveRole') {
$roleID = Request::post("roleid", false);
- $roleName = Request::post("roleName");
- $locations = Request::post("allLocations", "off") == "on" ? array(0) : Request::post("locations");
+ $rolename = Request::post("rolename");
+ $locations = Request::post("allLocations", "off") == "on" ? array(NULL) : Request::post("locations");
$permissions = Request::post("allPermissions", "off") == "on" ? array("*") : Request::post("permissions");;
- PermissionDbUpdate::saveRole($roleName, $locations, $permissions, $roleID);
+ PermissionDbUpdate::saveRole($rolename, $locations, $permissions, $roleID);
}
}
@@ -61,7 +61,7 @@ class Page_PermissionManager extends Page
$data = array("user" => GetPermissionData::getUserData(), "roles" => GetPermissionData::getRoles());
Render::addTemplate('userstable', $data);
} elseif ($show === "locations") {
- $data = array("location" => GetPermissionData::getLocationData(), "roles" => GetPermissionData::getRoles());
+ $data = array("location" => GetPermissionData::getLocationData(), "allroles" => GetPermissionData::getRoles());
Render::addTemplate('locationstable', $data);
}
} elseif ($show === "roleEditor") {
@@ -72,7 +72,7 @@ class Page_PermissionManager extends Page
if ($roleID) {
$roleData = GetPermissionData::getRoleData($roleID);
$data["roleid"] = $roleID;
- $data["roleName"] = $roleData["name"];
+ $data["rolename"] = $roleData["rolename"];
if (count($roleData["locations"]) == 1 && $roleData["locations"][0] == 0) {
$data["allLocChecked"] = "checked";
$data["selectizeClass"] = "faded unclickable";
@@ -93,7 +93,7 @@ class Page_PermissionManager extends Page
$permissions = PermissionUtil::getPermissions();
- $data["locations"] = GetPermissionData::getLocations($selectedLocations);
+ $data["locations"] = Location::getLocations($selectedLocations);
$data["moduleNames"] = array();
foreach (array_keys($permissions) as $moduleid) {
$data["moduleNames"][] = array("id" => $moduleid, "name" => Module::get($moduleid)->getDisplayName());
@@ -107,21 +107,11 @@ class Page_PermissionManager extends Page
// Menu: Selected table is shown in blue (btn-primary)
private function setButtonColors($show) {
if ($show === 'roles') {
- $buttonColors['rolesButtonClass'] = 'btn-primary';
- $buttonColors['usersButtonClass'] = 'btn-default';
- $buttonColors['locationsButtonClass'] = 'btn-default';
+ $buttonColors['rolesButtonClass'] = 'active';
} elseif ($show === 'users') {
- $buttonColors['rolesButtonClass'] = 'btn-default';
- $buttonColors['usersButtonClass'] = 'btn-primary';
- $buttonColors['locationsButtonClass'] = 'btn-default';
+ $buttonColors['usersButtonClass'] = 'active';
} elseif ($show === 'locations') {
- $buttonColors['rolesButtonClass'] = 'btn-default';
- $buttonColors['usersButtonClass'] = 'btn-default';
- $buttonColors['locationsButtonClass'] = 'btn-primary';
- } else {
- $buttonColors['rolesButtonClass'] = 'btn-default';
- $buttonColors['usersButtonClass'] = 'btn-default';
- $buttonColors['locationsButtonClass'] = 'btn-default';
+ $buttonColors['locationsButtonClass'] = 'active';
}
return $buttonColors;
diff --git a/modules-available/permissionmanager/style.css b/modules-available/permissionmanager/style.css
index f1d0646f..abc3270a 100644
--- a/modules-available/permissionmanager/style.css
+++ b/modules-available/permissionmanager/style.css
@@ -7,7 +7,7 @@
margin-left: 10px;
}
-#roleName {
+#rolename {
width: 200px;
display: inline-block;
margin-left: 20px;
diff --git a/modules-available/permissionmanager/templates/_page.html b/modules-available/permissionmanager/templates/_page.html
index 65a52c52..ff487c8f 100644
--- a/modules-available/permissionmanager/templates/_page.html
+++ b/modules-available/permissionmanager/templates/_page.html
@@ -5,17 +5,17 @@
<input type="hidden" name="do" value="permissionmanager">
<div class="btn-group">
- <button class="btn {{rolesButtonClass}}" type="submit" name="show" value="roles">
+ <button class="btn btn-default {{rolesButtonClass}}" type="submit" name="show" value="roles">
<span class="glyphicon glyphicon-education"></span>
{{lang_Roles}}
</button>
- <button class="btn {{usersButtonClass}}" type="submit" name="show" value="users">
+ <button class="btn btn-default {{usersButtonClass}}" type="submit" name="show" value="users">
<span class="glyphicon glyphicon-user"></span>
{{lang_Users}}
</button>
- <button class="btn {{locationsButtonClass}}" type="submit" name="show" value="locations">
+ <button class="btn btn-default {{locationsButtonClass}}" type="submit" name="show" value="locations">
<span class="glyphicon glyphicon-home"></span>
{{lang_Locations}}
</button>
diff --git a/modules-available/permissionmanager/templates/locationstable.html b/modules-available/permissionmanager/templates/locationstable.html
index 79b0a076..dcfefa94 100644
--- a/modules-available/permissionmanager/templates/locationstable.html
+++ b/modules-available/permissionmanager/templates/locationstable.html
@@ -3,9 +3,9 @@
<div class="col-md-4">
<select multiple name="roles[]" id="select-role">
<option value>{{lang_selectizePlaceholder}}</option>
- {{#roles}}
- <option value="{{roleId}}">{{roleName}}</option>
- {{/roles}}
+ {{#allroles}}
+ <option value="{{roleid}}">{{rolename}}</option>
+ {{/allroles}}
</select>
</div>
</div>
@@ -23,10 +23,10 @@
<tbody>
{{#location}}
<tr data-selectizeCount='0'>
- <td>{{locname}}</td>
+ <td>{{locationpad}} {{locationname}}</td>
<td>
{{#roles}}
- <span class="label label-default customSpanMargin roleId-{{roleId}}">{{roleName}}</span>
+ <span class="label label-default customSpanMargin roleid-{{roleid}}">{{rolename}}</span>
{{/roles}}
</td>
</tr>
diff --git a/modules-available/permissionmanager/templates/roleeditor.html b/modules-available/permissionmanager/templates/roleeditor.html
index fd78fc54..359f09a1 100644
--- a/modules-available/permissionmanager/templates/roleeditor.html
+++ b/modules-available/permissionmanager/templates/roleeditor.html
@@ -6,7 +6,7 @@
<div class="row">
<div class="col-md-12" style="margin-bottom: 20px;">
<b>{{lang_Name}}:</b>
- <input name="roleName" value="{{roleName}}" type="text" id="roleName" class="form-control">
+ <input name="rolename" value="{{rolename}}" type="text" id="rolename" class="form-control">
<button type="submit" id="saveButton" class="btn btn-primary pull-right"><span class="glyphicon glyphicon-floppy-disk"></span> {{lang_Save}}</button>
<button type="button" id="cancelButton" class="btn btn-default pull-right">{{lang_Cancel}}</button>
</div>
@@ -20,7 +20,7 @@
<select multiple name="locations[]" id="select-location">
<option value></option>
{{#locations}}
- <option value="{{locid}}" {{selected}}>{{locName}}</option>
+ <option value="{{locationid}}" {{#selected}}selected{{/selected}}>{{locationpad}} {{locationname}}</option>
{{/locations}}
</select>
</div>
@@ -121,7 +121,7 @@
});
$('form').submit(function () {
- var name = $.trim($('#roleName').val());
+ var name = $.trim($('#rolename').val());
if (name === '') {
alert('{{lang_emptyNameWarning}}');
return false;
diff --git a/modules-available/permissionmanager/templates/rolestable.html b/modules-available/permissionmanager/templates/rolestable.html
index dab0faeb..99401624 100644
--- a/modules-available/permissionmanager/templates/rolestable.html
+++ b/modules-available/permissionmanager/templates/rolestable.html
@@ -24,12 +24,12 @@
<tbody>
{{#roles}}
<tr class="rolesRow">
- <td class="rolesData">{{roleName}}</td>
+ <td class="rolesData">{{rolename}}</td>
<td class="text-center">
- <a class="btn btn-xs btn-info" href="?do=permissionmanager&show=roleEditor&roleid={{roleId}}"><span class="glyphicon glyphicon-edit"></span></a>
+ <a class="btn btn-xs btn-info" href="?do=permissionmanager&show=roleEditor&roleid={{roleid}}"><span class="glyphicon glyphicon-edit"></span></a>
</td>
<td class="text-center">
- <a class="btn btn-xs btn-danger" href="#deleteModal" data-toggle="modal" data-target="#deleteModal" onclick="deleteRole('{{roleId}}')"><span class="glyphicon glyphicon-trash"></span></a>
+ <a class="btn btn-xs btn-danger" href="#deleteModal" data-toggle="modal" data-target="#deleteModal" onclick="deleteRole('{{roleid}}')"><span class="glyphicon glyphicon-trash"></span></a>
</td>
</tr>
{{/roles}}
@@ -66,8 +66,8 @@
window.location.href = "?do=permissionmanager&show=roleEditor"
}
- function deleteRole($roleId) {
- $(".modal-footer #deleteId").val($roleId);
+ function deleteRole($roleid) {
+ $(".modal-footer #deleteId").val($roleid);
}
function searchFieldFunction() {
diff --git a/modules-available/permissionmanager/templates/userstable.html b/modules-available/permissionmanager/templates/userstable.html
index e794608c..bd48d16d 100644
--- a/modules-available/permissionmanager/templates/userstable.html
+++ b/modules-available/permissionmanager/templates/userstable.html
@@ -10,7 +10,7 @@
<select multiple name="roles[]" id="select-role">
<option value>{{lang_selectizePlaceholder}}</option>
{{#roles}}
- <option value="{{roleId}}">{{roleName}}</option>
+ <option value="{{roleid}}">{{rolename}}</option>
{{/roles}}
</select>
</div>
@@ -33,7 +33,7 @@
<td>{{username}}</td>
<td>
{{#roles}}
- <span class="label label-default customSpanMargin roleId-{{roleId}}">{{roleName}}</span>
+ <span class="label label-default customSpanMargin roleid-{{roleid}}">{{rolename}}</span>
{{/roles}}
</td>
<td data-sort-value="0">
@@ -71,11 +71,11 @@
<tbody>
{{#roles}}
<tr>
- <td>{{roleName}}</td>
+ <td>{{rolename}}</td>
<td data-sort-value="0">
<div class="checkbox">
- <input id="add{{roleId}}" type="checkbox" name="roles[]" value='{{roleId}}'>
- <label for="add{{roleId}}"></label>
+ <input id="add{{roleid}}" type="checkbox" name="roles[]" value='{{roleid}}'>
+ <label for="add{{roleid}}"></label>
</div>
</td>
</tr>
@@ -114,11 +114,11 @@
<tbody>
{{#roles}}
<tr>
- <td>{{roleName}}</td>
+ <td>{{rolename}}</td>
<td data-sort-value="0">
<div class="checkbox">
- <input id="remove{{roleId}}" type="checkbox" name="roles[]" value='{{roleId}}'>
- <label for="remove{{roleId}}"></label>
+ <input id="remove{{roleid}}" type="checkbox" name="roles[]" value='{{roleid}}'>
+ <label for="remove{{roleid}}"></label>
</div>
</td>
</tr>