summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/ajax
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-02-17 18:26:29 +0100
committerVincent Petry <pvince81@owncloud.com>2014-02-17 18:34:59 +0100
commit94b3296a71c5950f70919836bc12f0066016b705 (patch)
tree21316cadee878c5907397acff7ae9bdaf8ee8d7b /apps/files_trashbin/ajax
parentd5397d813cd731b5bf8ac4b7c193ac39d704af6e (diff)
downloadnextcloud-server-94b3296a71c5950f70919836bc12f0066016b705.tar.gz
nextcloud-server-94b3296a71c5950f70919836bc12f0066016b705.zip
Trashbin select all now doesn't send file list
- Fixed "delete" and "restore" actions to not send the file list when all files are selected - When some files are selected, sends the current dir - Removed "dirListing" attribute as the backend is able to compute the value based on the current dir
Diffstat (limited to 'apps/files_trashbin/ajax')
-rw-r--r--apps/files_trashbin/ajax/delete.php16
-rw-r--r--apps/files_trashbin/ajax/undelete.php31
2 files changed, 32 insertions, 15 deletions
diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php
index 75d481768ad..ebabc5bc7a2 100644
--- a/apps/files_trashbin/ajax/delete.php
+++ b/apps/files_trashbin/ajax/delete.php
@@ -2,42 +2,38 @@
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
+$folder = isset($_POST['dir']) ? $_POST['dir'] : '/';
// "empty trash" command
if (isset($_POST['allfiles']) and $_POST['allfiles'] === 'true'){
$deleteAll = true;
- $folder = isset($_POST['dir']) ? $_POST['dir'] : '/';
if ($folder === '/' || $folder === '') {
OCA\Files_Trashbin\Trashbin::deleteAll();
$list = array();
} else {
- $dirname = dirname($folder);
- if ( $dirname !== '/' && $dirname !== '.' ) {
- $dirlisting = '1';
- } else {
- $dirlisting = '0';
- }
$list[] = $folder;
+ $folder = dirname($folder);
}
}
else {
$deleteAll = false;
$files = $_POST['files'];
- $dirlisting = $_POST['dirlisting'];
$list = json_decode($files);
}
+
+$folder = rtrim($folder, '/') . '/';
$error = array();
$success = array();
$i = 0;
foreach ($list as $file) {
- if ( $dirlisting === '0') {
+ if ($folder === '/') {
$file = ltrim($file, '/');
$delimiter = strrpos($file, '.d');
$filename = substr($file, 0, $delimiter);
$timestamp = substr($file, $delimiter+2);
} else {
- $filename = $file;
+ $filename = $folder . '/' . $file;
$timestamp = null;
}
diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php
index 876ad269a70..9c3ccba7ed8 100644
--- a/apps/files_trashbin/ajax/undelete.php
+++ b/apps/files_trashbin/ajax/undelete.php
@@ -4,15 +4,36 @@ OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
$files = $_POST['files'];
-$dirlisting = $_POST['dirlisting'];
-$list = json_decode($files);
+$dir = '/';
+if (isset($_POST['dir'])) {
+ $dir = rtrim($_POST['dir'], '/'). '/';
+}
+$allFiles = false;
+if (isset($_POST['allfiles']) and $_POST['allfiles'] === 'true') {
+ $allFiles = true;
+ $list = array();
+ $dirListing = true;
+ if ($dir === '' || $dir === '/') {
+ $dirListing = false;
+ }
+ foreach (OCA\Files_Trashbin\Helper::getTrashFiles($dir) as $file) {
+ $fileName = $file['name'];
+ if (!$dirListing) {
+ $fileName .= '.d' . $file['timestamp'];
+ }
+ $list[] = $fileName;
+ }
+} else {
+ $list = json_decode($files);
+}
$error = array();
$success = array();
$i = 0;
foreach ($list as $file) {
- if ( $dirlisting === '0') {
+ $path = $dir . '/' . $file;
+ if ($dir === '/') {
$file = ltrim($file, '/');
$delimiter = strrpos($file, '.d');
$filename = substr($file, 0, $delimiter);
@@ -23,9 +44,9 @@ foreach ($list as $file) {
$timestamp = null;
}
- if ( !OCA\Files_Trashbin\Trashbin::restore($file, $filename, $timestamp) ) {
+ if ( !OCA\Files_Trashbin\Trashbin::restore($path, $filename, $timestamp) ) {
$error[] = $filename;
- OC_Log::write('trashbin','can\'t restore ' . $filename, OC_Log::ERROR);
+ OC_Log::write('trashbin', 'can\'t restore ' . $filename, OC_Log::ERROR);
} else {
$success[$i]['filename'] = $file;
$success[$i]['timestamp'] = $timestamp;