本文整理汇总了PHP中CRequest::getController方法的典型用法代码示例。如果您正苦于以下问题:PHP CRequest::getController方法的具体用法?PHP CRequest::getController怎么用?PHP CRequest::getController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRequest
的用法示例。
在下文中一共展示了CRequest::getController方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkRight
/**
* 是否有权限
*/
public static function checkRight($thisRoute = null)
{
// 用户资源
$userData = CSession::get('user');
if ($userData['groupId'] == 1) {
return true;
}
$userRightList = isset($userData['rightAll']) ? $userData['rightAll'] : array();
// 附加公共资源
array_push($userRightList, 'system@welcome');
array_push($userRightList, 'system@navList');
array_push($userRightList, 'system@addNav');
array_push($userRightList, 'system@addNavHandle');
array_push($userRightList, 'system@ajaxAddNav');
array_push($userRightList, 'system@editNav');
array_push($userRightList, 'system@editNavHandle');
array_push($userRightList, 'system@delNav');
array_push($userRightList, 'system@changeMyPassword');
array_push($userRightList, 'system@changeMyPassHandle');
array_push($userRightList, 'adminRole@messageCenterForClient');
array_push($userRightList, 'system@seeHelp');
// 转小写
foreach ($userRightList as $key => $val) {
$userRightList[$key] = strtolower($val);
}
// 获取当前请求的路由
if ($thisRoute == null) {
$route = CRequest::getController() . '@' . str_replace(CConfig::getInstance()->load('ACTION_PREFIX'), '', CRequest::getAction());
} else {
$route = $thisRoute;
}
return in_array(strtolower($route), $userRightList);
}
示例2: display
public function display($templateName = '', $isCache = false, $num = '')
{
if (empty($templateName)) {
$templateName = CRequest::getController() . '/' . str_replace(CConfig::getInstance()->load('ACTION_PREFIX'), '', CRequest::getAction());
}
parent::display($templateName, $isCache, $num);
}
示例3: setInitData
/**
* 设置基础数据
*/
public static function setInitData($viewObject)
{
$prefix = CConfig::getInstance()->load('ACTION_PREFIX');
$viewObject->assign('thisUrl', urlencode(CRequest::getUrl()));
$viewObject->assign('base64Url', CEncrypt::safe_b64encode(CRequest::getUrl()));
$viewObject->assign('controller', CRequest::getController());
$viewObject->assign('action', CRequest::getAction());
$viewObject->assign('actionPre', $prefix);
$viewObject->assign('ip', CRequest::getIp());
$viewObject->assign('module', CRequest::getModule());
$viewObject->assign('time', time());
$viewObject->assign('sessionID', session_id());
$viewObject->assign('path', CRequest::getPath());
$viewObject->assign('staticUrl', CConfig::getInstance('site')->load('staticUrl'));
$viewObject->assign('uploadStaticUrl', CConfig::getInstance('site')->load('uploadStaticUrl'));
$viewObject->assign('siteName', CConfig::getInstance('site')->load('siteName'));
}
示例4: Action_editRole
/**
* 编辑角色权限
*/
public function Action_editRole()
{
$id = $this->Args('id', 'int');
if ($_POST) {
// 变动参数
$addData['rightList'] = implode(',', (array) $this->Args('rights', 'array', 'post', true));
// 产品 渠道
$addData['parent_id'] = $this->Args('parent_id', 'int');
if ($addData['parent_id'] == 0) {
// 判断是否是超级管理员
$userData = CSession::get('user');
if ($userData['groupData']['gid'] != 1) {
$this->displayAjax(false, '您不是超级管理员账户,您无法创建顶级角色分组');
}
}
$status = CModel::factory('adminRoleModel')->update($addData, array('gid' => $id));
if (false == $status) {
$errorMessage = CDatabase::getDatabase()->errorInfo();
$errorMessage = isset($errorMessage[2]) ? $errorMessage[2] : '';
}
$this->assignAjax('redirect_url', $this->createUrl('index', CRequest::getController()));
$this->displayAjax(true, '更新成功');
}
$list = CModel::factory('adminRoleModel')->getCategoryTreeList();
// 过滤起可控的管理角色
$list = CModel::factory('adminRoleModel')->filterUserRole($list);
$rightData = CModel::factory('adminRightsModel')->getAllRights();
// var_dump($rightData);
$rightArray = array();
$rightUndefined = array();
foreach ($rightData as $key => $item) {
preg_match('/\\[.*?\\]/', $item['name'], $localPre);
if (isset($localPre[0])) {
$arrayKey = trim($localPre[0], '[]');
$rightArray[$arrayKey][] = $item;
} else {
$rightUndefined[] = $item;
}
}
// 获取该角色信息
$data = CModel::factory('adminRoleModel')->getUserRole($id);
if ($data) {
$data['rightList'] = explode(',', $data['rightList']);
}
// 按照权限过滤资源表
$rightArray = CModel::factory('adminRightsModel')->filterRight($rightArray);
$this->assign('list', $list);
$this->assign('id', $id);
$this->assign('data', $data);
$this->assign('rightArray', $rightArray);
// []中匹配正确的权限资源
$this->assign('rightUndefined', $rightUndefined);
// 未被定义的权限资源
$this->display();
}