Source for file level.php
Documentation is available at level.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
* @package Joomla.Administrator
* @var array A list of the access levels in use.
* Method to test whether a record can be deleted.
* @param object $record A record object.
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
// Check if the access level is being used by any content.
// Populate the list once.
$query =
$db->getQuery(true)
->select('DISTINCT access');
// from is added dynamically
// Get all the tables and the prefix
$tables =
$db->getTableList();
//$fields = $db->getTableFields($tables);
$prefix =
$db->getPrefix();
foreach ($tables as $table)
// Get all of the columns in the table
$fields =
$db->getTableColumns($table);
// We are looking for the access field. If custom tables are using something other
// than the 'access' field they are on their own unfortunately.
// Also make sure the table prefix matches the live db prefix (eg, it is not a "bak_" table)
if ((strpos($table, $prefix) ===
0) &&
(isset
($fields['access'])))
// Lookup the distinct values of the field.
->from($db->quoteName($table));
$values =
$db->loadColumn();
catch
(RuntimeException $e)
// TODO Could assemble an array of the tables used by each view level list those,
// giving the user a clue in the error where to look.
// Ok, after all that we are ready to check the record :)
return parent::canDelete($record);
* Returns a reference to the a Table object, always creating it.
* @param type The table type to instantiate
* @param string A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional.
* @return JTable A database object
public function getTable($type =
'Viewlevel', $prefix =
'JTable', $config =
array())
* Method to get a single record.
* @param integer The id of the primary key.
* @return mixed Object on success, false on failure.
public function getItem($pk =
null)
$result =
parent::getItem($pk);
// Convert the params field to an array.
* Method to get the record form.
* @param array $data An optional array of data for the form to interogate.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @return JForm A JForm object on success, false on failure
public function getForm($data =
array(), $loadData =
true)
$form =
$this->loadForm('com_users.level', 'level', array('control' =>
'jform', 'load_data' =>
$loadData));
* Method to get the data that should be injected in the form.
* @return mixed The data for the form.
// Check the session for previously entered form data.
* Override preprocessForm to load the user plugin group instead of content.
* @param object A form object.
* @param mixed The data expected for the form.
* @throws Exception if there is an error in the form event.
parent::preprocessForm($form, $data, 'user');
* Method to save the form data.
* @param array The form data.
* @return boolean True on success.
public function save($data)
if (!isset
($data['rules']))
$data['rules'] =
array();
return parent::save($data);
Documentation generated on Tue, 19 Nov 2013 15:07:01 +0100 by phpDocumentor 1.4.3