API16

JModelForm/checkout: Difference between revisions

From Joomla! Documentation

Doxiki (talk | contribs)
New page: ===Description=== Method to check-out a row for editing. <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>Edit Descripton<nowiki...
 
m clean up
Line 2: Line 2:
Method to check-out a row for editing.
Method to check-out a row for editing.


<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>[[Description:JModelForm/checkout|Edit Descripton]]<nowiki>]</nowiki>
</span>


{{Description:JModelForm/checkout}}
 
{{subst:Description:JModelForm/checkout}}


===Syntax===
===Syntax===
Line 65: Line 63:
</source>
</source>


<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[SeeAlso:JModelForm/checkout|Edit See Also]]<nowiki>]</nowiki>
{{subst:SeeAlso:JModelForm/checkout}}
</span>
{{SeeAlso:JModelForm/checkout}}


===Examples===
===Examples===

Revision as of 14:15, 24 March 2017

Description

Method to check-out a row for editing.


{{subst:Description:JModelForm/checkout}}

Syntax

checkout($pk=null)
Parameter Name Default Value Description
$pk null $pk The numeric id of the primary key.

Returns

boolean False on failure or error, true otherwise.

Defined in

libraries/joomla/application/component/modelform.php

Importing

jimport( 'joomla.application.component.modelform' );

Source Body

public function checkout($pk = null)
{
        // Only attempt to check the row in if it exists.
        if ($pk)
        {
                $user = JFactory::getUser();

                // Get an instance of the row to checkout.
                $table = $this->getTable();
                if (!$table->load($pk)) {
                        $this->setError($table->getError());
                        return false;
                }

                // Check if this is the user having previously checked out the row.
                if ($table->checked_out > 0 && $table->checked_out != $user->get('id'))
                {
                        $this->setError(JText::_('JError_Checkout_user_mismatch'));
                        return false;
                }

                // Attempt to check the row out.
                if (!$table->checkout($user->get('id'), $pk))
                {
                        $this->setError($table->getError());
                        return false;
                }
        }

        return true;
}


{{subst:SeeAlso:JModelForm/checkout}}

Examples

<CodeExamplesForm />