Source for file users.php

Documentation is available at users.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_users
  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('_JEXEC'or die;
  11.  
  12. /**
  13.  * Users component helper.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_users
  17.  * @since       1.6
  18.  */
  19. {
  20.     /**
  21.      * @var    JObject  A cache for the available actions.
  22.      * @since  1.6
  23.      */
  24.     protected static $actions;
  25.  
  26.     /**
  27.      * Configure the Linkbar.
  28.      *
  29.      * @param   string  $vName  The name of the active view.
  30.      *
  31.      * @return  void 
  32.      *
  33.      * @since   1.6
  34.      */
  35.     public static function addSubmenu($vName)
  36.     {
  37.         JHtmlSidebar::addEntry(
  38.             JText::_('COM_USERS_SUBMENU_USERS'),
  39.             'index.php?option=com_users&view=users',
  40.             $vName == 'users'
  41.         );
  42.  
  43.         // Groups and Levels are restricted to core.admin
  44.         $canDo self::getActions();
  45.  
  46.         if ($canDo->get('core.admin'))
  47.         {
  48.             JHtmlSidebar::addEntry(
  49.                 JText::_('COM_USERS_SUBMENU_GROUPS'),
  50.                 'index.php?option=com_users&view=groups',
  51.                 $vName == 'groups'
  52.             );
  53.             JHtmlSidebar::addEntry(
  54.                 JText::_('COM_USERS_SUBMENU_LEVELS'),
  55.                 'index.php?option=com_users&view=levels',
  56.                 $vName == 'levels'
  57.             );
  58.             JHtmlSidebar::addEntry(
  59.                 JText::_('COM_USERS_SUBMENU_NOTES'),
  60.                 'index.php?option=com_users&view=notes',
  61.                 $vName == 'notes'
  62.             );
  63.  
  64.             $extension JFactory::getApplication()->input->getString('extension');
  65.             JHtmlSidebar::addEntry(
  66.                 JText::_('COM_USERS_SUBMENU_NOTE_CATEGORIES'),
  67.                 'index.php?option=com_categories&extension=com_users',
  68.                 $vName == 'categories' || $extension == 'com_users'
  69.             );
  70.         }
  71.     }
  72.  
  73.     /**
  74.      * Gets a list of the actions that can be performed.
  75.      *
  76.      * @return  JObject 
  77.      *
  78.      * @since   1.6
  79.      * @todo    Refactor to work with notes
  80.      */
  81.     public static function getActions()
  82.     {
  83.         if (empty(self::$actions))
  84.         {
  85.             $user JFactory::getUser();
  86.             self::$actions new JObject;
  87.  
  88.             $actions JAccess::getActions('com_users');
  89.  
  90.             foreach ($actions as $action)
  91.             {
  92.                 self::$actions->set($action->name$user->authorise($action->name'com_users'));
  93.             }
  94.         }
  95.  
  96.         return self::$actions;
  97.     }
  98.  
  99.     /**
  100.      * Get a list of filter options for the blocked state of a user.
  101.      *
  102.      * @return  array  An array of JHtmlOption elements.
  103.      *
  104.      * @since   1.6
  105.      */
  106.     public static function getStateOptions()
  107.     {
  108.         // Build the filter options.
  109.         $options array();
  110.         $options[JHtml::_('select.option''0'JText::_('JENABLED'));
  111.         $options[JHtml::_('select.option''1'JText::_('JDISABLED'));
  112.  
  113.         return $options;
  114.     }
  115.  
  116.     /**
  117.      * Get a list of filter options for the activated state of a user.
  118.      *
  119.      * @return  array  An array of JHtmlOption elements.
  120.      *
  121.      * @since   1.6
  122.      */
  123.     public static function getActiveOptions()
  124.     {
  125.         // Build the filter options.
  126.         $options array();
  127.         $options[JHtml::_('select.option''0'JText::_('COM_USERS_ACTIVATED'));
  128.         $options[JHtml::_('select.option''1'JText::_('COM_USERS_UNACTIVATED'));
  129.  
  130.         return $options;
  131.     }
  132.  
  133.     /**
  134.      * Get a list of the user groups for filtering.
  135.      *
  136.      * @return  array  An array of JHtmlOption elements.
  137.      *
  138.      * @since   1.6
  139.      */
  140.     public static function getGroups()
  141.     {
  142.         $db JFactory::getDbo();
  143.         $query $db->getQuery(true)
  144.             ->select('a.id AS value')
  145.             ->select('a.title AS text')
  146.             ->select('COUNT(DISTINCT b.id) AS level')
  147.             ->from('#__usergroups as a')
  148.             ->join('LEFT''#__usergroups  AS b ON a.lft > b.lft AND a.rgt < b.rgt')
  149.             ->group('a.id, a.title, a.lft, a.rgt')
  150.             ->order('a.lft ASC');
  151.         $db->setQuery($query);
  152.  
  153.         try
  154.         {
  155.             $options $db->loadObjectList();
  156.         }
  157.         catch (RuntimeException $e)
  158.         {
  159.             JError::raiseNotice(500$e->getMessage());
  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.  
  193.     /**
  194.      * Creates a list of two factor authentication methods used in com_users
  195.      * on user view
  196.      *
  197.      * @return  array 
  198.      *
  199.      * @since   3.2.0
  200.      */
  201.     public static function getTwoFactorMethods()
  202.     {
  203.         // Load the Joomla! RAD layer
  204.         if (!defined('FOF_INCLUDED'))
  205.         {
  206.             include_once JPATH_LIBRARIES '/fof/include.php';
  207.         }
  208.  
  209.         FOFPlatform::getInstance()->importPlugin('twofactorauth');
  210.         $identities FOFPlatform::getInstance()->runPlugins('onUserTwofactorIdentify'array());
  211.  
  212.         $options array(
  213.             JHtml::_('select.option''none'JText::_('COM_USERS_OPTION_OTPMETHOD_NONE')'value''text'),
  214.         );
  215.  
  216.         if (!empty($identities))
  217.         {
  218.             foreach ($identities as $identity)
  219.             {
  220.                 if (!is_object($identity))
  221.                 {
  222.                     continue;
  223.                 }
  224.  
  225.                 $options[JHtml::_('select.option'$identity->method$identity->title'value''text');
  226.             }
  227.         }
  228.  
  229.         return $options;
  230.     }
  231. }

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