| [ Index ] |
PHP Cross Reference of Joomla 2.5.4 DE |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @package Joomla.Administrator 4 * @subpackage com_users 5 * 6 * @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved. 7 * @license GNU General Public License version 2 or later; see LICENSE.txt 8 */ 9 10 // No direct access. 11 defined('_JEXEC') or die; 12 13 /** 14 * Users component helper. 15 * 16 * @package Joomla.Administrator 17 * @subpackage com_users 18 * @since 1.6 19 */ 20 class UsersHelper 21 { 22 /** 23 * @var JObject A cache for the available actions. 24 * @since 1.6 25 */ 26 protected static $actions; 27 28 /** 29 * Configure the Linkbar. 30 * 31 * @param string $vName The name of the active view. 32 * 33 * @return void 34 * 35 * @since 1.6 36 */ 37 public static function addSubmenu($vName) 38 { 39 JSubMenuHelper::addEntry( 40 JText::_('COM_USERS_SUBMENU_USERS'), 41 'index.php?option=com_users&view=users', 42 $vName == 'users' 43 ); 44 45 // Groups and Levels are restricted to core.admin 46 $canDo = self::getActions(); 47 48 if ($canDo->get('core.admin')) 49 { 50 JSubMenuHelper::addEntry( 51 JText::_('COM_USERS_SUBMENU_GROUPS'), 52 'index.php?option=com_users&view=groups', 53 $vName == 'groups' 54 ); 55 JSubMenuHelper::addEntry( 56 JText::_('COM_USERS_SUBMENU_LEVELS'), 57 'index.php?option=com_users&view=levels', 58 $vName == 'levels' 59 ); 60 JSubMenuHelper::addEntry( 61 JText::_('COM_USERS_SUBMENU_NOTES'), 62 'index.php?option=com_users&view=notes', 63 $vName == 'notes' 64 ); 65 66 $extension = JRequest::getString('extension'); 67 JSubMenuHelper::addEntry( 68 JText::_('COM_USERS_SUBMENU_NOTE_CATEGORIES'), 69 'index.php?option=com_categories&extension=com_users.notes', 70 $vName == 'categories' || $extension == 'com_users.notes' 71 ); 72 } 73 } 74 75 /** 76 * Gets a list of the actions that can be performed. 77 * 78 * @return JObject 79 * 80 * @since 1.6 81 * @todo Refactor to work with notes 82 */ 83 public static function getActions() 84 { 85 if (empty(self::$actions)) 86 { 87 $user = JFactory::getUser(); 88 self::$actions = new JObject; 89 90 $actions = array( 91 'core.admin', 'core.manage', 'core.create', 'core.edit', 'core.edit.state', 'core.delete' 92 ); 93 94 foreach ($actions as $action) 95 { 96 self::$actions->set($action, $user->authorise($action, 'com_users')); 97 } 98 } 99 100 return self::$actions; 101 } 102 103 /** 104 * Get a list of filter options for the blocked state of a user. 105 * 106 * @return array An array of JHtmlOption elements. 107 * 108 * @since 1.6 109 */ 110 static function getStateOptions() 111 { 112 // Build the filter options. 113 $options = array(); 114 $options[] = JHtml::_('select.option', '0', JText::_('JENABLED')); 115 $options[] = JHtml::_('select.option', '1', JText::_('JDISABLED')); 116 117 return $options; 118 } 119 120 /** 121 * Get a list of filter options for the activated state of a user. 122 * 123 * @return array An array of JHtmlOption elements. 124 * 125 * @since 1.6 126 */ 127 static function getActiveOptions() 128 { 129 // Build the filter options. 130 $options = array(); 131 $options[] = JHtml::_('select.option', '0', JText::_('COM_USERS_ACTIVATED')); 132 $options[] = JHtml::_('select.option', '1', JText::_('COM_USERS_UNACTIVATED')); 133 134 return $options; 135 } 136 137 /** 138 * Get a list of the user groups for filtering. 139 * 140 * @return array An array of JHtmlOption elements. 141 * 142 * @since 1.6 143 */ 144 static function getGroups() 145 { 146 $db = JFactory::getDbo(); 147 $db->setQuery( 148 'SELECT a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level' . 149 ' FROM #__usergroups AS a' . 150 ' LEFT JOIN '.$db->quoteName('#__usergroups').' AS b ON a.lft > b.lft AND a.rgt < b.rgt' . 151 ' GROUP BY a.id, a.title, a.lft, a.rgt' . 152 ' ORDER BY a.lft ASC' 153 ); 154 $options = $db->loadObjectList(); 155 156 // Check for a database error. 157 if ($db->getErrorNum()) 158 { 159 JError::raiseNotice(500, $db->getErrorMsg()); 160 return null; 161 } 162 163 foreach ($options as &$option) 164 { 165 $option->text = str_repeat('- ', $option->level).$option->text; 166 } 167 168 return $options; 169 } 170 171 /** 172 * Creates a list of range options used in filter select list 173 * used in com_users on users view 174 * 175 * @return array 176 * 177 * @since 2.5 178 */ 179 public static function getRangeOptions() 180 { 181 $options = array( 182 JHtml::_('select.option', 'today', JText::_('COM_USERS_OPTION_RANGE_TODAY')), 183 JHtml::_('select.option', 'past_week', JText::_('COM_USERS_OPTION_RANGE_PAST_WEEK')), 184 JHtml::_('select.option', 'past_1month', JText::_('COM_USERS_OPTION_RANGE_PAST_1MONTH')), 185 JHtml::_('select.option', 'past_3month', JText::_('COM_USERS_OPTION_RANGE_PAST_3MONTH')), 186 JHtml::_('select.option', 'past_6month', JText::_('COM_USERS_OPTION_RANGE_PAST_6MONTH')), 187 JHtml::_('select.option', 'past_year', JText::_('COM_USERS_OPTION_RANGE_PAST_YEAR')), 188 JHtml::_('select.option', 'post_year', JText::_('COM_USERS_OPTION_RANGE_POST_YEAR')), 189 ); 190 return $options; 191 } 192 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Tue Apr 3 11:40:28 2012 | Cross-referenced by PHPXref 0.7.1 |