- md5
- 053d6c20842931d5672cf0b4223c1299
- sha1
- ab896a12704a58bf4d829a1501c188a561d3ac89
- sha256
- 08f3f7561dd495a35d2d9c762605ac6bd9f7328258ec87c90bead474df1535c9
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access.
defined('_JEXEC') or die;
/**
* Users component helper.
*
* @package Joomla.Administrator
* @subpackage com_users
* @since 1.6
*/
class UsersHelper
{
/**
* @var JObject A cache for the available actions.
* @since 1.6
*/
protected static $actions;
/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 1.6
*/
public static function addSubmenu($vName)
{
JSubMenuHelper::addEntry(
JText::_('COM_USERS_SUBMENU_USERS'),
'index.php?option=com_users&view=users',
$vName == 'users'
);
// Groups and Levels are restricted to core.admin
$canDo = self::getActions();
if ($canDo->get('core.admin'))
{
JSubMenuHelper::addEntry(
JText::_('COM_USERS_SUBMENU_GROUPS'),
'index.php?option=com_users&view=groups',
$vName == 'groups'
);
JSubMenuHelper::addEntry(
JText::_('COM_USERS_SUBMENU_LEVELS'),
'index.php?option=com_users&view=levels',
$vName == 'levels'
);
JSubMenuHelper::addEntry(
JText::_('COM_USERS_SUBMENU_NOTES'),
'index.php?option=com_users&view=notes',
$vName == 'notes'
);
$extension = JRequest::getString('extension');
JSubMenuHelper::addEntry(
JText::_('COM_USERS_SUBMENU_NOTE_CATEGORIES'),
'index.php?option=com_categories&extension=com_users',
$vName == 'categories' || $extension == 'com_users'
);
}
}
/**
* Gets a list of the actions that can be performed.
*
* @return JObject
*
* @since 1.6
* @todo Refactor to work with notes
*/
public static function getActions()
{
if (empty(self::$actions))
{
$user = JFactory::getUser();
self::$actions = new JObject;
$actions = JAccess::getActions('com_users');
foreach ($actions as $action)
{
self::$actions->set($action->name, $user->authorise($action->name, 'com_users'));
}
}
return self::$actions;
}
/**
* Get a list of filter options for the blocked state of a user.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
static function getStateOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0', JText::_('JENABLED'));
$options[] = JHtml::_('select.option', '1', JText::_('JDISABLED'));
return $options;
}
/**
* Get a list of filter options for the activated state of a user.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
static function getActiveOptions()
{
// Build the filter options.
$options = array();
$options[] = JHtml::_('select.option', '0', JText::_('COM_USERS_ACTIVATED'));
$options[] = JHtml::_('select.option', '1', JText::_('COM_USERS_UNACTIVATED'));
return $options;
}
/**
* Get a list of the user groups for filtering.
*
* @return array An array of JHtmlOption elements.
*
* @since 1.6
*/
static function getGroups()
{
$db = JFactory::getDbo();
$db->setQuery(
'SELECT a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level' .
' FROM #__usergroups AS a' .
' LEFT JOIN '.$db->quoteName('#__usergroups').' AS b ON a.lft > b.lft AND a.rgt < b.rgt' .
' GROUP BY a.id, a.title, a.lft, a.rgt' .
' ORDER BY a.lft ASC'
);
$options = $db->loadObjectList();
// Check for a database error.
if ($db->getErrorNum())
{
JError::raiseNotice(500, $db->getErrorMsg());
return null;
}
foreach ($options as &$option)
{
$option->text = str_repeat('- ', $option->level).$option->text;
}
return $options;
}
/**
* Creates a list of range options used in filter select list
* used in com_users on users view
*
* @return array
*
* @since 2.5
*/
public static function getRangeOptions()
{
$options = array(
JHtml::_('select.option', 'today', JText::_('COM_USERS_OPTION_RANGE_TODAY')),
JHtml::_('select.option', 'past_week', JText::_('COM_USERS_OPTION_RANGE_PAST_WEEK')),
JHtml::_('select.option', 'past_1month', JText::_('COM_USERS_OPTION_RANGE_PAST_1MONTH')),
JHtml::_('select.option', 'past_3month', JText::_('COM_USERS_OPTION_RANGE_PAST_3MONTH')),
JHtml::_('select.option', 'past_6month', JText::_('COM_USERS_OPTION_RANGE_PAST_6MONTH')),
JHtml::_('select.option', 'past_year', JText::_('COM_USERS_OPTION_RANGE_PAST_YEAR')),
JHtml::_('select.option', 'post_year', JText::_('COM_USERS_OPTION_RANGE_POST_YEAR')),
);
return $options;
}
}
The same content is in 11 releases, Joomla 2.5.18 to 2.5.28. See them all, or every version of this file.