File: /var/www/vhosts/pgkdistribution.com.au/citisolar.com.au/tmp/admin/models/fusers.php
<?php
/**
* @Copyright Freestyle Joomla (C) 2010
* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
*
* This file is part of Freestyle Testimonials
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
?>
<?php
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();
jimport( 'joomla.application.component.model' );
class FstsModelFusers extends JModel
{
var $_data;
var $_total = null;
var $lists = array(0);
var $_pagination = null;
function __construct()
{
parent::__construct();
$mainframe = JFactory::getApplication(); global $option;
$context = "users_";
// Get pagination request variables
$limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int');
$limitstart = JRequest::getVar('limitstart', 0, '', 'int');
$search = $mainframe->getUserStateFromRequest( $context.'search', 'search', '', 'string' );
$search = JString::strtolower($search);
$filter_order = $mainframe->getUserStateFromRequest( $context.'filter_order', 'filter_order', '', 'cmd' );
$filter_order_Dir = $mainframe->getUserStateFromRequest( $context.'filter_order_Dir', 'filter_order_Dir', '', 'word' );
$this->lists['order_Dir'] = $filter_order_Dir;
$this->lists['order'] = $filter_order;
$this->lists['search'] = $search;
// In case limit has been changed, adjust it
$limitstart = ($limit != 0 ? (floor($limitstart / $limit) * $limit) : 0);
$this->setState('limit', $limit);
$this->setState('limitstart', $limitstart);
}
function _buildQuery()
{
$db =& JFactory::getDBO();
$query = ' SELECT u.*, CONCAT(m.username," (",m.name,")") as name FROM #__fst_user as u LEFT JOIN #__users as m ON u.user_id = m.id';
$where = array();
if ($this->lists['search']) {
$where[] = '(LOWER( name ) LIKE '.$db->Quote( '%'.$db->getEscaped( $this->lists['search'], true ).'%', false ) . ')';
}
if ($this->lists['order']) {
$order = ' ORDER BY '. $this->lists['order'] .' '. $this->lists['order_Dir'];
}
$where = (count($where) ? ' WHERE '.implode(' AND ', $where) : '');
$query .= $where;
return $query;
}
function getData()
{
// Lets load the data if it doesn't already exist
if (empty( $this->_data ))
{
$query = $this->_buildQuery();
$this->_data = $this->_getList( $query, $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_data;
}
function getTotal()
{
// Load the content if it doesn't already exist
if (empty($this->_total)) {
$query = $this->_buildQuery();
$this->_total = $this->_getListCount($query);
}
return $this->_total;
}
function getPagination()
{
// Load the content if it doesn't already exist
if (empty($this->_pagination)) {
jimport('joomla.html.pagination');
$this->_pagination = new JPagination($this->getTotal(), $this->getState('limitstart'), $this->getState('limit') );
}
return $this->_pagination;
}
function getLists()
{
return $this->lists;
}
}