本文整理匯總了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();
}