Exemplo n.º 1
0
 private function throwMsgCheck($str)
 {
     $msg = NULL;
     foreach (func_get_args() as $v) {
         $split = explode("/", $v);
         switch ($split[0]) {
             case "is_login":
                 is_login() or $msg = "你必须登录才能操作";
                 break;
             case "is_post":
                 req()->is_post() or $msg = "必须使用POST请求访问";
                 break;
             case "is_get":
                 req()->is_get() or $msg = "必须使用GET请求访问";
                 break;
             case "is_active":
                 is_login() && login_user()->is_active() or $msg = "必须的激活用户才能访问";
                 break;
             case "un_active":
                 is_login() && !login_user()->is_active() or $msg = "必须的未激活用户才能访问";
                 break;
             case "edit_email":
                 edit_email_action() or $msg = "只有指定用户可修改邮箱";
                 break;
             case "power":
                 is_login() && login_user()->Permission($split[1]) or $msg = "你的访问权限不足";
                 break;
             case 'is_ajax':
                 req()->is_ajax() or $msg = "必须使用AJAX请求访问";
                 break;
             default:
                 $msg = "未知异常信息";
         }
         if ($msg !== NULL) {
             throw new \Exception($msg);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * 获取用户中心菜单
  * @return array
  */
 private function get_user_menu_list()
 {
     $menu = [['url' => ['Photo'], 'name' => '图片中心', 'sub' => [['url' => ['Photo', 'add_pic'], 'name' => '添加图片'], ['url' => ['Photo', 'edit_pic'], 'name' => '编辑图片', 'hide' => true], ['url' => ['Photo', 'add_gallery'], 'name' => '添加图集'], ['url' => ['Photo', 'edit_gallery'], 'name' => '编辑图集', 'hide' => true], ['url' => ['Photo', 'list_gallery'], 'name' => '图集管理'], ['url' => ['Photo', 'gallery_comment'], 'name' => '图集评论'], ['url' => ['Photo', 'list_pic'], 'name' => '图片管理'], ['url' => ['Photo', 'picture_comment'], 'name' => '图片评论']]], ['url' => ['Follow'], 'name' => '我的关注', 'sub' => [['url' => ['Follow', 'me'], 'name' => '关注的用户'], ['url' => ['Follow', 'gallery'], 'name' => '关注的图集'], ['url' => ['Follow', 'ta'], 'name' => '粉丝'], ['url' => ['Follow', 'mutual'], 'name' => '互相关注'], ['url' => ['Follow', 'feed'], 'name' => '我的动态'], ['url' => ['Follow', 'comment'], 'name' => '我的评论']]], ['url' => ['User'], 'name' => '用户中心', 'sub' => [['name' => '编辑信息', 'url' => ['User', 'edit_info']], ['name' => '切换头像', 'url' => ['User', 'edit_avatar']], ['name' => '密码与安全', 'url' => ['User', 'password']], ['name' => '更换邮箱', 'url' => ['User', 'email'], 'hide' => !edit_email_action()], ['name' => '激活用户', 'url' => ['User', 'activation'], 'hide' => login_user()->is_active()]]], ['name' => '消息中心', 'url' => ['Message'], 'sub' => [['name' => '收信箱', 'url' => ['Message', 'inbox']], ['name' => '发信箱', 'url' => ['Message', 'outbox']], ['name' => '通知设置', 'url' => ['Message', 'option']]]]];
     if (login_user()->Permission('Posts')) {
         $menu[] = ['name' => '文章发布', 'url' => ['Posts'], 'sub' => [['name' => '管理', 'url' => ['Posts', 'management']], ['name' => '评论', 'url' => ['Posts', 'comment']], ['name' => '编辑', 'url' => ['Posts', 'edit'], 'hide' => true]]];
     }
     return hook()->apply('Theme_get_menu', $menu);
 }