-
Notifications
You must be signed in to change notification settings - Fork 1
/
incPrivileges.php
34 lines (30 loc) · 987 Bytes
/
incPrivileges.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
<?php
if (isset($_SESSION['username'])) {
$privileges=array();
$sql ="SELECT p.name
FROM user u inner join `m_user_role` mur on u.id=mur.user_id
inner join m_role_privilege mrp on mur.role_id=mrp.role_id
inner join privilege p on p.id=mrp.privilege_id
WHERE u.username ='" . $_SESSION['username'] . "'";
$result=$dds->setSQL($sql);
while ($rrow=$dds->getNextRow()) {
$privileges[$rrow[0]]="true";
}
$sql ="SELECT r.name
FROM user u inner join `m_user_role` mur on u.id=mur.user_id
inner join role r on r.id=mur.role_id
WHERE u.username ='" . $_SESSION['username'] . "'";
$result=$dds->setSQL($sql);
while ($rrow=$dds->getNextRow()) {
if ($rrow[0]=="admin") $user_is_admin=true;
}
}
function active_priv($privName) {
global $privileges;
global $user_is_admin;
$retVal=false;
if (isset($privileges[$privName])) $retVal=true;
if ($user_is_admin) $retVal=true;
return $retVal;
}
?>