You are here

function _draggableviews_click_sort in DraggableViews 6.3

Same name and namespace in other branches
  1. 7 draggableviews.inc \_draggableviews_click_sort()

Click Sort

The nodes are already in the right order. Simply assign ascending values. Re-execute view and refresh info array.

Parameters

$info: The structured info array. Look at _draggableviews_info(..) to learn more.

1 call to _draggableviews_click_sort()
draggableviews_views_pre_render in ./draggableviews.module
Imlpementing hook_views_pre_render

File

./draggableviews.inc, line 627
Draggableviews processing functions. Rough summary of what functions in this file do:

Code

function _draggableviews_click_sort(&$info) {

  // Check permissions.
  if (!user_access('Allow Reordering')) {
    drupal_set_message(t('You are not allowed to reorder nodes.'), 'error');
    return;
  }

  // Check if structure is locked.
  if ($info['locked']) {
    drupal_set_message(t('The structure is locked.'), 'error');
    return;
  }

  // If the items to display per page are limited we load the entire view.
  $pager = $info['view']->pager;
  if ($pager['items_per_page'] > 0) {
    _draggableviews_reload_info($info, DRAGGABLEVIEWS_DBQUERY_LIMIT, 0, $pager['offset']);
  }

  // First bring all child nodes down to the root level. We can't keep the hierarchy information
  // because the nodes have been mixed up thoroughly.
  if (isset($info['hierarchy'])) {
    foreach ($info['nodes'] as $nid => $values) {
      $info['nodes'][$nid]['parent'] = 0;
      $info['nodes'][$nid]['depth'] = 0;
    }
  }

  // Assign ascending numbers
  _draggableviews_ascending_numbers($info, $pager['offset'], TRUE);
  _draggableviews_save_hierarchy($info);

  // Re-execute view with original page settings.
  _draggableviews_reload_info($info, $pager['items_per_page'], $pager['current_page'], $pager['offset']);
}