Source for file logout.php

Documentation is available at logout.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Plugin
  4.  * @subpackage  System.logout
  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('JPATH_BASE'or die;
  11.  
  12. /**
  13.  * Plugin class for logout redirect handling.
  14.  *
  15.  * @package     Joomla.Plugin
  16.  * @subpackage  System.logout
  17.  * @since       1-6
  18.  */
  19. class PlgSystemLogout extends JPlugin
  20. {
  21.     /**
  22.      * Load the language file on instantiation.
  23.      *
  24.      * @var    boolean 
  25.      * @since  3.1
  26.      */
  27.     protected $autoloadLanguage = true;
  28.  
  29.     /**
  30.      * Object Constructor.
  31.      *
  32.      * @access    public
  33.      * @param   object    The object to observe -- event dispatcher.
  34.      * @param   object    The configuration object for the plugin.
  35.      * @return  void 
  36.      * @since   1.6
  37.      */
  38.     public function __construct(&$subject$config)
  39.     {
  40.         parent::__construct($subject$config);
  41.  
  42.         $input JFactory::getApplication()->input;
  43.         $hash  JApplication::getHash('PlgSystemLogout');
  44.         if (JFactory::getApplication()->isSite(&& $input->cookie->getString($hash))
  45.         {
  46.             // Destroy the cookie
  47.             $conf JFactory::getConfig();
  48.             $cookie_domain $conf->get('config.cookie_domain''');
  49.             $cookie_path   $conf->get('config.cookie_path''/');
  50.             setcookie($hashfalsetime(86400$cookie_path$cookie_domain);
  51.  
  52.             // Set the error handler for E_ALL to be the class handleError method.
  53.             JError::setErrorHandling(E_ALL'callback'array('PlgSystemLogout''handleError'));
  54.         }
  55.     }
  56.  
  57.     /**
  58.      * This method should handle any logout logic and report back to the subject
  59.      *
  60.      * @param   array  $user        Holds the user data.
  61.      * @param   array  $options    Array holding options (client, ...).
  62.      *
  63.      * @return  boolean Always returns true
  64.      * @since   1.6
  65.      */
  66.     public function onUserLogout($user$options array())
  67.     {
  68.         if (JFactory::getApplication()->isSite())
  69.         {
  70.             // Create the cookie
  71.             $hash JApplication::getHash('PlgSystemLogout');
  72.             $conf JFactory::getConfig();
  73.             $cookie_domain     $conf->get('config.cookie_domain''');
  74.             $cookie_path     $conf->get('config.cookie_path''/');
  75.             setcookie($hashtruetime(86400$cookie_path$cookie_domain);
  76.         }
  77.         return true;
  78.     }
  79.  
  80.     public static function handleError(&$error)
  81.     {
  82.         // Get the application object.
  83.         $app JFactory::getApplication();
  84.  
  85.         // Make sure the error is a 403 and we are in the frontend.
  86.         if ($error->getCode(== 403 and $app->isSite())
  87.         {
  88.             // Redirect to the home page
  89.             $app->enqueueMessage(JText::_('PLG_SYSTEM_LOGOUT_REDIRECT'));
  90.             $app->redirect('index.php'true);
  91.         }
  92.         else
  93.         {
  94.             // Render the error page.
  95.             JError::customErrorPage($error);
  96.         }
  97.     }
  98. }

Documentation generated on Tue, 19 Nov 2013 15:07:28 +0100 by phpDocumentor 1.4.3