Source for file controller.php

Documentation is available at controller.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_login
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Login Controller
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_login
  17.  * @since       1.5
  18.  */
  19. {
  20.     /**
  21.      * Typical view method for MVC based architecture
  22.      *
  23.      * This function is provide as a default implementation, in most cases
  24.      * you will need to override it in your own controllers.
  25.      *
  26.      * @param   boolean            If true, the view output will be cached
  27.      * @param   array  An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
  28.      * @return  JController        This object to support chaining.
  29.      * @since   1.5
  30.      */
  31.     public function display($cachable false$urlparams false)
  32.     {
  33.         // Special treatment is required for this component, as this view may be called
  34.         // after a session timeout. We must reset the view and layout prior to display
  35.         // otherwise an error will occur.
  36.  
  37.         $this->input->set('view''login');
  38.         $this->input->set('layout''default');
  39.  
  40.         parent::display();
  41.     }
  42.  
  43.     /**
  44.      * Method to log in a user.
  45.      *
  46.      * @return  void 
  47.      */
  48.     public function login()
  49.     {
  50.         // Check for request forgeries.
  51.         JSession::checkToken('request'or jexit(JText::_('JINVALID_TOKEN'));
  52.  
  53.         $app JFactory::getApplication();
  54.  
  55.         $model $this->getModel('login');
  56.         $credentials $model->getState('credentials');
  57.         $return $model->getState('return');
  58.  
  59.         $result $app->login($credentialsarray('action' => 'core.login.admin'));
  60.  
  61.         if (!($result instanceof Exception))
  62.         {
  63.             $app->redirect($return);
  64.         }
  65.  
  66.         parent::display();
  67.     }
  68.  
  69.     /**
  70.      * Method to log out a user.
  71.      *
  72.      * @return  void 
  73.      */
  74.     public function logout()
  75.     {
  76.         JSession::checkToken('request'or jexit(JText::_('JInvalid_Token'));
  77.  
  78.         $app JFactory::getApplication();
  79.  
  80.         $userid $this->input->getInt('uid'null);
  81.  
  82.         $options array(
  83.             'clientid' => ($userid1
  84.         );
  85.  
  86.         $result $app->logout($userid$options);
  87.  
  88.         if (!($result instanceof Exception))
  89.         {
  90.             $model     $this->getModel('login');
  91.             $return $model->getState('return');
  92.             $app->redirect($return);
  93.         }
  94.  
  95.         parent::display();
  96.     }
  97. }

Documentation generated on Tue, 19 Nov 2013 14:57:06 +0100 by phpDocumentor 1.4.3