/**
  * testing method to check if sendMail confirmation is correct.
  */
 public function testSendConfirmationAdminProfilUser()
 {
     $criteria = new EMongoCriteria();
     $criteria->login = "******";
     $user = User::model()->find($criteria);
     $this->assertTrue(CommonMailer::sendConfirmationAdminProfilUser($user));
 }
 /**
  * action to add a new profil to an user.
  */
 public function actionUpdateSubscribe()
 {
     $model = new User();
     if (isset(Yii::app()->user->id)) {
         $model = User::model()->findByPk(new MongoID(Yii::app()->user->id));
     }
     if (isset($_POST['User'])) {
         $profilSelected = array_filter($_POST['User']['profil']);
         $test = empty($profilSelected);
         if (!empty($profilSelected)) {
             if (in_array('clinicien', $profilSelected)) {
                 array_push($model->profil, 'clinicien');
                 $model->address = $_POST['User']['address'];
                 if ($model->save()) {
                     CommonMailer::sendConfirmationAdminProfilUser($model);
                     CommonMailer::sendMailInscriptionUser($model->email, $model->login, $model->prenom, $model->nom, $model->password);
                     Yii::app()->user->setState('profil', $model->profil);
                     Yii::app()->user->setFlash('success', Yii::t('common', 'clinicianProfileCreated'));
                     $this->redirect(array('site/index'));
                 }
             } else {
                 if (in_array('neuropathologiste', $profilSelected)) {
                     if ($_POST['User']['centre'] == null || $_POST['User']['centre'] == "") {
                         $model->addError('centre', Yii::t('common', 'referenceCenterRequired'));
                         Yii::app()->user->setFlash('error', Yii::t('common', 'referenceCenterRequired'));
                     } else {
                         $model->centre = $_POST['User']['centre'];
                     }
                 }
                 if (!$model->hasErrors()) {
                     CommonMailer::sendMailConfirmationProfilEmail($model, implode('', $profilSelected), $model->centre);
                     Yii::app()->user->setFlash('success', Yii::t('common', 'askProfile') . implode("", $profilSelected) . Yii::t('common', 'askProfile1'));
                     $this->redirect(array('site/index'));
                 }
             }
         } else {
             $model->addError('profil', Yii::t('common', 'selectProfile'));
         }
     }
     $this->render('_updateSubscribeForm', array('model' => $model));
 }