summaryrefslogtreecommitdiffstats
path: root/files/ajax/delete.php
diff options
context:
space:
mode:
Diffstat (limited to 'files/ajax/delete.php')
-rw-r--r--files/ajax/delete.php19
1 files changed, 6 insertions, 13 deletions
diff --git a/files/ajax/delete.php b/files/ajax/delete.php
index 782db215dfc..b6bc859897c 100644
--- a/files/ajax/delete.php
+++ b/files/ajax/delete.php
@@ -3,14 +3,7 @@
// Init owncloud
require_once('../../lib/base.php');
-// We send json data
-header( "Content-Type: application/jsonrequest" );
-
-// Check if we are a user
-if( !OC_User::isLoggedIn()){
- echo json_encode( array( "status" => "error", "data" => array( "message" => "Authentication error" )));
- exit();
-}
+OC_JSON::checkLoggedIn();
// Get data
$dir = $_GET["dir"];
@@ -18,19 +11,19 @@ $files = isset($_GET["file"]) ? $_GET["file"] : $_GET["files"];
$files = explode(';', $files);
$filesWithError = '';
-$status = 'success';
+$success = true;
//Now delete
foreach($files as $file) {
if( !OC_Files::delete( $dir, $file )){
$filesWithError .= $file . "\n";
- $status = 'error';
+ $success = false;
}
}
-if($status == 'success') {
- echo json_encode( array( "status" => $status, "data" => array( "dir" => $dir, "files" => $files )));
+if(success) {
+ OC_JSON::success(array("data" => array( "dir" => $dir, "files" => $files )));
} else {
- echo json_encode( array( "status" => $status, "data" => array( "message" => "Could not delete:\n" . $filesWithError )));
+ OC_JSON::error(array("data" => array( "message" => "Could not delete:\n" . $filesWithError )));
}
?>