/** * Authenticates a user. * @return boolean whether authentication succeeds. */ public function authenticate() { if ($this->user_type == 1 || $this->user_type == 2) { $criteria = new CDbCriteria(); $criteria->condition = 'LOWER(mid)=' . strtolower($this->username) . ' AND management_user_level_id=' . $this->user_type; $user = Management::model()->find($criteria); } else { if ($this->user_type == 4) { $user = Doctor::model()->find('LOWER(did)=?', array(strtolower($this->username))); } else { if ($this->user_type == 3) { $user = Patient::model()->find('LOWER(pid)=?', array(strtolower($this->username))); } else { $user = Nurses::model()->find('LOWER(nid)=?', array(strtolower($this->username))); } } } if ($user === null) { $this->errorCode = self::ERROR_USERNAME_INVALID; } else { if (!($user->pass == $this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { if ($this->user_type == 1 || $this->user_type == 2) { $this->_id = $user->mid; $this->username = $user->mid; } else { if ($this->user_type == 4) { $this->_id = $user->did; $this->username = $user->did; } else { if ($this->user_type == 3) { $this->_id = $user->pid; $this->username = $user->pid; } else { $this->_id = $user->nid; $this->username = $user->nid; } } } $this->_type = $this->user_type; $this->errorCode = self::ERROR_NONE; $this->setState("type", $this->_type); } } return $this->errorCode == self::ERROR_NONE; }
public function actionViewNurse() { $this->authenUser(); $nurseId; $nurseData; if (isset($_REQUEST['nurseId'])) { $nurseId = $_REQUEST['nurseId']; if (!is_numeric($nurseId)) { $this->redirect($statusCode = 404); } else { $nurseData = Nurses::model()->find('nid=?', array($nurseId)); if ($nurseData == null) { $this->redirect($statusCode = 404); } // invalid request redirected to 404 not found page } } $this->render('viewNurse', array('nurseProfile' => $nurseData)); }
public function actionViewProfile() { $this->authenUser(); $nurseProfile = Nurses::model()->find('nid=?', array($this->userId)); $this->render('viewProfile', array('nurseProfile' => $nurseProfile)); }