Current File : /home/pacjaorg/public_html/km/administrator/components/com_djclassifieds/models/userspoints.php
<?php
/**
 * @package DJ-Classifieds
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email: contact@dj-extensions.com
 */

defined('_JEXEC') or die;

class DJClassifiedsModelUsersPoints extends JModelList
{
	public function __construct($config = array())
	{
		if (empty($config['filter_fields'])) {
			$config['filter_fields'] = array(
				'id', 'p.id',
				'points', 'p.points',
				'user', 'p.user',				
				'date', 'p.date'
			);
		}

		parent::__construct($config);
	}
	protected function populateState($ordering = null, $direction = null)
	{
		// List state information.
		parent::populateState('p.id', 'desc');

		$search = $this->getUserStateFromRequest($this->context.'.filter.search', 'filter_search');
		$this->setState('filter.search', $search);

		// Load the parameters.
		$params = JComponentHelper::getParams('com_djclassifieds');
		$this->setState('params', $params);

		$order = $this->getUserStateFromRequest($this->context.'.filter.order', 'filter_order');
		if($order){
			$this->setState('list.ordering', $order);
		}
		$order_dir = $this->getUserStateFromRequest($this->context.'.filter.order_Dir', 'filter_order_Dir');
		if($order_dir){
			$this->setState('list.direction', $order_dir);
		}
	}

	protected function getStoreId($id = '')
	{
		// Compile the store id.
		$id	.= ':'.$this->getState('filter.search');

		return parent::getStoreId($id);
	}

	protected function getListQuery()
	{
		// Create a new query object.
		$db = $this->getDbo();
		$query = $db->getQuery(true);

		// Select the required fields from the table.
		$query->select('p.*');
		$query->from('#__djcf_users_points AS p');		
		
		$query->select('u.name as u_name');
		$query->join('LEFT', '#__users AS u ON u.id=p.user_id');		
		
		// Filter by search in title.
		$search = $this->getState('filter.search');
		if (!empty($search)) {
			$search_id = $db->Quote($db->escape($search, true));
			$search = $db->Quote('%'.$db->escape($search, true).'%');
			$query->where('(p.description LIKE '.$search.' OR u.name LIKE '.$search.' OR u.username LIKE '.$search.' OR u.email LIKE '.$search.' OR p.id='.$search_id.')');
		}

		// Add the list ordering clause.
		$orderCol	= $this->state->get('list.ordering');
		$orderDirn	= $this->state->get('list.direction');
	
		$query->order($db->escape($orderCol.' '.$orderDirn));

		return $query;
	}	
}
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

Site will be available soon. Thank you for your patience!