Source for file notes.php
Documentation is available at notes.php
* @package Joomla.Administrator
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* User notes model class.
* @package Joomla.Administrator
* @param array $config An optional associative array of configuration settings.
// Set the list ordering fields.
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
* Build an SQL query to load the list data.
* @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set.
$query =
$db->getQuery(true);
$section =
$this->getState('filter.category_id');
// Select the required fields from the table.
'a.id, a.subject, a.checked_out, a.checked_out_time,' .
'a.catid, a.created_time, a.review_time,' .
'a.state, a.publish_up, a.publish_down'
$query->from('#__user_notes AS a');
// Join over the category
$query->select('c.title AS category_title, c.params AS category_params')
->join('LEFT', '#__categories AS c ON c.id = a.catid');
// Join over the users for the note user.
$query->select('u.name AS user_name')
->join('LEFT', '#__users AS u ON u.id = a.user_id');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON uc.id = a.checked_out');
// Filter by search in title
$search =
$this->getState('filter.search');
$query->where('a.id = ' . (int)
substr($search, 3));
elseif (stripos($search, 'uid:') ===
0)
$query->where('a.user_id = ' . (int)
substr($search, 4));
$search =
$db->quote('%' .
$db->escape($search, true) .
'%');
$query->where('((a.subject LIKE ' .
$search .
') OR (u.name LIKE ' .
$search .
') OR (u.username LIKE ' .
$search .
'))');
// Filter by published state
$published =
$this->getState('filter.state');
$query->where('a.state = '.(int)
$published);
} elseif ($published ===
'')
$query->where('(a.state IN (0, 1))');
// Filter by a single or group of categories.
$categoryId = (int)
$this->getState('filter.category_id');
$query->where('a.catid = ' .
$categoryId);
// Filter by a single user.
$userId = (int)
$this->getState('filter.user_id');
// Add the body and where filter.
->where('a.user_id = ' .
$userId);
// Add the list ordering clause.
$orderCol =
$this->state->get('list.ordering');
$orderDirn =
$this->state->get('list.direction');
$query->order($db->escape($orderCol .
' ' .
$orderDirn));
* 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 $id A prefix for the store id.
* @return string A store id.
$id .=
':' .
$this->getState('filter.search');
$id .=
':' .
$this->getState('filter.state');
$id .=
':' .
$this->getState('filter.category_id');
* Gets a user object if the user filter is set.
* @return JUser The JUser object
// Filter by search in title
$user->load((int)
$search);
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
protected function populateState($ordering =
null, $direction =
null)
// Adjust the context to support modal layouts.
if ($layout =
$input->get('layout'))
$value =
$app->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $value);
$this->setState('filter.state', $published);
$section =
$app->getUserStateFromRequest($this->context .
'.filter.category_id', 'filter_category_id');
$this->setState('filter.category_id', $section);
$userId =
$input->get('u_id', 0, 'int');
$this->setState('filter.user_id', $userId);
Documentation generated on Tue, 19 Nov 2013 15:09:38 +0100 by phpDocumentor 1.4.3