/**
* Method to checkin a row.
*
* @param integer $pk The numeric id of the primary key.
*
* @return boolean False on failure or error, true otherwise.
*
* @since 1.6
*/
public function checkin($pk = null)
{
// Only attempt to check the row in if it exists.
if ($pk) {
$user = Factory::getUser();
// Get an instance of the row to checkin.
$table = $this->getTable();
if (!$table->load($pk)) {
$this->setError($table->getError());
return false;
}
// If there is no checked_out or checked_out_time field, just return true.
if (!$table->hasField('checked_out') || !$table->hasField('checked_out_time')) {
return true;
}
$checkedOutField = $table->getColumnAlias('checked_out');
// Check if this is the user having previously checked out the row.
if ($table->{$checkedOutField} > 0 && $table->{$checkedOutField} != $user->get('id') && !$user->authorise('core.manage', 'com_checkin')) {
$this->setError(Text::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH'));
return false;
}
// Attempt to check the row in.
if (!$table->checkIn($pk)) {
$this->setError($table->getError());
return false;
}
}
return true;
}