Révision b8087750
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views_bulk_operations/actions/book.action.inc | ||
---|---|---|
58 | 58 |
function views_bulk_operations_move_to_book_action($node, $context = array()) { |
59 | 59 |
if (isset($context['book'])) { |
60 | 60 |
$book_node = node_load($context['book']); |
61 |
$mlid = db_select('menu_links' , 'ml')
|
|
62 |
->condition('ml.link_path' , 'node/' . $node->nid)
|
|
63 |
->fields('ml' , array('mlid'))
|
|
61 |
$mlid = db_select('menu_links', 'ml') |
|
62 |
->condition('ml.link_path', 'node/' . $node->nid) |
|
63 |
->fields('ml', array('mlid')) |
|
64 | 64 |
->execute() |
65 | 65 |
->fetchField(); |
66 | 66 |
$node->book['mlid'] = $mlid; |
... | ... | |
71 | 71 |
} |
72 | 72 |
|
73 | 73 |
/** |
74 |
* Adds the action 'Remove node from a parent book' |
|
74 |
* Adds the action 'Remove node from a parent book'.
|
|
75 | 75 |
*/ |
76 |
function views_bulk_operations_remove_from_book_action($node, $context) { |
|
77 |
$book = $node->book['mlid']; |
|
76 |
function views_bulk_operations_remove_from_book_action($node) { |
|
78 | 77 |
book_node_delete($node); |
78 |
// Remove book to avoid book_node_update() from building the links again. |
|
79 |
unset($node->book); |
|
79 | 80 |
} |
drupal7/sites/all/modules/views_bulk_operations/actions/modify.action.inc | ||
---|---|---|
55 | 55 |
} |
56 | 56 |
} |
57 | 57 |
|
58 |
if (in_array($key, $context['append']['bundle_' . $bundle_name]) && !empty($entity->$key)) {
|
|
58 |
if (in_array($key, $context['append']['bundle_' . $bundle_name]) && !empty($entity->{$key})) {
|
|
59 | 59 |
$entity->{$key}[$language] = array_merge($entity->{$key}[$language], $pseudo_entity->{$key}[$language]); |
60 | 60 |
|
61 | 61 |
// Check if we breached cardinality, and notify the user. |
... | ... | |
96 | 96 |
|
97 | 97 |
if (!empty($context['selected']['properties'])) { |
98 | 98 |
foreach ($context['selected']['properties'] as $key) { |
99 |
if (!$wrapper->$key->access('update')) {
|
|
99 |
if (!$wrapper->{$key}->access('update')) {
|
|
100 | 100 |
// No access. |
101 | 101 |
continue; |
102 | 102 |
} |
103 | 103 |
|
104 | 104 |
if (in_array($key, $context['append']['properties'])) { |
105 |
$old_values = $wrapper->$key->value();
|
|
106 |
$wrapper->$key->set($context['properties'][$key]);
|
|
105 |
$old_values = $wrapper->{$key}->value();
|
|
106 |
$wrapper->{$key}->set($context['properties'][$key]);
|
|
107 | 107 |
$new_values = $wrapper->{$key}->value(); |
108 | 108 |
$all_values = array_merge($old_values, $new_values); |
109 |
$wrapper->$key->set($all_values);
|
|
109 |
$wrapper->{$key}->set($all_values);
|
|
110 | 110 |
} |
111 | 111 |
else { |
112 | 112 |
$value = $context['properties'][$key]; |
113 | 113 |
if (is_string($value)) { |
114 | 114 |
$value = token_replace($value, array($context['entity_type'] => $entity), array('sanitize' => FALSE)); |
115 | 115 |
} |
116 |
$wrapper->$key->set($value);
|
|
116 |
$wrapper->{$key}->set($value);
|
|
117 | 117 |
} |
118 | 118 |
} |
119 | 119 |
} |
... | ... | |
193 | 193 |
$form['properties'][$key]['#maxlength'] = 255; |
194 | 194 |
} |
195 | 195 |
|
196 |
if (!empty($property['options list'])) { |
|
196 |
if (!empty($property['options list']) && is_callable($property['options list'])) {
|
|
197 | 197 |
$form['properties'][$key]['#type'] = 'select'; |
198 |
$form['properties'][$key]['#options'] = $property['options list']($key, array());
|
|
198 |
$form['properties'][$key]['#options'] = call_user_func_array($property['options list'], array($key, array()));
|
|
199 | 199 |
|
200 | 200 |
if ($property['type'] == 'list') { |
201 | 201 |
$form['properties'][$key]['#type'] = 'checkboxes'; |
... | ... | |
405 | 405 |
$properties = _views_bulk_operations_modify_action_get_properties($form_state['entity_type']); |
406 | 406 |
foreach ($form_state['selected']['properties'] as $key) { |
407 | 407 |
$value = $form_state['values']['properties'][$key]; |
408 |
if (!$wrapper->$key->validate($value)) {
|
|
408 |
if (!$wrapper->{$key}->validate($value)) {
|
|
409 | 409 |
$label = $properties[$key]['label']; |
410 | 410 |
form_set_error('properties][' . $key, t('%label contains an invalid value.', array('%label' => $label))); |
411 | 411 |
} |
drupal7/sites/all/modules/views_bulk_operations/actions_permissions.info | ||
---|---|---|
3 | 3 |
package = Administration |
4 | 4 |
core = 7.x |
5 | 5 |
|
6 |
; Information added by Drupal.org packaging script on 2017-02-21
|
|
7 |
version = "7.x-3.4"
|
|
6 |
; Information added by Drupal.org packaging script on 2018-05-08
|
|
7 |
version = "7.x-3.5"
|
|
8 | 8 |
core = "7.x" |
9 | 9 |
project = "views_bulk_operations" |
10 |
datestamp = "1487698687" |
|
11 |
|
|
10 |
datestamp = "1525821486" |
drupal7/sites/all/modules/views_bulk_operations/js/views_bulk_operations.js | ||
---|---|---|
38 | 38 |
|
39 | 39 |
$('.vbo-table-select-all', form).show(); |
40 | 40 |
// This is the "select all" checkbox in (each) table header. |
41 |
$('.vbo-table-select-all', form).click(function() { |
|
42 |
var table = $(this).closest('table')[0]; |
|
43 |
$('input[id^="edit-views-bulk-operations"]:not(:disabled)', table).prop('checked', this.checked);
|
|
41 |
$('input.vbo-table-select-all', form).click(function() {
|
|
42 |
var table = $(this).closest('table:not(.sticky-header)')[0];
|
|
43 |
$('.vbo-select:not(:disabled)', table).prop('checked', this.checked);
|
|
44 | 44 |
Drupal.vbo.toggleButtonsState(form); |
45 | 45 |
|
46 | 46 |
// Toggle the visibility of the "select all" row (if any). |
... | ... | |
57 | 57 |
// Set up the ability to click anywhere on the row to select it. |
58 | 58 |
if (Drupal.settings.vbo.row_clickable) { |
59 | 59 |
$('.views-table tbody tr', form).click(function(event) { |
60 |
if (event.target.tagName.toLowerCase() != 'input' && event.target.tagName.toLowerCase() != 'a') { |
|
61 |
$('input[id^="edit-views-bulk-operations"]:not(:disabled)', this).each(function() { |
|
62 |
var checked = this.checked; |
|
63 |
// trigger() toggles the checkmark *after* the event is set, |
|
64 |
// whereas manually clicking the checkbox toggles it *beforehand*. |
|
65 |
// that's why we manually set the checkmark first, then trigger the |
|
66 |
// event (so that listeners get notified), then re-set the checkmark |
|
67 |
// which the trigger will have toggled. yuck! |
|
68 |
this.checked = !checked; |
|
69 |
$(this).trigger('click'); |
|
70 |
this.checked = !checked; |
|
60 |
var tagName = event.target.tagName.toLowerCase(); |
|
61 |
if (tagName != 'input' && tagName != 'a' && tagName != 'label') { |
|
62 |
$('.vbo-select:not(:disabled)', this).each(function() { |
|
63 |
// Always return true for radios, you cannot de-select a radio by clicking on it, |
|
64 |
// it should be the same when clicking on a row. |
|
65 |
this.checked = $(this).is(':radio') ? true : !this.checked; |
|
66 |
$(this).trigger('change'); |
|
71 | 67 |
}); |
72 | 68 |
} |
73 | 69 |
}); |
... | ... | |
92 | 88 |
$('.vbo-select-all-markup', form).show(); |
93 | 89 |
|
94 | 90 |
$('.vbo-select-this-page', form).click(function() { |
95 |
$('input[id^="edit-views-bulk-operations"]', form).prop('checked', this.checked);
|
|
91 |
$('.vbo-select', form).prop('checked', this.checked);
|
|
96 | 92 |
Drupal.vbo.toggleButtonsState(form); |
97 | 93 |
$('.vbo-select-all-pages', form).prop('checked', false); |
98 | 94 |
|
... | ... | |
100 | 96 |
$('.vbo-table-select-all', form).prop('checked', this.checked); |
101 | 97 |
}); |
102 | 98 |
$('.vbo-select-all-pages', form).click(function() { |
103 |
$('input[id^="edit-views-bulk-operations"]', form).prop('checked', this.checked);
|
|
99 |
$('.vbo-select', form).prop('checked', this.checked);
|
|
104 | 100 |
Drupal.vbo.toggleButtonsState(form); |
105 | 101 |
$('.vbo-select-this-page', form).prop('checked', false); |
106 | 102 |
|
... | ... | |
117 | 113 |
Drupal.vbo.toggleButtonsState(form); |
118 | 114 |
}); |
119 | 115 |
|
120 |
$('.vbo-select', form).click(function() { |
|
116 |
// Handle a "change" event originating either from a row click or an actual checkbox click. |
|
117 |
$('.vbo-select', form).change(function() { |
|
121 | 118 |
// If a checkbox was deselected, uncheck any "select all" checkboxes. |
122 | 119 |
if (!this.checked) { |
123 | 120 |
$('.vbo-select-this-page', form).prop('checked', false); |
... | ... | |
147 | 144 |
// If no rows are checked, disable any form submit actions. |
148 | 145 |
var selectbox = $('select[name="operation"]', form); |
149 | 146 |
var checkedCheckboxes = $('.vbo-select:checked', form); |
150 |
var buttons = $('[id^="edit-select"] input[type="submit"]', form); |
|
147 |
// The .vbo-prevent-toggle CSS class is added to buttons to prevent toggling |
|
148 |
// between disabled and enabled. For example the case of an 'add' button. |
|
149 |
var buttons = $('[id^="edit-select"] [type="submit"]:not(.vbo-prevent-toggle)', form); |
|
151 | 150 |
|
152 | 151 |
if (selectbox.length) { |
153 | 152 |
var has_selection = checkedCheckboxes.length && selectbox.val() !== '0'; |
drupal7/sites/all/modules/views_bulk_operations/plugins/operation_types/action.class.php | ||
---|---|---|
128 | 128 |
actions_list(); |
129 | 129 |
|
130 | 130 |
$submit_callback = $this->operationInfo['callback'] . '_submit'; |
131 |
$this->formOptions = $submit_callback($form, $form_state); |
|
131 |
// If the return value from the callback is an options array, store it for |
|
132 |
// later union onto the context. |
|
133 |
$options = $submit_callback($form, $form_state); |
|
134 |
if ($options && is_array($options)) { |
|
135 |
$this->formOptions = $options; |
|
136 |
} |
|
132 | 137 |
} |
133 | 138 |
|
134 | 139 |
/** |
drupal7/sites/all/modules/views_bulk_operations/views/views_bulk_operations_handler_field_operations.inc | ||
---|---|---|
285 | 285 |
'#type' => 'radio', |
286 | 286 |
'#parents' => array($this->options['id']), |
287 | 287 |
'#return_value' => $id, |
288 |
'#attributes' => array('class' => array('vbo-select')), |
|
288 | 289 |
); |
289 | 290 |
} |
290 | 291 |
else { |
drupal7/sites/all/modules/views_bulk_operations/views_bulk_operations.info | ||
---|---|---|
9 | 9 |
files[] = plugins/operation_types/base.class.php |
10 | 10 |
files[] = views/views_bulk_operations_handler_field_operations.inc |
11 | 11 |
|
12 |
; Information added by Drupal.org packaging script on 2017-02-21
|
|
13 |
version = "7.x-3.4"
|
|
12 |
; Information added by Drupal.org packaging script on 2018-05-08
|
|
13 |
version = "7.x-3.5"
|
|
14 | 14 |
core = "7.x" |
15 | 15 |
project = "views_bulk_operations" |
16 |
datestamp = "1487698687" |
|
17 |
|
|
16 |
datestamp = "1525821486" |
drupal7/sites/all/modules/views_bulk_operations/views_bulk_operations.module | ||
---|---|---|
13 | 13 |
|
14 | 14 |
/** |
15 | 15 |
* Implements hook_action_info(). |
16 |
* |
|
16 | 17 |
* Registers custom VBO actions as Drupal actions. |
17 | 18 |
*/ |
18 | 19 |
function views_bulk_operations_action_info() { |
... | ... | |
20 | 21 |
$files = views_bulk_operations_load_action_includes(); |
21 | 22 |
foreach ($files as $filename) { |
22 | 23 |
$action_info_fn = 'views_bulk_operations_'. str_replace('.', '_', basename($filename, '.inc')).'_info'; |
23 |
$action_info = call_user_func($action_info_fn); |
|
24 |
if (is_array($action_info)) { |
|
25 |
$actions += $action_info; |
|
24 |
if (is_callable($action_info_fn)) { |
|
25 |
$action_info = call_user_func($action_info_fn); |
|
26 |
if (is_array($action_info)) { |
|
27 |
$actions += $action_info; |
|
28 |
} |
|
29 |
} |
|
30 |
else { |
|
31 |
watchdog('views bulk operations', 'views_bulk_operations_action_info() expects action filenames to have a matching valid callback function named: %function', array('%function' => $action_info_fn), WATCHDOG_WARNING); |
|
26 | 32 |
} |
27 | 33 |
} |
28 | 34 |
|
... | ... | |
190 | 196 |
$operations += $plugin['list callback'](); |
191 | 197 |
} |
192 | 198 |
|
193 |
uasort($operations, create_function('$a, $b', 'return strcasecmp($a["label"], $b["label"]);'));
|
|
199 |
uasort($operations, '_views_bulk_operations_sort_operations_by_label');
|
|
194 | 200 |
} |
195 | 201 |
|
196 | 202 |
if (!empty($operation_id)) { |
... | ... | |
201 | 207 |
} |
202 | 208 |
} |
203 | 209 |
|
210 |
/** |
|
211 |
* Sort function used by uasort in views_bulk_operations_get_operation_info(). |
|
212 |
* |
|
213 |
* A closure would be better suited for this, but closure support was added in |
|
214 |
* PHP 5.3 and D7 supports 5.2. |
|
215 |
*/ |
|
216 |
function _views_bulk_operations_sort_operations_by_label($a, $b) { |
|
217 |
return strcasecmp($a['label'], $b['label']); |
|
218 |
} |
|
219 |
|
|
204 | 220 |
/** |
205 | 221 |
* Returns an operation instance. |
206 | 222 |
* |
... | ... | |
523 | 539 |
$enable_select_all_pages = FALSE; |
524 | 540 |
// If the view is paginated, and "select all items on all pages" is |
525 | 541 |
// enabled, tell that to the theme function. |
526 |
if (count($vbo->view->result) != $vbo->view->total_rows && $vbo->get_vbo_option('enable_select_all_pages')) { |
|
542 |
if (isset($vbo->view->total_rows) && count($vbo->view->result) != $vbo->view->total_rows && $vbo->get_vbo_option('enable_select_all_pages')) {
|
|
527 | 543 |
$enable_select_all_pages = TRUE; |
528 | 544 |
} |
529 | 545 |
$form['select_all_markup'] = array( |
... | ... | |
842 | 858 |
|
843 | 859 |
// All items on all pages should be selected, add a batch job to gather |
844 | 860 |
// and enqueue them. |
845 |
if ($select_all_pages && $vbo->view->query->pager->has_more_records()) {
|
|
861 |
if ($select_all_pages && ($vbo->view->query->pager->has_more_records() || $vbo->view->query->pager->get_current_page() > 0)) {
|
|
846 | 862 |
$total_rows = $vbo->view->total_rows; |
847 | 863 |
|
848 | 864 |
$batch['operations'][] = array( |
... | ... | |
1186 | 1202 |
$skip_permission_check = $operation->getAdminOption('skip_permission_check'); |
1187 | 1203 |
// Filter out entities that can't be accessed. |
1188 | 1204 |
foreach ($entities as $id => $entity) { |
1189 |
if (!$skip_permission_check && !_views_bulk_operations_entity_access($operation, $entity_type, $entity, $account)) {
|
|
1205 |
if (!$skip_permission_check && !_views_bulk_operations_entity_access($operation, $entity_type, $entity, $user)) {
|
|
1190 | 1206 |
$context['results']['log'][] = t('Skipped %operation on @type %title due to insufficient permissions.', array( |
1191 | 1207 |
'%operation' => $operation->label(), |
1192 | 1208 |
'@type' => $entity_type, |
drupal7/sites/all/modules/views_bulk_operations/views_bulk_operations.rules.inc | ||
---|---|---|
173 | 173 |
$entity_type = $vbo->get_entity_type(); |
174 | 174 |
$entities = entity_metadata_wrapper("list<$entity_type>", array()); |
175 | 175 |
foreach ($vbo->view->result as $row_index => $result) { |
176 |
$entities[] = entity_metadata_wrapper($entity_type, $vbo->get_value($result)); |
|
176 |
// Grab the entire entity if it's already loaded or fall back to the |
|
177 |
// entity identifier. |
|
178 |
$entity = $vbo->get_value($result); |
|
179 |
$data = $entity ? $entity : $result->{$vbo->real_field}; |
|
180 |
$entities[] = entity_metadata_wrapper($entity_type, $data); |
|
177 | 181 |
} |
178 | 182 |
|
179 | 183 |
return array('entity_list' => $entities); |
Formats disponibles : Unified diff
Weekly update of contrib modules