function _views_bulk_operations_adjust_selection in Views Bulk Operations (VBO) 6.3
Helper function to adjust the selected set of nodes based on different situations.
1 call to _views_bulk_operations_adjust_selection()
- views_bulk_operations_form_submit in ./
views_bulk_operations.module - Submit handler for the selected operation.
File
- ./
views_bulk_operations.module, line 425 - Allows operations to be performed on items selected in a view.
Code
function _views_bulk_operations_adjust_selection(&$selection, $select_all, $exposed_input, $arguments, $plugin) {
if ($select_all) {
// Adjust selection to select all nodes across pages.
$view = views_get_view($plugin->view->vid ? $plugin->view->vid : $plugin->view->name);
$view
->set_exposed_input($exposed_input);
$view
->set_arguments($arguments);
$view
->build($plugin->view->current_display);
$view->query
->set_limit(NULL);
// reset the work done by the pager
$view->query
->set_offset(NULL);
// HACK for date_api_filter_handler: set $_GET with the exposed_input.
$_GET += $exposed_input;
$view
->execute($plugin->view->current_display);
$selection = array();
foreach ($view->result as $num => $result) {
$selection[$num + 1] = $result;
}
}
else {
// Adjust selection to filter out previous selections.
$results = array();
foreach ($plugin->view->result as $num => $result) {
if ($selection[$num + 1]) {
$results[$num + 1] = $result;
}
}
$selection = $results;
}
// Adjust sticky selection accordingly.
$_SESSION['vbo_values'][$_GET['q']]['objects'] = array(
'selection' => $selection,
'select_all' => $select_all,
);
}