Esempio n. 1
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $credentialsModel = new UserCredentials('register');
     $profilesModel = new UserProfiles();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['UserCredentials']) && isset($_POST['UserProfiles'])) {
         $data = $_POST;
         $credentialsModel->attributes = $_POST['UserCredentials'];
         $profilesModel->attributes = $_POST['UserProfiles'];
         $data['UserCredentials']['verified_by'] = Yii::app()->user->id;
         $id = UserApi::createUser($credentialsModel, $profilesModel);
         if ($id) {
             $data["temp_password"] = $credentialsModel->password;
             EmailApi::sendEmail($credentialsModel->email_id, "REGISTRATION.SUCCESS", $data);
             $this->redirect(array('view', 'id' => $id['credential']->id));
         } else {
             $credentialsModel->attributes = $data['UserCredentials'];
             $credentialsModel->validate(array('email_id', 'password', 'password2', 'status'));
             $profilesModel->attributes = $data['UserProfiles'];
             $profilesModel->validate(array('first_name', 'last_name'));
         }
     }
     $this->render('create', array('credentialsModel' => $credentialsModel, 'profilesModel' => $profilesModel));
 }
Esempio n. 2
0
 public function actionSignup()
 {
     Yii::beginProfile('signup');
     $model = new UserProfiles();
     //$this->performAjaxValidation(array($model));
     //die();
     if (isset($_POST['submit'])) {
         $models = UserApi::createUser($_POST['UserProfiles']);
     }
     $this->render('signup', array('model' => $model));
     Yii::endProfile('signup');
 }
Esempio n. 3
0
 public function actionRegister()
 {
     if (!Yii::app()->user->isGuest) {
         $this->redirect('/home');
     }
     $credentialsModel = UserApi::populateCredentialsModel(null, 'register');
     $profilesModel = UserApi::populateProfilesModel(null, 'register');
     /*require_once(Yii::app()->params["rootDir"].'/library/facebook/src/facebook.php');
     	 $facebook = new Facebook(array(
     	 'appId'  => Yii::app()->params["fbAppId"],
     	 'secret' => Yii::app()->params["fbSecret"],
     	 ));*/
     $this->performAjaxValidation(array($credentialsModel, $profilesModel));
     //$this->performAjaxValidation($profilesModel);
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'register-form') {
         echo CActiveForm::validate(array($credentialsModel, $profilesModel));
         //echo CActiveForm::validate($profilesModel);
         Yii::app()->end();
     }
     /*
      * Check if the user has reached this page through a widget.
      */
     if (isset($_POST['UserCredentials']) && !isset($_POST['UserProfiles'])) {
         $credentialsModel = UserApi::populateCredentialsModel($_POST['UserCredentials'], 'register');
         $credentialsModel->validate(array('email_id', 'password', 'password_confirm'));
         $profilesModel = UserApi::populateProfilesModel(null, 'register');
         //	$this->render('account',array('credentialsModel'=>$credentialsModel,'profilesModel'=>$profilesModel,'login'=>$loginModel));
     } else {
         if (isset($_POST['UserCredentials']) && isset($_POST['UserProfiles'])) {
             // save here
             $credentialsModel = UserApi::populateCredentialsModel($_POST['UserCredentials'], 'register');
             $credResult = $credentialsModel->validate(array('email_id', 'password', 'password_confirm'));
             $profilesModel = UserApi::populateProfilesModel($_POST['UserProfiles'], 'register');
             $profResult = $profilesModel->validate(array('first_name', 'last_name', 'gender', 'address_line1', 'address_line2', 'country_id', 'state_id', 'city_id', 'zip', 'mobile', 'telephone', 'agree, verifyCode'));
             if ($credResult && $profResult) {
                 $result = true;
                 $models = UserApi::createUser($credentialsModel, $profilesModel);
                 // Redirect to thanks page.
                 // @todo link to success page.
                 if ($models) {
                     $data = array();
                     $data["user"] = $models['credential']->id;
                     EmailApi::sendEmail($credentialsModel->email_id, "REGISTRATION.ACTIVATION", $data);
                     $session = new CHttpSession();
                     $session->open();
                     $session['registration-success'] = 'true';
                     $resendUrl = Yii::app()->createUrl('/account/resendEmail');
                     Yii::app()->user->setFlash('success', "Thanks for registering. We have sent you an email with activation information.\n\t\t\t\t\t\t<br/> Please add " . Yii::app()->params['adminEmail'] . " to your whitelist. \n\t\t\t\t\t\tIf you have not received the email click here to <a href='{$resendUrl}'>resend</a>.");
                     $this->redirect('/home');
                 }
                 //	else
                 //		$this->render('account',array('credentialsModel'=>$credentialsModel,'profilesModel'=>$profilesModel,'login'=>$loginModel));
                 // save())
             }
         }
     }
     // else
     $this->render('register', array('credentialsModel' => $credentialsModel, 'profilesModel' => $profilesModel));
 }
