Since: 1.7.0

class Usergroup extends Table

Usergroup table class.

Traits

DispatcherAwareTrait

Trait which contains the legacy methods that formerly were inherited from \Joomla\CMS\Object\CMSObject to set and get errors in a class.

Trait which contains the legacy methods that formerly were inherited from \Joomla\CMS\Object\CMSObject to set and get properties of the current class.

Properties

protected array deprecated Since: 1.7.0
$_errors

An array of error messages or Exception objects.

from  LegacyErrorHandlingTrait
protected string Since: 1.7.0
$_tbl

Name of the database table to model.

from  Table
protected string Since: 1.7.0
$_tbl_key

Name of the primary key field in the table.

from  Table
protected array Since: 3.0.1
$_tbl_keys

Name of the primary key fields in the table.

from  Table
protected DatabaseDriver Since: 1.7.0
$_db

DatabaseDriver object.

from  Table
protected bool Since: 1.7.0
$_trackAssets

Should rows be tracked as ACL assets?

from  Table
protected Rules Since: 1.7.0
$_rules

The rules associated with this record.

from  Table
protected bool Since: 1.7.0
$_locked

Indicator that the tables have been locked.

from  Table
protected bool Since: 3.1.4
$_autoincrement

Indicates that the primary keys autoincrement.

from  Table
protected array Since: 3.4.0
$_columnAlias

Array with alias for "special" columns such as ordering, hits etc etc

from  Table
protected array Since: 3.3
$_jsonEncode

An array of key names to be json encoded in the bind function

from  Table
protected bool Since: 3.10.0
$_supportNullValue

Indicates that columns fully support the NULL value in the database

from  Table
string Since: 4.0.0
$typeAlias

The UCM type alias. Used for tags, content versioning etc. Leave blank to effectively disable these features.

from  Table

Methods

string
getError(int $i = null, bool $toString = true) deprecated

Get the most recent error message.

array
getErrors() deprecated

Return all errors, if any.

void
setError(string $error) deprecated

Add an error message.

mixed
def(string $property, mixed $default = null) deprecated

Sets a default value if not already assigned

mixed
get(string $property, mixed $default = null) deprecated

Returns a property of the object or the default value if the property is not set.

array
getProperties(bool $public = true) deprecated

Returns an associative array of object properties.

mixed
set(string $property, mixed $value = null) deprecated

Modifies a property of the object, creating it if it does not already exist.

bool
setProperties(mixed $properties) deprecated

Set the object properties based on a named array/hash.

__construct(DatabaseDriver $db, DispatcherInterface|null $dispatcher = null)

Constructor

mixed
getFields(bool $reload = false)

Get the columns from database table.

from  Table
static Table|bool
getInstance(string $type, string $prefix = 'JTable', array $config = []) deprecated

Static method to get an instance of a Table class if it can be found in the table include paths.

from  Table
static array
addIncludePath(array|string $path = null) deprecated

Add a filesystem path where Table should search for table class files.

from  Table
string
_getAssetName()

Method to compute the default name of the asset.

from  Table
string
_getAssetTitle()

Method to return the title to use for the asset table.

from  Table
int
_getAssetParentId(Table|null $table = null, ?int $id = null)

Method to get the parent asset under which to register this one.

from  Table
void
appendPrimaryKeys(DatabaseQuery $query, mixed $pk = null)

Method to append the primary keys for this table to a query.

from  Table
string
getTableName()

Method to get the database table name for the class.

from  Table
string
getKeyName(bool $multiple = false)

Method to get the primary key field name for the table.

from  Table
mixed
getId()

Returns the identity (primary key) value of this record

from  Table
DatabaseDriver
getDbo()

Method to get the DatabaseDriver object.

from  Table
bool
setDbo(DatabaseDriver $db)

Method to set the DatabaseDriver object.

from  Table
void
setRules(mixed $input)

Method to set rules for the record.

from  Table
getRules()

Method to get the rules for the record.

from  Table
void
reset()

Method to reset class properties to the defaults set in the class definition.

