diff options
author | Björn Schießle <schiessle@owncloud.com> | 2013-01-18 17:50:44 +0100 |
---|---|---|
committer | Björn Schießle <schiessle@owncloud.com> | 2013-01-22 15:33:54 +0100 |
commit | 1255791ef2535aac96889f6be8c8b5b163b45be6 (patch) | |
tree | d6d7e192006238dfc3a8f0b21e65c3c206839c96 /apps/files_trashbin/ajax/undelete.php | |
parent | 655a20f963e5cd0d73d2abfbcdde0a3519e85be2 (diff) | |
download | nextcloud-server-1255791ef2535aac96889f6be8c8b5b163b45be6.tar.gz nextcloud-server-1255791ef2535aac96889f6be8c8b5b163b45be6.zip |
handle group restore
Diffstat (limited to 'apps/files_trashbin/ajax/undelete.php')
-rw-r--r-- | apps/files_trashbin/ajax/undelete.php | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php index f55629d695c..05b5e7a5ee4 100644 --- a/apps/files_trashbin/ajax/undelete.php +++ b/apps/files_trashbin/ajax/undelete.php @@ -4,11 +4,34 @@ if(!OC_User::isLoggedIn()) { exit;
} -$timestamp = isset( $_REQUEST['timestamp'] ) ? $_REQUEST['timestamp'] : ''; -$filename = isset( $_REQUEST['filename'] ) ? trim($_REQUEST['filename'], '/\\') : ''; +$files = $_REQUEST['files']; +$list = explode(';', $files); -if ( OCA_Trash\Trashbin::restore($filename, $timestamp) ) { - OCP\JSON::success(array("data" => array('filename'=>$filename, 'timestamp' => $timestamp))); +$error = array(); + +$i = 0; +foreach ($list as $file) { + $delimiter = strrpos($file, '.d'); + $filename = substr($file, 0, $delimiter); + $timestamp = substr($file, $delimiter+2); + + if ( !OCA_Trash\Trashbin::restore($filename, $timestamp) ) { + $error[] = $filename; + } else { + $success[$i]['filename'] = $filename; + $success[$i]['timestamp'] = $timestamp; + $i++; + } + +} + +if ( $error ) { + $filelist = ''; + foreach ( $error as $e ) { + $filelist .= $e.', '; + } + OCP\JSON::error(array("data" => array("message" => "Couldn't restore ".rtrim($filelist,', '), "success" => $success, "error" => $error))); } else { - OCP\JSON::error(array("data" => array("message" => "Couldn't restore ".$filename))); + OCP\JSON::success(array("data" => array("success" => $success))); } + |