本文整理匯總了PHP中util::isAccess方法的典型用法代碼示例。如果您正苦於以下問題:PHP util::isAccess方法的具體用法?PHP util::isAccess怎麽用?PHP util::isAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類util
的用法示例。
在下文中一共展示了util::isAccess方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: console
/**
* 控製台命令
*/
public function console()
{
$returnStruct = array('status' => 0, 'code' => 501, 'msg' => _('Not Implemented'), 'content' => array());
try {
//* 初始化返回數據 */
$returnStatus = 1;
$returnCode = 200;
$returnMessage = '';
$returnData = array();
//* 收集請求數據 ==根據業務邏輯定製== */
$requestData = $this->input->post();
//* 實現功能後屏蔽此異常拋出 */
//throw new MyRuntimeException(_('Not Implemented'),501);
//* 權限驗證,數據驗證,邏輯驗證 ==根據業務邏輯定製== */
if (util::isAccess(array(Logon::$MGR_ROLE_LABEL_SYS_ADMIN), array(Logon::$MGR_ROLE_LABEL_DENIED, Logon::$MGR_ROLE_LABEL_GUEST), $this->getMgrRole()) == FALSE) {
throw new MyRuntimeException(_('Access Denied'), 403);
}
//* 權限驗證 ==根據業務邏輯定製== */
//* 數據驗證 ==根據業務邏輯定製== */
//* 邏輯驗證 ==根據業務邏輯定製== */
// 調用底層服務
// 執行業務邏輯
//* 補充&修改返回結構體 */
$returnStruct['status'] = $returnStatus;
$returnStruct['code'] = $returnCode;
$returnStruct['msg'] = $returnMessage;
$returnStruct['content'] = $returnData;
//* 請求類型 */
if ($this->isAjaxRequest()) {
throw new MyRuntimeException(_('Not Implemented'), 501);
// ajax 請求
// json 輸出
$this->template->content = $returnStruct;
} else {
// html 輸出
//* 模板輸出 */
$this->template = new View('layout/base_html');
$this->template->returnStruct = $returnStruct;
$content = new View($this->packageName . '/' . $this->className . '/' . __FUNCTION__);
//* 變量綁定 */
$this->template->title = Lemon::config('site.name');
$this->template->content = $content;
//* 請求結構數據綁定 */
$this->template->content->requestData = $requestData;
//* 返回結構體綁定 */
$this->template->content->returnStruct = $returnStruct;
//:: 當前應用專用數據
$this->template->content->title = Lemon::config('site.name');
$addonJsLinkContext = '';
$addonJsLinkContext .= '<script type="text/javascript" src="http://res.zr4u.com/res/js/jquery/jquery-1.4.2.min.js"></script>' . PHP_EOL;
$addonJsLinkContext .= '<script type="text/javascript" src="http://res.zr4u.com/res/js/jquery/plugins/jquery.terminal.min.js"></script>' . PHP_EOL;
$this->template->addonJsLinkContext = $addonJsLinkContext;
$addonCssContentContext = '';
$addonCssContentContext .= 'body { margin: 0;}' . PHP_EOL;
$this->template->addonCssContentContext = $addonCssContentContext;
}
// end of request type determine
} catch (MyRuntimeException $ex) {
$returnStruct['status'] = 0;
$returnStruct['code'] = $ex->getCode();
$returnStruct['msg'] = $ex->getMessage();
//TODO 異常處理
//throw $ex;
if ($this->isAjaxRequest()) {
$this->template->content = $returnStruct;
} else {
$this->template->returnStruct = $returnStruct;
$content = new View('info');
$this->template->content = $content;
//* 請求結構數據綁定 */
$this->template->content->requestData = $requestData;
//* 返回結構體綁定 */
$this->template->content->returnStruct = $returnStruct;
}
}
}
示例2: delete
/**
* 刪除數據 action
*/
public function delete()
{
$returnStruct = array('status' => 0, 'code' => 501, 'msg' => _('Not Implemented'), 'content' => array());
try {
// 是否調用本地服務
$useLocalService = TRUE;
//$useLocalService = FALSE;
//* 初始化返回數據 */
$returnStatus = 1;
$returnCode = 200;
$returnMessage = '';
$returnData = array();
//* 收集請求數據 ==根據業務邏輯定製== */
$requestData = $this->input->get();
//* 實現功能後屏蔽此異常拋出 */
//throw new MyRuntimeException(_('Not Implemented'),501);
//* 權限驗證,數據驗證,邏輯驗證 ==根據業務邏輯定製== */
//if(util::isAccess(array(Logon::$MGR_ROLE_LABEL_SYS_ADMIN,), array(Logon::$USER_ROLE_LABEL_DENIED,Logon::$USER_ROLE_LABEL_GUEST), $this->getUserRoleLabel())==FALSE){
// throw new MyRuntimeException(_('Access Denied'),403);
//}
if (util::isAccess('*', array(Logon::$USER_ROLE_LABEL_DENIED), $this->getUserRoleLabel()) == FALSE) {
throw new MyRuntimeException(_('Access Denied'), 403);
}
//* 權限驗證 ==根據業務邏輯定製== */
//* 數據驗證 ==根據業務邏輯定製== */
if (!isset($requestData['id']) || empty($requestData['id']) || !is_numeric($requestData['id'])) {
throw new MyRuntimeException(_('Bad Request,id required'), 400);
}
//* 邏輯驗證 ==根據業務邏輯定製== */
// 調用底層服務
!isset($servRouteInstance) && ($servRouteInstance = ServRouteInstance::getInstance(ServRouteConfig::getInstance()));
// 執行業務邏輯
// TODO 根據數據特征定製對應的服務實例
if ($useLocalService == TRUE) {
!isset($attachmentService) && ($attachmentService = Attachment_Service::getInstance($servRouteInstance));
} else {
require_once Lemon::find_file('vendor', 'phprpc/phprpc_client', TRUE);
!isset($attachmentService) && ($attachmentService = new PHPRPC_Client(Lemon::config('phprpc.remote.Attachment.host')));
!isset($phprpcApiKey) && ($phprpcApiKey = Lemon::config('phprpc.remote.Attachment.apiKey'));
}
try {
if ($useLocalService == TRUE) {
$attachmentService->removeAttachmentDataByAttachmentId($requestData['id']);
} else {
$args = array($requestData['id']);
$sign = md5(json_encode($args) . $phprpcApiKey);
$attachmentService->phprpc_removeAttachmentDataByAttachmentId($requestData['id'], $sign);
}
} catch (MyRuntimeException $ex) {
//* ==根據業務邏輯定製== */
//FIXME 根據service層的異常做一些對應處理並拋出用戶友好的異常Message
throw $ex;
}
$returnMessage = _('Sucess');
//* 補充&修改返回結構體 */
$returnStruct['status'] = $returnStatus;
$returnStruct['code'] = $returnCode;
$returnStruct['msg'] = $returnMessage;
$returnStruct['content'] = $returnData;
//* 請求類型 */
if ($this->isAjaxRequest()) {
// ajax 請求
// json 輸出
$this->template->content = $returnStruct;
} else {
// html 輸出
//* 模板輸出 */
$this->template->returnStruct = $returnStruct;
$content = new View('info');
//* 變量綁定 */
$this->template->title = Lemon::config('site.name');
$this->template->content = $content;
//* 請求結構數據綁定 */
$this->template->content->requestData = $requestData;
//* 返回結構體綁定 */
$this->template->content->returnStruct = $returnStruct;
//:: 當前應用專用數據
$this->template->content->title = Lemon::config('site.name');
}
// end of request type determine
} catch (MyRuntimeException $ex) {
$returnStruct['status'] = 0;
$returnStruct['code'] = $ex->getCode();
$returnStruct['msg'] = $ex->getMessage();
//TODO 異常處理
//throw $ex;
if ($this->isAjaxRequest()) {
$this->template->content = $returnStruct;
} else {
$this->template->returnStruct = $returnStruct;
$content = new View('info');
$this->template->content = $content;
//* 請求結構數據綁定 */
$this->template->content->requestData = $requestData;
//* 返回結構體綁定 */
$this->template->content->returnStruct = $returnStruct;
}
//.........這裏部分代碼省略.........
示例3: attachment
/**
* rpc服務
*/
public function attachment()
{
$returnStruct = array('status' => 0, 'code' => 501, 'msg' => _('Not Implemented'), 'content' => array());
try {
//* 初始化返回數據 */
$returnStatus = 1;
$returnCode = 200;
$returnMessage = '';
$returnData = array();
//* 收集請求數據 ==根據業務邏輯定製== */
$requestData = $this->input->get();
//* 實現功能後屏蔽此異常拋出 */
//throw new MyRuntimeException(_('Not Implemented'),501);
//* 權限驗證,數據驗證,邏輯驗證 ==根據業務邏輯定製== */
//if(util::isAccess(array(Logon::$MGR_ROLE_LABEL_SYS_ADMIN,), array(Logon::$USER_ROLE_LABEL_DENIED,Logon::$USER_ROLE_LABEL_GUEST), $this->getUserRoleLabel())==FALSE){
// throw new MyRuntimeException(_('Access Denied'),403);
//}
if (util::isAccess('*', array(Logon::$USER_ROLE_LABEL_DENIED), $this->getUserRoleLabel()) == FALSE) {
throw new MyRuntimeException(_('Access Denied'), 403);
}
//* 權限驗證 ==根據業務邏輯定製== */
//* 數據驗證 ==根據業務邏輯定製== */
//* 邏輯驗證 ==根據業務邏輯定製== */
// 調用底層服務
!isset($servRouteInstance) && ($servRouteInstance = ServRouteInstance::getInstance(ServRouteConfig::getInstance()));
// 執行業務邏輯
require_once Lemon::find_file('vendor', 'phprpc/phprpc_server', TRUE);
$server = new PHPRPC_Server();
$server->add(array('phprpc_addAttachmentFileData', 'phprpc_getAttachmentDataById', 'phprpc_getStoreDataByStoreId', 'phprpc_getStoreDataByAttachmentId', 'phprpc_removeAttachmentDataByAttachmentId', 'phprpc_getStoreInfoByStoreId'), Attachment_Service::getInstance());
$server->start();
exit;
throw new MyRuntimeException(_('Internal Error'), 500);
//* 補充&修改返回結構體 */
$returnStruct['status'] = $returnStatus;
$returnStruct['code'] = $returnCode;
$returnStruct['msg'] = $returnMessage;
$returnStruct['content'] = $returnData;
//* 請求類型 */
if ($this->isAjaxRequest()) {
// ajax 請求
// json 輸出
$this->template->content = $returnStruct;
} else {
// html 輸出
//* 模板輸出 */
$this->template->returnStruct = $returnStruct;
$content = new View('info');
//* 變量綁定 */
$this->template->title = Lemon::config('site.name');
$this->template->content = $content;
//* 請求結構數據綁定 */
$this->template->content->requestData = $requestData;
//* 返回結構體綁定 */
$this->template->content->returnStruct = $returnStruct;
//:: 當前應用專用數據
$this->template->content->title = Lemon::config('site.name');
}
// end of request type determine
} catch (MyRuntimeException $ex) {
$returnStruct['status'] = 0;
$returnStruct['code'] = $ex->getCode();
$returnStruct['msg'] = $ex->getMessage();
//TODO 異常處理
//throw $ex;
if ($this->isAjaxRequest()) {
$this->template->content = $returnStruct;
} else {
$this->template->returnStruct = $returnStruct;
$content = new View('info');
$this->template->content = $content;
//* 請求結構數據綁定 */
$this->template->content->requestData = $requestData;
//* 返回結構體綁定 */
$this->template->content->returnStruct = $returnStruct;
}
}
}
示例4: info
public function info()
{
$returnStruct = array('status' => 0, 'code' => 501, 'msg' => _('Not Implemented'), 'content' => array());
try {
//* 初始化返回數據 */
$returnStatus = 1;
$returnCode = 200;
$returnMessage = '';
$returnData = array();
//* 收集請求數據 ==根據業務邏輯定製== */
$requestData = $this->input->get();
//* 實現功能後屏蔽此異常拋出 */
throw new MyRuntimeException(_('Not Implemented'), 501);
//* 權限驗證,數據驗證,邏輯驗證 ==根據業務邏輯定製== */
if (util::isAccess('*', array(Logon::$USER_ROLE_LABEL_DENIED, Logon::$USER_ROLE_LABEL_GUEST), $this->getUserRoleLabel()) == FALSE) {
throw new MyRuntimeException(_('Access Denied'), 403);
}
//* 權限驗證 ==根據業務邏輯定製== */
//* 數據驗證 ==根據業務邏輯定製== */
//* 邏輯驗證 ==根據業務邏輯定製== */
// 調用底層服務
// 執行業務邏輯
//* 補充&修改返回結構體 */
$returnStruct['status'] = $returnStatus;
$returnStruct['code'] = $returnCode;
$returnStruct['msg'] = $returnMessage;
$returnStruct['content'] = $returnData;
//* 請求類型 */
if ($this->isAjaxRequest()) {
// ajax 請求
// json 輸出
$this->template->content = $returnStruct;
} else {
// html 輸出
//* 模板輸出 */
$this->template->returnStruct = $returnStruct;
$content = new View('info');
//* 變量綁定 */
$this->template->title = Lemon::config('site.name');
$this->template->content = $content;
//* 請求結構數據綁定 */
$this->template->content->requestData = $requestData;
//* 返回結構體綁定 */
$this->template->content->returnStruct = $returnStruct;
//:: 當前應用專用數據
$this->template->content->title = Lemon::config('site.name');
}
// end of request type determine
} catch (MyRuntimeException $ex) {
$returnStruct['status'] = 0;
$returnStruct['code'] = $ex->getCode();
$returnStruct['msg'] = $ex->getMessage();
//TODO 異常處理
//throw $ex;
if ($this->isAjaxRequest()) {
$this->template->content = $returnStruct;
} else {
$this->template->returnStruct = $returnStruct;
$content = new View('info');
$this->template->content = $content;
//* 請求結構數據綁定 */
$this->template->content->requestData = $requestData;
//* 返回結構體綁定 */
$this->template->content->returnStruct = $returnStruct;
}
}
}