-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexample.php
49 lines (37 loc) · 1.17 KB
/
example.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
<pre>
<?php
/* Include the class */
require_once('class.acl.php');
/* List possible actions */
$actions = array(
'read',
'write',
'publish',
'delete'
);
/* Create a new object to generate a permissions set */
$permissionGenerator = new ACL($actions);
/* Add the permissions you want */
$permissionGenerator->addPermission('read');
$permissionGenerator->addPermission('write');
$permissionGenerator->addPermission('delete');
/* Remove the permissions you've changed your mind about */
$permissionGenerator->removePermission('read');
/* And get an integer that correlates to the set of permissions you chose. This
* can be stored and associated with a user account.
*/
$code = $permissionGenerator->evaluate();
/* Create an object and pass it a permissions code to test against */
$ACL = new ACL($actions, $code);
/* Get an array of possible actions you can test for */
$actions = $ACL->getActions();
/* Check which actions are allowed with the permissions code you passed in */
foreach ($actions as $action) {
if($ACL->hasPermission($action)) {
echo $action . ' is allowed <br>';
}else{
echo $action . ' is NOT allowed <br>';
}
}
?>
</pre>