- md5
- b9693219d6250e6a313c8824b5d80706
- sha1
- 1a5f0618db7f7b92a0373e43f19bea63bd559054
- sha256
- fd045ab750fb8629d0335379ef3c120be36cdf5934b1573f07639184254f9680
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
<?php
/**
* @package Joomla.Site
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Base controller class for Users.
*
* @package Joomla.Site
* @subpackage com_users
* @since 1.5
*/
class UsersController extends JControllerLegacy
{
/**
* Method to display a view.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
// Get the document object.
$document = JFactory::getDocument();
// Set the default view name and format from the Request.
$vName = $this->input->getCmd('view', 'login');
$vFormat = $document->getType();
$lName = $this->input->getCmd('layout', 'default');
if ($view = $this->getView($vName, $vFormat))
{
// Do any specific processing by view.
switch ($vName)
{
case 'registration':
// If the user is already logged in, redirect to the profile page.
$user = JFactory::getUser();
if ($user->get('guest') != 1)
{
// Redirect to profile page.
$this->setRedirect(JRoute::_('index.php?option=com_users&view=profile', false));
return;
}
// Check if user registration is enabled
if (JComponentHelper::getParams('com_users')->get('allowUserRegistration') == 0)
{
// Registration is disabled - Redirect to login page.
$this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false));
return;
}
// The user is a guest, load the registration model and show the registration page.
$model = $this->getModel('Registration');
break;
// Handle view specific models.
case 'profile':
// If the user is a guest, redirect to the login page.
$user = JFactory::getUser();
if ($user->get('guest') == 1)
{
// Redirect to login page.
$this->setRedirect(JRoute::_('index.php?option=com_users&view=login', false));
return;
}
$model = $this->getModel($vName);
break;
// Handle the default views.
case 'login':
$model = $this->getModel($vName);
break;
case 'reset':
// If the user is already logged in, redirect to the profile page.
$user = JFactory::getUser();
if ($user->get('guest') != 1)
{
// Redirect to profile page.
$this->setRedirect(JRoute::_('index.php?option=com_users&view=profile', false));
return;
}
$model = $this->getModel($vName);
break;
case 'remind':
// If the user is already logged in, redirect to the profile page.
$user = JFactory::getUser();
if ($user->get('guest') != 1)
{
// Redirect to profile page.
$this->setRedirect(JRoute::_('index.php?option=com_users&view=profile', false));
return;
}
$model = $this->getModel($vName);
break;
default:
$model = $this->getModel('Login');
break;
}
// Push the model into the view (as default).
$view->setModel($model, true);
$view->setLayout($lName);
// Push document object into the view.
$view->document = $document;
$view->display();
}
}
}
The same content is in 9 releases, Joomla 3.0.3 to 3.2.1. See them all, or every version of this file.