Joomla Platform  13.1
Documentation des API du framework Joomla Platform
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Pages
Référence de la classe JTableUsergroup
+ Graphe d'héritage de JTableUsergroup:
+ Graphe de collaboration de JTableUsergroup:

Liste de tous les membres

Fonctions membres publiques

 __construct (JDatabaseDriver $db)
 check ()
 rebuild ($parent_id=0, $left=0)
 store ($updateNulls=false)
 delete ($oid=null)
- Fonctions membres publiques inherited from JTable
 __construct ($table, $key, JDatabaseDriver $db)
 attachObserver (JObserverInterface $observer)
 getObserverOfClass ($observerClass)
 getFields ()
 appendPrimaryKeys ($query, $pk=null)
 getTableName ()
 getKeyName ($multiple=false)
 getDbo ()
 setDBO (JDatabaseDriver $db)
 setRules ($input)
 getRules ()
 reset ()
 bind ($src, $ignore=array())
 load ($keys=null, $reset=true)
 save ($src, $orderingFilter= '', $ignore= '')
 checkOut ($userId, $pk=null)
 checkIn ($pk=null)
 hasPrimaryKey ()
 hit ($pk=null)
 isCheckedOut ($with=0, $against=null)
 getNextOrder ($where= '')
 getPrimaryKey (array $keys=array())
 reorder ($where= '')
 move ($delta, $where= '')
 publish ($pks=null, $state=1, $userId=0)
- Fonctions membres publiques inherited from JObject
 __construct ($properties=null)
 __toString ()
 def ($property, $default=null)
 get ($property, $default=null)
 getProperties ($public=true)
 getError ($i=null, $toString=true)
 getErrors ()
 set ($property, $value=null)
 setProperties ($properties)
 setError ($error)

Additional Inherited Members

- Fonctions membres publiques statiques inherited from JTable
static getInstance ($type, $prefix= 'JTable', $config=array())
static addIncludePath ($path=null)
- Fonctions membres protégées inherited from JTable
 _getAssetName ()
 _getAssetTitle ()
 _getAssetParentId (JTable $table=null, $id=null)
 _lock ()
 _unlock ()
- Attributs protégés inherited from JTable
 $_tbl = ''
 $_tbl_key = ''
 $_tbl_keys = array()
 $_db
 $_trackAssets = false
 $_rules
 $_locked = false
 $_autoincrement = true
 $_observers
- Attributs protégés inherited from JObject
 $_errors = array()

Description détaillée

Définition à la ligne 19 du fichier usergroup.php.


Documentation des constructeurs et destructeur

JTableUsergroup::__construct ( JDatabaseDriver  $db)

Constructor

Paramètres:
JDatabaseDriver$dbDatabase driver object.
Depuis:
11.1

Définition à la ligne 28 du fichier usergroup.php.

{
parent::__construct('#__usergroups', 'id', $db);
}

Documentation des fonctions membres

JTableUsergroup::check ( )

Method to check the current record to save

Renvoie:
boolean True on success
Depuis:
11.1

Réimplémentée à partir de JTable.

Définition à la ligne 40 du fichier usergroup.php.

Références JText\_().

{
// Validate the title.
if ((trim($this->title)) == '')
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_USERGROUP_TITLE'));
return false;
}
// Check for a duplicate parent_id, title.
// There is a unique index on the (parent_id, title) field in the table.
$db = $this->_db;
$query = $db->getQuery(true)
->select('COUNT(title)')
->from($this->_tbl)
->where('title = ' . $db->quote(trim($this->title)))
->where('parent_id = ' . (int) $this->parent_id)
->where('id <> ' . (int) $this->id);
$db->setQuery($query);
if ($db->loadResult() > 0)
{
$this->setError(JText::_('JLIB_DATABASE_ERROR_USERGROUP_TITLE_EXISTS'));
return false;
}
return true;
}

+ Voici le graphe d'appel pour cette fonction :

JTableUsergroup::delete (   $oid = null)

Delete this object and its dependencies

Paramètres:
integer$oidThe primary key of the user group to delete.
Renvoie:
mixed Boolean or Exception.
Depuis:
11.1
Exceptions:
RuntimeExceptionon database error.
UnexpectedValueExceptionon data error.

Réimplémentée à partir de JTable.

Définition à la ligne 151 du fichier usergroup.php.

