コード例 #1
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));
 }
コード例 #2
0
ファイル: SiteController.php プロジェクト: romeo14/wallfeet
 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));
 }