public function actionLogin() { if (!Yii::app()->user->isGuest) { $this->redirect(array('/')); } $this->layout = 'login'; $model = new LoginForm(); // if it is ajax validation request if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') { echo CActiveForm::validate($model); Yii::app()->end(); } // collect user input data if (isset($_POST['LoginForm'])) { $model->attributes = $_POST['LoginForm']; // validate user input and redirect to the previous page if valid if ($model->validate() && $model->login()) { $this->redirect(Yii::app()->user->returnUrl); } } // display the login form $this->render('login', array('model' => $model, 'simplePage' => SimplePage::model()->findByAttributes(array('url' => '/cabinet/login')))); }
/** * 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 SimplePage the loaded model * @throws CHttpException */ public function loadModel($id) { $model = SimplePage::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
public function actionNonActiveIndex() { if (!Yii::app()->user->checkAccess('survey.nonActiveIndex')) { throw new Http403Exception(); } $dataProvider = LimeSurveyLocal::model()->search(); $criteria = new CDbCriteria(); $scopes = LimeSurveyLocal::model()->scopes(); $criteria->addCondition($scopes['nonActive']['condition']); if (!Yii::app()->user->checkAccess('survey.index')) { $surveyIdsByLocation = array(); foreach (Yii::app()->user->userModel->surveyUsers as $relation) { if (!isset($surveyIdsByLocation[$relation->surveyLocation])) { $surveyIdsByLocation[$relation->surveyLocation] = array(); } $surveyIdsByLocation[$relation->surveyLocation][] = $relation->surveyId; } $condition = array(); foreach ($surveyIdsByLocation as $location => $surveyIds) { if (!empty($surveyIds)) { $condition[] = "(t.sid in (" . implode(',', $surveyIds) . ") AND :className = '{$location}')"; } } if (!empty($condition)) { $criteria->addCondition(implode(" OR ", $condition)); } else { $criteria->addCondition("FALSE"); } } $dataProvider->setCriteria($criteria); $this->render("nonActiveIndex", array('simplePage' => SimplePage::model()->findByAttributes(array('url' => '/survey/nonActiveIndex')), 'dataProvider' => $dataProvider)); }