Source for file levels.php
Documentation is available at levels.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
* Methods supporting a list of user access level records.
* @package Joomla.Administrator
* @param array An optional associative array of configuration settings.
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
'ordering', 'a.ordering',
* 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);
// 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 $id A prefix for the store id.
* @return string A store id.
$id .=
':' .
$this->getState('filter.search');
* 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($db->quoteName('#__viewlevels') .
' AS a');
// Add the level in the tree.
$query->group('a.id, a.title, a.ordering, a.rules');
// Filter the items over the search string if set.
$search =
$this->getState('filter.search');
$query->where('a.id = ' . (int)
substr($search, 3));
$search =
$db->quote('%' .
$db->escape($search, true) .
'%');
$query->where('a.title LIKE ' .
$search);
// Add the list ordering clause.
$query->order($db->escape($this->getState('list.ordering', 'a.lft')) .
' ' .
$db->escape($this->getState('list.direction', 'ASC')));
//echo nl2br(str_replace('#__','jos_',$query));
* Method to adjust the ordering of a row.
* @param integer The ID of the primary key to move.
* @param integer Increment, usually +1 or -1
* @return boolean False on failure or error, true otherwise.
public function reorder($pk, $direction =
0)
// Sanitize the id and adjustment.
$pk =
(!empty($pk)) ?
$pk : (int)
$this->getState('level.id');
// Get an instance of the record's table.
$allow =
$user->authorise('core.edit.state', 'com_users');
$this->setError(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
// TODO: Where clause to restrict category.
* Saves the manually set order of records.
* @param array An array of primary key ids.
// update ordering values
foreach ($pks as $i =>
$pk)
$allow =
$user->authorise('core.edit.state', 'com_users');
// Prune items that you can't change.
elseif ($table->ordering !=
$order[$i])
$table->ordering =
$order[$i];
// Execute reorder for each category.
foreach ($conditions as $cond)
$table->reorder($cond[1]);
Documentation generated on Tue, 19 Nov 2013 15:07:01 +0100 by phpDocumentor 1.4.3