from  Table
bool
bind(mixed $src, mixed $ignore = [])

Method to bind an associative array or object to the TableInterface instance.

from  Table
bool
load(mixed $keys = null, bool $reset = true)

Method to load a row from the database by primary key and bind the fields to the TableInterface instance properties.

from  Table
bool
check()

Method to check the current record to save

bool
store(bool $updateNulls = false)

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

bool
save(array|object $src, string $orderingFilter = '', array|string $ignore = '')

Method to provide a shortcut to binding, checking and storing a Table instance to the database table.

from  Table
bool
delete(int $oid = null)

Delete this object and its dependencies

bool
checkOut(int $userId, mixed $pk = null)

Method to check a row out if the necessary properties/fields exist.

from  Table
bool
checkIn(mixed $pk = null)

Method to check a row in if the necessary properties/fields exist.

from  Table
bool
hasPrimaryKey()

Validate that the primary key has been set.

from  Table
bool
hit(mixed $pk = null)

Method to increment the hits for a row if the necessary property/field exists.

from  Table
bool
isCheckedOut(int $with = 0, int $against = null)

Method to determine if a row is checked out and therefore uneditable by a user.

from  Table
int
getNextOrder(string $where = '')

Method to get the next ordering value for a group of rows defined by an SQL WHERE clause.

from  Table
array
getPrimaryKey(array $keys = [])

Get the primary key values for this table using passed in values as a default.

from  Table
mixed
reorder(string|string[] $where = '')

Method to compact the ordering values of rows in a group of rows defined by an SQL WHERE clause.

from  Table
bool
move(int $delta, string|string[] $where = '')

Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.

from  Table
bool
publish(mixed $pks = null, int $state = 1, int $userId = 0)

Method to set the publishing state for a row or list of rows in the database table.

from  Table
bool
_lock()

Method to lock the database table for writing.

from  Table
string
getColumnAlias(string $column)

Method to return the real name of a "special" column such as ordering, hits, published etc etc. In this way you are free to follow your db naming convention and use the built in \Joomla functions.

from  Table
void
setColumnAlias(string $column, string $columnAlias)

Method to register a column alias for a "special" column.

from  Table
bool
_unlock()

Method to unlock the database table for writing.

from  Table
bool
hasField(string $key)

Check if the record has a property (applying a column alias if it exists)

from  Table
bool
rebuild(int $parentId = 0, int $left = 0)

Method to recursively rebuild the nested set tree.

Details

string getError(int $i = null, bool $toString = true) deprecated

Since: 1.7.0

deprecated 3.1.4 will be removed in 6.0 Will be removed without replacement Catch thrown Exceptions instead of getError

Get the most recent error message.

Parameters

int $i

Option error index.

bool $toString

Indicates if Exception objects should return their error message.

Return Value

string

Error message

array getErrors() deprecated

Since: 1.7.0

deprecated 3.1.4 will be removed in 6.0 Will be removed without replacement Catch thrown Exceptions instead of getErrors

Return all errors, if any.

Return Value

array

Array of error messages.

void setError(string $error) deprecated

Since: 1.7.0

deprecated 3.1.4 will be removed in 6.0 Will be removed without replacement Throw an Exception instead of using setError

Add an error message.

Parameters

string $error

Error message.

Return Value

void

mixed def(string $property, mixed $default = null) deprecated

Since: 1.7.0

deprecated 4.3.0 will be removed in 6.0 Defining dynamic properties should not be used anymore

Sets a default value if not already assigned

Parameters

string $property

The name of the property.

mixed $default

The default value.

Return Value

mixed

mixed get(string $property, mixed $default = null) deprecated

Since: 1.7.0

deprecated 4.3.0 will be removed in 6.0 Create a proper getter function for the property

Returns a property of the object or the default value if the property is not set.

Parameters

string $property

The name of the property.

mixed $default

The default value.

Return Value

mixed

The value of the property.

See also

\Joomla\CMS\Object\CMSObject::getProperties()

