aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/ajax
diff options
context:
space:
mode:
authorMichael Gapczynski <mtgap@owncloud.com>2013-05-27 11:35:57 -0400
committerMichael Gapczynski <mtgap@owncloud.com>2013-05-27 11:35:57 -0400
commit16925672e885071afab1fe158dc206ab8ed93baf (patch)
tree143f64c88d7d47cb0f5a3a7641228a7cae24821b /apps/files/ajax
parent0953b68556152187ed305323b64b186cc21c2ade (diff)
parent0c621ff6a93fe1b34c77257d83fd344489f59bab (diff)
downloadnextcloud-server-16925672e885071afab1fe158dc206ab8ed93baf.tar.gz
nextcloud-server-16925672e885071afab1fe158dc206ab8ed93baf.zip
Merge branch 'master' into googledrive
Diffstat (limited to 'apps/files/ajax')
-rw-r--r--apps/files/ajax/rawlist.php8
-rw-r--r--apps/files/ajax/rename.php53
2 files changed, 42 insertions, 19 deletions
diff --git a/apps/files/ajax/rawlist.php b/apps/files/ajax/rawlist.php
index 1cd2944483c..f568afad4da 100644
--- a/apps/files/ajax/rawlist.php
+++ b/apps/files/ajax/rawlist.php
@@ -15,6 +15,14 @@ $mimetype = isset($_GET['mimetype']) ? $_GET['mimetype'] : '';
// make filelist
$files = array();
+// If a type other than directory is requested first load them.
+if($mimetype && strpos($mimetype, 'httpd/unix-directory') === false) {
+ foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, 'httpd/unix-directory' ) as $i ) {
+ $i["date"] = OCP\Util::formatDate($i["mtime"] );
+ $i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir'): \mimetype_icon($i['mimetype']);
+ $files[] = $i;
+ }
+}
foreach( \OC\Files\Filesystem::getDirectoryContent( $dir, $mimetype ) as $i ) {
$i["date"] = OCP\Util::formatDate($i["mtime"] );
$i['mimetype_icon'] = $i['type'] == 'dir' ? \mimetype_icon('dir'): \mimetype_icon($i['mimetype']);
diff --git a/apps/files/ajax/rename.php b/apps/files/ajax/rename.php
index 9fd2ce3ad4b..f4551858283 100644
--- a/apps/files/ajax/rename.php
+++ b/apps/files/ajax/rename.php
@@ -1,26 +1,41 @@
<?php
-// Init owncloud
-
+/**
+ * ownCloud - Core
+ *
+ * @author Morris Jobke
+ * @copyright 2013 Morris Jobke morris.jobke@gmail.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
OCP\JSON::checkLoggedIn();
OCP\JSON::callCheck();
-// Get data
-$dir = stripslashes($_GET["dir"]);
-$file = stripslashes($_GET["file"]);
-$newname = stripslashes($_GET["newname"]);
-
-$l = OC_L10N::get('files');
+$files = new \OCA\Files\App(
+ \OC\Files\Filesystem::getView(),
+ \OC_L10n::get('files')
+);
+$result = $files->rename(
+ $_GET["dir"],
+ $_GET["file"],
+ $_GET["newname"]
+);
-if ( $newname !== '.' and ($dir != '' || $file != 'Shared') and $newname !== '.') {
- $targetFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $newname);
- $sourceFile = \OC\Files\Filesystem::normalizePath($dir . '/' . $file);
- 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" => $l->t("Unable to rename file") )));
- }
-}else{
- OCP\JSON::error(array("data" => array( "message" => $l->t("Unable to rename file") )));
-}
+if($result['success'] === true){
+ OCP\JSON::success(array('data' => $result['data']));
+} else {
+ OCP\JSON::error(array('data' => $result['data']));
+} \ No newline at end of file