public function edit($postArr)
 {
     if (!$postArr['id']) {
         return array('status' => -1, 'url' => 1, 'info' => '参数错误,id不存在.');
     }
     $addArr = array();
     if ($postArr['pwd']) {
         //如果设置密码
         if ($postArr['pwd'] != $postArr['pwd']) {
             return array('status' => -1, 'url' => 1, 'info' => '两次密码不一致');
         }
         $this->_utilUserSession = $this->getGlobal('util/session/UserSession', 'Util_UserSession');
         $addArr['pwd'] = $this->_utilUserSession->convertPwd($postArr['pwd']);
     }
     if (count($postArr['role'])) {
         $addArr['role'] = implode(',', $postArr['role']);
     }
     $addArr['login_count'] = $postArr['login_count'];
     $addArr['vuser'] = $postArr['vuser'];
     if ($this->update($addArr, "id={$postArr['id']}")) {
         return array('status' => 1, 'info' => '更新成功', 'url' => url('setup/user/index'));
     } else {
         return array('status' => -2, 'info' => '更新失败', 'url' => 1);
     }
 }
 /**
  * 获取用户模块
  */
 public function getUserModule()
 {
     $this->_utilUserSession = $this->getGlobal('util/session/UserSession', 'Util_UserSession');
     $userClass = $this->_utilUserSession->getUserClass();
     if (!$userClass instanceof Object) {
         return array();
     }
     $userRole = $userClass->role;
     $moduleList = params('act/module');
     $rbacEveryOne = config('RBAC_EVERYONE');
     //所有用户
     $rbacOnly = config('RBAC_ONLY');
     //登陆用户
     foreach ($moduleList as $key => &$val) {
         $val['url'] = url('index/index/left', array('module' => $val['module']));
         if (empty($val['act'])) {
             $val['checked'] = false;
             continue;
         }
         if ($val['act'] == $rbacEveryOne || $val['act'] == $rbacOnly) {
             $val['checked'] = true;
             continue;
         }
         $val['act'] = explode(',', $val['act']);
         $intersect = array_intersect($userRole, $val['act']);
         if (count($intersect)) {
             $val['checked'] = true;
         } else {
             $val['checked'] = false;
         }
     }
     return $moduleList;
 }
 public function edit($postArr)
 {
     if (empty($postArr['id'])) {
         return array('info' => '参数错误', 'status' => -1);
     }
     if (empty($postArr['title'])) {
         return array('info' => '标题不能为空', 'status' => -1);
     }
     if (empty($postArr['content'])) {
         return array('info' => '内容不能为空', 'status' => -1);
     }
     $editArr = array();
     $this->_utilUserSession = $this->getGlobal('util/session/UserSession', 'Util_UserSession');
     $userClass = $this->_utilUserSession->getUserClass();
     $editArr['title'] = $postArr['title'];
     $editArr['content'] = $postArr['content'];
     $editArr['type'] = $postArr['type'];
     $editArr['jump_url'] = $postArr['jump_url'] ? $postArr['jump_url'] : '0';
     $editArr['game_type'] = $postArr['game_type'];
     $editArr['is_top'] = $postArr['is_Top'];
     $editArr['user_id'] = $userClass->userId;
     $editArr['time'] = config('CURRENT_TIME');
     if ($this->update($editArr, "id='{$postArr['id']}'")) {
         return array('info' => '编辑资讯成功', 'status' => 1, 'url' => url('index/news/index'));
     } else {
         return array('info' => '编辑资讯失败', 'status' => -2);
     }
 }
 /**
  * 获取经过检测权限的菜单
  * @param $menus 菜单数组
  */
 public function getActMenus($menus)
 {
     if (!is_array($menus)) {
         return array();
     }
     $this->_userSession = $this->getGlobal('util/session/UserSession', 'Util_UserSession');
     foreach ($menus as $key => &$val) {
         if (isset($val['child'])) {
             if ($val['display'] == false) {
                 unset($menus[$key]);
                 continue;
             }
             if ($this->_userSession->checkAct($key) != 1) {
                 unset($menus[$key]);
                 continue;
             }
             foreach ($val['child'] as $childKey => &$childVal) {
                 if ($childVal['display'] == false) {
                     unset($val['child'][$childKey]);
                     continue;
                 }
                 if ($this->_userSession->checkAct($childKey) != 1) {
                     unset($val['child'][$childKey]);
                     continue;
                 }
                 $childVal['url'] = url(str_replace('_', '/', $childKey));
             }
         }
     }
     return $menus;
 }
 /**
  * 登录页面
  */
 public function cLogin()
 {
     if ($this->isPost()) {
         $this->_utilUserSession = $this->getGlobal('util/session/UserSession', 'Util_UserSession');
         $info = $this->_utilUserSession->login();
         if ($info['status'] == 1) {
             $this->success('登录成功', url('index/index/index'));
         } else {
             $this->error('登录失败', url('index/index/login'));
         }
     } else {
         $this->display();
     }
 }
 /**
  * 增加用户
  */
 public function cAdd()
 {
     if ($this->isPost()) {
         $this->_utilUserSession = $this->getGlobal('util/session/UserSession', 'Util_UserSession');
         $result = $this->_utilUserSession->createUser();
         if ($result['status'] == 1) {
             $this->success($result['info'], $result['url']);
         } else {
             $this->error($result['info'], $result['url']);
         }
     } else {
         $this->display(VIEW_PAGE);
     }
 }
 /**
  * 初始化
  */
 public function cIndex()
 {
     $this->_userSession = $this->getGlobal('util/session/UserSession', 'Util_UserSession');
     define('VIEW_PAGE', 'system/common/main');
     //默认显示主页面
     define('SUCCESS', 1);
     define('ERROR', -2);
     define('WARNING', -1);
     define('CUR_ACT', __MODULE__ . '_' . __CONTROL__ . '_' . __ACTION__);
     $act = $this->_userSession->checkAct(CUR_ACT);
     $msg = array(-1 => '您没有权限', -2 => '您还未登录');
     $url = array(-1 => 1, -2 => url('index/index/login'));
     if ($act != 1) {
         $this->error($msg[$act], $url[$act]);
     }
 }
 /**
  * 是否登录
  * @return bollean
  */
 public function isLogin()
 {
     if (is_numeric(self::$_curLoginUserId) && is_string(self::$_curLoginUser) && is_string(self::$_curLoginIp)) {
         return true;
     }
     $param = $this->getC(config('USER_COOKIE_KEY'));
     if (!$param) {
         return false;
     }
     loadCore('crypt/Des');
     $param = Des::decrypt($param, config('USER_KEY'));
     list($userId, $user, $ip) = explode('|', $param);
     if (is_numeric($userId) && is_string($user) && is_string($ip)) {
         self::$_curLoginUserId = $userId;
         self::$_curLoginUser = $user;
         self::$_curLoginIp = $ip;
         return true;
     } else {
         return false;
     }
 }