Source for file login.php

Documentation is available at login.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 Model
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_login
  17.  * @since       1.5
  18.  */
  19. class LoginModelLogin extends JModelLegacy
  20. {
  21.     /**
  22.      * Method to auto-populate the model state.
  23.      *
  24.      * Note. Calling getState in this method will result in recursion.
  25.      *
  26.      * @since   1.6
  27.      */
  28.     protected function populateState()
  29.     {
  30.         $credentials array(
  31.             'username' => JRequest::getVar('username''''method''username'),
  32.             'password' => JRequest::getVar('passwd''''post''string'JREQUEST_ALLOWRAW),
  33.             'secretkey' => JRequest::getVar('secretkey''''post''string'JREQUEST_ALLOWRAW),
  34.         );
  35.         $this->setState('credentials'$credentials);
  36.  
  37.         // check for return URL from the request first
  38.         if ($return JRequest::getVar('return''''method''base64'))
  39.         {
  40.             $return base64_decode($return);
  41.             if (!JUri::isInternal($return))
  42.             {
  43.                 $return '';
  44.             }
  45.         }
  46.  
  47.         // Set the return URL if empty.
  48.         if (empty($return))
  49.         {
  50.             $return 'index.php';
  51.         }
  52.  
  53.         $this->setState('return'$return);
  54.     }
  55.  
  56.     /**
  57.      * Get the administrator login module by name (real, eg 'login' or folder, eg 'mod_login')
  58.      *
  59.      * @param   string  $name   The name of the module
  60.      * @param   string  $title  The title of the module, optional
  61.      *
  62.      * @return  object  The Module object
  63.      *
  64.      * @since   11.1
  65.      */
  66.     public static function getLoginModule($name 'mod_login'$title null)
  67.     {
  68.         $result null;
  69.         $modules self::_load($name);
  70.         $total count($modules);
  71.  
  72.         for ($i 0$i $total$i++)
  73.         {
  74.             // Match the title if we're looking for a specific instance of the module
  75.             if (!$title || $modules[$i]->title == $title)
  76.             {
  77.                 $result $modules[$i];
  78.                 break// Found it
  79.             }
  80.         }
  81.  
  82.         // If we didn't find it, and the name is mod_something, create a dummy object
  83.         if (is_null($result&& substr($name04== 'mod_')
  84.         {
  85.             $result new stdClass;
  86.             $result->id 0;
  87.             $result->title '';
  88.             $result->module $name;
  89.             $result->position '';
  90.             $result->content '';
  91.             $result->showtitle 0;
  92.             $result->control '';
  93.             $result->params '';
  94.             $result->user 0;
  95.         }
  96.  
  97.         return $result;
  98.     }
  99.  
  100.     /**
  101.      * Load login modules.
  102.      *
  103.      * Note that we load regardless of state or access level since access
  104.      * for public is the only thing that makes sense since users are not logged in
  105.      * and the module lets them log in.
  106.      * This is put in as a failsafe to avoid super user lock out caused by an unpublished
  107.      * login module or by a module set to have a viewing access level that is not Public.
  108.      *
  109.      * @param   string  $name   The name of the module
  110.      *
  111.      * @return  array 
  112.      *
  113.      * @since   11.1
  114.      */
  115.     protected static function _load($module)
  116.     {
  117.         static $clean;
  118.  
  119.         if (isset($clean))
  120.         {
  121.             return $clean;
  122.         }
  123.  
  124.         $app JFactory::getApplication();
  125.         $lang JFactory::getLanguage()->getTag();
  126.         $clientId = (int) $app->getClientId();
  127.  
  128.         $cache JFactory::getCache('com_modules''');
  129.         $cacheid md5(serialize(array($clientId$lang)));
  130.         $loginmodule array();
  131.  
  132.         if (!($clean $cache->get($cacheid)))
  133.         {
  134.             $db JFactory::getDbo();
  135.  
  136.             $query $db->getQuery(true)
  137.                 ->select('m.id, m.title, m.module, m.position, m.showtitle, m.params')
  138.                 ->from('#__modules AS m')
  139.                 ->where('m.module =' $db->quote($module' AND m.client_id = 1')
  140.  
  141.                 ->join('LEFT''#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id')
  142.                 ->where('e.enabled = 1');
  143.  
  144.             // Filter by language
  145.             if ($app->isSite(&& $app->getLanguageFilter())
  146.             {
  147.                 $query->where('m.language IN (' $db->quote($lang',' $db->quote('*'')');
  148.             }
  149.  
  150.             $query->order('m.position, m.ordering');
  151.  
  152.             // Set the query
  153.             $db->setQuery($query);
  154.  
  155.             try
  156.             {
  157.                 $modules $db->loadObjectList();
  158.             }
  159.             catch (RuntimeException $e)
  160.             {
  161.                 JError::raiseWarning(500JText::sprintf('JLIB_APPLICATION_ERROR_MODULE_LOAD'$e->getMessage()));
  162.                 return $loginmodule;
  163.             }
  164.  
  165.             // Return to simple indexing that matches the query order.
  166.             $loginmodule $modules;
  167.  
  168.             $cache->store($loginmodule$cacheid);
  169.         }
  170.  
  171.         return $loginmodule;
  172.     }
  173. }

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