diff options
author | Christian Hofmaier | 2017-03-28 11:23:24 +0200 |
---|---|---|
committer | Christian Hofmaier | 2017-03-28 11:23:24 +0200 |
commit | 7807e30a69ab39b3f2a7f20d2608ba6b46b456e8 (patch) | |
tree | 0c9054b307b72d2a891e4b5b0e0a389acd9716cd /modules-available/permissionmanager/inc/getdata.inc.php | |
parent | [permission-manager] renamed module folder (diff) | |
download | slx-admin-7807e30a69ab39b3f2a7f20d2608ba6b46b456e8.tar.gz slx-admin-7807e30a69ab39b3f2a7f20d2608ba6b46b456e8.tar.xz slx-admin-7807e30a69ab39b3f2a7f20d2608ba6b46b456e8.zip |
[permission-manager] first part of UI, database table, sql queries and db methods
Diffstat (limited to 'modules-available/permissionmanager/inc/getdata.inc.php')
-rw-r--r-- | modules-available/permissionmanager/inc/getdata.inc.php | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/modules-available/permissionmanager/inc/getdata.inc.php b/modules-available/permissionmanager/inc/getdata.inc.php new file mode 100644 index 00000000..7eac333f --- /dev/null +++ b/modules-available/permissionmanager/inc/getdata.inc.php @@ -0,0 +1,43 @@ +<?php + +class GetData { + + // get UserIDs, User Login Names, User Roles + public static function getUserData() { + $res = self::queryUserData(); + $data = array(); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $data[] = array( + 'userid' => $row['userid'], + 'name' => $row['login'], + 'role' => explode(",",$row['role']) + ); + } + return $data; + } + + // get all roles from database (id and name) + public static function getRoles() { + $res = Database::simpleQuery("SELECT id, name FROM role ORDER BY name"); + $data = array(); + while ($row = $res->fetch(PDO::FETCH_ASSOC)) { + $data[] = array( + 'roleId' => $row['id'], + 'roleName' => $row['name'] + ); + } + return $data; + } + + // UserID, User Login Name, Roles of each User + private static function queryUserData() { + $res = Database::simpleQuery("SELECT user.userid AS userid, user.login AS login, GROUP_CONCAT(role.name) AS role + FROM user + LEFT JOIN userXrole ON user.userid = userXrole.userid + LEFT JOIN role ON userXrole.roleid = role.id + GROUP BY user.userid + "); + return $res; + } + +}
\ No newline at end of file |