本文整理汇总了PHP中role::verify方法的典型用法代码示例。如果您正苦于以下问题:PHP role::verify方法的具体用法?PHP role::verify怎么用?PHP role::verify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类role
的用法示例。
在下文中一共展示了role::verify方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set_order
/**
* 设定菜单的排序
*/
public function set_order()
{
//初始化返回数组
$return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
/* 验证是否可以操作 */
if (!role::verify('product_feature')) {
$return_struct['msg'] = Kohana::lang('o_global.permission_enough');
exit(json_encode($return_struct));
}
$request_data = $this->input->get();
$id = isset($request_data['id']) ? $request_data['id'] : '';
$order = isset($request_data['order']) ? $request_data['order'] : '';
if (empty($id) || empty($order) && $order != 0) {
$return_struct['msg'] = Kohana::lang('o_global.bad_request');
exit(json_encode($return_struct));
}
if (!is_numeric($order) || $order < 0) {
$return_struct['msg'] = Kohana::lang('o_global.position_rule');
exit(json_encode($return_struct));
}
$attribute_service = AttributeService::get_instance();
$attribute_service->set($id, array('order' => $order));
$return_struct = array('status' => 1, 'code' => 200, 'msg' => Kohana::lang('o_global.position_success'), 'content' => array('order' => $order));
exit(json_encode($return_struct));
}
示例2: set_order
/**
* 设定菜单的排序
*/
public function set_order()
{
//初始化返回数组
$return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
$request_data = $this->input->get();
$id = isset($request_data['id']) ? $request_data['id'] : '';
$order = isset($request_data['order']) ? $request_data['order'] : '';
/* 验证是否可以操作 */
if (!role::verify('inquiry_subject', site::id(), 0)) {
$return_struct['msg'] = Kohana::lang('o_global.permission_enough');
exit(json_encode($return_struct));
}
$validation = Validation::factory($request_data)->pre_filter('trim')->add_rules('id', 'required', 'digit')->add_rules('order', 'required', 'digit');
if (!$validation->validate()) {
$return_struct['msg'] = Kohana::lang('o_global.position_rule');
exit(json_encode($return_struct));
}
if (empty($id) || empty($order) && $order != 0) {
$return_struct['msg'] = Kohana::lang('o_global.bad_request');
exit(json_encode($return_struct));
}
if (!is_numeric($order) || $order < 0) {
$return_struct['msg'] = Kohana::lang('o_global.position_rule');
exit(json_encode($return_struct));
}
$inquieysubject_service = InquirysubjectService::get_instance();
$inquieysubject_service->set($id, array('position' => $order));
$return_struct = array('status' => 1, 'code' => 200, 'msg' => Kohana::lang('o_global.position_success'), 'content' => array('order' => $order));
exit(json_encode($return_struct));
}
示例3: show_toggle
public function show_toggle()
{
$return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
try {
//权限验证
if (!role::verify('user_attribute', $this->site_id, 0)) {
$return_struct['msg'] = Kohana::lang('o_global.permission_enough');
exit(json_encode($return_struct));
}
//收集信息
$request_data = $this->input->get();
if (empty($request_data) || !isset($request_data['attribute_id'])) {
if ($this->is_ajax_request()) {
$return_struct['msg'] = kohana::lang('o_user_attribute.data_lost');
$return_struct['code'] = 400;
exit(json_encode($return_struct));
} else {
throw new MyRuntimeException(kohana::lang('o_user_attribute.data_lost'), 400);
}
}
//调用底层Service
$user_attribute_service = User_attributeService::get_instance();
$user_attribute = $user_attribute_service->get($request_data['attribute_id']);
if (empty($user_attribute)) {
if ($this->is_ajax_request()) {
$return_struct['msg'] = kohana::lang('o_user_attribute.user_attribute_not_exist');
$return_struct['code'] = 400;
exit(json_encode($return_struct));
} else {
throw new MyRuntimeException(kohana::lang('o_user_attribute.user_attribute_not_exist'), 400);
}
}
$arrtibute_show = array('attribute_show' => 1 - $user_attribute['attribute_show']);
$user_attribute_service->set($user_attribute['id'], $arrtibute_show);
//* 补充&修改返回结构体 */
$return_struct['status'] = 1;
$return_struct['code'] = 200;
$return_struct['msg'] = kohana::lang('o_user_attribute.operator_success');
$return_struct['content'] = $arrtibute_show;
//* 请求类型 */
if ($this->is_ajax_request()) {
// ajax 请求
// json 输出
exit(json_encode($return_struct));
} else {
// html 输出
$this->template->return_struct = $return_struct;
$content = new View('info');
$this->template->content = $content;
//* 请求结构数据绑定 */
$this->template->content->request_data = $request_data;
//* 返回结构体绑定 */
$this->template->content->return_struct = $return_struct;
}
// end of request type determine
} catch (MyRuntimeException $ex) {
$return_struct['status'] = 0;
$return_struct['code'] = $ex->getCode();
$return_struct['msg'] = $ex->getMessage();
//TODO 异常处理
//throw $ex;
if ($this->is_ajax_request()) {
$this->template->content = $return_struct;
} else {
$this->template->return_struct = $return_struct;
$content = new View('info');
$this->template->content = $content;
//* 请求结构数据绑定 */
$this->template->content->request_data = $request_data;
//* 返回结构体绑定 */
$this->template->content->return_struct = $return_struct;
}
}
}
示例4: set_order
/**
* 设定菜单的排序
*/
public function set_order()
{
//初始化返回数组
$return_struct = array('status' => 0, 'code' => 501, 'msg' => 'Not Implemented', 'content' => array());
$request_data = $this->input->get();
$id = isset($request_data['id']) ? $request_data['id'] : '';
$order = isset($request_data['order']) ? $request_data['order'] : '';
/* 验证是否可以操作 */
if (!role::verify('doc_category', site::id(), 0)) {
$return_struct['msg'] = Kohana::lang('o_global.permission_enough');
exit(json_encode($return_struct));
}
if (empty($id) || empty($order) && $order != 0) {
$return_struct['msg'] = Kohana::lang('o_global.bad_request');
exit(json_encode($return_struct));
}
if (!is_numeric($order) || $order < 0) {
$return_struct['msg'] = Kohana::lang('o_global.position_rule');
exit(json_encode($return_struct));
}
if (Mydoc_category::instance()->set_order($id, $order)) {
$return_struct = array('status' => 1, 'code' => 200, 'msg' => Kohana::lang('o_global.position_success'), 'content' => array('order' => $order));
} else {
$return_struct['msg'] = Kohana::lang('o_global.position_error');
}
exit(json_encode($return_struct));
}