mirror of
https://github.com/newnius/YAO-portal.git
synced 2025-12-13 09:06:43 +00:00
init & add agent & add job
This commit is contained in:
34
util4p/AccessController.class.php
Executable file
34
util4p/AccessController.class.php
Executable file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
class AccessController
|
||||
{
|
||||
private static $rules_array = array();
|
||||
|
||||
/*
|
||||
* set privilege bitmap
|
||||
* sample $map = array(
|
||||
* 'post.add' => array('Admin', 'Moderator', 'User'),
|
||||
* 'post.comment' => array'Admin', 'Moderator', 'User'),
|
||||
* 'post.pin' => array('Admin', 'Moderator'),
|
||||
* 'user.block' => array('Admin')
|
||||
* );
|
||||
*/
|
||||
public static function setMap(array $map)
|
||||
{
|
||||
if (is_array($map)) {
|
||||
self::$rules_array = $map;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* AccessController::hasAccess('Moderator', 'user.block');
|
||||
*/
|
||||
public static function hasAccess($role, $operation)
|
||||
{
|
||||
if (array_key_exists($operation, self::$rules_array)) {
|
||||
return in_array($role, self::$rules_array[$operation]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user