/**
+----------------------------------------------------------
* 取得当前认证号的所有权限列表
+----------------------------------------------------------
* @param integer $authId 用户ID
+----------------------------------------------------------
* @access public
+----------------------------------------------------------
*/
static public function getAccessList($authId)
{
//echo "<pre>";print_r($authId);exit;
// Db方式权限数据
$db = Db::getInstance(C('RBAC_DB_DSN'));
$auth_type = C("AUTH_TYPE");
$table = array('role'=>C("DB_PREFIX").C('RBAC_ROLE_TABLE'),'user'=>C("DB_PREFIX").C('RBAC_USER_TABLE'),'access'=>C("DB_PREFIX").C('RBAC_ACCESS_TABLE'),'node'=>C("DB_PREFIX").C('RBAC_NODE_TABLE'));
$sql = "select node.auth_type,node.id,node.action,node.action_name,node.module,node.module_name from ".
$table['role']." as role,".
$table['user']." as user,".
$table['access']." as access ,".
$table['node']." as node ".
"where user.u_id='{$authId}' and user.role_id=role.id and access.role_id=role.id and role.status=1 and access.node_id=node.id and node.status=1";
$apps = $db->query($sql);
require_once('./Conf/Admin/authoritys.php');
$access = array();
foreach($apps as $key=>$app)
{
$appId = $app['id'];
$module_name = $app['module'];
$action_name = $app['action'];
$o_module_name = strtoupper($module_name);
$o_action_name = strtoupper($action_name);
$l_module_name = strtolower($module_name);
$l_action_name = strtolower($action_name);
// 读取项目的模块权限
if($app['auth_type']==0) //节点授权
{
$access[$o_module_name][$o_action_name] = true;
if(isset($authoritys['all'][$l_action_name]))
{
$authoritys_list = $authoritys['all'][$l_action_name];
foreach($authoritys_list as $authority_item)
{
$access[$o_module_name][strtoupper($authority_item)] = true;
}
}
if(isset($authoritys['actions'][$l_module_name][$l_action_name]))
{
$authoritys_list = $authoritys['actions'][$l_module_name][$l_action_name];
foreach($authoritys_list as $authority_item)
{
$access[$o_module_name][strtoupper($authority_item)] = true;
}
}
}
if($app['auth_type']==1) //模块授权
{
$access[$o_module_name][strtoupper($auth_type[$app['auth_type']])] = true;
}
if($app['auth_type']==2) //操作授权
{
$access[strtoupper($auth_type[$app['auth_type']])][$o_action_name] = true;
}
}
//不需要认证的模块
if(!empty($authoritys['no']) && is_array($authoritys['no'])){
foreach($authoritys['no'] as $module_name=>$action_name){
$o_module_name = strtoupper($module_name);
$o_action_name = strtoupper(key($action_name));
foreach($action_name as $keymodule=>$valaction){
$keymodule = strtoupper($keymodule);
$access[$o_module_name][$keymodule] = true;
}
}
}
return $access;
}
huicms.zip ( 8.45 KB 下载:74 次 )