array getProperties(bool $public = true) deprecated

Since: 1.7.0

deprecated 4.3.0 will be removed in 6.0 Create a proper getter function for the property

Returns an associative array of object properties.

Parameters

bool $public

If true, returns only the public properties.

Return Value

array

See also

\Joomla\CMS\Object\CMSObject::get()

mixed set(string $property, mixed $value = null) deprecated

Since: 1.7.0

deprecated 4.3.0 will be removed in 6.0 Create a proper setter function for the property

Modifies a property of the object, creating it if it does not already exist.

Parameters

string $property

The name of the property.

mixed $value

The value of the property to set.

Return Value

mixed

Previous value of the property.

bool setProperties(mixed $properties) deprecated

Since: 1.7.0

deprecated 4.3.0 will be removed in 6.0 Create a proper setter function for the property

Set the object properties based on a named array/hash.

Parameters

mixed $properties

Either an associative array or another object.

Return Value

bool

See also

\Joomla\CMS\Object\CMSObject::set()

__construct(DatabaseDriver $db, DispatcherInterface|null $dispatcher = null)

Since: 1.7.0

Constructor

Parameters

DatabaseDriver $db

DatabaseDriver object.

DispatcherInterface|null $dispatcher

Event dispatcher for this table

mixed getFields(bool $reload = false)

Since: 1.7.0

Get the columns from database table.

Parameters

bool $reload

flag to reload cache

Return Value

mixed

An array of the field names, or false if an error occurs.

Exceptions

UnexpectedValueException

static Table|bool getInstance(string $type, string $prefix = 'JTable', array $config = []) deprecated

Since: 1.7.0

deprecated 4.3 will be removed in 6.0 Use the MvcFactory instead Example: Factory::getApplication()->bootComponent('...')->getMVCFactory()->createTable($name, $prefix, $config);

Static method to get an instance of a Table class if it can be found in the table include paths.

To add include paths for searching for Table classes see Table::addIncludePath().

Parameters

string $type

The type (name) of the Table class to get an instance of.

string $prefix

An optional prefix for the table class name.

array $config

An optional array of configuration values for the Table object.

Return Value

Table|bool

A Table object if found or boolean false on failure.

static array addIncludePath(array|string $path = null) deprecated

Since: 1.7.0

deprecated 4.3 will be removed in 6.0 Should not be used anymore as tables are loaded through the MvcFactory

Add a filesystem path where Table should search for table class files.

Parameters

array|string $path

A filesystem path or array of filesystem paths to add.

Return Value

array

An array of filesystem paths to find Table classes in.

protected string _getAssetName()

Since: 1.7.0

Method to compute the default name of the asset.

The default name is in the form table_name.id where id is the value of the primary key of the table.

Return Value

string

protected string _getAssetTitle()

Since: 1.7.0

Method to return the title to use for the asset table.

In tracking the assets a title is kept for each asset so that there is some context available in a unified access manager. Usually this would just return $this->title or $this->name or whatever is being used for the primary name of the row. If this method is not overridden, the asset name is used.

Return Value

string

The string to use as the title in the asset table.

protected int _getAssetParentId(Table|null $table = null, ?int $id = null)

Since: 1.7.0

Method to get the parent asset under which to register this one.

By default, all assets are registered to the ROOT node with ID, which will default to 1 if none exists. An extended class can define a table and ID to lookup. If the asset does not exist it will be created.

Parameters

Table|null $table

A Table object for the asset parent.

?int $id

Id to look up

Return Value

int

void appendPrimaryKeys(DatabaseQuery $query, mixed $pk = null)

Since: 3.1.4

Method to append the primary keys for this table to a query.

Parameters

DatabaseQuery $query

A query object to append.

mixed $pk

Optional primary key parameter.

Return Value

void

string getTableName()

Since: 1.7.0

Method to get the database table name for the class.

Return Value

string

The name of the database table being modeled.

string getKeyName(bool $multiple = false)

Since: 1.7.0

Method to get the primary key field name for the table.

Parameters

