MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mpermssaguldap.class
Ir para a documentação deste ficheiro.
1
<?php
41
class
MPermsSaguLdap
extends
MPerms
42
{
43
private
$auth;
44
private
$module;
45
46
public
function
__construct
()
47
{
48
parent::__construct();
49
50
$this->module =
'admin'
;
51
52
$this->perms = array ( A_ACCESS => _M(
'Acesso/Visualização'
, $this->module),
53
A_INSERT => _M(
"Inserção"
, $this->module),
54
A_DELETE => _M(
"Exclusão"
, $this->module),
55
A_UPDATE => _M(
"Atualização"
, $this->module),
56
A_EXECUTE => _M(
"Execução"
, $this->module),
57
A_ADMIN => _M(
"Administrator"
, $this->module)
58
);
59
60
$MIOLO
=
MIOLO::getInstance
();
61
$this->manager =
$MIOLO
;
62
63
$MIOLO
->import(
'classes::security::mpermssaguldap'
);
64
$this->schema =
$MIOLO
->getConf(
'login.ldap.schema'
);
65
$this->base = $this->manager->getConf(
'login.ldap.base'
);
66
67
$this->auth = $this->manager->GetAuth();
68
}
69
70
public
function
setAuth
($auth)
71
{
72
$this->auth = $auth;
73
}
74
75
public
function
checkAccess
($transaction, $perm, $deny =
false
, $group =
false
)
76
{
77
$MIOLO
=
MIOLO::getInstance
();
78
$module =
MIOLO::getCurrentModule
();
79
$action
=
MIOLO::getCurrentAction
();
80
81
if
( $this->auth->IsLogged() )
82
{
83
$login = $this->auth->GetLogin();
// MLogin object
84
85
$transaction = strtoupper($transaction);
86
$rights = $this->
getRights
($login->id, $transaction);
// user rights
87
88
if
( strlen($rights) > 0 )
89
{
90
if
( in_array(A_ADMIN, $rights) )
91
{
92
return
true
;
93
}
94
elseif ( in_array($perm, $rights) )
95
{
96
return
true
;
97
}
98
}
99
}
100
101
if
( $deny )
102
{
103
$transaction = $this->
getTransactionName
($transaction);
104
105
$msg = _M(
'Acesso negado'
, $this->module) .
"<br><br>\n"
.
106
'<center><big><i><font color=red>'
. _M(
'Transação: '
, $module) .
"$transaction ("
. $this->perms[$perm] .
")</font></i></big></center><br><br>\n"
.
107
_M(
'Por favor, informe um usuário/senha válido para ter acesso a este conteúdo'
, $this->module) .
"<br>"
;
108
109
$go = $this->manager->history->Back(
'action'
);
110
$error =
Prompt::Error
($msg, $go, $caption,
''
);
111
$error->addButton( _M(
' Login '
), $this->manager->getActionURL($this->manager->getConf(
'login.module'
),
'login'
,
null
,array(
'return_to'
=>urlencode(str_replace(
'&'
,
'&'
, $this->manager->history->Top())))),
''
);
112
113
$this->manager->Prompt($error,$deny);
114
}
115
116
return
$ok;
117
}
118
119
public
function
getRights
($login, $transaction)
120
{
121
$this->manager->loadMADConf();
122
$db = $this->manager->getDatabase($this->module);
123
$iduser = $this->getIduser($login);
124
125
$sql =
"SELECT A.rights
126
FROM miolo_access A
127
INNER JOIN miolo_groupuser B
128
ON (B.idgroup = A.idgroup)
129
INNER JOIN miolo_transaction C
130
ON (C.idtransaction = A.idtransaction)
131
WHERE B.iduser = '$iduser'
132
AND lower(C.m_transaction) = '"
. strtolower($transaction) .
"'"
;
133
134
$result = $db->query($sql);
135
136
if
( count($result) > 0 )
137
{
138
unset($rights);
139
foreach
( $result AS $index => $value )
140
{
141
$rights[] = $value[0];
142
}
143
}
144
145
return
$rights;
146
}
147
148
public
function
getTransactionName
($transaction)
149
{
150
$this->manager->loadMADConf();
151
$db = $this->manager->getDatabase($this->module);
152
153
$sql =
"SELECT A.nametransaction
154
FROM miolo_transaction A
155
WHERE lower(A.m_transaction) = '"
. strtolower($transaction) .
"'"
;
156
157
$result = $db->query($sql);
158
159
return
$result[0][0];
160
}
161
162
public
function
getIdUser
($login)
163
{
164
$search =
'(objectClass='
.($this->schema ==
'system'
?
'person'
:
'mioloUser'
).
')'
;
165
166
$nameAttr =
'name'
;
167
168
if
( $this->schema ==
'system'
)
169
{
170
$nameAttr = $this->manager->getConf(
'login.ldap.userName'
);
171
}
172
173
$filter = $login =
"(uid=$login)"
;
174
175
$search =
'(&(objectClass='
.($this->schema ==
'system'
?
'person'
:
'mioloUser'
).
")$filter)"
;
176
177
$sr= ldap_search( $this->auth->conn, $this->base, $search, array(
'uidnumber'
));
178
ldap_sort($this->auth->conn, $sr, $nameAttr);
179
$info = ldap_get_entries($this->auth->conn, $sr);
180
181
for
( $c=0; $c < $info[
'count'
]; $c++ )
182
{
183
$id
= $info[$c][
'uidnumber'
][0];
184
185
$return =
$id
;
186
}
187
188
return
$return;
189
}
190
191
public
function
checkTransactionParents
($transaction, $perm)
192
{
193
194
}
195
}
196
?>
MIOLO\getCurrentModule
static getCurrentModule()
Definição
miolo.class:1066
MIOLO\getCurrentAction
static getCurrentAction()
Definição
miolo.class:1086
MIOLO\getInstance
static getInstance()
Definição
miolo.class:134
MPermsSaguLdap
Definição
mpermssaguldap.class:42
MPermsSaguLdap\__construct
__construct()
Definição
mpermssaguldap.class:46
MPermsSaguLdap\getRights
getRights($login, $transaction)
Definição
mpermssaguldap.class:119
MPermsSaguLdap\checkTransactionParents
checkTransactionParents($transaction, $perm)
Definição
mpermssaguldap.class:191
MPermsSaguLdap\getIdUser
getIdUser($login)
Definição
mpermssaguldap.class:162
MPermsSaguLdap\getTransactionName
getTransactionName($transaction)
Definição
mpermssaguldap.class:148
MPermsSaguLdap\checkAccess
checkAccess($transaction, $perm, $deny=false, $group=false)
Definição
mpermssaguldap.class:75
MPermsSaguLdap\setAuth
setAuth($auth)
Definição
mpermssaguldap.class:70
MPerms
Definição
mperms.class:3
MPrompt\Error
static Error($msg='', $goto='', $caption='', $event='')
Definição
mprompt.class:90
$MIOLO
$MIOLO
Definição
mdatetimefield.class:25
$action
$action
Definição
base.php:4
$id
$id
Definição
base.php:5
classes
security
mpermssaguldap.class
Gerado por
1.10.0