summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2011-04-18 16:48:35 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2011-04-18 16:48:35 +0200
commit5a11e739b4fe3562df139798eac3566fa4809d60 (patch)
treefa371fc6366139ec85a8eeb3510272dd0e18d250
parentca00d37a710673fa359daf1817da78787a137f01 (diff)
downloadnextcloud-server-5a11e739b4fe3562df139798eac3566fa4809d60.tar.gz
nextcloud-server-5a11e739b4fe3562df139798eac3566fa4809d60.zip
implemented deleting multiple files
-rw-r--r--files/ajax/delete.php21
-rw-r--r--files/js/files.js19
2 files changed, 34 insertions, 6 deletions
diff --git a/files/ajax/delete.php b/files/ajax/delete.php
index 113476f0254..79caf4d0bb2 100644
--- a/files/ajax/delete.php
+++ b/files/ajax/delete.php
@@ -14,14 +14,23 @@ if( !OC_USER::isLoggedIn()){
// Get data
$dir = $_GET["dir"];
-$file = $_GET["file"];
+$files = isset($_GET["file"]) ? $_GET["file"] : $_GET["files"];
-// Delete
-if( OC_FILES::delete( $dir, $file )){
- echo json_encode( array( "status" => "success", "data" => array( "dir" => $dir, "file" => $file )));
+$files = explode(';', $files);
+$filesWithError = '';
+$status = 'success';
+//Now delete
+foreach($files as $file) {
+ if( !OC_FILES::delete( $dir, $file )){
+ $filesWithError .= $file . "\n";
+ $status = 'error';
+ }
}
-else{
- echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to delete file" )));
+
+if($status == 'success') {
+ echo json_encode( array( "status" => $status, "data" => array( "dir" => $dir, "files" => $files )));
+} else {
+ echo json_encode( array( "status" => $status, "data" => array( "message" => "Could not delete:\n" . $filesWithError )));
}
?>
diff --git a/files/js/files.js b/files/js/files.js
index 4bf1c77fdbd..06d5dbf0328 100644
--- a/files/js/files.js
+++ b/files/js/files.js
@@ -113,6 +113,25 @@ $(document).ready(function() {
window.location='ajax/download.php?files='+files+'&dir='+dir;
return false;
});
+
+ $('.delete').click(function(event) {
+ var files='';
+ $('td.selection input:checkbox:checked').parent().parent().children('.filename').each(function(i,element){
+ files+=';'+$(element).text();
+ });
+ files=files.substr(1);//remove leading ;
+
+ //send the browser to the download location
+ $.ajax({
+ url: 'ajax/delete.php',
+ data: "dir="+$('#dir').val()+"&files="+files,
+ complete: function(data){
+ boolOperationFinished(data, false);
+ }
+ });
+
+ return false;
+ });
});
function uploadFinished() {