예제 #1
0
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     Profile::$regMode = true;
     $model = new RegistrationForm();
     $profile = new Profile();
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
             if ($model->validate() && $profile->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = UserModule::encrypting($model->password);
                 $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                 $model->superuser = 0;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 if ($model->save()) {
                     $profile->user_id = $model->id;
                     $profile->save();
                     if (Yii::app()->controller->module->sendActivationMail) {
                         $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                         UserModule::sendMail($model->email, UserModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please activate you account go to {activation_url}", array('{activation_url}' => $activation_url)));
                     }
                     if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                         $identity = new UserIdentity($model->username, $soucePassword);
                         $identity->authenticate();
                         Yii::app()->user->login($identity, 0);
                         $model->lastvisit_at = date('Y-m-d H:i:s');
                         $model->save();
                         $this->redirect(UserModule::getReturnUrl());
                     } else {
                         if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Contact Admin to activate your account."));
                         } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                         } elseif (Yii::app()->controller->module->loginNotActiv) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email or login."));
                         } else {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email."));
                         }
                         $this->refresh();
                     }
                 }
             } else {
                 $profile->validate();
             }
         }
         $this->render('/user/registration', array('model' => $model, 'profile' => $profile));
     }
 }
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     //var_dump("test");exit;
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     //var_dump($model);exit;
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     //var_dump($_POST['ajax']);exit;
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             //var_dump($_POST['RegistrationForm']);exit;
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
             if ($model->validate() && $profile->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = AdminModule::encrypting(microtime() . $model->password);
                 $model->password = AdminModule::encrypting($model->password);
                 $model->verifyPassword = AdminModule::encrypting($model->verifyPassword);
                 $model->superuser = 0;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 if ($model->save()) {
                     $profile->user_id = $model->id;
                     $profile->save();
                     if (Yii::app()->controller->module->sendActivationMail) {
                         $activation_url = $this->createAbsoluteUrl('/admin/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                         AdminModule::sendMail($model->email, AdminModule::t("Anda registrasi dari {site_name}", array('{site_name}' => Yii::app()->name)), AdminModule::t("Silahkan Aktifkan akun anda melalui link {activation_url}", array('{activation_url}' => $activation_url)));
                     }
                     if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                         $identity = new UserIdentity($model->username, $soucePassword);
                         $identity->authenticate();
                         Yii::app()->user->login($identity, 0);
                         $this->redirect(Yii::app()->controller->module->returnUrl);
                     } else {
                         if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                             Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Hubungi Admin untuk mengaktifkan akun anda."));
                         } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                             Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Silahkan {{login}}.", array('{{login}}' => CHtml::link(AdminModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                         } elseif (Yii::app()->controller->module->loginNotActiv) {
                             Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Silahkan cek email anda atau login."));
                         } else {
                             Yii::app()->user->setFlash('registration', AdminModule::t("Terima kasih anda sudah mendaftar. Silahkan cek email anda."));
                         }
                         $this->refresh();
                     }
                 }
             } else {
                 $profile->validate();
             }
         }
         $this->render('/user/registration', array('model' => $model, 'profile' => $profile));
     }
 }
예제 #3
0
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = $_POST['Profile'];
             if ($model->validate() && $profile->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = UserModule::encrypting($model->password);
                 $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                 $model->createtime = time();
                 $model->lastvisit = (Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin ? time() : 0;
                 $model->superuser = 0;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 if ($model->save()) {
                     $profile->user_id = $model->id;
                     $profile->save();
                     // assign user the 'Authenticated' role for Rights module
                     $authenticatedName = Rights::module()->authenticatedName;
                     Rights::assign($authenticatedName, $model->id);
                     // end of change
                     if (Yii::app()->controller->module->sendActivationMail) {
                         $activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                         UserModule::sendMail($model->email, UserModule::t("You have registered at {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please activate your account. Go to {activation_url}", array('{activation_url}' => $activation_url)));
                     }
                     if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                         $identity = new UserIdentity($model->username, $soucePassword);
                         $identity->authenticate();
                         Yii::app()->user->login($identity, 0);
                         $this->redirect(Yii::app()->controller->module->returnUrl);
                     } else {
                         if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Contact Admin to activate your account."));
                         } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                         } elseif (Yii::app()->controller->module->loginNotActiv) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please check your email or login."));
                         } else {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for registering. Please check your email."));
                         }
                         $this->refresh();
                     }
                 }
             }
         }
         $this->render('/user/registration', array('form' => $model, 'profile' => $profile));
     }
 }
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $this->seo(Yii::t('admin', 'Registration'));
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
             if ($model->validate() && $profile->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = UserModule::encrypting($model->password);
                 $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                 $model->superuser = 0;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 //Стартуем транзакции чтобы убедиться в целостности данных
                 $transaction = Yii::app()->db->beginTransaction();
                 try {
                     //Сохраняем все данные
                     $model->save(false);
                     $profile->user_id = $model->id;
                     $profile->save();
                     $roles = $this->setUserRoles($model->id);
                     $roles->save();
                     $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                     $send = Email::sendUserNoReply($model->username, $model->email, Yii::t('admin', 'Confirm registration'), UserModule::t("Please activate you account go to {activation_url}", array('{activation_url}' => $activation_url)));
                     if ($send) {
                         Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email."));
                     } else {
                         Yii::app()->user->setFlash('registration', Yii::t('admin', 'Upon registration error occurred. Please re-register or contact us.'));
                     }
                     if ($transaction->commit()) {
                     }
                     $this->refresh();
                 } catch (Exception $e) {
                     $transaction->rollback();
                 }
             }
         }
         $this->render('/user/registration', array('model' => $model, 'profile' => $profile));
     }
 }
