Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.68 KB | None | 0 0
  1. <?php
  2. use \Orm\Model\Branch;
  3.  
  4. class Controller_Default extends Controller_Template
  5. {
  6.     public  $template       = 'default/template';
  7.  
  8.     private function after_login()
  9.     {
  10.         /*
  11.         Session::set("all_branches", Model_Branch::find('all'));
  12.  
  13.         $user_fields    = Auth::get_profile_fields();
  14.         Session::set("pce_user", $user_fields);
  15.  
  16.         $user_branches  = Model_Branch::find('all', array('where' => array(array('id', 'in', unserialize($user_fields['branches'])))));
  17.         Session::set('pce_user.branches', $user_branches);
  18.         Session::set('pce_user.active_branches', $user_branches);
  19.         */
  20.        
  21.         PCE::login_redirect();
  22.     }
  23.  
  24.     public function action_login()
  25.     {
  26.         if(Auth::check())
  27.         {
  28.             //already logged in
  29.             Messages::success(__('login.already_loggedin'));
  30.             $this->after_login();
  31.         }
  32.         elseif(!Input::post())
  33.         {
  34.             //please log in
  35.             Messages::info(__('login.please'));
  36.         }
  37.  
  38.         if($input = Input::post())
  39.         {
  40.             // check the credentials.
  41.             if (Auth::login(Input::param('username'), Input::param('password')))
  42.             {
  43.                 if (Input::param('remember_me', false))
  44.                 {
  45.                     //create a remember_me cookie
  46.                     Auth::remember_me();
  47.                 }
  48.                 else
  49.                 {
  50.                     //delete any remember_me cookies present
  51.                     Auth::dont_remember_me();
  52.                 }
  53.  
  54.                 //login successful => set message and redirect
  55.                 Messages::success(__('login.success'));
  56.                 $this->after_login();
  57.             }
  58.             else
  59.             {
  60.                 // login failed, show an error message
  61.                 \Messages::error(__('login.failure'));
  62.             }
  63.         }
  64.  
  65.         $this->template->title = 'PCexpres order management system &raquo; Index';
  66.         $this->template->content = View::forge('default/index');
  67.     }
  68.  
  69.     public function action_logout()
  70.     {
  71.         // remove the remember-me cookie, we logged-out on purpose
  72.         \Auth::dont_remember_me();
  73.         // logout
  74.         \Auth::logout();     
  75.         // inform the user the logout was successful
  76.         \Messages::success(__('login.logout'));
  77.         //redirect to login
  78.         Response::redirect('/');
  79.     }
  80.  
  81.     public function action_404()
  82.     {
  83.         $data['subnav'] = array('404'=> 'active' );
  84.         $this->template->title = 'PCexpres order management system &raquo; 404';
  85.         $this->template->content = Presenter::forge('default/404')->set($data);
  86.     }
  87.  
  88.  
  89.     public function action_disambiguation()
  90.     {
  91.         if(!Auth::check())
  92.         {
  93.             Response::redirect('/');
  94.         }
  95.  
  96.         $data['subnav'] = array('disambiguation'=> 'active' );
  97.         $this->template->title = 'PCexpres order management system &raquo; Disambiguation';
  98.         $this->template->content = View::forge('default/disambiguation')->set($data);
  99.     }
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement