You are here

function views_bulk_operations_select in Views Bulk Operations (VBO) 6

AJAX callback to update selection.

1 string reference to 'views_bulk_operations_select'
views_bulk_operations_menu in ./views_bulk_operations.module
Implementation of hook_menu().

File

./views_bulk_operations.module, line 1135
Allows operations to be performed on items selected in a view.

Code

function views_bulk_operations_select() {
  $view_id = $_REQUEST['view_id'];
  $view_name = $_REQUEST['view_name'];
  foreach (json_decode($_REQUEST['selection'], TRUE) as $selection => $value) {
    switch ($selection) {
      case 'operation':
        $_SESSION['vbo_values'][$view_name][$view_id]['operation'] = $value;
        break;
      case 'selectall':
        $_SESSION['vbo_values'][$view_name][$view_id]['selectall'] = $value > 0;
        if ($value == -1) {

          // -1 => reset selection
          $_SESSION['vbo_values'][$view_name][$view_id]['selection'] = array();
        }
        break;
      default:
        $_SESSION['vbo_values'][$view_name][$view_id]['selection'][$selection] = $value > 0;
        break;
    }
  }
  drupal_json(array(
    'selected' => count(array_filter($_SESSION['vbo_values'][$view_name][$view_id]['selection'])),
    'unselected' => count(array_filter($_SESSION['vbo_values'][$view_name][$view_id]['selection'], '_views_bulk_operations_filter_invert')),
    'selectall' => $_SESSION['vbo_values'][$view_name][$view_id]['selectall'],
  ));
  exit;
}