-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin_page.php
141 lines (119 loc) · 3.03 KB
/
admin_page.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
require_once("models/config.php");
if (!securePage($_SERVER['PHP_SELF'])){die();}
$pageId = $_GET['id'];
//Check if selected pages exist
if(!pageIdExists($pageId)){
header("Location: admin_pages.php"); die();
}
$pageDetails = fetchPageDetails($pageId); //Fetch information specific to page
//Forms posted
if(!empty($_POST)){
$update = 0;
if(!empty($_POST['private'])){ $private = $_POST['private']; }
//Toggle private page setting
if (isset($private) AND $private == 'Yes'){
if ($pageDetails['private'] == 0){
if (updatePrivate($pageId, 1)){
$successes[] = lang("PAGE_PRIVATE_TOGGLED", array("private"));
}
else {
$errors[] = lang("SQL_ERROR");
}
}
}
elseif ($pageDetails['private'] == 1){
if (updatePrivate($pageId, 0)){
$successes[] = lang("PAGE_PRIVATE_TOGGLED", array("public"));
}
else {
$errors[] = lang("SQL_ERROR");
}
}
//Remove permission level(s) access to page
if(!empty($_POST['removePermission'])){
$remove = $_POST['removePermission'];
if ($deletion_count = removePage($pageId, $remove)){
$successes[] = lang("PAGE_ACCESS_REMOVED", array($deletion_count));
}
else {
$errors[] = lang("SQL_ERROR");
}
}
//Add permission level(s) access to page
if(!empty($_POST['addPermission'])){
$add = $_POST['addPermission'];
if ($addition_count = addPage($pageId, $add)){
$successes[] = lang("PAGE_ACCESS_ADDED", array($addition_count));
}
else {
$errors[] = lang("SQL_ERROR");
}
}
$pageDetails = fetchPageDetails($pageId);
}
$pagePermissions = fetchPagePermissions($pageId);
$permissionData = fetchAllPermissions();
echo resultBlock($errors,$successes);
echo "
<form name='adminPage' action='".$_SERVER['PHP_SELF']."?id=".$pageId."' method='post'>
<input type='hidden' name='process' value='1'>
<table class='admin'>
<tr><td>
<h3>Page Information</h3>
<div id='regbox'>
<p>
<label>ID:</label>
".$pageDetails['id']."
</p>
<p>
<label>Name:</label>
".$pageDetails['page']."
</p>
<p>
<label>Private:</label>";
//Display private checkbox
if ($pageDetails['private'] == 1){
echo "<input type='checkbox' name='private' id='private' value='Yes' checked>";
}
else {
echo "<input type='checkbox' name='private' id='private' value='Yes'>";
}
echo "
</p>
</div></td><td>
<h3>Page Access</h3>
<div id='regbox'>
<p>
Remove Access:";
//Display list of permission levels with access
foreach ($permissionData as $v1) {
if(isset($pagePermissions[$v1['id']])){
echo "<br><input type='checkbox' name='removePermission[".$v1['id']."]' id='removePermission[".$v1['id']."]' value='".$v1['id']."'> ".$v1['name'];
}
}
echo"
</p><p>Add Access:";
//Display list of permission levels without access
foreach ($permissionData as $v1) {
if(!isset($pagePermissions[$v1['id']])){
echo "<br><input type='checkbox' name='addPermission[".$v1['id']."]' id='addPermission[".$v1['id']."]' value='".$v1['id']."'> ".$v1['name'];
}
}
echo"
</p>
</div>
</td>
</tr>
</table>
<p>
<label> </label>
<input type='submit' value='Update' class='submit' />
</p>
</form>
</div>
<div id='bottom'></div>
</div>
</body>
</html>";
?>