예제 #5
0
 public function actionRegistration()
 {
     $model = new RegistrationForm();
     $profile = new Profile();
     if (($uid = Yii::app()->user->id) === true) {
         $this->redirect(Yii::app()->homeUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             //$profile->attributes=$_POST['Profile'];
             if ($model->validate() && $profile->validate()) {
                 $sourcePassword = $model->password;
                 $model->password = Yii::app()->user->encrypt($model->password);
                 $model->verifyPassword = Yii::app()->user->encrypt($model->verifyPassword);
                 $model->activkey = Yii::app()->user->encrypt(microtime() . $model->password);
                 $model->createtime = time();
                 $model->lastvisit = Yii::app()->user->autoLogin && Yii::app()->user->loginNotActive ? time() : 0;
                 $model->superuser = 0;
                 $model->status = 0;
                 if ($model->save()) {
                     $profile->user_id = $model->id;
                     $profile->save();
                     $headers = "From: " . Yii::app()->params['adminEmail'] . "\r\nReply-To: " . Yii::app()->params['adminEmail'];
                     $activation_url = 'http://' . $_SERVER['HTTP_HOST'] . $this->createUrl('user/activation', array("activkey" => $model->activkey, "email" => $model->email));
                     mail($model->email, "You registered from " . Yii::app()->name, "Please activate your account go to {$activation_url}.", $headers);
                     if (Yii::app()->user->loginNotActive) {
                         if (Yii::app()->user->autoLogin) {
                             $identity = new UserIdentity($model->username, $sourcePassword);
                             $identity->authenticate();
                             Yii::app()->user->login($identity, 0);
                             $this->redirect(Yii::app()->user->returnUrl);
                         } else {
                             Yii::app()->user->setFlash('registration', Yii::t("user", "Thank you for your registration. Please check your email or login."));
                             $this->refresh();
                         }
                     } else {
                         Yii::app()->user->setFlash('registration', Yii::t("user", "Thank you for your registration. Please check your email."));
                         $this->refresh();
                     }
                 }
             }
         }
         $this->render('/user/registration', array('form' => $model, 'profile' => $profile));
     }
 }
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $profile = new User();
     $model = new RegistrationForm();
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         echo CActiveForm::validate(array($model, $profile), array('email', 'username'));
         Yii::app()->end();
     }
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm']) && isset($_POST['User'])) {
             $profile->attributes = $_POST['User'];
             $model->attributes = $_POST['RegistrationForm'];
             if ($model->validate() && $profile->validate()) {
                 $profile->role = User::ROLE_MEMBER;
                 if ($profile->save()) {
                     $model->user_id = $profile->user_id;
                     $soucePassword = $model->password;
                     $model->password = UserModule::encrypting($model->password);
                     $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                     $model->save();
                     /*
                      * if (Yii::app()->controller->module->sendActivationMail) { $activation_url = $this->createAbsoluteUrl('/user/activation/activation',array("activkey" => $model->activkey, "email" => $model->email)); UserModule::sendMail($model->email,UserModule::t("You registered from {site_name}",array('{site_name}'=>Yii::app()->name)),UserModule::t("Please activate you account go to {activation_url}",array('{activation_url}'=>$activation_url))); }
                      */
                     $identity = new UserIdentity($model->username, $soucePassword);
                     $identity->authenticate();
                     Yii::app()->user->login($identity, 0);
                     $this->redirect(Yii::app()->controller->module->loginUrl);
                     /*
                      * if ((Yii::app()->controller->module->loginNotActiv||(Yii::app()->controller->module->activeAfterRegister&&Yii::app()->controller->module->sendActivationMail==false))&&Yii::app()->controller->module->autoLogin) { $identity=new UserIdentity($model->username,$soucePassword); $identity->authenticate(); Yii::app()->user->login($identity,0); $this->redirect(Yii::app()->controller->module->returnUrl); } else { if (!Yii::app()->controller->module->activeAfterRegister&&!Yii::app()->controller->module->sendActivationMail) { Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Contact Admin to activate your account.")); } elseif(Yii::app()->controller->module->activeAfterRegister&&Yii::app()->controller->module->sendActivationMail==false) { Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please {{login}}.",array('{{login}}'=>CHtml::link(UserModule::t('Login'),Yii::app()->controller->module->loginUrl)))); } elseif(Yii::app()->controller->module->loginNotActiv) { Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please check your email or login.")); } else { Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please check your email.")); } $this->refresh(); }
                      */
                 }
             } else {
                 $profile->validate();
                 $model->validate();
             }
         }
         $this->render('/user/registration', array('login' => $model, 'model' => $profile));
     }
 }
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     $org = new Organisation();
     // ajax validator
     //if(isset($_POST['ajax']) && $_POST['ajax']==='registration-form')
     //{
     //        echo UActiveForm::validate(array($model,$profile));
     //        Yii::app()->end();
     //}
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         if ($_POST['RegistrationForm']['service'] == 2) {
             ////////////////////////////////////////////////////////////////////////////////
             //$name = trim($org->name);
             $name = trim($_POST['Organisation']['name']);
             $exOrgCount = Organisation::model()->count('name=:param_name', array(':param_name' => $name));
             if ($exOrgCount > 0) {
                 $org->validatorList->add(CValidator::createValidator('unique', $org, 'name', array('message' => Yii::t('app', 'Group Name already exists'))));
             } else {
                 if (strlen($name) == 0) {
                     $org->validatorList->add(CValidator::createValidator('required', $org, 'name', array('message' => Yii::t('app', 'Group Name canot be blank'))));
                 }
             }
             ////////////////////////////////////////////////////////////////////////////////
             echo UActiveForm::validate(array($model, $profile, $org));
             Yii::app()->end();
         } else {
             echo UActiveForm::validate(array($model, $profile));
             Yii::app()->end();
         }
     }
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
             $valid = $model->validate();
             $valid = $profile->validate() && $valid;
             if ($_POST['RegistrationForm']['service'] == 2) {
                 $org->name = trim($_POST['Organisation']['name']);
                 $valid = $org->validate() && $valid;
             }
             //if($model->validate()&&$profile->validate())
             if ($valid) {
                 $soucePassword = $model->password;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = UserModule::encrypting($model->password);
                 $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                 $model->superuser = 0;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 $orgDuplicateCheck = false;
                 $flag = true;
                 $role = 'Authenticated';
                 if ($model->service == 1) {
                     $orgDuplicateCheck = true;
                     $role = 'Individual';
                 } else {
                     if ($model->service == 2 && isset($_POST['Organisation']['name'])) {
                         $org->name = trim($_POST['Organisation']['name']);
                         $flag = Organisation::model()->exists('name=:param_name_check', array(':param_name_check' => $org->name));
                         if (!$flag) {
                             $orgDuplicateCheck = true;
                         }
                         $role = 'Org_Admin';
                     } else {
                         //$org->validatorList->add(CValidator::createValidator('unique', $org, 'name', array('message'=>Yii::t('app','Group Name Already Exists'))));
                         $org->validate();
                         Yii::app()->user->setFlash('registration', UserModule::t("Group Name already exists"));
                     }
                 }
                 if ($orgDuplicateCheck) {
                     if ($model->save()) {
                         $profile->user_id = $model->id;
                         $profile->firstname = $model->firstname;
                         $profile->lastname = $model->lastname;
                         $profile->save();
                         $this->assignRole($model->id, $role);
                         //If Service=2 ~ Organisation Save New (Non-Existent) Organisation
                         if (!$flag) {
                             $org->created_by = $model->id;
                             $org->type = 'Other';
                             //$org->timestamp_create = date('Y-m-d H:i:s');
                             if ($org->save()) {
                                 $model->organisation_id = $org->id;
                                 $model->organisation_administrator = 1;
                                 $model->save(false);
                                 try {
                                     //Create Organisation Group
                                     $group = new Group();
                                     $group->group_name = $org->name;
                                     $group->parent_group_id = 0;
                                     $group->organisation_id = $org->id;
                                     $group->timestamp_created = date('Y-m-d H:i":');
                                     $group->save(false);
                                     $groupMember = new GroupMember();
                                     $groupMember->group_id = $group->group_id;
                                     $groupMember->user_id = $model->id;
                                     $groupMember->manager_flag = 1;
                                     //$groupMember->created_by = 0;
                                     //$groupMember->timestamp_created = date('Y-m-d H:i:s');
                                     $groupMember->save(false);
                                 } catch (Exception $ex) {
                                     Yii::log($ex->getMessage(), 'error', 'Custom');
                                 }
                             } else {
                                 Yii::app()->user->setFlash('registration', UserModule::t("Oop! Soemthing Went Wrong"));
                             }
                         }
                         if (Yii::app()->controller->module->sendActivationMail) {
                             $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                             UserModule::sendMail($model->email, UserModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Please activate your account by going to {activation_url}", array('{activation_url}' => $activation_url)));
                         }
                         if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                             $identity = new UserIdentity($model->username, $soucePassword);
                             $identity->authenticate();
                             Yii::app()->user->login($identity, 0);
                             $this->redirect(Yii::app()->controller->module->returnUrl);
                         } else {
                             if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                                 Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Contact Admin to activate your account."));
                             } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                                 Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                             } elseif (Yii::app()->controller->module->loginNotActiv) {
                                 Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email to login."));
                             } else {
                                 //Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please check your email."));
                                 Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your spam/junk folder if you email is not in inbox."));
                             }
                             $this->refresh();
                         }
                     }
                 }
             } else {
                 $profile->validate();
             }
         }
         $this->render('/user/registration', array('model' => $model, 'profile' => $profile, 'org' => $org));
     }
 }
