Exemple #1
0
 /**
  * 查看当前用户是否有权限访问
  * @param $style 12为用户权限2级
  * @return true为成功,false为失败
  */
 public static function userCategorySeleteByStyle($style = NULL)
 {
     $message = true;
     if (!empty($_SESSION['userid'])) {
         $userid = $_SESSION['userid'];
         $user = beu_users::model()->findByPk($userid);
         if ($user == null) {
             $message = false;
         } else {
             if (!empty($user['permissions'])) {
                 $permissions = json_decode($user['permissions'], true);
                 if (count($permissions) > 0) {
                     if (!in_array($style, $permissions)) {
                         $message = false;
                     }
                 }
             } else {
                 $message = false;
             }
         }
     } else {
         $message = false;
     }
     return $message;
 }
Exemple #2
0
 /**
  * 验证用户名是否可用
  **/
 public static function VerificationUserName($username)
 {
     $ret = array('status' => 0, 'msg' => '');
     try {
         if (empty($username)) {
             throw new Exception('用户名不能为空');
         }
         $user = beu_users::model()->findAll('username=:username', array(':username' => $username));
         if (!empty($user)) {
             throw new Exception('用户名已存在,不可用!');
         }
         $ret['status'] = 1;
     } catch (Exception $e) {
         $ret['msg'] = $e->getMessage();
     }
     return $ret;
 }