소스 검색

Merge branch 'master' of http://10.1.1.202:3030/steve07s/Authorization

manto07m 3 년 전
부모
커밋
d686c5303a
3개의 변경된 파일124개의 추가작업 그리고 35개의 파일을 삭제
  1. 18 1
      assets/stylesheets/role.css
  2. 78 27
      script/php/API/get_dept_user.php
  3. 28 7
      script/php/API/get_group.php

+ 18 - 1
assets/stylesheets/role.css

@@ -80,6 +80,19 @@
     color: white;
     color: white;
 }
 }
 
 
+.btn-Admin {
+    color: #ffffff;
+    text-shadow: 0 -1px 0 rgb(0 0 0 / 25%);
+    background-color: #E60086;
+    border-color: #E60086;
+}
+
+.btn-Admin:hover {
+    border-color: #e42795 !important;
+    background-color: #e42795;
+    color: white;
+}
+
 
 
 
 
 .dropdown-menu > .li-User > a{
 .dropdown-menu > .li-User > a{
@@ -102,5 +115,9 @@
 }
 }
 
 
 .dropdown-menu > .li-Guest > a{
 .dropdown-menu > .li-Guest > a{
-    color: #00b92e;
+    color: #E60086;
+}
+
+.dropdown-menu > .li-Admin > a{
+    color: #E60086;
 }
 }

+ 78 - 27
script/php/API/get_dept_user.php

@@ -1,42 +1,93 @@
 <?php
 <?php
 session_start();
 session_start();
 include('../permission/connect_sql.php');
 include('../permission/connect_sql.php');
+
+$user_id = $_SESSION['UserID'];
+$sql = "SELECT [GroupID] FROM [permissions].[dbo].[UserGroup] WHERE [UserID] = ?;";
+$stmt = sqlsrv_query($conn, $sql, array($user_id));
+$is_admin = false;
+while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
+    if ($row["GroupID"] == 'Admin') {
+        $is_admin = true;
+    }
+}
+
 $user_list = array();
 $user_list = array();
-$sql = "SELECT DISTINCT [User].[UserID],[Account],[UserName],[DepartmentID],[Group].[GroupID],[GroupName] FROM [User] 
+$users = array();
+$permissions = array();
+if ($is_admin) {
+    $sql = "SELECT DISTINCT [User].[UserID],[Account],[UserName],[DepartmentID],[Group].[GroupID],[GroupName] FROM [User] 
 LEFT JOIN [UserGroup] ON [User].[UserID] = [UserGroup].[UserID] 
 LEFT JOIN [UserGroup] ON [User].[UserID] = [UserGroup].[UserID] 
 LEFT JOIN [Group] ON [UserGroup].[GroupID] = [Group].[GroupID]
 LEFT JOIN [Group] ON [UserGroup].[GroupID] = [Group].[GroupID]
 LEFT JOIN [GroupRight] ON [GroupRight].[GroupID] = [Group].[GroupID] 
 LEFT JOIN [GroupRight] ON [GroupRight].[GroupID] = [Group].[GroupID] 
 LEFT JOIN [WebPage] ON [WebPage].[PgroupID] = [GroupRight].[PgroupID]
 LEFT JOIN [WebPage] ON [WebPage].[PgroupID] = [GroupRight].[PgroupID]
-WHERE [DepartmentID] = (SELECT [DepartmentID] FROM [User] WHERE [UserID] = ?) ORDER BY [GroupName]";
-$stmt = sqlsrv_query($conn, $sql, array($_SESSION['UserID']));
-$users = array();
-$permissions = array();
-while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
-    if (in_array($row["UserID"], $user_list)) {
-        $index = array_search($row["UserID"],$user_list);
-        array_push($users[$index]["GroupID"],$row["GroupID"]);
-        array_push($users[$index]["GroupName"],$row["GroupName"]);
-    } else {
+ORDER BY [GroupName]";
+    $stmt = sqlsrv_query($conn, $sql);
+
+    while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
+        if (in_array($row["UserID"], $user_list)) {
+            $index = array_search($row["UserID"], $user_list);
+            array_push($users[$index]["GroupID"], $row["GroupID"]);
+            array_push($users[$index]["GroupName"], $row["GroupName"]);
+        } else {
+            $temp = array();
+            $temp["UserID"] = $row["UserID"];
+            $temp["Account"] = $row["Account"];
+            $temp["UserName"] = $row["UserName"];
+            $temp["DepartmentID"] = $row["DepartmentID"];
+            $temp["GroupID"] = array($row["GroupID"]);
+            $temp["GroupName"] = array($row["GroupName"]);
+            array_push($users, $temp);
+            array_push($user_list, $row["UserID"]);
+        }
+    }
+
+    $sql = "SELECT [GroupID],[GroupName] FROM [Group] WHERE [GroupID] != 'Admin'";
+    $stmt = sqlsrv_query($conn, $sql, array($_SESSION['UserID']));
+    while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
         $temp = array();
         $temp = array();
-        $temp["UserID"] = $row["UserID"];
-        $temp["Account"] = $row["Account"];
-        $temp["UserName"] = $row["UserName"];
-        $temp["DepartmentID"] = $row["DepartmentID"];
-        $temp["GroupID"] = array($row["GroupID"]);
-        $temp["GroupName"] = array($row["GroupName"]);
-        array_push($users, $temp);
-        array_push($user_list, $row["UserID"]);
+        $temp["GroupID"] = $row["GroupID"];
+        $temp["GroupName"] = $row["GroupName"];
+        array_push($permissions, $temp);
     }
     }