예제 #8
0
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     Yii::import('application.modules.user.models.*');
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
             if ($model->validate() && $profile->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = UserModule::encrypting($model->password);
                 $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                 $model->superuser = 0;
                 $model->status = 1;
                 if ($model->save()) {
                     $profile->user_id = $model->id;
                     $profile->save();
                     //if (Yii::app()->controller->module->sendActivationMail) {
                     //$activation_url = $this->createAbsoluteUrl('/user/activation/activation',array("activkey" => $model->activkey, "email" => $model->email));
                     //UserModule::sendMail($model->email,UserModule::t("You registered from {site_name}",array('{site_name}'=>Yii::app()->name)),UserModule::t("Please activate you account go to {activation_url}",array('{activation_url}'=>$activation_url)));
                     //}
                     // Add them to Subscribe system
                     if ($_POST['subscribe']) {
                         $email = $model->email;
                         $subscription = Subscribers::model()->find('email = :email', array(':email' => $email));
                         if (isset($subscription->id)) {
                         } else {
                             $subscription = new Subscribers();
                             $subscription->email = $email;
                             $subscription->activation = $subscription->generateActivation($email);
                             $subscription->subscribed = 1;
                             $subscription->confirmed = 0;
                             $subscription->ip_address = $_SERVER['REMOTE_ADDR'];
                             if ($subscription->save()) {
                                 $url = 'http://' . $_SERVER['HTTP_HOST'] . '/e/' . $subscription->activation;
                                 $unsub_url = 'http://' . $_SERVER['HTTP_HOST'] . '/unsub/' . $subscription->activation;
                                 $sbj = "Confirmation - XXX Coupon Daily P**n Deals";
                                 $to = array($subscription->email);
                                 $reply_hash = 'XXX Coupon Confirmation <*****@*****.**>';
                                 $mail = $this->ses;
                                 //Yii::import('application.extensions.sesmail.*');
                                 //require_once('vendors/aws-sdk/sdk.class.php');
                                 //$mail = new YiiSesMail;
                                 $mail->view = 'confirm';
                                 $mail->setBody(array('url' => $url, 'ip_address' => $subscription->ip_address, 'unsub_url' => $unsub_url));
                                 $mail->send($reply_hash, $to, $sbj);
                             }
                         }
                     }
                     if (!empty($_POST['RegistrationForm']['redirect'])) {
                         Yii::app()->user->setFlash('success', "Okay, you're set.  We are sending you off to your offer now.  Thanks for joining us!");
                         $this->redirect(urldecode($_POST['RegistrationForm']['redirect']));
                     } else {
                         Yii::app()->user->setFlash('success', "Okay, you're set.  Thank you for registering with us.  Enjoy the offers!");
                         $this->redirect('/');
                     }
                     /*if ((Yii::app()->controller->module->loginNotActiv||(Yii::app()->controller->module->activeAfterRegister&&Yii::app()->controller->module->sendActivationMail==false))&&Yii::app()->controller->module->autoLogin) {
                     				$identity=new UserIdentity($model->username,$soucePassword);
                     				$identity->authenticate();
                     				Yii::app()->user->login($identity,0);
                     				$this->redirect(Yii::app()->controller->module->returnUrl);
                     		} else {
                     			if (!Yii::app()->controller->module->activeAfterRegister&&!Yii::app()->controller->module->sendActivationMail) {
                     				Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Contact Admin to activate your account."));
                     			} elseif(Yii::app()->controller->module->activeAfterRegister&&Yii::app()->controller->module->sendActivationMail==false) {
                     				Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please {{login}}.",array('{{login}}'=>CHtml::link(UserModule::t('Login'),Yii::app()->controller->module->loginUrl))));
                     			} elseif(Yii::app()->controller->module->loginNotActiv) {
                     				Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please check your email or login."));
                     			} else {
                     				Yii::app()->user->setFlash('registration',UserModule::t("Thank you for your registration. Please check your email."));
                     			}
                     			$this->refresh();
                     		}*/
                 }
             } else {
                 $profile->validate();
             }
         }
         $this->render('/registration/registration', array('model' => $model, 'profile' => $profile));
     }
 }
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     Profile::$regMode = true;
     $model = new RegistrationForm();
     $profile = new Profile();
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
             if ($model->validate() && $profile->validate()) {
                 //$soucePassword = $model->password;
                 //$realp = PasswordHelper::generateStrongPassword();
                 //$model->password = $realp;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = PasswordHelper::hashPassword($model->password);
                 $model->verifyPassword = $model->password;
                 $model->superuser = 0;
                 $model->type = 1;
                 $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                 if ($model->save()) {
                     $profile->user_id = $model->id;
                     $profile->save();
                     if (Yii::app()->controller->module->sendActivationMail) {
                         $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                         $name = $_POST['Profile']['first_name'] . ' ' . $_POST['Profile']['last_name'];
                         UserModule::sendMail($model->email, UserModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("<div style='border: 1px solid #FCC32A;border-radius:5px;box-shadow:1px 5px 5px;background-color:#FFFFEE;'><div style='background-color:#333;border-radius:5px;padding:10px;'><img src='http://yorshop.com/img/main_logo.png' style='float:left'/><h2 style='color: #FFF;width:70%;margin-left:15%;'>Successful  Registration</h2><hr/></div><div style='padding:10px;'><p><strong>Dear {name},</strong></p><p>Thank you for registering at <a href='{site_url}' target='blank'>{site_name}</a>.</p><p>Please activate your account by clicking: <a href='{activation_url}' target='blank'>{activation_url}</a> or copy and paste it in your browser.</p><p><a href='{site_url}' target='blank' ><img src='http://yorshop.com/img/form_submit.png'/></a></p></div><div style='padding:0px 10px 0px;'><p>If you need any assistance or have any inquiry or suggestion, feel free to contact our customer service team at <a href='mailto:info@yorshop.com'>info@yorshop.com</a> or call us at <strong>0700 967 7467</strong> between 8am and 10pm on weekdays and 9am to 6pm on weekends, we would be happy to guide you.</p> <address>Thank You!<br/>Your Yorshop Team</address></div></div>", array('{activation_url}' => $activation_url, '{name}' => $name, '{site_name}' => Yii::app()->name, '{site_url}' => UtilityHelper::yiiparam('site_name'))));
                     }
                     if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                         $identity = new UserIdentity($model->username, $soucePassword);
                         $identity->authenticate();
                         Yii::app()->user->login($identity, 0);
                         $this->redirect(Yii::app()->controller->module->returnUrl);
                     } else {
                         if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Contact Admin to activate your account."));
                         } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                         } elseif (Yii::app()->controller->module->loginNotActiv) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email or login."));
                         } else {
                             Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email."));
                         }
                         $this->refresh();
                     }
                 }
             } else {
                 $profile->validate();
             }
         }
         if (isset($this->location)) {
             $this->render('frontend.views.user.registration', array('model' => $model, 'profile' => $profile));
         } else {
             $this->render('/user/registration', array('model' => $model, 'profile' => $profile));
         }
     }
 }
