MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mperms.class
Ir para a documentação deste ficheiro.
1
<?php
2
class
MPerms
extends
MService
3
{
4
private
$auth;
5
public
$perms
;
6
7
function
__construct
()
8
{
9
parent::__construct();
10
$this->auth = $this->manager->GetAuth();
11
$this->perms = array
12
(
13
'A_ACCESS'
=>
"SELECT"
,
14
'A_INSERT'
=>
"INSERT"
,
15
'A_DELETE'
=>
"DELETE"
,
16
'A_UPDATE'
=>
"UPDATE"
,
17
'A_EXECUTE'
=>
"EXECUTE"
,
18
'A_ADMIN'
=>
"SYSTEM"
19
);
20
21
}
22
23
function
CheckAccess
($transaction, $access, $deny =
false
, $group=
false
, $login =
null
)
24
{
25
if
($this->auth->IsLogged())
26
{
27
$login = is_object($login) ? $login : $this->auth->GetLogin();
// MLogin object
28
$transaction = strtoupper($transaction);
// Transaction name
29
$isAdmin = $login->IsAdmin();
// Is administrator?
30
$rights = (int)$login->rights[$transaction];
// user rights
31
$rightsInAll = (int)$login->rights[
'ALL'
];
// user rights in all transactions
32
$ok = (($rights & $access) == $access) || (($rightsInAll & $access) == $access) || ($isAdmin);
33
}
34
35
if
(!$ok && $deny)
36
{
37
$msg = _M(
'Access Denied'
) .
"<br><br>\n"
.
38
'<center><big><i><font color=red>'
. _M(
'Transaction: '
) .
"$transaction</font></i></big></center><br><br>\n"
.
39
_M(
'Please inform a valid login/password to access this content.'
) .
"<br>"
;
40
41
$users = $this->
GetGroupsAllowed
($transaction, $access);
42
if
($users)
43
{
44
$msg .=
"<br><br>\n"
. _M(
'Groups with access rights'
) .
":<ul><li>"
. implode(
'<li>'
, $users) .
'</ul>'
;
45
}
46
$go = $this->manager->history->Back(
'action'
);
47
$error =
Prompt::Error
($msg, $go, $caption,
''
);
48
$error->AddButton(_M(
' Login '
), $this->manager->getActionURL($this->manager->getConf(
'login.module'
),
'login'
,
null
,array(
'return_to'
=>urlencode($this->manager->history->Top()))),
''
);
49
$this->manager->Prompt($error,$deny);
50
//$this->manager->Error($msg, $go);
51
}
52
return
$ok;
53
}
54
55
function
GetTransactionRights
($transaction, $login)
56
{
57
$user = $this->manager->GetBusinessMAD(
'user'
);
58
$user->GetByLogin($login);
59
return
$user->GetTransactionRights($transaction);
60
}
61
62
function
GetRights
($login, $transaction)
63
{
64
$user = $this->manager->GetBusinessMAD(
'user'
);
65
$user->GetByLogin($login);
66
return
$user->GetRights($transaction);
67
}
68
69
function
GetGroups
($login)
70
{
71
$user = $this->manager->GetBusinessMAD(
'user'
);
72
$user->GetByLogin($login);
73
return
$user->GetArrayGroups();
74
}
75
76
function
isMemberOf
($login, $group)
77
{
78
$groups = $this->auth->GetLogin()->groups;
79
$ok = $groups[strtoupper($group)] || $groups[
'ADMIN'
];
80
return
$ok;
81
}
82
83
function
isAdmin
()
84
{
85
return
$this->auth->GetLogin()->IsAdmin();
86
}
87
88
function
GetUsersAllowed
($trans,
$action
= A_ACCESS)
89
{
90
$transaction = $this->manager->GetBusinessMAD(
'transaction'
);
91
$transaction->GetByName($trans);
92
return
$transaction->GetUsersAllowed(
$action
);
93
}
94
95
function
GetGroupsAllowed
($trans,
$action
= A_ACCESS)
96
{
97
$transaction = $this->manager->GetBusinessMAD(
'transaction'
);
98
$transaction->GetByName($trans);
99
return
$transaction->GetGroupsAllowed(
$action
);
100
}
101
}
102
?>
MPerms
Definição
mperms.class:3
MPerms\__construct
__construct()
Definição
mperms.class:7
MPerms\CheckAccess
CheckAccess($transaction, $access, $deny=false, $group=false, $login=null)
Definição
mperms.class:23
MPerms\GetGroupsAllowed
GetGroupsAllowed($trans, $action=A_ACCESS)
Definição
mperms.class:95
MPerms\$perms
$perms
Definição
mperms.class:5
MPerms\isAdmin
isAdmin()
Definição
mperms.class:83
MPerms\GetTransactionRights
GetTransactionRights($transaction, $login)
Definição
mperms.class:55
MPerms\GetUsersAllowed
GetUsersAllowed($trans, $action=A_ACCESS)
Definição
mperms.class:88
MPerms\GetRights
GetRights($login, $transaction)
Definição
mperms.class:62
MPerms\GetGroups
GetGroups($login)
Definição
mperms.class:69
MPerms\isMemberOf
isMemberOf($login, $group)
Definição
mperms.class:76
MPrompt\Error
static Error($msg='', $goto='', $caption='', $event='')
Definição
mprompt.class:90
MService
Definição
mservice.class:7
$action
$action
Definição
base.php:4
classes
security
mperms.class
Gerado por
1.10.0