diff options
author | Simon Rettberg | 2021-05-06 10:26:09 +0200 |
---|---|---|
committer | Simon Rettberg | 2021-05-11 14:51:13 +0200 |
commit | 8dc2b92d667f1401ab9f1315a36add61658f899c (patch) | |
tree | 452c5fe040055884cf9d9ee834415db84999a9a1 /modules-available/permissionmanager/inc/getpermissiondata.inc.php | |
parent | [session] Add simple session overview table (diff) | |
download | slx-admin-8dc2b92d667f1401ab9f1315a36add61658f899c.tar.gz slx-admin-8dc2b92d667f1401ab9f1315a36add61658f899c.tar.xz slx-admin-8dc2b92d667f1401ab9f1315a36add61658f899c.zip |
Moderize Database handling
* Auto-convert to utf8mb4_unicode_520_ci
* Use foreach instead of while to loop over results
* Drop useless statement caching
* Keep emulated prepares, as we sometimes loop over nested queries
Diffstat (limited to 'modules-available/permissionmanager/inc/getpermissiondata.inc.php')
-rw-r--r-- | modules-available/permissionmanager/inc/getpermissiondata.inc.php | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/modules-available/permissionmanager/inc/getpermissiondata.inc.php b/modules-available/permissionmanager/inc/getpermissiondata.inc.php index 4dfb09ec..ead1e020 100644 --- a/modules-available/permissionmanager/inc/getpermissiondata.inc.php +++ b/modules-available/permissionmanager/inc/getpermissiondata.inc.php @@ -19,7 +19,7 @@ class GetPermissionData LEFT JOIN role ON role_x_user.roleid = role.roleid "); $userdata = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $userdata[$row['userid'] . ' ' . $row['login']][] = array( 'roleid' => $row['roleid'], 'rolename' => $row['rolename'] @@ -47,7 +47,7 @@ class GetPermissionData $res = Database::simpleQuery("SELECT role.roleid AS roleid, rolename, GROUP_CONCAT(COALESCE(locationid, 0)) AS locationids FROM role INNER JOIN role_x_location ON role.roleid = role_x_location.roleid GROUP BY roleid ORDER BY rolename ASC"); $locations = Location::getLocations(0, 0, false, true); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $locationids = explode(",", $row['locationids']); if (in_array("0", $locationids)) { $locationids = array_map("intval", Location::extractIds(Location::getTree())); @@ -103,13 +103,13 @@ class GetPermissionData if ($res === false) return false; $data["locations"] = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $data["locations"][] = $row['locationid']; } $res = Database::simpleQuery("SELECT roleid, permissionid FROM role_x_permission WHERE roleid = :roleid", array("roleid" => $roleid)); $data["permissions"] = array(); - while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + foreach ($res as $row) { $data["permissions"][] = $row['permissionid']; } return $data; |