Source for file user.php

Documentation is available at user.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  HTML
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Utility class working with users
  14.  *
  15.  * @package     Joomla.Libraries
  16.  * @subpackage  HTML
  17.  * @since       2.5
  18.  */
  19. abstract class JHtmlUser
  20. {
  21.     /**
  22.      * Displays a list of user groups.
  23.      *
  24.      * @param   boolean  $includeSuperAdmin  true to include super admin groups, false to exclude them
  25.      *
  26.      * @return  array  An array containing a list of user groups.
  27.      *
  28.      * @since   2.5
  29.      */
  30.     public static function groups($includeSuperAdmin false)
  31.     {
  32.         $db JFactory::getDbo();
  33.         $query $db->getQuery(true)
  34.             ->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level')
  35.             ->from($db->quoteName('#__usergroups'' AS a')
  36.             ->join('LEFT'$db->quoteName('#__usergroups'' AS b ON a.lft > b.lft AND a.rgt < b.rgt')
  37.             ->group('a.id, a.title, a.lft, a.rgt')
  38.             ->order('a.lft ASC');
  39.         $db->setQuery($query);
  40.         $options $db->loadObjectList();
  41.  
  42.         for ($i 0$n count($options)$i $n$i++)
  43.         {
  44.             $options[$i]->text str_repeat('- '$options[$i]->level$options[$i]->text;
  45.             $groups[JHtml::_('select.option'$options[$i]->value$options[$i]->text);
  46.         }
  47.  
  48.         // Exclude super admin groups if requested
  49.         if (!$includeSuperAdmin)
  50.         {
  51.             $filteredGroups array();
  52.  
  53.             foreach ($groups as $group)
  54.             {
  55.                 if (!JAccess::checkGroup($group->value'core.admin'))
  56.                 {
  57.                     $filteredGroups[$group;
  58.                 }
  59.             }
  60.             $groups $filteredGroups;
  61.         }
  62.  
  63.         return $groups;
  64.     }
  65.  
  66.     /**
  67.      * Get a list of users.
  68.      *
  69.      * @return  string 
  70.      *
  71.      * @since   2.5
  72.      */
  73.     public static function userlist()
  74.     {
  75.         $db    JFactory::getDbo();
  76.         $query $db->getQuery(true)
  77.             ->select('a.id AS value, a.name AS text')
  78.             ->from('#__users AS a')
  79.             ->where('a.block = 0')
  80.             ->order('a.name');
  81.         $db->setQuery($query);
  82.         $items $db->loadObjectList();
  83.  
  84.         return $items;
  85.     }
  86. }

Documentation generated on Tue, 19 Nov 2013 15:16:17 +0100 by phpDocumentor 1.4.3