forked from dzdevteam/mod_steamlogin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.php
executable file
·93 lines (85 loc) · 2.57 KB
/
helper.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* @version 1.0.0
* @package mod_steamlogin
* @copyright Copyright (C) 2013. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @author DZ Team <[email protected]> - dezign.vn
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
abstract class modSteamLoginHelper
{
public static function getReturnURL($params, $type)
{
$app = JFactory::getApplication();
$router = $app->getRouter();
$url = null;
if ($itemid = $params->get($type))
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('link'))
->from($db->quoteName('#__menu'))
->where($db->quoteName('published') . '=1')
->where($db->quoteName('id') . '=' . $db->quote($itemid));
$db->setQuery($query);
if ($link = $db->loadResult())
{
if ($router->getMode() == JROUTER_MODE_SEF)
{
$url = 'index.php?Itemid='.$itemid;
}
else {
$url = $link.'&Itemid='.$itemid;
}
}
}
if (!$url)
{
$url = self::getCurrentUrl();
}
return $url;
}
public static function getCurrentUrl()
{
$url = null;
// Stay on the same page
$uri = clone JUri::getInstance();
$app = JFactory::getApplication();
$router = $app->getRouter();
$vars = $router->parse($uri);
unset($vars['lang']);
if ($router->getMode() == JROUTER_MODE_SEF)
{
if (isset($vars['Itemid']))
{
$itemid = $vars['Itemid'];
$menu = $app->getMenu();
$item = $menu->getItem($itemid);
unset($vars['Itemid']);
if (isset($item) && $vars == $item->query)
{
$url = 'index.php?Itemid='.$itemid;
}
else {
$url = 'index.php?'.JUri::buildQuery($vars).'&Itemid='.$itemid;
}
}
else
{
$url = 'index.php?'.JUri::buildQuery($vars);
}
}
else
{
$url = 'index.php?'.JUri::buildQuery($vars);
}
return $url;
}
public static function getType()
{
$user = JFactory::getUser();
return (!$user->get('guest')) ? 'logout' : 'login';
}
}