예제 #10
0
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     if (isset($_GET['period']) and !empty($_GET['period']) and !empty($_GET['sahkoposti']) and $_GET['session'] == Yii::app()->getSession()->getSessionId() and !empty($_GET['kayttokoodi'])) {
         Yii::app()->user->setState('period', $_GET['period']);
         Yii::app()->user->setState('sahkoposti', $_GET['sahkoposti']);
         Yii::app()->user->setState('kayttokoodi', $_GET['kayttokoodi']);
     }
     $model = new RegistrationForm();
     $profile = new Profile();
     $profile->regMode = true;
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         echo UActiveForm::validate(array($model, $profile));
         Yii::app()->end();
     }
     if (Yii::app()->user->id) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
             if ($model->validate() && $profile->validate()) {
                 $soucePassword = $model->password;
                 $model->activkey = UserModule::encrypting(microtime() . $model->password);
                 $model->password = UserModule::encrypting($model->password);
                 $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                 $model->superuser = 0;
                 // Uusi myyja
                 if (isset($_POST['myyja']) and $_POST['myyja'] == 1) {
                     Yii::app()->user->setState('myyja', true);
                     $vahvistuskoodi = substr(str_shuffle(str_repeat('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789', 8)), 0, 8);
                     $model->myyja_vahvistus = $vahvistuskoodi;
                     if (isset($_POST['paa_myyja'])) {
                         $model->paa_myyja = $_POST['paa_myyja'];
                     }
                     $model->myyja = 1;
                 }
                 // Uusi myyja -->
                 if (isset($_POST['myyjaID']) and !empty($_POST['myyjaID'])) {
                     $model->myyjaID = $_POST['myyjaID'];
                 }
                 $model->status = 1;
                 if ($model->save()) {
                     $profile->user_id = $model->id;
                     $profile->mainosten_lahetys = 1;
                     $profile->save();
                     /*
                     							if (Yii::app()->controller->module->sendActivationMail) {
                     								$activation_url = $this->createAbsoluteUrl('/user/activation/activation',array("activkey" => $model->activkey, "email" => $model->email));
                     								UserModule::sendMail($model->email,UserModule::t("You registered from {site_name}",array('{site_name}'=>Yii::app()->name)),UserModule::t("Please activate you account go to {activation_url}",array('{activation_url}'=>$activation_url)));
                     							}
                     */
                     if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                         $identity = new UserIdentity($model->username, $soucePassword);
                         $identity->authenticate();
                         Yii::app()->user->login($identity, 0);
                         $this->redirect(Yii::app()->controller->module->returnUrl);
                     } else {
                         if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Kiitos rekisteröitymisestäsi. Aktivoitintiviesti on lähetetty sähköpostiisi."));
                         } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Kiitos rekisteröitymisestäsi. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                         } elseif (Yii::app()->controller->module->loginNotActiv) {
                             Yii::app()->user->setFlash('registration', UserModule::t("Kiitos rekisteröitymisestäsi. Aktivoitintiviesti on lähetetty sähköpostiisi."));
                         } else {
                             Yii::app()->user->setFlash('registration', UserModule::t("Kiitos rekisteröitymisestäsi."));
                             $model = new UserLogin();
                             $model->username = $_POST['RegistrationForm']['username'];
                             $model->password = $_POST['RegistrationForm']['password'];
                             if ($model->validate()) {
                                 if (isset(Yii::app()->user->myyja)) {
                                     $this->redirect(array('/user/profile/edit'));
                                 } else {
                                     $this->redirect(array('/site/kiitos_rekisteroinnista'));
                                 }
                             }
                         }
                         $this->refresh();
                     }
                 }
             } else {
                 $profile->validate();
             }
         }
         $this->render('/user/registration', array('model' => $model, 'profile' => $profile));
     }
 }
