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如何检查控制器权限?的更多相关文章

  1. 安装帝国CMS遇到“修改php.ini,将:short_open_tag 设为 On”的解决方法+“建立目录不成功!请检查目录权限”问题

    想用安装个帝国CMS来做个网站,于是下载了程序,上传到服务器上,但是在输入安装路径的时候却给出了如下图示: 您的PHP配置文件php.ini配置有问题,请按下面操作即可解决: 1.修改php.ini, ...

  2. 关于使用WeUI在IE中提示“font-face 未能完成 OpenType 嵌入权限检查。权限必须是可安装的。”的问题

    @font-face是css3中定义字体的规则. 首先,在使用weui时,在Chrome.Firefox下没有问题,但是在IE下提示“font-face 未能完成 OpenType 嵌入权限检查.权限 ...

  3. 帝国CMS“建立目录不成功!请检查目录权限”的解决办法

    初次安装帝国CMS就遇到了一个问题,在提交或者修改信息的时候提示“建立目录不成功!请检查目录权限”,无法生成页面.检查了文件夹的读写权限和用户访问权限,发现都一切正常.那么到底是哪里出错了呢? 其实是 ...

  4. 帝国cms“建立目录不成功,请检查目录权限”的解决方法

    就这个看似简单的问题我折腾了两天,百度看产生这个问题的原因有很多也很宽泛,大部分说的是初始化内置数据,但我出现“建立目录不成功,请检查目录权限”的原因估计只有少部分人会遇到. 内置初始化数据是你上传文 ...

  5. Android权限安全(1)自定义,检查,使用权限

    1.自定义权限: <!-- 定义自定义权限 --> <permission android:name="com.example.f6k5i8.checkpermission ...

  6. 定时检查SetUID 权限文件列表的脚本文件

    [root@localhost ~]# find / -perm -4000 -o -perm -2000 > /root/suid.list #-perm安装权限査找.-4000对应的是Set ...

  7. Android 开发技巧 - Android 6.0 以上权限大坑和权限检查基类封装

    简单介绍 关于运行时权限的说法,早在Google发布android 6.0的时候,大家也听得蛮多的.从用户的角度来讲,用户是受益方,更好的保护用户的意思,而对于开发者来说,无疑增加了工作量. 对于6. ...

  8. 权限检查联系人ProfileProvider

    每日一贴,今天的内容关键字为权限检查 ProfileProvider继承自AbstractContyactsProvider. 源代码请自行下载     每日一道理 书籍好比一架梯子,它能引领人们登上 ...

  9. C语言,如何检查文件是否存在和权限的信息

    按功能access,头文件io.h(linux通过使用unistd.h    int   access(const   char   *filename,   int   amode); amode參 ...

随机推荐

  1. javascript中的对象创建与继承

    js是一门基于原型的面向对象语言,与传统的面向对象如Java,C#相比,它在对象创建及继承上有自己独特的实现方式,本文主要描述js中对象创建及继承的一些实践. 1.对象创建 方式一:工厂模式创建对象 ...

  2. run()和start()的区别

    run没有启新的线程,start方法才会调用Thread的native的start0方法,start0会调用run方法,开启新的线程,博主这么做,不是多线程顺序执行,而是把业务阻塞在主线程里.请打印: ...

  3. BZOJ 1106 [POI2007]立方体大作战tet(树状数组)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=1106 [题目大意] 给定玩家一个有2n个元素的栈,元素一个叠一个地放置. 这些元素拥有 ...

  4. 【找规律】【DFS】Gym - 101174H - Pascal's Hyper-Pyramids

    二维下,如果把杨辉三角按照题目里要求的那样摆放,容易发现,第i行第j列的数(从0开始标号)是C(i+j,i)*C(j,j). 高维下也有类似规律,比如三维下,最后一层的数其实是C(i+j+k,i)*C ...

  5. php应用数据库连接中的单例模式

    所谓的单例模式简而言之就是某个类在运行过程中只有一个实例,并且能够自行实例化并为整个系统的运行提供这个实例.在数据库连接中使用单例模式实例化数据库连接对象主要是可以避免重复的实例化对象而造成资源的浪费 ...

  6. Android显示GIF动画 GifView

    android中显示gif动画原生态一般支持的不是很好,故找了一个开源的项目,现简单介绍如下: GifView 是一个为了解决android中现在没有直接显示gif的view,只能通过mediapla ...

  7. 【mysql】新方法修改数据库密码以及解决--ERROR 1045 (28000)的问题

    之前 有写过一篇修改mysql数据库的密码的一篇随笔, 地址是:http://www.cnblogs.com/sxdcgaq8080/p/5667124.html 但是此次采用原本的老方法,出现了问题 ...

  8. LookupError: unknown encoding: cp65001

    在CMD下解释运行python时出现LookupError: unknown encoding: cp65001错误(编码错误) 在cmd下chcp命令(大概是change codepage?)可查看 ...

  9. ubuntu安装elasticSearch及插件

    原文地址:http://www.niu12.com/article/18 前提 1.安装好Java1.8以上环境并配置好JAVA_HOME(elasticsearch运行环境) 2.node环境6.5 ...

  10. 天台人满为患,不如来看下这个Ramnit蠕虫DesktopLayer.exe分析

    今年的世界杯越来越看不懂,想去天台吹吹风都不一定有位置,心凉了,事儿还得做,先从网上抓个可疑样本压压惊!上手分析才发现并没有我想得那么简单…… 一.基本信息 MD5 ff5e1f27193ce51ee ...