PageRenderTime 32ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/mod_login/helper.php

https://bitbucket.org/programmerlab/ourteam.co.in
PHP | 121 lines | 74 code | 13 blank | 34 comment | 11 complexity | 81dff994d160748fc4f87456c773df0b MD5 | raw file
Possible License(s): GPL-2.0, GPL-3.0, 0BSD, MIT, LGPL-2.1
  1. <?php
  2. /**
  3. * @package Joomla.Site
  4. * @subpackage mod_login
  5. *
  6. * @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE.txt
  8. */
  9. defined('_JEXEC') or die;
  10. /**
  11. * Helper for mod_login
  12. *
  13. * @package Joomla.Site
  14. * @subpackage mod_login
  15. *
  16. * @since 1.5
  17. */
  18. class ModLoginHelper
  19. {
  20. /**
  21. * Retrieve the url where the user should be returned after logging in
  22. *
  23. * @param \Joomla\Registry\Registry $params module parameters
  24. * @param string $type return type
  25. *
  26. * @return string
  27. */
  28. public static function getReturnURL($params, $type)
  29. {
  30. $app = JFactory::getApplication();
  31. $router = $app::getRouter();
  32. $url = null;
  33. if ($itemid = $params->get($type))
  34. {
  35. $db = JFactory::getDbo();
  36. $query = $db->getQuery(true)
  37. ->select($db->quoteName('link'))
  38. ->from($db->quoteName('#__menu'))
  39. ->where($db->quoteName('published') . '=1')
  40. ->where($db->quoteName('id') . '=' . $db->quote($itemid));
  41. $db->setQuery($query);
  42. if ($link = $db->loadResult())
  43. {
  44. if ($router->getMode() == JROUTER_MODE_SEF)
  45. {
  46. $url = 'index.php?Itemid=' . $itemid;
  47. }
  48. else
  49. {
  50. $url = $link . '&Itemid=' . $itemid;
  51. }
  52. }
  53. }
  54. if (!$url)
  55. {
  56. // Stay on the same page
  57. $vars = $router->getVars();
  58. unset($vars['lang']);
  59. if ($router->getMode() == JROUTER_MODE_SEF)
  60. {
  61. if (isset($vars['Itemid']))
  62. {
  63. $itemid = $vars['Itemid'];
  64. $menu = $app->getMenu();
  65. $item = $menu->getItem($itemid);
  66. unset($vars['Itemid']);
  67. if (isset($item) && $vars == $item->query)
  68. {
  69. $url = 'index.php?Itemid=' . $itemid;
  70. }
  71. else
  72. {
  73. $url = 'index.php?' . JUri::buildQuery($vars) . '&Itemid=' . $itemid;
  74. }
  75. }
  76. else
  77. {
  78. $url = 'index.php?' . JUri::buildQuery($vars);
  79. }
  80. }
  81. else
  82. {
  83. $url = 'index.php?' . JUri::buildQuery($vars);
  84. }
  85. }
  86. return base64_encode($url);
  87. }
  88. /**
  89. * Returns the current users type
  90. *
  91. * @return string
  92. */
  93. public static function getType()
  94. {
  95. $user = JFactory::getUser();
  96. return (!$user->get('guest')) ? 'logout' : 'login';
  97. }
  98. /**
  99. * Get list of available two factor methods
  100. *
  101. * @return array
  102. */
  103. public static function getTwoFactorMethods()
  104. {
  105. require_once JPATH_ADMINISTRATOR . '/components/com_users/helpers/users.php';
  106. return UsersHelper::getTwoFactorMethods();
  107. }
  108. }