-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_page.php
189 lines (162 loc) · 5.46 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<?php
/*
UserCake Version: 2.0.2
http://usercake.com
*/
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();
require_once("models/header.php");
?>
<body>
<div id="wrapper">
<?php include("navigation.php");?>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">The <img src="img/evarilos.png"/> benchmarking platform</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<h3>Permission configuration</h3>
<div class="panel panel-default">
<div class="panel-body">
<?php echo resultBlock($errors,$successes); ?>
<form class="form-horizontal" name='adminPage' action=" <?php $_SERVER['PHP_SELF']?>?id=<?=$pageId?> " method="post">
<fieldset>
<div class="form-group">
<h4 class="control-label col-sm-2">Page info</h4>
</div>
<div class="form-group">
<label class="control-label col-sm-2">ID:</label>
<div class="col-sm-10">
<label class="form-control"><?=$pageDetails['id']?></label>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Name:</label>
<div class="col-sm-10">
<input class="form-control" type='text' name='name' value="<?=$pageDetails['page']?>" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Private:</label>
<div class="col-sm-10">
<div class="checkbox"><label>
<?php
//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'>";
}
?>
</label></div>
</div>
</div>
</br></br></br>
<div class="form-group">
<h4 class="control-label col-sm-2">Page Access</h4>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Remove access:</label>
<div class="col-sm-10">
<?php
//Display list of permission levels with access
foreach ($permissionData as $v1) {
if(isset($pagePermissions[$v1['id']])){
echo "<div class=\"checkbox\"><label>";
echo "<input type='checkbox' name='removePermission[".$v1['id']."]' id='removePermission[".$v1['id']."]' value='".$v1['id']."'> ".$v1['name'];
echo "</label></div>";
}
}
?>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2">Add access:</label>
<div class="col-sm-10">
<?php
//Display list of permission levels without access
foreach ($permissionData as $v1) {
if(!isset($pagePermissions[$v1['id']])){
echo "<div class=\"checkbox\"><label>";
echo "<input type='checkbox' name='addPermission[".$v1['id']."]' id='addPermission[".$v1['id']."]' value='".$v1['id']."'> ".$v1['name'];
echo "</label></div>";
}
}
?>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Update</button>
</div>
</div>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<?php require_once("models/footerscripts.php"); ?>
</body>
</html>