public function loadhistory()
{
$model = $this->getModel();
$table = $model->getTable();
$historyId = $this->input->getInt('version_id', null);
if (!$model->loadhistory($historyId, $table)) {
$this->setMessage($model->getError(), 'error');
$this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));
return false;
}
if (empty($key)) {
$key = $table->getKeyName();
}
$recordId = $table->{$key};
$urlVar = empty($this->urlVar) ? $key : $this->urlVar;
if (!$this->allowEdit(array($key => $recordId), $key)) {
$this->setMessage(Text::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED'), 'error');
$this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false));
$table->checkIn();
return false;
}
$this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $urlVar), false));
if (!$table->check() || !$table->store()) {
$this->setMessage($table->getError(), 'error');
return false;
}
$this->setMessage(Text::sprintf('JLIB_APPLICATION_SUCCESS_LOAD_HISTORY', $model->getState('save_date'), $model->getState('version_note')));
$this->postSaveHook($model);
return true;
}