[ Index ]

PHP Cross Reference of Joomla 1.5.26 DE

title

Body

[close]

/administrator/components/com_users/views/users/ -> view.html.php (source)

   1  <?php
   2  /**
   3  * @version        $Id: view.html.php 19343 2010-11-03 18:12:02Z ian $
   4  * @package        Joomla
   5  * @subpackage    Users
   6  * @copyright    Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
   7  * @license        GNU/GPL, see LICENSE.php
   8  * Joomla! is free software. This version may have been modified pursuant
   9  * to the GNU General Public License, and as distributed it includes or
  10  * is derivative of works licensed under the GNU General Public License or
  11  * other free or open source software licenses.
  12  * See COPYRIGHT.php for copyright notices and details.
  13  */
  14  
  15  // Check to ensure this file is included in Joomla!
  16  defined('_JEXEC') or die( 'Restricted access' );
  17  
  18  jimport( 'joomla.application.component.view');
  19  
  20  /**
  21   * HTML View class for the Users component
  22   *
  23   * @static
  24   * @package        Joomla
  25   * @subpackage    Users
  26   * @since 1.0
  27   */
  28  class UsersViewUsers extends JView
  29  {
  30  	function display($tpl = null)
  31      {
  32          global $mainframe, $option;
  33  
  34          $db                =& JFactory::getDBO();
  35          $currentUser    =& JFactory::getUser();
  36          $acl            =& JFactory::getACL();
  37  
  38          $filter_order        = $mainframe->getUserStateFromRequest( "$option.filter_order",        'filter_order',        'a.name',    'cmd' );
  39          $filter_order_Dir    = $mainframe->getUserStateFromRequest( "$option.filter_order_Dir",    'filter_order_Dir',    '',            'word' );
  40          $filter_type        = $mainframe->getUserStateFromRequest( "$option.filter_type",        'filter_type',         0,            'string' );
  41          $filter_logged        = $mainframe->getUserStateFromRequest( "$option.filter_logged",        'filter_logged',     0,            'int' );
  42          $search                = $mainframe->getUserStateFromRequest( "$option.search",            'search',             '',            'string' );
  43          if (strpos($search, '"') !== false) {
  44              $search = str_replace(array('=', '<'), '', $search);
  45          }
  46          $search = JString::strtolower($search);
  47  
  48          $limit        = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' );
  49          $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0, 'int' );
  50  
  51          $where = array();
  52          if (isset( $search ) && $search!= '')
  53          {
  54              $searchEscaped = $db->Quote( '%'.$db->getEscaped( $search, true ).'%', false );
  55              $where[] = 'a.username LIKE '.$searchEscaped.' OR a.email LIKE '.$searchEscaped.' OR a.name LIKE '.$searchEscaped;
  56          }
  57          if ( $filter_type )
  58          {
  59              if ( $filter_type == 'Public Frontend' )
  60              {
  61                  $where[] = ' a.usertype = \'Registered\' OR a.usertype = \'Author\' OR a.usertype = \'Editor\' OR a.usertype = \'Publisher\' ';
  62              }
  63              else if ( $filter_type == 'Public Backend' )
  64              {
  65                  $where[] = 'a.usertype = \'Manager\' OR a.usertype = \'Administrator\' OR a.usertype = \'Super Administrator\' ';
  66              }
  67              else
  68              {
  69                  $where[] = 'a.usertype = LOWER( '.$db->Quote($filter_type).' ) ';
  70              }
  71          }
  72          if ( $filter_logged == 1 )
  73          {
  74              $where[] = 's.userid = a.id';
  75          }
  76          else if ($filter_logged == 2)
  77          {
  78              $where[] = 's.userid IS NULL';
  79          }
  80  
  81          // exclude any child group id's for this user
  82          $pgids = $acl->get_group_children( $currentUser->get('gid'), 'ARO', 'RECURSE' );
  83  
  84          if (is_array( $pgids ) && count( $pgids ) > 0)
  85          {
  86              JArrayHelper::toInteger($pgids);
  87              $where[] = 'a.gid NOT IN (' . implode( ',', $pgids ) . ')';
  88          }
  89          $filter = '';
  90          if ($filter_logged == 1 || $filter_logged == 2)
  91          {
  92              $filter = ' INNER JOIN #__session AS s ON s.userid = a.id';
  93          }
  94  
  95          // ensure filter_order has a valid value.
  96          if (!in_array($filter_order, array('a.name', 'a.username', 'a.block', 'groupname', 'a.email', 'a.lastvisitDate', 'a.id'))) {
  97              $filter_order = 'a.name';
  98          }
  99  
 100          if (!in_array(strtoupper($filter_order_Dir), array('ASC', 'DESC'))) {
 101              $filter_order_Dir = '';
 102          }
 103  
 104          $orderby = ' ORDER BY '. $filter_order .' '. $filter_order_Dir;
 105          $where = ( count( $where ) ? ' WHERE (' . implode( ') AND (', $where ) . ')' : '' );
 106  
 107          $query = 'SELECT COUNT(a.id)'
 108          . ' FROM #__users AS a'
 109          . $filter
 110          . $where
 111          ;
 112          $db->setQuery( $query );
 113          $total = $db->loadResult();
 114  
 115          jimport('joomla.html.pagination');
 116          $pagination = new JPagination( $total, $limitstart, $limit );
 117  
 118          $query = 'SELECT a.*, g.name AS groupname'
 119              . ' FROM #__users AS a'
 120              . ' INNER JOIN #__core_acl_aro AS aro ON aro.value = a.id'
 121              . ' INNER JOIN #__core_acl_groups_aro_map AS gm ON gm.aro_id = aro.id'
 122              . ' INNER JOIN #__core_acl_aro_groups AS g ON g.id = gm.group_id'
 123              . $filter
 124              . $where
 125              . ' GROUP BY a.id'
 126              . $orderby
 127          ;
 128          $db->setQuery( $query, $pagination->limitstart, $pagination->limit );
 129          $rows = $db->loadObjectList();
 130  
 131          $n = count( $rows );
 132          $template = 'SELECT COUNT(s.userid)'
 133              . ' FROM #__session AS s'
 134              . ' WHERE s.userid = %d'
 135          ;
 136          for ($i = 0; $i < $n; $i++)
 137          {
 138              $row = &$rows[$i];
 139              $query = sprintf( $template, intval( $row->id ) );
 140              $db->setQuery( $query );
 141              $row->loggedin = $db->loadResult();
 142          }
 143  
 144          // get list of Groups for dropdown filter
 145          $query = 'SELECT name AS value, name AS text'
 146              . ' FROM #__core_acl_aro_groups'
 147              . ' WHERE name != "ROOT"'
 148              . ' AND name != "USERS"'
 149          ;
 150          $db->setQuery( $query );
 151          $types[]         = JHTML::_('select.option',  '0', '- '. JText::_( 'Select Group' ) .' -' );
 152          foreach( $db->loadObjectList() as $obj )
 153          {
 154              $types[] = JHTML::_('select.option',  $obj->value, JText::_( $obj->text ) );
 155          }
 156          $lists['type']     = JHTML::_('select.genericlist',   $types, 'filter_type', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_type" );
 157  
 158          // get list of Log Status for dropdown filter
 159          $logged[] = JHTML::_('select.option',  0, '- '. JText::_( 'Select Log Status' ) .' -');
 160          $logged[] = JHTML::_('select.option',  1, JText::_( 'Logged In' ) );
 161          $lists['logged'] = JHTML::_('select.genericlist',   $logged, 'filter_logged', 'class="inputbox" size="1" onchange="document.adminForm.submit( );"', 'value', 'text', "$filter_logged" );
 162  
 163          // table ordering
 164          $lists['order_Dir']    = $filter_order_Dir;
 165          $lists['order']        = $filter_order;
 166  
 167          // search filter
 168          $lists['search']= $search;
 169  
 170          $this->assignRef('user',        JFactory::getUser());
 171          $this->assignRef('lists',        $lists);
 172          $this->assignRef('items',        $rows);
 173          $this->assignRef('pagination',    $pagination);
 174  
 175          parent::display($tpl);
 176      }
 177  }


Generated: Wed Mar 28 15:54:07 2012 Cross-referenced by PHPXref 0.7.1