예제 #11
0
    /**
     * Registration user
     */
    public function actionRegistration()
    {
        $model = new RegistrationForm();
        $profile = new Profile();
        $profile->regMode = true;
        // ajax validator
        if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
            echo UActiveForm::validate(array($model, $profile));
            Yii::app()->end();
        }
        if (Yii::app()->user->id) {
            $this->redirect(Yii::app()->controller->module->profileUrl);
        } else {
            if (isset($_POST['RegistrationForm'])) {
                $model->attributes = $_POST['RegistrationForm'];
                $profile->attributes = isset($_POST['Profile']) ? $_POST['Profile'] : array();
                if ($model->validate() && $profile->validate()) {
                    $soucePassword = $model->password;
                    $model->activkey = UserModule::encrypting(microtime() . $model->password);
                    $model->password = UserModule::encrypting($model->password);
                    $model->verifyPassword = UserModule::encrypting($model->verifyPassword);
                    $model->superuser = 0;
                    $model->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
                    if ($model->save()) {
                        $profile->user_id = $model->id;
                        $profile->save();
                        if (Yii::app()->controller->module->sendActivationMail) {
                            $activation_url = $this->createAbsoluteUrl('/user/activation/activation', array("activkey" => $model->activkey, "email" => $model->email));
                            $messageText = '<b>Welcome to instanttop!</b><br><br>
										Click on this link 
							<p><a href="' . $activation_url . '">' . $activation_url . '</a></p>
							<p>to activate your account or copy and paste the link into a
								browser. Dont forget your Login name is your user name or your E-mail.
								We are always here to help you can contact our customer care
								team via email 24 hours a day</p> 
							<p>Kind regards,<br>
							Your' . Yii::app()->name . ' team </p>';
                            UserModule::sendMail($model->email, UserModule::t("You registered from {site_name}", array('{site_name}' => Yii::app()->name)), $messageText);
                        }
                        if ((Yii::app()->controller->module->loginNotActiv || Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) && Yii::app()->controller->module->autoLogin) {
                            $identity = new UserIdentity($model->username, $soucePassword);
                            $identity->authenticate();
                            Yii::app()->user->login($identity, 0);
                            $this->redirect(Yii::app()->controller->module->returnUrl);
                        } else {
                            if (!Yii::app()->controller->module->activeAfterRegister && !Yii::app()->controller->module->sendActivationMail) {
                                Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Contact Admin to activate your account."));
                            } elseif (Yii::app()->controller->module->activeAfterRegister && Yii::app()->controller->module->sendActivationMail == false) {
                                Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('Login'), Yii::app()->controller->module->loginUrl))));
                            } elseif (Yii::app()->controller->module->loginNotActiv) {
                                Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email or login."));
                            } else {
                                Yii::app()->user->setFlash('registration', UserModule::t("Thank you for your registration. Please check your email."));
                            }
                            $this->refresh();
                        }
                    }
                } else {
                    $profile->validate();
                }
            }
            $this->render('/user/registration', array('model' => $model, 'profile' => $profile));
        }
    }
 /**
  * Registration user
  */
 public function actionRegistration()
 {
     $model = new RegistrationForm();
     if (isset($_GET['role']) && $_GET['role'] == 'Customer') {
         $role = 'Customer';
     } elseif (isset($_GET['role']) && $_GET['role'] == 'Author') {
         $role = 'Author';
     } elseif (isset($_GET['role']) && $_GET['role'] == 'Manager') {
         $role = 'Manager';
     } else {
         $role = 'Customer';
     }
     if (Yii::app()->user->id && (!Yii::app()->user->hasFlash('reg_success') && !Yii::app()->user->hasFlash('reg_failed'))) {
         $this->redirect(Yii::app()->controller->module->profileUrl);
     } else {
         if (isset($_POST['RegistrationForm'])) {
             $model->attributes = $_POST['RegistrationForm'];
             if ($model->validate()) {
                 $soucePassword = $this->generate_password(8);
                 $model->password = UserModule::encrypting($soucePassword);
                 $model->superuser = 0;
                 $model->status = 1;
                 $model->username = $model->email;
                 if ($model->save()) {
                     $AuthAssignment = new AuthAssignment();
                     $AuthAssignment->attributes = array('itemname' => $role, 'userid' => $model->id);
                     $AuthAssignment->save();
                     //$login_url = '<a href="'.$this->createAbsoluteUrl('/user/login').'">'.Yii::app()->name.'</a>';
                     //UserModule::sendMail($model->email,UserModule::t("You registered from {site_name}",array('{site_name}'=>Yii::app()->name)),UserModule::t("You have registred from {login_url}<br /><br />Your password: {pass}",array('{login_url}'=>$login_url, '{pass}'=>$soucePassword)));
                     // новая служба системных сообщений
                     $type_id = Emails::TYPE_11;
                     $email = new Emails();
                     $criteria = new CDbCriteria();
                     $criteria->order = 'id DESC';
                     $criteria->limit = 1;
                     $user = User::model()->findAll($criteria);
                     $user = $user[0];
                     $email->from_id = 1;
                     $email->to_id = $user->id;
                     $rec = Templates::model()->findAll("`type_id`='{$type_id}'");
                     $title = $rec[0]->title;
                     $body = $rec[0]->text;
                     $id = Campaign::getId();
                     $email->campaign = Campaign::getName();
                     $email->name = $model->full_name;
                     $email->login = $model->username;
                     $email->password = $soucePassword;
                     $email->page_cabinet = 'http://' . $_SERVER['SERVER_NAME'] . '/user/profile/edit';
                     $email->sendTo($user->email, $body, $type_id);
                     $identity = new UserIdentity($model->username, $soucePassword);
                     $identity->authenticate();
                     Yii::app()->user->login($identity, 0);
                     //$this->redirect(Yii::app()->controller->module->returnUrl);
                     Yii::app()->user->setFlash('reg_success', UserModule::t("Thank you for your registration. Password has been sent to your e-mail. Please check your e-mail ({{email}}) before start.", ['{{email}}' => $model->email]));
                     $this->refresh();
                     //Yii::app()->end();
                 } else {
                     Yii::app()->user->setFlash('reg_failed', UserModule::t("Sorry, something wrong... :("));
                     $this->refresh();
                 }
             }
         }
         Yii::app()->theme = 'client';
         $this->render('/user/registration', array('model' => $model, 'role' => $role));
     }
 }
