function gathercontent_upload_finished in GatherContent 7.3
Same name and namespace in other branches
- 8.5 gathercontent_upload_ui/gathercontent_upload_ui.module \gathercontent_upload_finished()
- 8.3 gathercontent.module \gathercontent_upload_finished()
Finished callback.
@inheritdoc
1 string reference to 'gathercontent_upload_finished'
- gathercontent_views_vbo_upload in ./
gathercontent.module - @TODO: function comment!!!
File
- ./
gathercontent.module, line 1531
Code
function gathercontent_upload_finished($success, $results, $operations) {
if ($success) {
// Select all items with uuid.
$query = new EntityFieldQuery();
$result = $query
->entityCondition('entity_type', 'gathercontent_operation_item')
->propertyCondition('operation_uuid', $results['uuid'])
->execute();
if (isset($result['gathercontent_operation_item'])) {
$operation_items = entity_load('gathercontent_operation_item', array_keys($result['gathercontent_operation_item']));
$success_counter = 0;
$nids = array(
'success' => array(),
'failed' => array(),
);
foreach ($operation_items as $operation_item) {
if ($operation_item->status === 'Success') {
$success_counter++;
$nids['success'][] = array(
'nid' => $operation_item->nid,
'gathercontent_id' => $operation_item->gathercontent_id,
);
}
else {
$nids['failed'][] = array(
'nid' => $operation_item->nid,
'gathercontent_id' => $operation_item->gathercontent_id,
);
}
}
$unsuccessful = count($result['gathercontent_operation_item']) - $success_counter;
drupal_set_message(format_plural($success_counter, '1 item was uploaded successfully.', '@count items were uploaded successfully.'));
if ($unsuccessful > 0) {
drupal_set_message(format_plural($unsuccessful, '1 item was not uploaded. Check errors below.', '@count items were not uploaded. Check errors below.'), 'error');
}
module_invoke_all('gathercontent_post_upload', $nids['success'], $nids['failed'], $results['uuid']);
}
drupal_goto('admin/content/upload/result/' . $results['uuid']);
}
else {
$error_operation = reset($operations);
drupal_set_message(t('An error occurred while processing @operation with arguments : @args', array(
'@operation' => $error_operation[0],
'@args' => print_r($error_operation[0], TRUE),
)), 'error');
}
}