-}
+} else {
+    $sql = "SELECT DISTINCT [User].[UserID],[Account],[UserName],[DepartmentID],[Group].[GroupID],[GroupName] FROM [User] 
+    LEFT JOIN [UserGroup] ON [User].[UserID] = [UserGroup].[UserID] 
+    LEFT JOIN [Group] ON [UserGroup].[GroupID] = [Group].[GroupID]
+    LEFT JOIN [GroupRight] ON [GroupRight].[GroupID] = [Group].[GroupID] 
+    LEFT JOIN [WebPage] ON [WebPage].[PgroupID] = [GroupRight].[PgroupID]
+    WHERE [DepartmentID] = (SELECT [DepartmentID] FROM [User] WHERE [UserID] = ?) AND [Group].[GroupID] != 'Admin' ORDER BY [GroupName]";
+    $stmt = sqlsrv_query($conn, $sql, array($_SESSION['UserID']));
 
 
-$sql = "SELECT [GroupID],[GroupName] FROM [Group] WHERE [GroupID] != 'Admin'";
-$stmt = sqlsrv_query($conn, $sql, array($_SESSION['UserID']));
-while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
-    $temp = array();
-    $temp["GroupID"] = $row["GroupID"];
-    $temp["GroupName"] = $row["GroupName"];
-    array_push($permissions, $temp);
+    while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
+        if (in_array($row["UserID"], $user_list)) {
+            $index = array_search($row["UserID"], $user_list);
+            array_push($users[$index]["GroupID"], $row["GroupID"]);
+            array_push($users[$index]["GroupName"], $row["GroupName"]);
+        } else {
+            $temp = array();
+            $temp["UserID"] = $row["UserID"];
+            $temp["Account"] = $row["Account"];
+            $temp["UserName"] = $row["UserName"];
+            $temp["DepartmentID"] = $row["DepartmentID"];
+            $temp["GroupID"] = array($row["GroupID"]);
+            $temp["GroupName"] = array($row["GroupName"]);
+            array_push($users, $temp);
+            array_push($user_list, $row["UserID"]);
+        }
+    }
+
+    $sql = "SELECT [GroupID],[GroupName] FROM [Group] WHERE [GroupID] != 'Admin'";
+    $stmt = sqlsrv_query($conn, $sql, array($_SESSION['UserID']));
+    while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
+        $temp = array();
+        $temp["GroupID"] = $row["GroupID"];
+        $temp["GroupName"] = $row["GroupName"];
+        array_push($permissions, $temp);
+    }
 }
 }
+
+
 $data["users"] = $users;
 $data["users"] = $users;
 $data["permissions"] = $permissions;
 $data["permissions"] = $permissions;
 echo json_encode($data);
 echo json_encode($data);

+ 28 - 7
script/php/API/get_group.php

@@ -1,14 +1,35 @@
 <?php
 <?php
 session_start();
 session_start();
 include('../permission/connect_sql.php');
 include('../permission/connect_sql.php');
+$user_id = $_SESSION['UserID'];
+$sql = "SELECT [GroupID] FROM [permissions].[dbo].[UserGroup] WHERE [UserID] = ?;";
+$stmt = sqlsrv_query($conn, $sql, array($user_id));
+$is_admin = false;
+while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
+        if ($row["GroupID"] == 'Admin') {
+                $is_admin = true;
+        }
+}
 $group = array();
 $group = array();
-$sql = "SELECT [GroupID],[GroupName] FROM [Group] WHERE [GroupID] != 'Admin' AND [GroupID] != 'User' AND [GroupID] != 'Guest'";
-$stmt = sqlsrv_query($conn, $sql);
-while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {    
-        $temp = array();
-        $temp["GroupID"] = $row["GroupID"];
-        $temp["GroupName"] = $row["GroupName"];
-        array_push($group, $temp);    
+if ($is_admin) {
+        $sql = "SELECT [GroupID],[GroupName] FROM [Group] WHERE [GroupID] != 'User' AND [GroupID] != 'Guest'";
+        $stmt = sqlsrv_query($conn, $sql);
+        while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
+                $temp = array();
+                $temp["GroupID"] = $row["GroupID"];
+                $temp["GroupName"] = $row["GroupName"];
+                array_push($group, $temp);
+        }
+} else {
+        $sql = "SELECT [GroupID],[GroupName] FROM [Group] WHERE [GroupID] != 'Admin' AND [GroupID] != 'User' AND [GroupID] != 'Guest'";
+        $stmt = sqlsrv_query($conn, $sql);
+        while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) {
+                $temp = array();
+                $temp["GroupID"] = $row["GroupID"];
+                $temp["GroupName"] = $row["GroupName"];
+                array_push($group, $temp);
+        }
 }
 }
 
 
+
 echo json_encode($group);
 echo json_encode($group);