/**
* Method to save the submitted ordering values for records.
*
* @return boolean True on success
*
* @since 1.6
*/
public function saveorder()
{
// Check for request forgeries.
$this->checkToken();
// Get the input
$pks = (array) $this->input->post->get('cid', array(), 'int');
$order = (array) $this->input->post->get('order', array(), 'int');
// Remove zero PKs and corresponding order values resulting from input filter for PK
foreach ($pks as $i => $pk) {
if ($pk === 0) {
unset($pks[$i]);
unset($order[$i]);
}
}
// Get the model
$model = $this->getModel();
// Save the ordering
$return = $model->saveorder($pks, $order);
$redirect = Route::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false);
if ($return === false) {
// Reorder failed
$message = Text::sprintf('JLIB_APPLICATION_ERROR_REORDER_FAILED', $model->getError());
$this->setRedirect($redirect, $message, 'error');
return false;
} else {
// Reorder succeeded.
$this->setMessage(Text::_('JLIB_APPLICATION_SUCCESS_ORDERING_SAVED'));
$this->setRedirect($redirect);
return true;
}
}