[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/libraries/joomla/html/html/ -> user.php (source)

   1  <?php
   2  /**
   3   * @package     Joomla.Platform
   4   * @subpackage  HTML
   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
   8   */
   9  
  10  defined('JPATH_PLATFORM') or die;
  11  
  12  /**
  13   * Utility class working with users
  14   *
  15   * @package     Joomla.Platform
  16   * @subpackage  HTML
  17   * @since       11.4
  18   */
  19  abstract class JHtmlUser
  20  {
  21      /**
  22       * Displays a list of user groups.
  23       *
  24       * @return  array  An array containing a list of user groups.
  25       *
  26       * @since   11.4
  27       */
  28  	public static function groups()
  29      {
  30          $db = JFactory::getDbo();
  31          $query = $db->getQuery(true);
  32          $query->select('a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level');
  33          $query->from($db->quoteName('#__usergroups') . ' AS a');
  34          $query->join('LEFT', $db->quoteName('#__usergroups') . ' AS b ON a.lft > b.lft AND a.rgt < b.rgt');
  35          $query->group('a.id, a.title, a.lft, a.rgt');
  36          $query->order('a.lft ASC');
  37          $db->setQuery($query);
  38          $options = $db->loadObjectList();
  39  
  40          // Check for a database error.
  41          if ($db->getErrorNum())
  42          {
  43              JError::raiseNotice(500, $db->getErrorMsg());
  44              return null;
  45          }
  46  
  47          for ($i = 0, $n = count($options); $i < $n; $i++)
  48          {
  49              $options[$i]->text = str_repeat('- ', $options[$i]->level) . $options[$i]->text;
  50              $groups[] = JHtml::_('select.option', $options[$i]->value, $options[$i]->text);
  51          }
  52  
  53          return $groups;
  54      }
  55  
  56      /**
  57       * Get a list of users.
  58       *
  59       * @return  string
  60       *
  61       * @since   11.4
  62       */
  63  	public static function userlist()
  64      {
  65          // Get the database object and a new query object.
  66          $db        = JFactory::getDBO();
  67          $query    = $db->getQuery(true);
  68  
  69          // Build the query.
  70          $query->select('a.id AS value, a.name AS text');
  71          $query->from('#__users AS a');
  72          $query->where('a.block = 0');
  73          $query->order('a.name');
  74  
  75          // Set the query and load the options.
  76          $db->setQuery($query);
  77          $items = $db->loadObjectList();
  78  
  79          // Detect errors
  80          if ($db->getErrorNum())
  81          {
  82              JError::raiseWarning(500, $db->getErrorMsg());
  83          }
  84  
  85          return $items;
  86      }
  87  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1