예제 #13
0
 /**
  * Страница авторизации/регистрации
  */
 public function actionLogin()
 {
     $model = new UserLogin();
     $registration_form = new RegistrationForm();
     $user_recovery_form = new UserRecoveryForm();
     // if it is ajax validation request
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'login-form') {
         echo CActiveForm::validate($model);
         Yii::app()->end();
     }
     if (isset($_POST['UserLogin'])) {
         $model->attributes = $_POST['UserLogin'];
         if ($model->validate()) {
             //print_r($model->attributes);die;
             $this->lastViset();
             $this->redirect(array('my/index'));
         }
     }
     if (isset($_POST['RegistrationForm'])) {
         $registration_form->attributes = $_POST['RegistrationForm'];
         $registration_form->username = $registration_form->email;
         if ($registration_form->validate()) {
             $soucePassword = $registration_form->password;
             $registration_form->activkey = UserModule::encrypting(microtime() . $registration_form->password);
             $registration_form->password = UserModule::encrypting($registration_form->password);
             $registration_form->verifyPassword = UserModule::encrypting($registration_form->verifyPassword);
             $registration_form->superuser = 0;
             $registration_form->status = Yii::app()->controller->module->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_NOACTIVE;
             if ($registration_form->save()) {
                 $activation_url = $this->createAbsoluteUrl('site/activation', array("activkey" => $registration_form->activkey, "email" => $registration_form->email));
                 //UserModule::sendMail($registration_form->email,UserModule::t("Вы зарегистрировались на сайте {site_name}",array('{site_name}'=>Yii::app()->name)),UserModule::t("Для активации вашего аккаунта, перейдите пожалуста по ссылке {activation_url}",array('{activation_url}'=>$activation_url)));
                 UserModule::sendMail($registration_form->email, UserModule::t("Вы зарегистрировались на сайте {site_name}", array('{site_name}' => Yii::app()->name)), UserModule::t("Здравствуйте. Благодарим Вас за регистрацию на сервисе сохранения закладок " . Yii::app()->name . ". Для активации аккаунта перейдите по ссылке.<br> {activation_url}", array('{activation_url}' => $activation_url)));
                 return $this->redirect(array('site/regsuccess'));
             }
         }
     }
     if (isset($_POST['UserRecoveryForm'])) {
         $user_recovery_form->attributes = $_POST['UserRecoveryForm'];
         if ($user_recovery_form->validate()) {
             $user = User::model()->notsafe()->findbyPk($user_recovery_form->user_id);
             //$activation_url = 'http://' . $_SERVER['HTTP_HOST'].$this->createUrl(implode(array("/user/recovery")),array("activkey" => $user->activkey, "email" => $user->email));
             $activation_url = $this->createAbsoluteUrl('site/recovery', array("activkey" => $user->activkey, "email" => $user->email));
             $subject = UserModule::t("Запрос на восстановление пароля на сайте {site_name}", array('{site_name}' => Yii::app()->name));
             $message = UserModule::t("Вы запросили восстановление пароля на сайте {site_name}. Для получения нового пароля, перейдите по ссылке <br> {activation_url}.", array('{site_name}' => Yii::app()->name, '{activation_url}' => $activation_url));
             UserModule::sendMail($user->email, $subject, $message);
             Yii::app()->user->setFlash('recoveryMessage', UserModule::t("Ссылка на восстановление пароля<br>отправлена на вашу почту."));
             $this->refresh();
         }
     }
     $this->render('login', array('model' => $model, 'registration_form' => $registration_form, 'user_recovery_form' => $user_recovery_form));
 }