{
if ($oid)
{
$this->load($oid);
}
if ($this->id == 0)
{
throw new UnexpectedValueException('Global Category not found');
}
if ($this->parent_id == 0)
{
throw new UnexpectedValueException('Root categories cannot be deleted.');
}
if ($this->lft == 0 || $this->rgt == 0)
{
throw new UnexpectedValueException('Left-Right data inconsistency. Cannot delete usergroup.');
}
$db = $this->_db;
// Select the usergroup ID and its children
$query = $db->getQuery(true)
->select($db->quoteName('c.id'))
->from($db->quoteName($this->_tbl) . 'AS c')
->where($db->quoteName('c.lft') . ' >= ' . (int) $this->lft)
->where($db->quoteName('c.rgt') . ' <= ' . (int) $this->rgt);
$db->setQuery($query);
$ids = $db->loadColumn();
if (empty($ids))
{
throw new UnexpectedValueException('Left-Right data inconsistency. Cannot delete usergroup.');
}
// Delete the category dependencies
// @todo Remove all related threads, posts and subscriptions
// Delete the usergroup and its children
$query->clear()
->delete($db->quoteName($this->_tbl))
->where($db->quoteName('id') . ' IN (' . implode(',', $ids) . ')');
$db->setQuery($query);
$db->execute();
// Delete the usergroup in view levels
$replace = array();
foreach ($ids as $id)
{
$replace[] = ',' . $db->quote("[$id,") . ',' . $db->quote("[") . ')';
$replace[] = ',' . $db->quote(",$id,") . ',' . $db->quote(",") . ')';
$replace[] = ',' . $db->quote(",$id]") . ',' . $db->quote("]") . ')';
$replace[] = ',' . $db->quote("[$id]") . ',' . $db->quote("[]") . ')';
}
$query->clear()
->select('id, rules')
->from('#__viewlevels');
$db->setQuery($query);
$rules = $db->loadObjectList();
$match_ids = array();
foreach ($rules as $rule)
{
foreach ($ids as $id)
{
if (strstr($rule->rules, '[' . $id) || strstr($rule->rules, ',' . $id) || strstr($rule->rules, $id . ']'))
{
$match_ids[] = $rule->id;
}
}
}
if (!empty($match_ids))
{
$query->clear()
->set('rules=' . str_repeat('replace(', 4 * count($ids)) . 'rules' . implode('', $replace))
->update('#__viewlevels')
->where('id IN (' . implode(',', $match_ids) . ')');
$db->setQuery($query);
$db->execute();
}
// Delete the user to usergroup mappings for the group(s) from the database.
$query->clear()
->delete($db->quoteName('#__user_usergroup_map'))
->where($db->quoteName('group_id') . ' IN (' . implode(',', $ids) . ')');
$db->setQuery($query);
$db->execute();
return true;
}
JTableUsergroup::rebuild (   $parent_id = 0,
  $left = 0 
)

Method to recursively rebuild the nested set tree.

Paramètres:
integer$parent_idThe root of the tree to rebuild.
integer$leftThe left id to start with in building the tree.
Renvoie:
boolean True on success
Depuis:
11.1

Définition à la ligne 81 du fichier usergroup.php.

{
// Get the database object
$db = $this->_db;
// Get all children of this node
$db->setQuery('SELECT id FROM ' . $this->_tbl . ' WHERE parent_id=' . (int) $parent_id . ' ORDER BY parent_id, title');
$children = $db->loadColumn();
// The right value of this node is the left value + 1
$right = $left + 1;
// Execute this function recursively over all children
for ($i = 0, $n = count($children); $i < $n; $i++)
{
// $right is the current right value, which is incremented on recursion return
$right = $this->rebuild($children[$i], $right);
// If there is an update failure, return false to break out of the recursion
if ($right === false)
{
return false;
}
}
// We've got the left value, and now that we've processed
// the children of this node we also know the right value
$db->setQuery('UPDATE ' . $this->_tbl . ' SET lft=' . (int) $left . ', rgt=' . (int) $right . ' WHERE id=' . (int) $parent_id);
// If there is an update failure, return false to break out of the recursion
if (!$db->execute())
{
return false;
}
// Return the right value of this node + 1
return $right + 1;
}
JTableUsergroup::store (   $updateNulls = false)

Inserts a new row if id is zero or updates an existing row in the database table

Paramètres:
boolean$updateNullsIf false, null object variables are not updated
Renvoie:
boolean True if successful, false otherwise and an internal error message is set
Depuis:
11.1

Réimplémentée à partir de JTable.

Définition à la ligne 129 du fichier usergroup.php.

{
if ($result = parent::store($updateNulls))
{
// Rebuild the nested set tree.
$this->rebuild();
}
return $result;
}

La documentation de cette classe a été générée à partir du fichier suivant :