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