diff --git a/admin/themes/default/js/batchManagerGlobal.js b/admin/themes/default/js/batchManagerGlobal.js index 803402dbe..8e04e1f04 100644 --- a/admin/themes/default/js/batchManagerGlobal.js +++ b/admin/themes/default/js/batchManagerGlobal.js @@ -278,25 +278,32 @@ jQuery('#applyAction').click(function(e) { continue; } - queuedManager.add({ - type: 'POST', - url: 'ws.php?format=json', - data: { - method: "pwg.images.delete", - pwg_token: jQuery("input[name=pwg_token").val(), - return_details: true, - image_id: image_ids.join(',') - }, - dataType: 'json', - success: ( function(data) { - todo += data.result.nb_processed; - progressDelete(todo, progressBar_max, true) - }), - error: ( function(data) { - todo += deleteBlockSize; // TODO: might be not exact, if last query - progressDelete(todo, progressBar_max, false) - }) - }); + (function(ids) { + var thisBatchSize = ids.length; + queuedManager.add({ + type: 'POST', + url: 'ws.php?format=json', + data: { + method: "pwg.images.delete", + pwg_token: jQuery("input[name=pwg_token").val(), + image_id: ids + }, + dataType: 'json', + success: function(data) { + todo += thisBatchSize; + var isOk = data.stat && "ok" == data.stat; + if (isOk && data.result != thisBatchSize) + /*TODO: user feedback only data.result images out of thisBatchSize were deleted*/; + /*TODO: user feedback if isError*/ + progressDelete(todo, progressBar_max, isOk); + }, + error: function(data) { + todo += thisBatchSize; + /*TODO: user feedback*/ + progressDelete(todo, progressBar_max, false); + } + }); + } )(image_ids); image_ids = Array(); } diff --git a/include/ws_functions/pwg.images.php b/include/ws_functions/pwg.images.php index b6647c8b5..08e847aa3 100644 --- a/include/ws_functions/pwg.images.php +++ b/include/ws_functions/pwg.images.php @@ -1737,15 +1737,10 @@ function ws_images_delete($params, $service) } include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); - delete_elements($image_ids, true); + $ret = delete_elements($image_ids, true); invalidate_user_cache(); - if ($params['return_details']) - { - return array( - 'nb_processed' => count($image_ids), - ); - } + return $ret; } /** diff --git a/ws.php b/ws.php index 16329635b..1d1f6b6f0 100644 --- a/ws.php +++ b/ws.php @@ -504,7 +504,6 @@ function ws_addDefaultMethods( $arr ) array( 'image_id' => array('flags'=>WS_PARAM_ACCEPT_ARRAY), 'pwg_token' => array(), - 'return_details' => array('default'=>false, 'type'=>WS_TYPE_BOOL), ), 'Deletes image(s).', $ws_functions_root . 'pwg.images.php',