本文整理汇总了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;
}
}
}