API15:JTableUser/store
From Joomla! Documentation
Description
Inserts a new row if id is zero or updates an existing row in the database table
[<! removed edit link to red link >]
<! removed transcluded page call, red link never existed >
Syntax
store($updateNulls=false)
| Parameter Name | Default Value | Description |
|---|---|---|
| $updateNulls | false | If false, null object variables are not updated |
Returns
null|string null if successful otherwise returns and error message
Defined in
libraries/joomla/database/table/user.php
Importing
jimport( 'joomla.database.table.user' );
Source Body
function store( $updateNulls=false )
{
$acl =& JFactory::getACL();
$section_value = 'users';
$k = $this->_tbl_key;
$key = $this->$k;
if ($key)
{
// existing record
$ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls );
// syncronise ACL
// single group handled at the moment
// trivial to expand to multiple groups
$object_id = $acl->get_object_id( $section_value, $this->$k, 'ARO' );
$groups = $acl->get_object_groups( $object_id, 'ARO' );
$acl->del_group_object( $groups[0], $section_value, $this->$k, 'ARO' );
$acl->add_group_object( $this->gid, $section_value, $this->$k, 'ARO' );
$acl->edit_object( $object_id, $section_value, $this->_db->getEscaped( $this->name ), $this->$k, 0, 0, 'ARO' );
}
else
{
// new record
$ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key );
// syncronise ACL
$acl->add_object( $section_value, $this->name, $this->$k, null, null, 'ARO' );
$acl->add_group_object( $this->gid, $section_value, $this->$k, 'ARO' );
}
if( !$ret )
{
$this->setError( strtolower(get_class( $this ))."::". JText::_( 'store failed' ) ."<br />" . $this->_db->getErrorMsg() );
return false;
}
else
{
return true;
}
}
[<! removed edit link to red link >] <! removed transcluded page call, red link never existed >
Examples
Code Examples