Exemplo n.º 1
0
 public function actionReg()
 {
     $user = '';
     $valid = false;
     if (isset($_POST["RegistrationForm"]["all_valid"])) {
         $valid = $_POST["RegistrationForm"]["all_valid"] == '1';
     }
     $model = new RegistrationForm();
     if (!Yii::$app->request->isPjax && Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         if ($valid) {
             if ($user = $model->reg()) {
                 Yii::$app->session->setFlash('regSuccess');
             } else {
                 Yii::$app->session->setFlash('regError');
                 Yii::error('Error while registration!');
             }
         } else {
             Yii::$app->session->setFlash('regFillReq');
         }
     }
     return $this->render('registration_form', ['model' => $model, 'user' => $user]);
 }
Exemplo n.º 2
0
 public function actionRegistration()
 {
     $model = new RegistrationForm();
     if ($model->load(Yii::$app->request->post()) && $model->register()) {
         return $this->render('registration-success');
     }
     return $this->render('registration', ['model' => $model]);
 }
Exemplo n.º 3
0
 public function actionRegistration()
 {
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new RegistrationForm();
     if ($model->load(Yii::$app->request->post()) && $model->register()) {
         return $this->goBack();
     }
     return $this->render('registration', ['model' => $model]);
 }
Exemplo n.º 4
0
 public function actionLogin()
 {
     if (!Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new LoginForm();
     $registration_model = new RegistrationForm();
     if ($model->load(Yii::$app->request->post(), 'LoginForm') && $model->login()) {
         return $this->goBack();
     }
     if ($registration_model->load(Yii::$app->request->post(), 'RegistrationForm') && $registration_model->register()) {
         return $this->redirect('personal-details');
     }
     return $this->render('login', ['model' => $model, 'registration_model' => $registration_model]);
 }
Exemplo n.º 5
0
 public function actionRegister()
 {
     if (!Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $model = new RegistrationForm();
     if ($model->load(Yii::$app->request->post()) && $model->register()) {
         Yii::$app->session->setFlash('success', 'Регистрация прошла успешно');
         return $this->goHome();
     } else {
         Yii::$app->session->setFlash('error', 'Возникла ошибка при регистрации');
         Yii::error('Ошибка при регистрации');
     }
     return $this->render('register', ['model' => $model]);
 }
 public function actionChecklogin()
 {
     if (!Yii::$app->user->getIsGuest()) {
         if (Yii::$app->request->isAjax) {
             $data = Yii::$app->request->post();
             $username = $_POST['value'];
             $model = new RegistrationForm();
             if (($userDat = $model->isUsernameExist($username)) && $userDat['ID'] != Yii::$app->user->getId()) {
                 return json_encode(Yii::t('registration', 'Login is not free'));
             } else {
                 return json_encode('ok');
             }
         }
     } else {
         return $this->goHome();
     }
 }
 public function actionRegister()
 {
     $model = new RegistrationForm();
     $form = Yii::$app->request->post('RegistrationForm');
     $user = new User();
     $model->attributes = $form;
     $email = $user->checkEmail($model->email);
     if ($model->validate()) {
         if ($email["count"] == 0) {
             $user->addUser($model);
             return $this->redirect('http://masterillla.com/web/index.php?r=registration/success');
         } else {
             return $this->redirect('http://masterillla.com/web/index.php?r=registration/error');
         }
     } else {
         return $this->redirect('http://masterillla.com/web/index.php?r=registration/error');
     }
 }
 public function actionSubcat()
 {
     if (!Yii::$app->user->getIsGuest()) {
         $out = [];
         $isEmpty = true;
         if (isset($_POST['depdrop_parents'])) {
             $parents = $_POST['depdrop_parents'];
             if ($parents != null) {
                 $cat_id = $parents[0];
                 $out = RegistrationForm::getGroups($cat_id);
                 $isEmpty = false;
                 echo Json::encode(['output' => $out, 'selected' => '']);
             }
         }
         if ($isEmpty) {
             echo Json::encode(['output' => [['id' => '1', 'name' => '<sub-cat-name1>'], ['id' => '2', 'name' => '<sub-cat-name2>']], 'selected' => '']);
         }
     } else {
         return $this->goHome();
     }
 }
Exemplo n.º 9
0
 /**
  * actionRegister
  *
  * the Register action contains most of the logic behind user registration.
  * When it is called it checks to see if any data can be loaded into the
  * RegistrationForm model. If not then that means the user has not yet been
  * taken to the registration page, so it collects the data need to render
  * the registration page/form (all of the states and counties needed to fill
  * in the dropdowns, etc.) and renders view/site/registration. If however
  * data is able to be loaded into the RegistrationForm model, then that
  * means that the user has already submitted a filled out form, so it calls
  * model->validate() to make sure that all of the input is good and to make
  * sure that the entered username and email address have not already been
  * taken. If that does not return any errors then newUser(), a member
  * function of SiteController, is called and the RegistrationForm model is
  * passed in. After that, registration-confirm is rendered.
  */
 public function actionRegister()
 {
     /**
      * check if the user is already logged in
      * if so, do nothing and return them to the home screen
      */
     if (!\Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     /** 
      * loads model that will store all data entered into the ActiveForm
      * on register.php and contains all front-end validation rules
      */
     $model = new RegistrationForm();
     /* Used to populate 'select state' dropdown and 'select region' section */
     $stateList = State::find()->all();
     /* Used to populate the 'select region' multiselects */
     $countyList = County::find()->orderBy('name')->all();
     /**
      * if the user has made a 'post' request AND registration form model
      * is able to succesfully register the user based on the inputted information 
      */
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         /* Calls member function newUser() and passes in a populated model */
         $this->newUser($model);
         /* registration was successful, go back to registration-confirm view */
         return $this->render('registration-confirm', ['model' => $model]);
     } else {
         /**
          * The user has not yet been taken to the registration form so
          * render the registration view and pass in an empty RegistrationForm
          * model that is stored in $model
          */
         return $this->render('register', ['model' => $model, 'stateList' => $stateList, 'countyList' => $countyList]);
     }
 }