-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathpermission.php
46 lines (38 loc) · 1.17 KB
/
permission.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
<?php
/**
* A class designed to take care of permissions
*
* @author Lauge Rud Knudsen <[email protected]>
* @version V2
*/
class Permission {
/** @var int The id of the permission node */
protected $id;
/** @var string The name of the permission node */
protected $name;
/** @var bool The allowed state of the permission node */
protected $allowed;
public function getId() {
return $this->id;
}
public function getName() {
return $this->name;
}
public function getAllowed() {
return $this->allowed;
}
public function read($roleid, $permissionid) {
$statement = dbConnection::getInstance()->prepare('SELECT r.permissionid, p.name, r.allowed '
. 'FROM rolepermissions AS r '
. 'LEFT JOIN permissions AS p ON r.permissionid = p.permissionid '
. 'WHERE r.permissionid = :permissionid AND r.roleid = :roleid');
$statement->bindParam(':permissionid', $permissionid);
$statement->bindParam(':roleid', $roleid);
$statement->execute();
while ($row = $statement->fetch()) {
$this->id = $row[0];
$this->name = $row[1];
$this->allowed = $row[2];
}
}
}