[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/administrator/components/com_login/ -> controller.php (source)

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


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1