Source for file messages.php
Documentation is available at messages.php
* @package Joomla.Administrator
* @subpackage com_messages
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Messages Component Messages Model
* @package Joomla.Administrator
* @subpackage com_messages
* @param array An optional associative array of configuration settings.
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
'user_id_from', 'a.user_id_from',
'user_id_to', 'a.user_id_to',
'date_time', 'a.date_time',
'priority', 'a.priority',
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
protected function populateState($ordering =
null, $direction =
null)
// Load the filter state.
$this->setState('filter.search', $search);
$this->setState('filter.state', $state);
// List state information.
* Method to get a store id based on model configuration state.
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* @param string A prefix for the store id.
* @return string A store id.
$id .=
':' .
$this->getState('filter.search');
$id .=
':' .
$this->getState('filter.state');
* Build an SQL query to load the list data.
// Create a new query object.
$query =
$db->getQuery(true);
// Select the required fields from the table.
$query->from('#__messages AS a');
// Join over the users for message owner.
$query->join('INNER', '#__users AS u ON u.id = a.user_id_from')
->where('a.user_id_to = ' . (int)
$user->get('id'));
// Filter by published state.
$state =
$this->getState('filter.state');
$query->where('a.state = ' . (int)
$state);
$query->where('(a.state IN (0, 1))');
// Filter by search in subject or message.
$search =
$this->getState('filter.search');
$search =
$db->quote('%' .
$db->escape($search, true) .
'%', false);
$query->where('a.subject LIKE ' .
$search .
' OR a.message LIKE ' .
$search);
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering', 'a.date_time')) .
' ' .
$db->escape($this->getState('list.direction', 'DESC')));
//echo nl2br(str_replace('#__','jos_',$query));
Documentation generated on Tue, 19 Nov 2013 15:08:09 +0100 by phpDocumentor 1.4.3