summaryrefslogtreecommitdiffstats
path: root/lib/ocs.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ocs.php')
-rw-r--r--lib/ocs.php123
1 files changed, 6 insertions, 117 deletions
diff --git a/lib/ocs.php b/lib/ocs.php
index 7350c3c8821..1cec3ecc7c0 100644
--- a/lib/ocs.php
+++ b/lib/ocs.php
@@ -23,8 +23,6 @@
*
*/
-
-
/**
* Class to handle open collaboration services API requests
*
@@ -72,14 +70,7 @@ class OC_OCS {
}
}
- /**
- main function to handle the REST request
- **/
- public static function handle() {
- // overwrite the 404 error page returncode
- header("HTTP/1.0 200 OK");
-
-
+ public static function notFound() {
if($_SERVER['REQUEST_METHOD'] == 'GET') {
$method='get';
}elseif($_SERVER['REQUEST_METHOD'] == 'PUT') {
@@ -91,114 +82,11 @@ class OC_OCS {
echo('internal server error: method not supported');
exit();
}
-
- // preprocess url
- $url = strtolower($_SERVER['REQUEST_URI']);
- if(substr($url, (strlen($url)-1))<>'/') $url.='/';
- $ex=explode('/', $url);
- $paracount=count($ex);
$format = self::readData($method, 'format', 'text', '');
+ $txt='Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
+ $txt.=OC_OCS::getDebugOutput();
+ echo(OC_OCS::generateXml($format,'failed',999,$txt));
- // eventhandler
- // CONFIG
- // apiconfig - GET - CONFIG
- if(($method=='get') and ($ex[$paracount-3] == 'v1.php') and ($ex[$paracount-2] == 'config')) {
- OC_OCS::apiconfig($format);
-
- // PERSON
- // personcheck - POST - PERSON/CHECK
- } elseif(($method=='post') and ($ex[$paracount-4] == 'v1.php') and ($ex[$paracount-3]=='person') and ($ex[$paracount-2] == 'check')) {
- $login = self::readData($method, 'login', 'text');
- $passwd = self::readData($method, 'password', 'text');
- OC_OCS::personcheck($format, $login, $passwd);
-
- // ACTIVITY
- // activityget - GET ACTIVITY page,pagesize als urlparameter
- }elseif(($method=='get') and ($ex[$paracount-3] == 'v1.php') and ($ex[$paracount-2] == 'activity')) {
- $page = self::readData($method, 'page', 'int', 0);
- $pagesize = self::readData($method, 'pagesize', 'int', 10);
- if($pagesize<1 or $pagesize>100) $pagesize=10;
- OC_OCS::activityget($format, $page, $pagesize);
-
- // activityput - POST ACTIVITY
- }elseif(($method=='post') and ($ex[$paracount-3] == 'v1.php') and ($ex[$paracount-2] == 'activity')) {
- $message = self::readData($method, 'message', 'text');
- OC_OCS::activityput($format, $message);
-
-
- // PRIVATEDATA
- // get - GET DATA
- }elseif(($method=='get') and ($ex[$paracount-4] == 'v1.php') and ($ex[$paracount-2] == 'getattribute')) {
- OC_OCS::privateDataGet($format);
-
- }elseif(($method=='get') and ($ex[$paracount-5] == 'v1.php') and ($ex[$paracount-3] == 'getattribute')) {
- $app=$ex[$paracount-2];
- OC_OCS::privateDataGet($format, $app);
- }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-4] == 'getattribute')) {
-
- $key=$ex[$paracount-2];
- $app=$ex[$paracount-3];
- OC_OCS::privateDataGet($format, $app, $key);
-
- // set - POST DATA
- }elseif(($method=='post') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-4] == 'setattribute')) {
- $key=$ex[$paracount-2];
- $app=$ex[$paracount-3];
- $value = self::readData($method, 'value', 'text');
- OC_OCS::privatedataset($format, $app, $key, $value);
- // delete - POST DATA
- }elseif(($method=='post') and ($ex[$paracount-6] =='v1.php') and ($ex[$paracount-4] == 'deleteattribute')) {
- $key=$ex[$paracount-2];
- $app=$ex[$paracount-3];
- OC_OCS::privatedatadelete($format, $app, $key);
-
- // CLOUD
- // systemWebApps
- }elseif(($method=='get') and ($ex[$paracount-5] == 'v1.php') and ($ex[$paracount-4]=='cloud') and ($ex[$paracount-3] == 'system') and ($ex[$paracount-2] == 'webapps')) {
- OC_OCS::systemwebapps($format);
-
- // quotaget
- }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'quota')) {
- $user=$ex[$paracount-3];
- OC_OCS::quotaget($format, $user);
-
- // quotaset
- }elseif(($method=='post') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'quota')) {
- $user=$ex[$paracount-3];
- $quota = self::readData('post', 'quota', 'int');
- OC_OCS::quotaset($format, $user, $quota);
-
- // keygetpublic
- }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'publickey')) {
- $user=$ex[$paracount-3];
- OC_OCS::publicKeyGet($format, $user);
-
- // keygetprivate
- }elseif(($method=='get') and ($ex[$paracount-6] == 'v1.php') and ($ex[$paracount-5]=='cloud') and ($ex[$paracount-4] == 'user') and ($ex[$paracount-2] == 'privatekey')) {
- $user=$ex[$paracount-3];
- OC_OCS::privateKeyGet($format, $user);
-
-
-// add more calls here
-// please document all the call in the draft spec
-// http://www.freedesktop.org/wiki/Specifications/open-collaboration-services-1.7#CLOUD
-
-// TODO:
-// users
-// groups
-// bookmarks
-// sharing
-// versioning
-// news (rss)
-
-
-
- }else{
- $txt='Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'."\n";
- $txt.=OC_OCS::getdebugoutput();
- echo(OC_OCS::generatexml($format, 'failed', 999, $txt));
- }
- exit();
}
/**
@@ -378,7 +266,8 @@ class OC_OCS {
* @param string $format
* @return string xml/json
*/
- private static function apiConfig($format) {
+ public static function apiConfig($parameters) {
+ $format = $parameters['format'];
$user=OC_OCS::checkpassword(false);
$url=substr(OCP\Util::getServerHost().$_SERVER['SCRIPT_NAME'], 0, -11).'';