bool $multiple

True to return all primary keys (as an array) or false to return just the first one (as a string).

Return Value

string

The name of the primary key for the table.

mixed getId()

Since: 4.0.0

Returns the identity (primary key) value of this record

Return Value

mixed

DatabaseDriver getDbo()

Since: 1.7.0

Method to get the DatabaseDriver object.

Return Value

DatabaseDriver

The internal database driver object.

bool setDbo(DatabaseDriver $db)

Since: 1.7.0

Method to set the DatabaseDriver object.

Parameters

DatabaseDriver $db

A DatabaseDriver object to be used by the table object.

Return Value

bool

True on success.

void setRules(mixed $input)

Since: 1.7.0

Method to set rules for the record.

Parameters

mixed $input

A Rules object, JSON string, or array.

Return Value

void

Rules getRules()

Since: 1.7.0

Method to get the rules for the record.

Return Value

Rules object

void reset()

Since: 1.7.0

Method to reset class properties to the defaults set in the class definition.

It will ignore the primary key as well as any private class properties.

Return Value

void

bool bind(mixed $src, mixed $ignore = [])

Since: 1.7.0

Method to bind an associative array or object to the TableInterface instance.

This method only binds properties that are publicly accessible and optionally takes an array of properties to ignore when binding.

Parameters

mixed $src

An associative array or object to bind to the TableInterface instance.

mixed $ignore

An optional array or space separated list of properties to ignore while binding.

Return Value

bool

True on success.

Exceptions

UnexpectedValueException

bool load(mixed $keys = null, bool $reset = true)

Since: 1.7.0

Method to load a row from the database by primary key and bind the fields to the TableInterface instance properties.

Parameters

mixed $keys

An optional primary key value to load the row by, or an array of fields to match. If not set the instance property value is used.

bool $reset

True to reset the default values before loading the new row.

Return Value

bool

True if successful. False if row not found.

Exceptions

RuntimeException
UnexpectedValueException

bool check()

Since: 1.7.0

Method to check the current record to save

Return Value

bool

True if the instance is sane and able to be stored in the database.

bool store(bool $updateNulls = false)

Since: 1.7.0

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

Parameters

bool $updateNulls

True to update fields even if they are null.

Return Value

bool

True on success.

bool save(array|object $src, string $orderingFilter = '', array|string $ignore = '')

Since: 1.7.0

Method to provide a shortcut to binding, checking and storing a Table instance to the database table.

The method will check a row in once the data has been stored and if an ordering filter is present will attempt to reorder the table rows based on the filter. The ordering filter is an instance property name. The rows that will be reordered are those whose value matches the Table instance for the property specified.

Parameters

array|object $src

An associative array or object to bind to the Table instance.

string $orderingFilter

Filter for the order updating

array|string $ignore

An optional array or space separated list of properties to ignore while binding.

Return Value

bool

True on success.

bool delete(int $oid = null)

Since: 1.7.0

Delete this object and its dependencies

Parameters

int $oid

The primary key of the user group to delete.

Return Value

bool

True on success.

Exceptions

RuntimeException
UnexpectedValueException

bool checkOut(int $userId, mixed $pk = null)

Since: 1.7.0

Method to check a row out if the necessary properties/fields exist.

To prevent race conditions while editing rows in a database, a row can be checked out if the fields 'checked_out' and 'checked_out_time' are available. While a row is checked out, any attempt to store the row by a user other than the one who checked the row out should be held until the row is checked in again.

Parameters

int $userId

The Id of the user checking out the row.

mixed $pk

An optional primary key value to check out. If not set the instance property value is used.

Return Value

bool

True on success.

Exceptions

UnexpectedValueException

bool checkIn(mixed $pk = null)

Since: 1.7.0

Method to check a row in if the necessary properties/fields exist.

Checking a row in will allow other users the ability to edit the row.

Parameters

mixed $pk

An optional primary key value to check out. If not set the instance property value is used.

Return Value

bool

True on success.

Exceptions

UnexpectedValueException

