SugarCRM如何检查控制器权限?
SugarController定义了一个实例变量$hasAccess,布尔值,默认为true。该实例变量指示使用者是否有执行摸个action的权限:
class SugarController{
    /**
     * This can be set from the application to tell us whether we have authorization to
     * process the action. If this is set we will default to the noaccess view.
     */
    public $hasAccess = true;
    public function process(){
        ......
        //check to ensure we have access to the module.
        if($this->hasAccess){
            ... ...
        }else{
            $this->no_access();
        }
    }
}
$hasAccess的值在SugarApplication中设置,当SugarApplication::execute()执行时调用handleAccessControl()检查是否有授权:
class SugarApplication
{
var $controller = null; /**
* Perform execution of the application. This method is called from index2.php
*/
function execute(){
......
$this->controller = ControllerFactory::getController($module);
$this->preProcess();
......
} function preProcess(){
......
$this->handleAccessControl();
} /**
* Handles everything related to authorization.
*/
function handleAccessControl(){
if($GLOBALS['current_user']->isDeveloperForAnyModule())
return; if(!empty($_REQUEST['action']) && $_REQUEST['action']=="RetrieveEmail")
return; if (!is_admin($GLOBALS['current_user']) && !empty($GLOBALS['adminOnlyList'][$this->controller->module])
&& !empty($GLOBALS['adminOnlyList'][$this->controller->module]['all'])
&& (empty($GLOBALS['adminOnlyList'][$this->controller->module][$this->controller->action]) || $GLOBALS['adminOnlyList'][$this->controller->module][$this->controller->action] != 'allow')) {
$this->controller->hasAccess = false;
return;
} // Bug 20916 - Special case for check ACL access rights for Subpanel QuickCreates
if (isset($_POST['action']) && $_POST['action'] == 'SubpanelCreates') {
$actual_module = $_POST['target_module'];
if (!empty($GLOBALS['modListHeader']) && !in_array($actual_module,$GLOBALS['modListHeader'])) {
$this->controller->hasAccess = false;
}
return;
} if (!empty($GLOBALS['current_user']) && empty($GLOBALS['modListHeader']))
$GLOBALS['modListHeader'] = query_module_access_list($GLOBALS['current_user']); if (in_array($this->controller->module, $GLOBALS['modInvisList']) &&
((in_array('Activities', $GLOBALS['moduleList']) &&
in_array('Calendar',$GLOBALS['moduleList'])) &&
in_array($this->controller->module, $GLOBALS['modInvisListActivities']))
){
$this->controller->hasAccess = false;
return;
}
}
}
重点看一下对$GLOBALS['adminOnlyList']的判断。$GLOBALS['adminOnlyList']在inclue/modules.php中设置,指示哪些模块只有是管理员才有权限执行:
// index.php
// require_once('include/entryPoint.php')
// require_once('include/modules.php'); $adminOnlyList = array(
//module => list of actions (all says all actions are admin only)
//'Administration'=>array('all'=>1, 'SupportPortal'=>'allow'),
'Dropdown'=>array('all'=>1),
'Dynamic'=>array('all'=>1),
'DynamicFields'=>array('all'=>1),
'Currencies'=>array('all'=>1),
'EditCustomFields'=>array('all'=>1),
'FieldsMetaData'=>array('all'=>1),
'LabelEditor'=>array('all'=>1),
'ACL'=>array('all'=>1),
'ACLActions'=>array('all'=>1),
'ACLRoles'=>array('all'=>1),
'UpgradeWizard' => array('all' => 1),
'Studio' => array('all' => 1),
'Schedulers' => array('all' => 1),
);
SugarCRM如何检查控制器权限?的更多相关文章
- 安装帝国CMS遇到“修改php.ini,将:short_open_tag 设为 On”的解决方法+“建立目录不成功!请检查目录权限”问题
		
想用安装个帝国CMS来做个网站,于是下载了程序,上传到服务器上,但是在输入安装路径的时候却给出了如下图示: 您的PHP配置文件php.ini配置有问题,请按下面操作即可解决: 1.修改php.ini, ...
 - 关于使用WeUI在IE中提示“font-face 未能完成 OpenType 嵌入权限检查。权限必须是可安装的。”的问题
		
