Back to AdminModel class

Method checkin

public int|bool
checkin
(mixed $pks = array())
Method override to check-in a record or an array of record
Parameters
  • mixed $pks The ID of the primary key or an array of IDs
Returns
  • int|bool Boolean false if there is an error, otherwise the count of records checked in.
Since
  • 1.6
Class: AdminModel
Project: Joomla

Method checkin - Source code

/**
 * Method override to check-in a record or an array of record
 *
 * @param   mixed  $pks  The ID of the primary key or an array of IDs
 *
 * @return  integer|boolean  Boolean false if there is an error, otherwise the count of records checked in.
 *
 * @since   1.6
 */
public function checkin($pks = array())
{
    $pks = (array) $pks;
    $table = $this->getTable();
    $count = 0;
    if (empty($pks)) {
        $pks = array((int) $this->getState($this->getName() . '.id'));
    }
    $checkedOutField = $table->getColumnAlias('checked_out');
    // Check in all items.
    foreach ($pks as $pk) {
        if ($table->load($pk)) {
            if ($table->{$checkedOutField} > 0) {
                if (!parent::checkin($pk)) {
                    return false;
                }
                $count++;
            }
        } else {
            $this->setError($table->getError());
            return false;
        }
    }
    return $count;
}