- md5
- 7191a7d27e6c472aeaf28d3c444c4bef
- sha1
- acde920eddcf6e46a2c3e32375a6f0817c5c36fe
- sha256
- 1675d9ae1b6a074ee915560501bfdd958d8f621235b47d7e96fc5fdd4935867e
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
<?php
/**
* @package Joomla.Site
* @subpackage mod_login
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Module\Login\Site\Helper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Uri\Uri;
/**
* Helper for mod_login
*
* @since 1.5
*/
class LoginHelper
{
/**
* Retrieve the URL where the user should be returned after logging in
*
* @param \Joomla\Registry\Registry $params module parameters
* @param string $type return type
*
* @return string
*/
public static function getReturnUrl($params, $type)
{
$item = Factory::getApplication()->getMenu()->getItem($params->get($type));
// Stay on the same page
$url = Uri::getInstance()->toString();
if ($item) {
$lang = '';
if ($item->language !== '*' && Multilanguage::isEnabled()) {
$lang = '&lang=' . $item->language;
}
$url = 'index.php?Itemid=' . $item->id . $lang;
}
return base64_encode($url);
}
/**
* Returns the current users type
*
* @return string
*/
public static function getType()
{
$user = Factory::getUser();
return (!$user->get('guest')) ? 'logout' : 'login';
}
/**
* Retrieve the URL for the registration page
*
* @param \Joomla\Registry\Registry $params module parameters
*
* @return string
*/
public static function getRegistrationUrl($params)
{
$regLink = 'index.php?option=com_users&view=registration';
$regLinkMenuId = $params->get('customRegLinkMenu');
// If there is a custom menu item set for registration => override default
if ($regLinkMenuId) {
$item = Factory::getApplication()->getMenu()->getItem($regLinkMenuId);
if ($item) {
$regLink = 'index.php?Itemid=' . $regLinkMenuId;
if ($item->language !== '*' && Multilanguage::isEnabled()) {
$regLink .= '&lang=' . $item->language;
}
}
}
return $regLink;
}
}
The same content is in 5 releases, Joomla 4.2.0-beta3 to 4.2.1-rc2. See them all, or every version of this file.