bool hasPrimaryKey()

Since: 3.1.4

Validate that the primary key has been set.

Return Value

bool

True if the primary key(s) have been set.

bool hit(mixed $pk = null)

Since: 1.7.0

Method to increment the hits for a row if the necessary property/field exists.

Parameters

mixed $pk

An optional primary key value to increment. If not set the instance property value is used.

Return Value

bool

True on success.

Exceptions

UnexpectedValueException

bool isCheckedOut(int $with = 0, int $against = null)

Since: 1.7.0

Method to determine if a row is checked out and therefore uneditable by a user.

If the row is checked out by the same user, then it is considered not checked out -- as the user can still edit it.

Parameters

int $with

The user ID to perform the match with, if an item is checked out by this user the function will return false.

int $against

The user ID to perform the match against when the function is used as a static function.

Return Value

bool

True if checked out.

int getNextOrder(string $where = '')

Since: 1.7.0

Method to get the next ordering value for a group of rows defined by an SQL WHERE clause.

This is useful for placing a new item last in a group of items in the table.

Parameters

string $where

WHERE clause to use for selecting the MAX(ordering) for the table.

Return Value

int

The next ordering value.

Exceptions

UnexpectedValueException

array getPrimaryKey(array $keys = [])

Since: 3.1.4

Get the primary key values for this table using passed in values as a default.

Parameters

array $keys

Optional primary key values to use.

Return Value

array

An array of primary key names and values.

mixed reorder(string|string[] $where = '')

Since: 1.7.0

Method to compact the ordering values of rows in a group of rows defined by an SQL WHERE clause.

Parameters

string|string[] $where

WHERE clause to use for limiting the selection of rows to compact the ordering values.

Return Value

mixed

Boolean True on success.

Exceptions

UnexpectedValueException

bool move(int $delta, string|string[] $where = '')

Since: 1.7.0

Method to move a row in the ordering sequence of a group of rows defined by an SQL WHERE clause.

Negative numbers move the row up in the sequence and positive numbers move it down.

Parameters

int $delta

The direction and magnitude to move the row in the ordering sequence.

string|string[] $where

WHERE clause to use for limiting the selection of rows to compact the ordering values.

Return Value

bool

True on success.

Exceptions

UnexpectedValueException

bool publish(mixed $pks = null, int $state = 1, int $userId = 0)

Since: 1.7.0

Method to set the publishing state for a row or list of rows in the database table.

The method respects checked out rows by other users and will attempt to checkin rows that it can after adjustments are made.

Parameters

mixed $pks

An optional array of primary key values to update. If not set the instance property value is used.

int $state

The publishing state. eg. [0 = unpublished, 1 = published]

int $userId

The user ID of the user performing the operation.

Return Value

bool

True on success; false if $pks is empty.

protected bool _lock()

Since: 1.7.0

Method to lock the database table for writing.

Return Value

bool

True on success.

Exceptions

RuntimeException

string getColumnAlias(string $column)

Since: 3.4

Method to return the real name of a "special" column such as ordering, hits, published etc etc. In this way you are free to follow your db naming convention and use the built in \Joomla functions.

Parameters

string $column

Name of the "special" column (ie ordering, hits)

Return Value

string

The string that identify the special

void setColumnAlias(string $column, string $columnAlias)

Since: 3.4

Method to register a column alias for a "special" column.

Parameters

string $column

The "special" column (ie ordering)

string $columnAlias

The real column name (ie foo_ordering)

Return Value

void

protected bool _unlock()

Since: 1.7.0

Method to unlock the database table for writing.

Return Value

bool

True on success.

bool hasField(string $key)

Since: 3.9.11

Check if the record has a property (applying a column alias if it exists)

Parameters

string $key

key to be checked

Return Value

bool

bool rebuild(int $parentId = 0, int $left = 0)

Since: 1.7.0

Method to recursively rebuild the nested set tree.

Parameters

int $parentId

The root of the tree to rebuild.

int $left

The left id to start with in building the tree.

Return Value

bool

True on success