public function checkUserAdmin($accessRole_id = '')
 {
     $session = new CHttpSession();
     $session->open();
     $user_id = $session['uid'];
     //        App::pr($user_id,2);
     $user_rid = $session['rid'];
     if (!empty($user_id)) {
         if (!empty($accessRole_id)) {
             //            App::pr($accessRole_id,2);
             $record = UserMaster::model()->find("u_id = {$user_id} AND ur_id IN({$accessRole_id})");
             //            App::pr($record,2);
             if (!empty($record)) {
                 return true;
             } else {
                 return false;
             }
         } else {
             $record = UserMaster::model()->findByPk($user_id);
             if (!empty($record)) {
                 return true;
             } else {
                 return false;
             }
         }
     } else {
         return FALSE;
     }
 }
 /**
  * Authenticates a user.
  * The example implementation makes sure if the username and password
  * are both 'demo'.
  * In practical applications, this should be changed to authenticate
  * against some persistent user identity storage (e.g. database).
  * @return boolean whether authentication succeeds.
  */
 public function authenticate()
 {
     //        echo '<pre>';print_r($this);
     $user = UserMaster::model()->findByAttributes(array('user_name' => $this->username));
     //        echo '<pre>';print_r($user);die;
     if ($user === null) {
         // No user found!
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($user->user_pass !== base64_encode($this->password)) {
             // Invalid password!
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             /**
              * @desc: Start the Session Here
              */
             $session = new CHttpSession();
             $session->open();
             /**
              * @desc: User Full Name
              */
             $session["fullname"] = ucfirst($user->first_name) . " " . ucfirst($user->last_name);
             /**
              * @desc: User ID
              */
             $session["uid"] = $user->u_id;
             /**
              * @desc: User Role Id for ACL Management
              */
             $session["rid"] = $user->ur_id;
             /**
              * @desc : User name
              */
             $session["uname"] = $user->first_name;
             $this->setState('id', $user->ur_id);
             $this->errorCode = self::ERROR_NONE;
         }
     }
     return !$this->errorCode;
 }
 /**
  * Returns the static model of the specified AR class.
  * @param string $className active record class name.
  * @return UserType the static model class
  */
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return UserMaster the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = UserMaster::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }