daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Jul 20th, 2017 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //widget inside the components
  2.  
  3.  
  4. <?php
  5. /*
  6.  *@Author Marvin D. 2011-02-08
  7.  * Login Component for the main page :P
  8.  */
  9. class Login extends CWidget
  10. {
  11.     public function init()
  12.     {
  13.        //leave this shit blank ok!
  14.     }
  15.     public function run()
  16.     {
  17.        
  18.             $model=new LoginForm;
  19.  
  20.         // if it is ajax validation request
  21.         if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
  22.         {
  23.             echo CActiveForm::validate($model);
  24.             Yii::app()->end();
  25.         }
  26.  
  27.         // collect user input data
  28.         if(isset($_POST['LoginForm']))
  29.         {
  30.             $model->username =$_POST['LoginForm']['username'];
  31.                         $model->password = $_POST['LoginForm']['password'];
  32.             // validate user input and redirect to the previous page if valid
  33.             if($model->validate() && $model->login())
  34.                                 if(Yii::app()->session->contains('cvform')){
  35.                                     Yii::app()->user->setReturnUrl($this->createUrl('wsrecruitcvhead/create',array('r'=>'wsrecruitcvhead/create','cvid'=>Yii::app()->user->id),'&'));
  36.                                      $this->controller->redirect(Yii::app()->user->returnUrl);
  37.                                 } else {
  38.                                      $this->controller->redirect(Yii::app()->user->returnUrl);
  39.                                 }
  40.  
  41.         // display the login form.. no need for this one
  42.         #$this->render('login',array('model'=>$model));
  43.        }
  44.         $this->render('login');
  45.     }
  46. }
  47.  
  48. ?>
  49.  
  50.  
  51. //hide it when user is already logged in ...main layout
  52.  
  53.                     <?php
  54.                     if(Yii::app()->user->isGuest){
  55.                         $this->widget('application.components.Login', array(
  56.                             ));
  57.                     }
  58.                     ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top