@font-face是css3中定义字体的规则. 首先,在使用weui时,在Chrome.Firefox下没有问题,但是在IE下提示“font-face 未能完成 OpenType 嵌入权限检查.权限 ...
 - 帝国CMS“建立目录不成功!请检查目录权限”的解决办法
		
初次安装帝国CMS就遇到了一个问题,在提交或者修改信息的时候提示“建立目录不成功!请检查目录权限”,无法生成页面.检查了文件夹的读写权限和用户访问权限,发现都一切正常.那么到底是哪里出错了呢? 其实是 ...
 - 帝国cms“建立目录不成功,请检查目录权限”的解决方法
		
就这个看似简单的问题我折腾了两天,百度看产生这个问题的原因有很多也很宽泛,大部分说的是初始化内置数据,但我出现“建立目录不成功,请检查目录权限”的原因估计只有少部分人会遇到. 内置初始化数据是你上传文 ...
 - Android权限安全(1)自定义,检查,使用权限
		
1.自定义权限: <!-- 定义自定义权限 --> <permission android:name="com.example.f6k5i8.checkpermission ...
 - 定时检查SetUID 权限文件列表的脚本文件
		
[root@localhost ~]# find / -perm -4000 -o -perm -2000 > /root/suid.list #-perm安装权限査找.-4000对应的是Set ...
 - Android 开发技巧 - Android 6.0 以上权限大坑和权限检查基类封装
		
简单介绍 关于运行时权限的说法,早在Google发布android 6.0的时候,大家也听得蛮多的.从用户的角度来讲,用户是受益方,更好的保护用户的意思,而对于开发者来说,无疑增加了工作量. 对于6. ...
 - 权限检查联系人ProfileProvider
		
每日一贴,今天的内容关键字为权限检查 ProfileProvider继承自AbstractContyactsProvider. 源代码请自行下载 每日一道理 书籍好比一架梯子,它能引领人们登上 ...
 - C语言,如何检查文件是否存在和权限的信息
		
按功能access,头文件io.h(linux通过使用unistd.h int access(const char *filename, int amode); amode參 ...
 
随机推荐
- 关于oracle存储过程需要注意的问题
			
在使用oracle存储过程时,有一些需要注意的地方,下面就来总结一下. 1.在oracle的存储过程中,数据表别名不能加as 也许是为了区分存储过程中的as,怕与过程中的as冲突. 如: select ...
 - [JSOI2017]原力(分块+map(hash))
			
题目描述 一个原力网络可以看成是一个可能存在重边但没有自环的无向图.每条边有一种属性和一个权值.属性可能是R.G.B三种当中的一种,代表这条边上 原力的类型.权值是一个正整数,代表这条边上的原力强度. ...
 - 某5道CF水题
			
1.PolandBall and Hypothesis 题面在这里! 大意就是让你找一个m使得n*m+1是一个合数. 首先对于1和2可以特判,是1输出3,是2输出4. 然后对于其他所有的n,我们都可以 ...
 - 【状压dp】Islands and Bridges
			
Islands and Bridges Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 11034 Accepted: 2 ...
 - 【数据结构(高效)/暴力】Parencodings
			
[poj1068] Parencodings Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 26686 Accepted ...
 - 【二分】【三分】【计算几何】XIII Open Championship of Y.Kupala Grodno SU Grodno, Saturday, April 29, 2017 Problem L. Lines and Polygon
			
题意:给你一个凸多边形,和多次询问,每次询问给你一条直线,问你这条直线与凸包上的顶点的最近距离是多少. 记当前询问的直线的斜率为K, 先找到与这条直线距离最远的两个点: 就把凸包所有的边当做有向直线进 ...
 - JDK源码学习笔记——String
			
1.学习jdk源码,从以下几个方面入手: 类定义(继承,实现接口等) 全局变量 方法 内部类 2.hashCode private int hash; public int hashCode() { ...
 - Problem I: 零起点学算法88——青年歌手大奖赛_评委会打分
			
#include<stdio.h> int main(void) { ],n,i; while(scanf("%d",&n)!=EOF) { n>& ...
 - FreeMarker输出$
			
FreeMarker如何输出$(美元符号) 使用${'$'} 如需要输出${user.id} 则${'$'}{user.id}
 - javacript总结
			
前端js总结 //getElementById函数 function $(id){ return document.getElementById(id); } //随机函数不包max //Math.f ...