1
0
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:
2019-01-15 10:02:28 +08:00
parent 71f1f10e2c
commit d0a4b891b5
321 changed files with 24657 additions and 1 deletions

View 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;
}
}