Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class ActivationController extends Controller
- {
- public $defaultAction = 'activation';
- /**
- * Activation user account
- */
- public function actionActivation () {
- $email = $_GET['email'];
- $activkey = $_GET['activkey'];
- $login = isset($_GET['login']) ? $_GET['login'] : 0;
- if ($email&&$activkey) {
- $find = User::model()->notsafe()->findByAttributes(array('email'=>$email));
- if (isset($find)&&$find->status) {
- $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("You account is active.")));
- } elseif(isset($find->activkey) && ($find->activkey==$activkey)) {
- $find->activkey = UserModule::encrypting(microtime());
- $find->status = 1;
- $find->save();
- if($login == '1'){
- $identity=new UserIdentity($find->email,'');
- $identity->authenticate(true);
- Yii::app()->user->login($identity,0);
- $this->redirect(array('//user/profile/edit'));
- //$this->redirect(Yii::app()->controller->module->returnUrl);
- } else {
- $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("You account is activated.")));
- }
- } else {
- $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Incorrect activation URL.")));
- }
- } else {
- $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Incorrect activation URL.")));
- }
- }
- public function actionNewsletter () {
- $email = $_GET['email'];
- $activkey = $_GET['activkey'];
- if ($email&&$activkey) {
- $find = User::model()->notsafe()->findByAttributes(array('email'=>$email));
- if (isset($find)&&$find->newsletter) {
- $this->render('/user/message',array('title'=>'Aktywacja newslettera', 'content'=>'Jesteś już zapisany do newslettera'));
- } elseif($find->getNewsletterActivKey() == $activkey) {
- $find->newsletter = 1;
- $find->save();
- $this->render('/user/message',array('title'=>'Aktywacja newslettera', 'content'=>'Zapisano do newslettera'));
- } else {
- $this->render('/user/message',array('title'=>'Aktywacja newslettera','content'=>UserModule::t("Incorrect activation URL.")));
- }
- } else {
- $this->render('/user/message',array('title'=>'Aktywacja newslettera','content'=>UserModule::t("Incorrect activation URL.")));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement