action.inc

  1. nittany7 modules/contrib/views_bulk_operations/plugins/operation_types/action.inc
  2. cis7 modules/contrib/views_bulk_operations/plugins/operation_types/action.inc
  3. mooc7 modules/contrib/views_bulk_operations/plugins/operation_types/action.inc

CTools plugin. Provides support for core actions.

Functions

Namesort descending Description
views_bulk_operations_operation_action_list Returns a prepared list of available actions.
views_bulk_operations_operation_advanced_action_list Get a list of advanced actions (created through the Action UI).

File

modules/contrib/views_bulk_operations/plugins/operation_types/action.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * CTools plugin. Provides support for core actions.
  5. */
  6. $plugin = array(
  7. 'title' => t('Action'),
  8. 'list callback' => 'views_bulk_operations_operation_action_list',
  9. 'handler' => array(
  10. 'file' => 'action.class.php',
  11. 'class' => 'ViewsBulkOperationsAction',
  12. ),
  13. );
  14. /**
  15. * Returns a prepared list of available actions.
  16. *
  17. * Actions are fetched by invoking hook_action_info() and by loading
  18. * advanced actions from the database.
  19. *
  20. * @param $operation_id
  21. * The full, prefixed operation_id of the operation (in this case, action)
  22. * to return, or NULL to return an array with all operations.
  23. */
  24. function views_bulk_operations_operation_action_list($operation_id = NULL) {
  25. $operations = &drupal_static(__FUNCTION__);
  26. if (!isset($operations)) {
  27. // Combined list of all actions and advanced actions.
  28. $actions_list = actions_list() + views_bulk_operations_operation_advanced_action_list();
  29. // Actions provided by Drupal that aren't usable in a VBO context.
  30. $hidden_actions = array(
  31. 'system_block_ip_action',
  32. 'system_goto_action',
  33. 'system_message_action',
  34. );
  35. $operations = array();
  36. foreach ($actions_list as $key => $action) {
  37. // Actions are keyed by callback.
  38. // Advanced actions are keyed by aid and store the callback separately.
  39. $callback = isset($action['callback']) ? $action['callback'] : $key;
  40. // This action needs to be skipped.
  41. if (in_array($callback, $hidden_actions)) {
  42. continue;
  43. }
  44. // All operations must be prefixed with the operation type.
  45. $new_operation_id = 'action::' . $key;
  46. $operations[$new_operation_id] = array(
  47. 'operation_type' => 'action',
  48. 'type' => $action['type'],
  49. // Keep the unprefixed key around, for internal use.
  50. 'key' => $key,
  51. 'callback' => $callback,
  52. 'label' => isset($action['label']) ? $action['label'] : '',
  53. 'parameters' => isset($action['parameters']) ? $action['parameters'] : array(),
  54. 'configurable' => !empty($action['configurable']) || !empty($action['vbo_configurable']),
  55. 'aggregate' => !empty($action['aggregate']),
  56. 'behavior' => isset($action['behavior']) ? $action['behavior'] : array(),
  57. 'permissions' => isset($action['permissions']) ? $action['permissions'] : NULL,
  58. 'pass rows' => !empty($action['pass rows']),
  59. );
  60. }
  61. }
  62. if (isset($operation_id)) {
  63. return isset($operations[$operation_id]) ? $operations[$operation_id] : FALSE;
  64. }
  65. else {
  66. return $operations;
  67. }
  68. }
  69. /**
  70. * Get a list of advanced actions (created through the Action UI).
  71. */
  72. function views_bulk_operations_operation_advanced_action_list() {
  73. $actions = array();
  74. $static_actions = actions_list();
  75. $result = db_query("SELECT * FROM {actions} WHERE parameters > ''");
  76. foreach ($result as $action) {
  77. $parameters = unserialize($action->parameters);
  78. $actions[$action->aid] = array(
  79. 'label' => isset($action->label) ? $action->label : '',
  80. 'callback' => $action->callback,
  81. 'type' => $action->type,
  82. 'configurable' => FALSE,
  83. 'parameters' => $parameters,
  84. );
  85. foreach (array('aggregate', 'behavior', 'permissions', 'pass rows') as $attribute) {
  86. if (isset($static_actions[$action->callback][$attribute])) {
  87. $actions[$action->aid][$attribute] = $static_actions[$action->callback][$attribute];
  88. }
  89. }
  90. if (isset($static_actions[$action->callback]['parameters'])) {
  91. $actions[$action->aid]['parameters'] = array_merge($actions[$action->aid]['parameters'], $static_actions[$action->callback]['parameters']);
  92. }
  93. }
  94. return $actions;
  95. }