Esempio n. 4
0
 public function actionAccount()
 {
     // Check if the user is not a guest. If member then redirect him to the dashboard here.
     // @todo Replace url to Dashboard url
     if (!Yii::app()->user->isGuest) {
         $this->redirect('/home');
     }
     // Create a new Front Login Form model.
     $loginModel = new FrontLoginForm();
     $this->performAjaxValidation($loginModel);
     // if it is ajax validation request
     if (isset($_POST['ajax'])) {
         //	var_dump($_POST['ajax']);die();
     }
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'front-login-form') {
         echo CActiveForm::validate($loginModel);
         Yii::app()->end();
     }
     // collect user input data
     if (isset($_POST['FrontLoginForm'])) {
         $loginModel->attributes = $_POST['FrontLoginForm'];
         // validate user input and redirect to the previous page if valid
         if ($loginModel->validate() && $loginModel->login()) {
             $this->redirect(Yii::app()->user->returnUrl);
         }
     }
     /*
      * This means the user has either come here for the first time or is trying to create
      * a new account.
      */
     $credentialsModel = UserApi::populateCredentialsModel(null, 'register');
     $profilesModel = UserApi::populateProfilesModel(null, 'register');
     require_once Yii::app()->params["rootDir"] . '/library/facebook/src/facebook.php';
     $facebook = new Facebook(array('appId' => Yii::app()->params["fbAppId"], 'secret' => Yii::app()->params["fbSecret"]));
     $this->performAjaxValidation($profilesModel);
     /*
      * Check if the user has reached this page through a widget.
      */
     if (isset($_POST['UserCredentials']) && !isset($_POST['UserProfiles'])) {
         $credentialsModel = UserApi::populateCredentialsModel($_POST['UserCredentials'], 'register');
         $credentialsModel->validate(array('email_id', 'password', 'password_confirm'));
         $profilesModel = UserApi::populateProfilesModel(null, 'register');
         //	$this->render('account',array('credentialsModel'=>$credentialsModel,'profilesModel'=>$profilesModel,'login'=>$loginModel));
     } else {
         if (isset($_POST['UserCredentials']) && isset($_POST['UserProfiles'])) {
             // save here
             $credentialsModel = UserApi::populateCredentialsModel($_POST['UserCredentials'], 'register');
             $credResult = $credentialsModel->validate(array('email_id', 'password', 'password_confirm'));
             $profilesModel = UserApi::populateProfilesModel($_POST['UserProfiles'], 'register');
             $profResult = $profilesModel->validate(array('first_name', 'last_name', 'gender', 'address_line1', 'address_line2', 'country_id', 'state_id', 'city_id', 'zip', 'phone', 'alt_phone', 'agree'));
             if ($credResult && $profResult) {
                 $result = true;
                 $models = UserApi::createUser($credentialsModel, $profilesModel);
                 // Redirect to thanks page.
                 // @todo link to success page.
                 if ($models) {
                     $data = array();
                     $data["user"] = $models['credential']->id;
                     EmailApi::sendEmail($credentialsModel->email_id, "REGISTRATION.ACTIVATION", $data);
                     $session = new CHttpSession();
                     $session->open();
                     $session['registration-success'] = 'true';
                     $this->redirect(array('/account/thanks', 'email' => $models['credential']->email_id));
                 }
                 //	else
                 //		$this->render('account',array('credentialsModel'=>$credentialsModel,'profilesModel'=>$profilesModel,'login'=>$loginModel));
                 // save())
             }
         }
     }
     // else
     $this->render('account', array('credentialsModel' => $credentialsModel, 'profilesModel' => $profilesModel, 'login' => $loginModel));
 }