Advertisement
eerrtt

Untitled

Mar 18th, 2014
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.50 KB | None | 0 0
  1. <?php
  2.  
  3. class ActivationController extends Controller
  4. {
  5.     public $defaultAction = 'activation';
  6.  
  7.    
  8.     /**
  9.      * Activation user account
  10.      */
  11.     public function actionActivation () {
  12.         $email = $_GET['email'];
  13.         $activkey = $_GET['activkey'];
  14.         $login = isset($_GET['login']) ? $_GET['login'] : 0;
  15.         if ($email&&$activkey) {
  16.             $find = User::model()->notsafe()->findByAttributes(array('email'=>$email));
  17.             if (isset($find)&&$find->status) {
  18.                 $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("You account is active.")));
  19.             } elseif(isset($find->activkey) && ($find->activkey==$activkey)) {
  20.                 $find->activkey = UserModule::encrypting(microtime());
  21.                 $find->status = 1;
  22.                 $find->save();
  23.                 if($login == '1'){
  24.                     $identity=new UserIdentity($find->email,'');
  25.                     $identity->authenticate(true);
  26.                     Yii::app()->user->login($identity,0);
  27.                     $this->redirect(array('//user/profile/edit'));
  28.                     //$this->redirect(Yii::app()->controller->module->returnUrl);
  29.                 } else {
  30.                     $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("You account is activated.")));
  31.                 }
  32.             } else {
  33.                 $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Incorrect activation URL.")));
  34.             }
  35.         } else {
  36.             $this->render('/user/message',array('title'=>UserModule::t("User activation"),'content'=>UserModule::t("Incorrect activation URL.")));
  37.         }
  38.     }
  39.    
  40.     public function actionNewsletter () {
  41.         $email = $_GET['email'];
  42.         $activkey = $_GET['activkey'];
  43.         if ($email&&$activkey) {
  44.             $find = User::model()->notsafe()->findByAttributes(array('email'=>$email));
  45.             if (isset($find)&&$find->newsletter) {
  46.                 $this->render('/user/message',array('title'=>'Aktywacja newslettera', 'content'=>'Jesteś już zapisany do newslettera'));
  47.             } elseif($find->getNewsletterActivKey() == $activkey) {
  48.                 $find->newsletter = 1;
  49.                 $find->save();
  50.                 $this->render('/user/message',array('title'=>'Aktywacja newslettera', 'content'=>'Zapisano do newslettera'));
  51.             } else {
  52.                 $this->render('/user/message',array('title'=>'Aktywacja newslettera','content'=>UserModule::t("Incorrect activation URL.")));
  53.             }
  54.         } else {
  55.             $this->render('/user/message',array('title'=>'Aktywacja newslettera','content'=>UserModule::t("Incorrect activation URL.")));
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement