/** * Authenticates an administrator. * @return boolean whether authentication succeeds. */ public function authenticate() { $record = Quantrivien::model()->findByAttributes(array('email' => $this->username)); if (!$record) { $this->errorCode = self::ERROR_USERNAME_INVALID; } elseif ($record->password != Quantrivien::saltPassword($this->password)) { $this->errorCode = self::ERROR_PASSWORD_INVALID; } else { $this->username = $record->ma_qtv; $this->setState('adminId', $record->ma_qtv); $this->setState('adminName', $record->ten_qtv); $this->errorCode = self::ERROR_NONE; } return $this->errorCode; }
/** * 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 Quantrivien the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Quantrivien::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }