Actions

API15

JTableUser/store

From Joomla! Documentation

< API15:JTableUser
Revision as of 17:17, 22 March 2010 by Doxiki (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

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

[Edit Descripton]

Description:JTableUser/store

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;
        }
}

[Edit See Also] SeeAlso:JTableUser/store

Examples

<CodeExamplesForm />