API16

JModelForm/checkout

From Joomla! Documentation

< API16:JModelForm
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Method to check-out a row for editing.



Syntax[edit]

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

Returns[edit]

boolean False on failure or error, true otherwise.

Defined in[edit]

libraries/joomla/application/component/modelform.php

Importing[edit]

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

Source Body[edit]

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



Examples[edit]

Code Examples[edit]