diff options
-rw-r--r-- | apps/files_trashbin/ajax/delete.php | 51 | ||||
-rw-r--r-- | apps/files_trashbin/ajax/undelete.php | 6 | ||||
-rw-r--r-- | apps/files_trashbin/index.php | 3 | ||||
-rw-r--r-- | apps/files_trashbin/js/trash.js | 42 | ||||
-rw-r--r-- | apps/files_trashbin/templates/index.php | 7 | ||||
-rw-r--r-- | apps/files_trashbin/templates/part.list.php | 6 |
6 files changed, 82 insertions, 33 deletions
diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index f41482bef55..34f35c39ccb 100644 --- a/apps/files_trashbin/ajax/delete.php +++ b/apps/files_trashbin/ajax/delete.php @@ -3,24 +3,43 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -$file = $_REQUEST['file']; +$files = $_POST['files']; +$dirlisting = $_POST['dirlisting']; +$list = json_decode($files); -$path_parts = pathinfo($file); -if ($path_parts['dirname'] == '.') { - $delimiter = strrpos($file, '.d'); - $filename = substr($file, 0, $delimiter); - $timestamp = substr($file, $delimiter+2); -} else { - $filename = $file; - $timestamp = null; -} +$error = array(); +$success = array(); -OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp); +$i = 0; +foreach ($list as $file) { + if ( $dirlisting=='0') { + $delimiter = strrpos($file, '.d'); + $filename = substr($file, 0, $delimiter); + $timestamp = substr($file, $delimiter+2); + } else { + $filename = $file; + $timestamp = null; + } + + OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp); + if (!OCA\Files_Trashbin\Trashbin::file_exists($filename, $timestamp)) { + $success[$i]['filename'] = $file; + $success[$i]['timestamp'] = $timestamp; + $i++; + } else { + $error[] = $filename; + } +} -if (!OCA\Files_Trashbin\Trashbin::file_exists($filename)) { - OCP\JSON::success(array("data" => array("filename" => $file))); -} else { +if ( $error ) { + $filelist = ''; + foreach ( $error as $e ) { + $filelist .= $e.', '; + } $l = OC_L10N::get('files_trashbin'); - OCP\JSON::error(array("data" => array("message" => $l->t("Couldn't delete %s permanently", array($file))))); + $message = $l->t("Couldn't delete %s permanently", array(rtrim($filelist, ', '))); + OCP\JSON::error(array("data" => array("message" => $message, + "success" => $success, "error" => $error))); +} else { + OCP\JSON::success(array("data" => array("success" => $success))); } - diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php index 6320c1d0827..93f2aaf1fa2 100644 --- a/apps/files_trashbin/ajax/undelete.php +++ b/apps/files_trashbin/ajax/undelete.php @@ -3,9 +3,9 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -$files = $_REQUEST['files']; -$dirlisting = $_REQUEST['dirlisting']; -$list = explode(';', $files); +$files = $_POST['files']; +$dirlisting = $_POST['dirlisting']; +$list = json_decode($files); $error = array(); $success = array(); diff --git a/apps/files_trashbin/index.php b/apps/files_trashbin/index.php index a2d4cc0a44d..d0b3030dbf8 100644 --- a/apps/files_trashbin/index.php +++ b/apps/files_trashbin/index.php @@ -16,6 +16,7 @@ OCP\Util::addScript('files', 'filelist'); $dir = isset($_GET['dir']) ? stripslashes($_GET['dir']) : ''; +$result = array(); if ($dir) { $dirlisting = true; $view = new \OC_FilesystemView('/'.\OCP\User::getUser().'/files_trashbin');
@@ -37,7 +38,7 @@ if ($dir) { ); }
} - closedir($fullpath); + closedir($dirContent); } else { $dirlisting = false; diff --git a/apps/files_trashbin/js/trash.js b/apps/files_trashbin/js/trash.js index 23e5fb2fc93..208cc88f0fd 100644 --- a/apps/files_trashbin/js/trash.js +++ b/apps/files_trashbin/js/trash.js @@ -6,9 +6,10 @@ $(document).ready(function() { var tr=$('tr').filterAttr('data-file', filename); var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform restore operation')+'" src="'+ OC.imagePath('core', 'loader.gif') +'"></a>'; var undeleteAction = $('tr').filterAttr('data-file',filename).children("td.date"); + var files = tr.attr('data-file'); undeleteAction[0].innerHTML = undeleteAction[0].innerHTML+spinner; $.post(OC.filePath('files_trashbin','ajax','undelete.php'), - {files:tr.attr('data-file'), dirlisting:tr.attr('data-dirlisting') }, + {files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') }, function(result){ for (var i = 0; i < result.data.success.length; i++) { var row = document.getElementById(result.data.success[i].filename); @@ -31,16 +32,17 @@ $(document).ready(function() { var deleteAction = $('tr').filterAttr('data-file',filename).children("td.date").children(".action.delete"); var oldHTML = deleteAction[0].outerHTML; var newHTML = '<img class="move2trash" data-action="Delete" title="'+t('files', 'delete file permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>'; + var files = tr.attr('data-file'); deleteAction[0].outerHTML = newHTML; $.post(OC.filePath('files_trashbin','ajax','delete.php'), - {file:tr.attr('data-file') }, + {files:JSON.stringify([files]), dirlisting:tr.attr('data-dirlisting') }, function(result){ - if ( result.status == 'success' ) { - var row = document.getElementById(result.data.filename); + for (var i = 0; i < result.data.success.length; i++) { + var row = document.getElementById(result.data.success[i].filename); row.parentNode.removeChild(row); - } else { - deleteAction[0].outerHTML = oldHTML; + } + if (result.status != 'success') { OC.dialogs.alert(result.data.message, 'Error'); } }); @@ -93,7 +95,7 @@ $(document).ready(function() { $('.undelete').click('click',function(event) { var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'perform restore operation')+'" src="'+ OC.imagePath('core', 'loader.gif') +'"></a>'; var files=getSelectedFiles('file'); - var fileslist=files.join(';'); + var fileslist = JSON.stringify(files); var dirlisting=getSelectedFiles('dirlisting')[0]; for (var i=0; i<files.length; i++) { @@ -113,7 +115,31 @@ $(document).ready(function() { } }); }); - + + $('.delete').click('click',function(event) { + console.log("delete selected"); + var spinner = '<img class="move2trash" title="'+t('files_trashbin', 'Delete permanently')+'" src="'+ OC.imagePath('core', 'loading.gif') +'"></a>'; + var files=getSelectedFiles('file'); + var fileslist = JSON.stringify(files); + var dirlisting=getSelectedFiles('dirlisting')[0]; + + for (var i=0; i<files.length; i++) { + var deleteAction = $('tr').filterAttr('data-file',files[i]).children("td.date"); + deleteAction[0].innerHTML = deleteAction[0].innerHTML+spinner; + } + + $.post(OC.filePath('files_trashbin','ajax','delete.php'), + {files:fileslist, dirlisting:dirlisting}, + function(result){ + for (var i = 0; i < result.data.success.length; i++) { + var row = document.getElementById(result.data.success[i].filename); + row.parentNode.removeChild(row); + } + if (result.status != 'success') { + OC.dialogs.alert(result.data.message, 'Error'); + } + }); + }); }); diff --git a/apps/files_trashbin/templates/index.php b/apps/files_trashbin/templates/index.php index c3e51b4becd..c948c94d552 100644 --- a/apps/files_trashbin/templates/index.php +++ b/apps/files_trashbin/templates/index.php @@ -25,6 +25,13 @@ </th> <th id="headerDate"> <span id="modified"><?php echo $l->t( 'Deleted' ); ?></span> + <span class="selectedActions"> + <a href="" class="delete"> + <?php echo $l->t('Delete')?> + <img class="svg" alt="<?php echo $l->t('Delete')?>" + src="<?php echo OCP\image_path("core", "actions/delete.svg"); ?>" /> + </a> + </span> </th> </tr> </thead> diff --git a/apps/files_trashbin/templates/part.list.php b/apps/files_trashbin/templates/part.list.php index fe8a71f44e6..2de0d7ee91a 100644 --- a/apps/files_trashbin/templates/part.list.php +++ b/apps/files_trashbin/templates/part.list.php @@ -1,12 +1,8 @@ <input type="hidden" id="disableSharing" data-status="<?php echo $_['disableSharing']; ?>"> <?php foreach($_['files'] as $file): - $simple_file_size = OCP\simple_file_size($file['size']); - // the bigger the file, the darker the shade of grey; megabytes*2 - $simple_size_color = intval(200-$file['size']/(1024*1024)*2); - if($simple_size_color<0) $simple_size_color = 0; $relative_deleted_date = OCP\relative_modified_date($file['timestamp']); // the older the file, the brighter the shade of grey; days*14 - $relative_date_color = round((time()-$file['mtime'])/60/60/24*14); + $relative_date_color = round((time()-$file['date'])/60/60/24*14); if($relative_date_color>200) $relative_date_color = 200; $name = str_replace('+', '%20', urlencode($file['name'])); $name = str_replace('%2F', '/', $name); |