argument_selector.action.inc 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @file
  4. * Passes selected ids as arguments to a page.
  5. * The ids might be entity ids or revision ids, depending on the type of the
  6. * VBO field.
  7. */
  8. /**
  9. * Implementation of hook_action_info().
  10. */
  11. function views_bulk_operations_argument_selector_action_info() {
  12. return array(
  13. 'views_bulk_operations_argument_selector_action' => array(
  14. 'label' => t('Pass ids as arguments to a page'),
  15. 'type' => 'entity',
  16. 'aggregate' => TRUE,
  17. 'configurable' => FALSE,
  18. 'hooks' => array(),
  19. 'triggers' => array('any'),
  20. ),
  21. );
  22. }
  23. /**
  24. * Implementation of a Drupal action.
  25. * Passes selected ids as arguments to a view.
  26. */
  27. function views_bulk_operations_argument_selector_action($entities, $context = array()) {
  28. $base_url = $context['settings']['url'];
  29. $arguments = implode(',', array_keys($entities));
  30. // Add a trailing slash if missing.
  31. if (substr($base_url, -1, 1) != '/') {
  32. $base_url .= '/';
  33. }
  34. drupal_goto($base_url . $arguments);
  35. }
  36. function views_bulk_operations_argument_selector_action_views_bulk_operations_form($options) {
  37. $form['url'] = array(
  38. '#title' => t('URL'),
  39. '#type' => 'textfield',
  40. '#description' => t('Enter a URL that the user will be sent to. A comma-separated list of selected ids will be appended.'),
  41. '#default_value' => isset($options['url']) ? $options['url'] : '',
  42. '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='),
  43. );
  44. return $form;
  45. }