Back to AdminController class

Method reorder

public bool
reorder
()
Changes the order of one or more records.
Returns
  • bool True on success
Since
  • 1.6

Method reorder - Source code

/**
 * Changes the order of one or more records.
 *
 * @return  boolean  True on success
 *
 * @since   1.6
 */
public function reorder()
{
    // Check for request forgeries.
    $this->checkToken();
    $ids = (array) $this->input->post->get('cid', array(), 'int');
    $inc = $this->getTask() === 'orderup' ? -1 : 1;
    // Remove zero values resulting from input filter
    $ids = array_filter($ids);
    $model = $this->getModel();
    $return = $model->reorder($ids, $inc);
    $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.
        $message = Text::_('JLIB_APPLICATION_SUCCESS_ITEM_REORDERED');
        $this->setRedirect($redirect, $message);
        return true;
    }
}