diff options
author | Robin Appelman <icewind@owncloud.com> | 2012-10-24 15:52:30 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2012-10-24 15:52:30 +0200 |
commit | 5a3d6805a2613c4f55daa971e112cc77f17b060f (patch) | |
tree | 38e17165b616821ac5c42ae3adb1fb7042b72e4e /apps/files/ajax/rename.php | |
parent | 7b150dfa963d81889b8d40bf3956795c9a712aec (diff) | |
download | nextcloud-server-5a3d6805a2613c4f55daa971e112cc77f17b060f.tar.gz nextcloud-server-5a3d6805a2613c4f55daa971e112cc77f17b060f.zip |
cleanup OC_Files a bit
Diffstat (limited to 'apps/files/ajax/rename.php')
-rw-r--r-- | apps/files/ajax/rename.php | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php index 45448279fa1..a2b9b8de257 100644 --- a/apps/files/ajax/rename.php +++ b/apps/files/ajax/rename.php @@ -11,10 +11,14 @@ $dir = stripslashes($_GET["dir"]); $file = stripslashes($_GET["file"]); $newname = stripslashes($_GET["newname"]); -// Delete -if( OC_Files::move( $dir, $file, $dir, $newname )) { - OCP\JSON::success(array("data" => array( "dir" => $dir, "file" => $file, "newname" => $newname ))); -} -else{ +if (OC_User::isLoggedIn() && ($dir != '' || $file != 'Shared')) { + $targetFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $file); + $sourceFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $newname); + if(\OC\Files\Filesystem::rename($sourceFile, $targetFile)) { + OCP\JSON::success(array("data" => array( "dir" => $dir, "file" => $file, "newname" => $newname ))); + } else { + OCP\JSON::error(array("data" => array( "message" => "Unable to rename file" ))); + } +}else{ OCP\JSON::error(array("data" => array( "message" => "Unable to rename file" ))); } |