예제 #14
0
 public function actionForm()
 {
     $this->cekLogin('form');
     if ($this->isWizard) {
         $this->backAction = 'division';
     }
     $model = new RegistrationForm();
     $model->initComponent($this->rec->id, O::app()->user->id);
     $form = new CForm(array('elements' => $model->elements, 'buttons' => array('submit-form' => array('type' => 'submit', 'label' => O::t('oprecx', 'Save'))), 'activeForm' => array('class' => 'CActiveForm'), 'attributes' => array('id' => 'reg-form')), $model);
     if ($form->submitted('save') && $form->validate() && $model->save()) {
         //if ($this->isWizard) $this->redirect($this->getURL('interview', array('wiz' => 1)));
         if ($this->afterSave('interview')) {
             return;
         }
     }
     $this->render('form', array('form' => $form));
 }
예제 #15
0
 /**
  * Affichage et traitement du formulaire d'inscription
  */
 public function actionRegistration()
 {
     $form = new RegistrationForm();
     $profile = UserModuleFactory::profile();
     $profile->regMode = true;
     // ajax validator
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'registration-form') {
         echo UActiveForm::validate(array($form, $profile));
         Yii::app()->end();
     }
     /** @var UserModule $userModule */
     $userModule = Yii::app()->controller->module;
     if (Yii::app()->user->id) {
         // Utilisateur déjà identifié : on le redirige sur sa page de profil
         $this->redirect($userModule->profileUrl);
     }
     if (isset($_POST['RegistrationForm'])) {
         // Création d'un nouvel utilisateur
         $form->attributes = $_POST['RegistrationForm'];
         if (!$form->validate()) {
             Yii::app()->user->setFlash('error', UserModule::t("Unable to validate user data"));
         } else {
             $profile->attributes = $_POST[get_class($profile)];
             if (!$profile->validate()) {
                 Yii::app()->user->setFlash('error', UserModule::t("Unable to validate profile data"));
             } else {
                 $sourcePassword = $form->password;
                 $form->activkey = UserModule::encrypting(microtime() . $form->password);
                 $form->password = UserModule::encrypting($form->password);
                 $form->verifyPassword = UserModule::encrypting($form->verifyPassword);
                 $form->superuser = 0;
                 $form->status = $userModule->activeAfterRegister ? User::STATUS_ACTIVE : User::STATUS_INACTIVE;
                 $transaction = Yii::app()->db->beginTransaction();
                 if ($ok = $form->save(false)) {
                     $profile->user_id = $form->id;
                     if ($ok = $profile->save()) {
                         // On envoie le mail de confirmation
                         if (!$this->notifyRegistration($form)) {
                             Yii::app()->user->setFlash('error', UserModule::t("The confirmation mail has not been sent. Please contact the administrator"));
                         }
                         // Connexion automatique du nouvel inscrit, selon la configuration
                         $autoConnect = ($userModule->loginNotActiv || $userModule->activeAfterRegister && $userModule->sendActivationMail == false) && $userModule->autoLogin;
                         if ($autoConnect) {
                             // Connexion automatique
                             $identity = new user\components\UserIdentity($form->username, $sourcePassword);
                             $identity->authenticate();
                             Yii::app()->user->login($identity, 0);
                             $this->redirect($userModule->returnUrl);
                         } else {
                             if (!$userModule->activeAfterRegister && !$userModule->sendActivationMail) {
                                 // Pas d'activation automatique ni de mail : il faut passer par l'admin pour activer le compte
                                 Yii::app()->user->setFlash('success', Yii::t("UserModule.msg", "Thank you for your registration. Please contact the administrator to activate your account"));
                             } elseif ($userModule->activeAfterRegister && $userModule->sendActivationMail == false) {
                                 // Activation au compte, pas de mail de confirmation : on peut se connecter tout de suite
                                 Yii::app()->user->setFlash('success', Yii::t("UserModule.msg", "Thank you for your registration. You can now {{login}}.", array('{{login}}' => CHtml::link(UserModule::t('login'), $userModule->loginUrl))));
                             } elseif ($userModule->loginNotActiv) {
                                 //
                                 Yii::app()->user->setFlash('success', Yii::t("UserModule.msg", "Thank you for your registration. Please check your email or login."));
                             } else {
                                 // par défaut : pas d'activation automatique, il faut répondre au mail de confirmation
                                 Yii::app()->user->setFlash('success', Yii::t("UserModule.msg", "Thank you for your registration. Please check your email."));
                             }
                         }
                     } else {
                         // if ($ok = $profile->save())
                         $msg = array("Erreur sur \$profile->save()", $profile);
                         Yii::log(h::_($msg, __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR);
                         Yii::app()->user->setFlash('error', Yii::t('msg', 'There are errors. Please check the form'));
                     }
                 } else {
                     // if ($ok = $form->save(false))
                     $msg = array("Erreur sur \$form->save()", $form);
                     Yii::log(h::_($msg, __FILE__, __LINE__, __METHOD__), CLogger::LEVEL_ERROR);
                     Yii::app()->user->setFlash('error', UserModule::t("Registration failed. Please contact the administrator"));
                 }
                 if ($ok) {
                     // Inscription validée, on redirige en page d'accueil
                     $transaction->commit();
                     $this->redirect('/');
                 } else {
                     $transaction->rollback();
                     $form->password = $sourcePassword;
                     $form->verifyPassword = $sourcePassword;
                     $this->refresh();
                 }
             }
         }
     }
     // Inscription en erreur, on ré-affiche le formulaire
     $this->render('/user/registration', array('model' => $form, 'profile' => $profile, 'page' => $this->getPage('inscription')));
 }