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