-
Notifications
You must be signed in to change notification settings - Fork 215
/
access.php
executable file
·86 lines (70 loc) · 2.4 KB
/
access.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
<?php
use DBA\QueryFilter;
use DBA\User;
use DBA\Factory;
require_once(dirname(__FILE__) . "/inc/load.php");
if (!Login::getInstance()->isLoggedin()) {
header("Location: index.php?err=4" . time() . "&fw=" . urlencode($_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']));
die();
}
AccessControl::getInstance()->checkPermission(DViewControl::ACCESS_VIEW_PERM);
Template::loadInstance("access/index");
Menu::get()->setActive("users_access");
//catch actions here...
if (isset($_POST['action']) && CSRF::check($_POST['csrf'])) {
$accessControlHandler = new AccessControlHandler();
$accessControlHandler->handle($_POST['action']);
if (UI::getNumMessages() == 0) {
Util::refresh();
}
}
if (isset($_GET['new'])) {
Template::loadInstance("access/new");
UI::add('pageTitle', "Create new Permission Group");
}
else if (isset($_GET['id'])) {
$group = Factory::getRightGroupFactory()->get($_GET['id']);
if ($group == null) {
UI::printError("ERROR", "Invalid permission group!");
}
else {
UI::add('group', $group);
if ($group->getPermissions() == 'ALL') {
UI::add('perm', 'ALL');
}
else {
UI::add('perm', new DataSet(json_decode($group->getPermissions(), true)));
}
$qF = new QueryFilter(User::RIGHT_GROUP_ID, $group->getId(), "=");
UI::add('users', Factory::getUserFactory()->filter([Factory::FILTER => $qF]));
$constants = DAccessControl::getConstants();
$constantsChecked = [];
foreach ($constants as $constant) {
if (is_array($constant)) {
$constant = $constant[0];
}
if ($constant != DAccessControl::PUBLIC_ACCESS && $constant != DAccessControl::LOGIN_ACCESS) {
$constantsChecked[] = $constant;
}
}
UI::add('constants', $constantsChecked);
UI::add('pageTitle', "Details of Permission Group " . htmlentities($group->getGroupName(), ENT_QUOTES, "UTF-8"));
Template::loadInstance("access/detail");
}
}
else {
// determine members and agents
$groups = Factory::getRightGroupFactory()->filter([]);
$users = array();
foreach ($groups as $group) {
$users[$group->getId()] = 0;
}
$allUsers = Factory::getUserFactory()->filter([]);
foreach ($allUsers as $user) {
$users[$user->getRightGroupId()]++;
}
UI::add('users', new DataSet($users));
UI::add('groups', $groups);
UI::add('pageTitle', "Permission Groups");
}
echo Template::getInstance()->render(UI::getObjects());