summaryrefslogtreecommitdiffstats
path: root/apps/files_trashbin/ajax
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_trashbin/ajax')
-rw-r--r--apps/files_trashbin/ajax/delete.php16
-rw-r--r--apps/files_trashbin/ajax/preview.php2
-rw-r--r--apps/files_trashbin/ajax/undelete.php31
3 files changed, 33 insertions, 16 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/preview.php b/apps/files_trashbin/ajax/preview.php
index 44738734b19..ce64d9ecc9f 100644
--- a/apps/files_trashbin/ajax/preview.php
+++ b/apps/files_trashbin/ajax/preview.php
@@ -11,7 +11,7 @@ if(!\OC_App::isEnabled('files_trashbin')){
exit;
}
-$file = array_key_exists('file', $_GET) ? (string) urldecode($_GET['file']) : '';
+$file = array_key_exists('file', $_GET) ? (string) $_GET['file'] : '';
$maxX = array_key_exists('x', $_GET) ? (int) $_GET['x'] : '44';
$maxY = array_key_exists('y', $_GET) ? (int) $_GET['y'] : '44';
$scalingUp = array_key_exists('scalingup', $_GET) ? (bool) $_GET['scalingup'] : true;
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;