API15

JTableUser/store: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Inserts a new row if id is zero or updates an existing row in the database table <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JT...
 
m removing red link to edit, no existant pages
Line 3: Line 3:


<span class="editsection" style="font-size:76%;">
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JTableUser/store|Edit Descripton]]<nowiki>]</nowiki>
<nowiki>[<! removed edit link to red link >]</nowiki>
</span>
</span>


{{Description:JTableUser/store}}
<! removed transcluded page call, red link never existed >


===Syntax===
===Syntax===
Line 78: Line 78:


<span class="editsection" style="font-size:76%;">
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[SeeAlso:JTableUser/store|Edit See Also]]<nowiki>]</nowiki>
<nowiki>[<! removed edit link to red link >]</nowiki>
</span>
</span>
{{SeeAlso:JTableUser/store}}
<! removed transcluded page call, red link never existed >


===Examples===
===Examples===
Line 93: Line 93:
  format= ,,,
  format= ,,,
</dpl>
</dpl>
[[Category:Archived pages API15]]

Revision as of 18:54, 12 May 2013

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

<CodeExamplesForm />