diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-02-19 10:24:21 +0100 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-02-19 10:24:21 +0100 |
commit | 51cef9d8f06586a4e7d4353cb5d7cc3fcddcf97a (patch) | |
tree | 7320bcbfad978c915899b3763ddc53b288472d2f /apps/files_trashbin/ajax/delete.php | |
parent | 9a93db96421b712d8b8485478db4b84594571c68 (diff) | |
download | nextcloud-server-51cef9d8f06586a4e7d4353cb5d7cc3fcddcf97a.tar.gz nextcloud-server-51cef9d8f06586a4e7d4353cb5d7cc3fcddcf97a.zip |
allow user to delete selected files from the trash bin permanently
Diffstat (limited to 'apps/files_trashbin/ajax/delete.php')
-rw-r--r-- | apps/files_trashbin/ajax/delete.php | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index 7a6bd1342ea..d922fafeb26 100644 --- a/apps/files_trashbin/ajax/delete.php +++ b/apps/files_trashbin/ajax/delete.php @@ -3,22 +3,46 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -$file = $_REQUEST['file']; +$files = $_REQUEST['files']; +$dirlisting = $_REQUEST['dirlisting']; +$list = explode(';', $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; +if (!is_array($list)){ + $list = array($list); } -if (OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp)) { - OCP\JSON::success(array("data" => array("filename" => $file))); -} else { - $l = OC_L10N::get('files_trashbin'); - OCP\JSON::error(array("data" => array("message" => $l->t("Couldn't delete %s permanently", array($file))))); +$error = array(); +$success = array(); + +$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; + } + + if(OCA\Files_Trashbin\Trashbin::delete($filename, $timestamp)) { + $success[$i]['filename'] = $file; + $success[$i]['timestamp'] = $timestamp; + $i++; + } else { + $error[] = $filename; + } } +if ( $error ) { + $filelist = ''; + foreach ( $error as $e ) { + $filelist .= $e.', '; + } + $l = OC_L10N::get('files_trashbin'); + $message = $l->t("Couldn't restore %s", array(rtrim($filelist, ', '))); + OCP\JSON::error(array("data" => array("message" => $message, + "success" => $success, "error" => $error))); +} else { + OCP\JSON::success(array("data" => array("success" => $success))); +} |