Source for file usergrouplist.php

Documentation is available at usergrouplist.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Libraries
  4.  * @subpackage  Form
  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.txt
  8.  */
  9.  
  10. defined('JPATH_BASE'or die;
  11.  
  12.  
  13. /**
  14.  * Field to load a list of available users statuses
  15.  *
  16.  * @package     Joomla.Libraries
  17.  * @subpackage  Form
  18.  * @since       3.2
  19.  */
  20. {
  21.     /**
  22.      * The form field type.
  23.      *
  24.      * @var        string 
  25.      * @since   3.2
  26.      */
  27.     protected $type = 'UserGroupList';
  28.  
  29.     /**
  30.      * Cached array of the category items.
  31.      *
  32.      * @var    array 
  33.      * @since  3.2
  34.      */
  35.     protected static $options array();
  36.  
  37.     /**
  38.      * Method to get the options to populate list
  39.      *
  40.      * @return  array  The field option objects.
  41.      *
  42.      * @since   3.2
  43.      */
  44.     protected function getOptions()
  45.     {
  46.         // Hash for caching
  47.         $hash md5($this->element);
  48.  
  49.         if (!isset(static::$options[$hash]))
  50.         {
  51.             static::$options[$hashparent::getOptions();
  52.  
  53.             $options array();
  54.  
  55.             $db JFactory::getDbo();
  56.             $query $db->getQuery(true)
  57.                 ->select('a.id AS value')
  58.                 ->select('a.title AS text')
  59.                 ->select('COUNT(DISTINCT b.id) AS level')
  60.                 ->from('#__usergroups as a')
  61.                 ->join('LEFT''#__usergroups  AS b ON a.lft > b.lft AND a.rgt < b.rgt')
  62.                 ->group('a.id, a.title, a.lft, a.rgt')
  63.                 ->order('a.lft ASC');
  64.             $db->setQuery($query);
  65.  
  66.             if ($options $db->loadObjectList())
  67.             {
  68.                 foreach ($options as &$option)
  69.                 {
  70.                     $option->text str_repeat('- '$option->level$option->text;
  71.                 }
  72.  
  73.                 static::$options[$hasharray_merge(static::$options[$hash]$options);
  74.             }
  75.         }
  76.  
  77.         return static::$options[$hash];
  78.     }
  79. }

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