Esempio n. 1
0
 /**
  * Displays the login page
  */
 public function actionLogin()
 {
     $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()) {
             $lastDemandRequest = Demande::model()->findByAttributes(array('id_user' => (string) Yii::app()->user->id, 'envoi' => 0), array('order' => 'date_demande desc'));
             if ($lastDemandRequest != null) {
                 $lastDemand = $lastDemandRequest;
                 $newDemand = false;
                 Yii::app()->session['activeDemand'] = array($lastDemand, $newDemand);
             } else {
                 $lastDemandRequest = new Demande();
                 $lastDemandRequest->id_user = (string) Yii::app()->user->id;
                 $lastDemandRequest->date_demande = date("Y-m-d H:i:s");
                 $lastDemandRequest->envoi = 0;
                 $lastDemandRequest->sampleList = array();
                 $lastDemandRequest->save();
                 $newDemand = true;
                 Yii::app()->session['activeDemand'] = array($lastDemandRequest, $newDemand);
             }
             $this->redirect(Yii::app()->user->returnUrl);
         }
     }
     // display the login form
     $this->render('login', array('model' => $model));
 }
Esempio n. 2
0
 /**
  * Crée une nouvelle demande
  */
 public function actionCreateNewDemand()
 {
     $demande = new Demande();
     $demande->id_user = (string) Yii::app()->user->id;
     $demande->date_demande = date("Y-m-d H:i:s");
     $demande->save();
     $newDemand = true;
     Yii::app()->session['activeDemand'] = array($demande, $newDemand);
     //        print Yii::t('common', 'activeDemandMsg') . $demande->_id;
     return;
 }