From 8ce3ea3e2c0fba2073cc9f279ab14f9d2bdbfdc4 Mon Sep 17 00:00:00 2001 From: Bjoern Schiessle Date: Mon, 2 Dec 2013 11:39:53 +0100 Subject: fix delete files from trash bin --- apps/files_trashbin/ajax/delete.php | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'apps/files_trashbin/ajax') diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index 5498250dbf5..7b1949e3154 100644 --- a/apps/files_trashbin/ajax/delete.php +++ b/apps/files_trashbin/ajax/delete.php @@ -6,10 +6,18 @@ OCP\JSON::callCheck(); // "empty trash" command $deleteAll = false; if (isset($_POST['allfiles']) and $_POST['allfiles'] === 'true'){ - $user = \OCP\User::getUser(); - $list = OCA\Files_Trashbin\Helper::getTrashFiles('/'); - $deleteAll = true; - $dirlisting = '0'; + $folder = isset($_POST['dir']) ? $_POST['dir'] : '/'; + if ($folder === '/') { + OCA\Files_Trashbin\Trashbin::deleteAll(); + $list = array(); + } else { + if ( strlen(dirname($folder)) > 1 ) { + $dirlisting = '1'; + } else { + $dirlisting = '0'; + } + $list[] = $folder; + } } else { $files = $_POST['files']; @@ -19,19 +27,13 @@ else { $error = array(); $success = array(); - $i = 0; foreach ($list as $file) { if ( $dirlisting === '0') { - if ($deleteAll) { - $filename = $file['name']; - $timestamp = $file['timestamp']; - } - else { - $delimiter = strrpos($file, '.d'); - $filename = substr($file, 0, $delimiter); - $timestamp = substr($file, $delimiter+2); - } + $file = ltrim($file, '/'); + $delimiter = strrpos($file, '.d'); + $filename = substr($file, 0, $delimiter); + $timestamp = substr($file, $delimiter+2); } else { $filename = $file; $timestamp = null; -- cgit v1.2.3