Files
OMS/app/openapi/lib/privilege.php
2025-12-28 23:13:25 +08:00

36 lines
1013 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Copyright © ShopeX http://www.shopex.cn. All rights reserved.
* See LICENSE file for license details.
*/
class openapi_privilege {
/**
* 检查Access
* @param mixed $flag flag
* @param mixed $obj obj
* @param mixed $method method
* @return mixed 返回验证结果
*/
static public function checkAccess($flag,$obj,$method){
if(!$flag){
return false;
}
$settingObj = app::get('openapi')->model('setting');
$settingInfo = $settingObj->dump(array('code'=>$flag,'status'=>1),'*');
if($settingInfo){
if(isset($settingInfo['config'][$obj]) && in_array($method,$settingInfo['config'][$obj])){
// 将setting信息存储到全局变量中供API方法使用
$GLOBALS['openapi_current_setting'] = $settingInfo;
return true;
}else{
return false;
}
}else{
return false;
}
}
}