summaryrefslogtreecommitdiffstats
path: root/files/ajax
diff options
context:
space:
mode:
authorJakob Sack <kde@jakobsack.de>2011-03-03 23:08:54 +0100
committerJakob Sack <kde@jakobsack.de>2011-03-03 23:08:54 +0100
commitf042e85d412fb323e5d3bb3e70d9d4ffa00a7907 (patch)
tree8561c3483d381d4cc5f54ca42a3f27a470e4c564 /files/ajax
parentf7f957abb92e5ce359d7eafa136406822fee0a51 (diff)
downloadnextcloud-server-f042e85d412fb323e5d3bb3e70d9d4ffa00a7907.tar.gz
nextcloud-server-f042e85d412fb323e5d3bb3e70d9d4ffa00a7907.zip
Beginning of some ajax features and an admin page for files
Diffstat (limited to 'files/ajax')
-rw-r--r--files/ajax/delete.php27
-rw-r--r--files/ajax/list.php36
-rw-r--r--files/ajax/rename.php28
3 files changed, 91 insertions, 0 deletions
diff --git a/files/ajax/delete.php b/files/ajax/delete.php
new file mode 100644
index 00000000000..113476f0254
--- /dev/null
+++ b/files/ajax/delete.php
@@ -0,0 +1,27 @@
+<?php
+
+// 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();
+}
+
+// Get data
+$dir = $_GET["dir"];
+$file = $_GET["file"];
+
+// Delete
+if( OC_FILES::delete( $dir, $file )){
+ echo json_encode( array( "status" => "success", "data" => array( "dir" => $dir, "file" => $file )));
+}
+else{
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to delete file" )));
+}
+
+?>
diff --git a/files/ajax/list.php b/files/ajax/list.php
new file mode 100644
index 00000000000..4694f842832
--- /dev/null
+++ b/files/ajax/list.php
@@ -0,0 +1,36 @@
+<?php
+
+// 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();
+}
+
+// Load the files
+$dir = isset( $_GET['dir'] ) ? $_GET['dir'] : '';
+
+$files = array();
+foreach( OC_FILES::getdirectorycontent( $dir ) as $i ){
+ $i["date"] = date( $CONFIG_DATEFORMAT, $i["mtime"] );
+ $files[] = $i;
+}
+
+// Make breadcrumb
+$breadcrumb = array();
+$pathtohere = "/";
+foreach( explode( "/", $dir ) as $i ){
+ if( $i != "" ){
+ $pathtohere .= "$i/";
+ $breadcrumb[] = array( "dir" => $pathtohere, "name" => $i );
+ }
+}
+
+echo json_encode( array( "status" => "success", "data" => array( "files" => $files, "breadcrumb" => $breadcrumb )));
+
+?>
diff --git a/files/ajax/rename.php b/files/ajax/rename.php
new file mode 100644
index 00000000000..86cb7944a88
--- /dev/null
+++ b/files/ajax/rename.php
@@ -0,0 +1,28 @@
+<?php
+
+// 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" => "Authentication error" ));
+ exit();
+}
+
+// Get data
+$dir = $_GET["dir"];
+$file = $_GET["file"];
+$newname = $_GET["newname"];
+
+// Delete
+if( OC_FILES::move( $dir, $file, $dir, $newname )) {
+ echo json_encode( array( "status" => "success", "data" => array( "dir" => $dir, "file" => $file, "newname" => $newname )));
+}
+else{
+ echo json_encode( array( "status" => "error", "data" => array( "message" => "Unable to rename file" )));
+}
+
+?>