This repository has been archived by the owner on May 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadmin_permission.php
105 lines (94 loc) · 2.93 KB
/
admin_permission.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
$permissionId = $_GET['id'];
//Check if selected permission level exists
if(!permissionIdExists($permissionId)){
header("Location: admin_permissions.php"); die();
}
$permissionDetails = fetchPermissionDetails($permissionId); //Fetch information specific to permission level
//Forms posted
if(!empty($_POST)){
//Delete selected permission level
if(!empty($_POST['delete'])){
$deletions = $_POST['delete'];
if ($deletion_count = deletePermission($deletions)){
$successes[] = lang("PERMISSION_DELETIONS_SUCCESSFUL", array($deletion_count));
}
else {
$errors[] = lang("SQL_ERROR");
}
}
else
{
//Update permission level name
if($permissionDetails['name'] != $_POST['name']) {
$permission = trim($_POST['name']);
//Validate new name
if (permissionNameExists($permission)){
$errors[] = lang("ACCOUNT_PERMISSIONNAME_IN_USE", array($permission));
}
elseif (minMaxRange(1, 50, $permission)){
$errors[] = lang("ACCOUNT_PERMISSION_CHAR_LIMIT", array(1, 50));
}
else {
if (updatePermissionName($permissionId, $permission)){
$successes[] = lang("PERMISSION_NAME_UPDATE", array($permission));
}
else {
$errors[] = lang("SQL_ERROR");
}
}
}
//Remove access to pages
if(!empty($_POST['removePermission'])){
$remove = $_POST['removePermission'];
if ($deletion_count = removePermission($permissionId, $remove)) {
$successes[] = lang("PERMISSION_REMOVE_USERS", array($deletion_count));
}
else {
$errors[] = lang("SQL_ERROR");
}
}
//Add access to pages
if(!empty($_POST['addPermission'])){
$add = $_POST['addPermission'];
if ($addition_count = addPermission($permissionId, $add)) {
$successes[] = lang("PERMISSION_ADD_USERS", array($addition_count));
}
else {
$errors[] = lang("SQL_ERROR");
}
}
//Remove access to pages
if(!empty($_POST['removePage'])){
$remove = $_POST['removePage'];
if ($deletion_count = removePage($remove, $permissionId)) {
$successes[] = lang("PERMISSION_REMOVE_PAGES", array($deletion_count));
}
else {
$errors[] = lang("SQL_ERROR");
}
}
//Add access to pages
if(!empty($_POST['addPage'])){
$add = $_POST['addPage'];
if ($addition_count = addPage($add, $permissionId)) {
$successes[] = lang("PERMISSION_ADD_PAGES", array($addition_count));
}
else {
$errors[] = lang("SQL_ERROR");
}
}
$permissionDetails = fetchPermissionDetails($permissionId);
}
}
$pagePermissions = fetchPermissionPages($permissionId); //Retrieve list of accessible pages
$permissionUsers = fetchPermissionUsers($permissionId); //Retrieve list of users with membership
$userData = fetchAllUsers(); //Fetch all users
$pageData = fetchAllPages(); //Fetch all pages
require_once("models/header.php");
include("models/menu.php");
include("include/html-templates/admin_permission.php");
include("models/plugins.php");
?>