You are here

function views_bulk_operations_form_validate in Views Bulk Operations (VBO) 5

Same name and namespace in other branches
  1. 6.3 views_bulk_operations.module \views_bulk_operations_form_validate()
  2. 6 views_bulk_operations.module \views_bulk_operations_form_validate()
  3. 7.3 views_bulk_operations.module \views_bulk_operations_form_validate()

File

./views_bulk_operations.module, line 305
Allow bulk node operations directly within views.

Code

function views_bulk_operations_form_validate($form_id, $form_values) {
  if ($form_values['step'] == VIEWS_BULK_OPS_STEP_VIEW || $form_values['step'] == VIEWS_BULK_OPS_STEP_SINGLE) {
    if (!array_sum($form_values['nodes'])) {

      // If all 0, no node selected
      form_set_error('nodes', t('No nodes selected. Please select one or more nodes.'));
    }
  }
  if ($form_values['step'] == VIEWS_BULK_OPS_STEP_VIEW) {
    if (!$form_values['action']) {

      // No action selected
      form_set_error('action', t('No action selected. Please select an action to perform.'));
    }
  }
  if ($form_values['step'] == VIEWS_BULK_OPS_STEP_CONFIG || $form_values['step'] == VIEWS_BULK_OPS_STEP_SINGLE) {
    $action = $form_values['action'];
    $operations = _views_bulk_operations_get_operations('enabled', $form_values['vid']);
    if ($operations[$action]['configurable']) {
      _views_bulk_operations_action_validate($operations[$action], $form_id, $form_values);
    }
  }
  if ($form_values['step'] == VIEWS_BULK_OPS_STEP_CONFIG || $form_values['step'] == VIEWS_BULK_OPS_STEP_CONFIRM) {
    $view = module_invoke('views', 'get_view', $form_values['vid']);
    $view->use_pager = FALSE;
  }
}