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.  * Extended Utility class for the Users component.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_users
  17.  * @since       2.5
  18.  */
  19. class JHtmlUsers
  20. {
  21.     /**
  22.      * Display an image.
  23.      *
  24.      * @param   string  $src  The source of the image
  25.      *
  26.      * @return  string  A <img> element if the specified file exists, otherwise, a null string
  27.      *
  28.      * @since   2.5
  29.      */
  30.     public static function image($src)
  31.     {
  32.         $src preg_replace('#[^A-Z0-9\-_\./]#i'''$src);
  33.         $file JPATH_SITE '/' $src;
  34.  
  35.         jimport('joomla.filesystem.path');
  36.         JPath::check($file);
  37.  
  38.         if (!file_exists($file))
  39.         {
  40.             return '';
  41.         }
  42.  
  43.         return '<img src="' JUri::root($src '" alt="" />';
  44.     }
  45.  
  46.     /**
  47.      * Displays an icon to add a note for this user.
  48.      *
  49.      * @param   integer  $userId  The user ID
  50.      *
  51.      * @return  string  A link to add a note
  52.      *
  53.      * @since   2.5
  54.      */
  55.     public static function addNote($userId)
  56.     {
  57.         $title JText::_('COM_USERS_ADD_NOTE');
  58.  
  59.         return '<a href="' JRoute::_('index.php?option=com_users&task=note.add&u_id=' . (int) $userId'">'
  60.             . '<span class="label label-info"><i class="icon-vcard"></i>' $title '</span></a>';
  61.     }
  62.  
  63.     /**
  64.      * Displays an icon to filter the notes list on this user.
  65.      *
  66.      * @param   integer  $count   The number of notes for the user
  67.      * @param   integer  $userId  The user ID
  68.      *
  69.      * @return  string  A link to apply a filter
  70.      *
  71.      * @since   2.5
  72.      */
  73.     public static function filterNotes($count$userId)
  74.     {
  75.         if (empty($count))
  76.         {
  77.             return '';
  78.         }
  79.  
  80.         $title JText::_('COM_USERS_FILTER_NOTES');
  81.  
  82.         return '<a href="' JRoute::_('index.php?option=com_users&view=notes&filter_search=uid:' . (int) $userId'">'
  83.             . JHtml::_('image''admin/filter_16.png''COM_USERS_NOTES'array('title' => $title)true'</a>';
  84.     }
  85.  
  86.     /**
  87.      * Displays a note icon.
  88.      *
  89.      * @param   integer  $count   The number of notes for the user
  90.      * @param   integer  $userId  The user ID
  91.      *
  92.      * @return  string  A link to a modal window with the user notes
  93.      *
  94.      * @since   2.5
  95.      */
  96.     public static function notes($count$userId)
  97.     {
  98.         if (empty($count))
  99.         {
  100.             return '';
  101.         }
  102.  
  103.         $title JText::plural('COM_USERS_N_USER_NOTES'$count);
  104.  
  105.         return '<a class="modal"'
  106.             . ' href="' JRoute::_('index.php?option=com_users&view=notes&tmpl=component&layout=modal&u_id=' . (int) $userId'"'
  107.             . ' rel="{handler: \'iframe\', size: {x: 800, y: 450}}">'
  108.             . '<span class="label label-info"><i class="icon-drawer-2"></i>' $title '</span></a>';
  109.     }
  110.  
  111.     /**
  112.      * Build an array of block/unblock user states to be used by jgrid.state,
  113.      * State options will be different for any user
  114.      * and for currently logged in user
  115.      *
  116.      * @param   boolean  $self  True if state array is for currently logged in user
  117.      *
  118.      * @return  array  a list of possible states to display
  119.      *
  120.      * @since  3.0
  121.      */
  122.     public static function blockStates$self false)
  123.     {
  124.         if ($self)
  125.         {
  126.             $states array(
  127.                 => array(
  128.                     'task'                => 'unblock',
  129.                     'text'                => '',
  130.                     'active_title'        => 'COM_USERS_USER_FIELD_BLOCK_DESC',
  131.                     'inactive_title'    => '',
  132.                     'tip'                => true,
  133.                     'active_class'        => 'unpublish',
  134.                     'inactive_class'    => 'unpublish'
  135.                 ),
  136.                 => array(
  137.                     'task'                => 'block',
  138.                     'text'                => '',
  139.                     'active_title'        => '',
  140.                     'inactive_title'    => 'COM_USERS_USERS_ERROR_CANNOT_BLOCK_SELF',
  141.                     'tip'                => true,
  142.                     'active_class'        => 'publish',
  143.                     'inactive_class'    => 'publish'
  144.                 )
  145.             );
  146.         }
  147.         else
  148.         {
  149.             $states array(
  150.                 => array(
  151.                     'task'                => 'unblock',
  152.                     'text'                => '',
  153.                     'active_title'        => 'COM_USERS_TOOLBAR_UNBLOCK',
  154.                     'inactive_title'    => '',
  155.                     'tip'                => true,
  156.                     'active_class'        => 'unpublish',
  157.                     'inactive_class'    => 'unpublish'
  158.                 ),
  159.                 => array(
  160.                     'task'                => 'block',
  161.                     'text'                => '',
  162.                     'active_title'        => 'COM_USERS_USER_FIELD_BLOCK_DESC',
  163.                     'inactive_title'    => '',
  164.                     'tip'                => true,
  165.                     'active_class'        => 'publish',
  166.                     'inactive_class'    => 'publish'
  167.                 )
  168.             );
  169.         }
  170.  
  171.         return $states;
  172.     }
  173.  
  174.     /**
  175.      * Build an array of activate states to be used by jgrid.state,
  176.      *
  177.      * @return  array  a list of possible states to display
  178.      *
  179.      * @since  3.0
  180.      */
  181.     public static function activateStates()
  182.     {
  183.         $states array(
  184.             1    => array(
  185.                 'task'                => 'activate',
  186.                 'text'                => '',
  187.                 'active_title'        => 'COM_USERS_TOOLBAR_ACTIVATE',
  188.                 'inactive_title'    => '',
  189.                 'tip'                => true,
  190.                 'active_class'        => 'unpublish',
  191.                 'inactive_class'    => 'unpublish'
  192.             ),
  193.             0    => array(
  194.                 'task'                => '',
  195.                 'text'                => '',
  196.                 'active_title'        => '',
  197.                 'inactive_title'    => 'COM_USERS_ACTIVATED',
  198.                 'tip'                => true,
  199.                 'active_class'        => 'publish',
  200.                 'inactive_class'    => 'publish'
  201.             )
  202.         );
  203.         return $states;
  204.     }
  205. }

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