PageRenderTime 91ms CodeModel.GetById 34ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_users/helpers/route.php

https://github.com/joebushi/joomla
PHP | 203 lines | 92 code | 25 blank | 86 comment | 14 complexity | 262f41f98572647479fcb391f7a9b2d4 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. <?php
  2. /**
  3. * @version $Id$
  4. * @package Joomla.Site
  5. * @subpackage com_users
  6. * @copyright Copyright (C) 2005 - 2010 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. * Users Route Helper
  12. *
  13. * @package Joomla.Site
  14. * @subpackage com_users
  15. * @version 1.0
  16. */
  17. class UsersHelperRoute
  18. {
  19. /**
  20. * Method to get the menu items for the component.
  21. *
  22. * @access public
  23. * @return array An array of menu items.
  24. * @since 1.0
  25. * @static
  26. */
  27. function &getItems()
  28. {
  29. static $items;
  30. // Get the menu items for this component.
  31. if (!isset($items))
  32. {
  33. // Include the site app in case we are loading this from the admin.
  34. require_once JPATH_SITE.DS.'includes'.DS.'application.php';
  35. $menu = &JSite::getMenu();
  36. $com = &JComponentHelper::getComponent('com_users');
  37. $items = $menu->getItems('component_id', $com->id);
  38. // If no items found, set to empty array.
  39. if (!$items) {
  40. $items = array();
  41. }
  42. }
  43. return $items;
  44. }
  45. /**
  46. * Method to get a route configuration for the login view.
  47. *
  48. * @access public
  49. * @return mixed Integer menu id on success, null on failure.
  50. * @since 1.0
  51. * @static
  52. */
  53. function getLoginRoute()
  54. {
  55. // Get the items.
  56. $items = &UsersHelperRoute::getItems();
  57. $itemid = null;
  58. // Search for a suitable menu id.
  59. foreach ($items as $item) {
  60. if (isset($item->query['view']) && $item->query['view'] === 'login') {
  61. $itemid = $item->id;
  62. break;
  63. }
  64. }
  65. return $itemid;
  66. }
  67. /**
  68. * Method to get a route configuration for the profile view.
  69. *
  70. * @access public
  71. * @return mixed Integer menu id on success, null on failure.
  72. * @since 1.0
  73. * @static
  74. */
  75. function getProfileRoute()
  76. {
  77. // Get the items.
  78. $items = &UsersHelperRoute::getItems();
  79. $itemid = null;
  80. // Search for a suitable menu id.
  81. //Menu link can only go to users own profile.
  82. foreach ($items as $item) {
  83. if (isset($item->query['view']) && $item->query['view'] === 'profile') {
  84. $itemid = $item->id;
  85. break;
  86. }
  87. }
  88. return $itemid;
  89. }
  90. /**
  91. * Method to get a route configuration for the registration view.
  92. *
  93. * @access public
  94. * @return mixed Integer menu id on success, null on failure.
  95. * @since 1.0
  96. * @static
  97. */
  98. function getRegistrationRoute()
  99. {
  100. // Get the items.
  101. $items = &UsersHelperRoute::getItems();
  102. $itemid = null;
  103. // Search for a suitable menu id.
  104. foreach ($items as $item) {
  105. if (isset($item->query['view']) && $item->query['view'] === 'registration') {
  106. $itemid = $item->id;
  107. break;
  108. }
  109. }
  110. return $itemid;
  111. }
  112. /**
  113. * Method to get a route configuration for the remind view.
  114. *
  115. * @access public
  116. * @return mixed Integer menu id on success, null on failure.
  117. * @since 1.0
  118. * @static
  119. */
  120. function getRemindRoute()
  121. {
  122. // Get the items.
  123. $items = &UsersHelperRoute::getItems();
  124. $itemid = null;
  125. // Search for a suitable menu id.
  126. foreach ($items as $item) {
  127. if (isset($item->query['view']) && $item->query['view'] === 'remind') {
  128. $itemid = $item->id;
  129. break;
  130. }
  131. }
  132. return $itemid;
  133. }
  134. /**
  135. * Method to get a route configuration for the resend view.
  136. *
  137. * @access public
  138. * @return mixed Integer menu id on success, null on failure.
  139. * @since 1.0
  140. * @static
  141. */
  142. function getResendRoute()
  143. {
  144. // Get the items.
  145. $items = &UsersHelperRoute::getItems();
  146. $itemid = null;
  147. // Search for a suitable menu id.
  148. foreach ($items as $item) {
  149. if (isset($item->query['view']) && $item->query['view'] === 'resend') {
  150. $itemid = $item->id;
  151. break;
  152. }
  153. }
  154. return $itemid;
  155. }
  156. /**
  157. * Method to get a route configuration for the reset view.
  158. *
  159. * @access public
  160. * @return mixed Integer menu id on success, null on failure.
  161. * @since 1.0
  162. * @static
  163. */
  164. function getResetRoute()
  165. {
  166. // Get the items.
  167. $items = &UsersHelperRoute::getItems();
  168. $itemid = null;
  169. // Search for a suitable menu id.
  170. foreach ($items as $item) {
  171. if (isset($item->query['view']) && $item->query['view'] === 'reset') {
  172. $itemid = $item->id;
  173. break;
  174. }
  175. }
  176. return $itemid;
  177. }
  178. }