aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Needham <tom@owncloud.com>2012-07-30 12:42:18 +0000
committerTom Needham <tom@owncloud.com>2012-07-30 12:42:18 +0000
commit9072106048265ce144227605c8919104acf6d746 (patch)
treec60f9b1e4a421ecb61e35821d57242e7509d1d2e
parentf09ecee63aa6ed3c43dd88b125647460b404a601 (diff)
downloadnextcloud-server-9072106048265ce144227605c8919104acf6d746.tar.gz
nextcloud-server-9072106048265ce144227605c8919104acf6d746.zip
Move OCS methods to lib/ocs/.php
-rw-r--r--lib/api.php2
-rw-r--r--lib/ocs/activity.php11
-rw-r--r--lib/ocs/cloud.php97
-rw-r--r--lib/ocs/config.php16
-rw-r--r--lib/ocs/person.php22
-rw-r--r--lib/ocs/privatedata.php37
6 files changed, 184 insertions, 1 deletions
diff --git a/lib/api.php b/lib/api.php
index b1176a07077..2203d86ac94 100644
--- a/lib/api.php
+++ b/lib/api.php
@@ -62,7 +62,7 @@ class OC_API {
}
}
// include core routes
- require_once(OC::$SERVERROOT.'core/routes.php');
+ require_once(OC::$SERVERROOT.'ocs/routes.php');
$name = $parameters['_name'];
$response = array();
diff --git a/lib/ocs/activity.php b/lib/ocs/activity.php
new file mode 100644
index 00000000000..3b090376e72
--- /dev/null
+++ b/lib/ocs/activity.php
@@ -0,0 +1,11 @@
+<?php
+
+class OC_OCS_Activity {
+
+ public static function activityGet($parameters){
+ // TODO
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/lib/ocs/cloud.php b/lib/ocs/cloud.php
new file mode 100644
index 00000000000..d0cd72e98c5
--- /dev/null
+++ b/lib/ocs/cloud.php
@@ -0,0 +1,97 @@
+<?php
+
+class OC_OCS_Cloud {
+
+ public static function systemwebapps($parameters){
+ $login = OC_OCS::checkpassword();
+ $apps = OC_App::getEnabledApps();
+ $values = array();
+ foreach($apps as $app) {
+ $info = OC_App::getAppInfo($app);
+ if(isset($info['standalone'])) {
+ $newvalue = array('name'=>$info['name'],'url'=>OC_Helper::linkToAbsolute($app,''),'icon'=>'');
+ $values[] = $newvalue;
+ }
+ }
+ return $values;
+ }
+
+ public static function getQuota($parameters){
+ $login=OC_OCS::checkpassword();
+ if(OC_Group::inGroup($login, 'admin') or ($login==$parameters['user'])) {
+
+ if(OC_User::userExists($parameters['user'])){
+ // calculate the disc space
+ $user_dir = '/'.$parameters['user'].'/files';
+ OC_Filesystem::init($user_dir);
+ $rootInfo=OC_FileCache::get('');
+ $sharedInfo=OC_FileCache::get('/Shared');
+ $used=$rootInfo['size']-$sharedInfo['size'];
+ $free=OC_Filesystem::free_space();
+ $total=$free+$used;
+ if($total==0) $total=1; // prevent division by zero
+ $relative=round(($used/$total)*10000)/100;
+
+ $xml=array();
+ $xml['quota']=$total;
+ $xml['free']=$free;
+ $xml['used']=$used;
+ $xml['relative']=$relative;
+
+ return $xml;
+ }else{
+ return 300;
+ }
+ }else{
+ return 300;
+ }
+ }
+
+ public static function setQuota($parameters){
+ $login=OC_OCS::checkpassword();
+ if(OC_Group::inGroup($login, 'admin')) {
+
+ // todo
+ // not yet implemented
+ // add logic here
+ error_log('OCS call: user:'.$parameters['user'].' quota:'.$parameters['quota']);
+
+ $xml=array();
+ return $xml;
+ }else{
+ return 300;
+ }
+ }
+
+ public static function getPublickey($parameters){
+ $login=OC_OCS::checkpassword();
+
+ if(OC_User::userExists($parameters['user'])){
+ // calculate the disc space
+ // TODO
+ return array();
+ }else{
+ return 300;
+ }
+ }
+
+ public static function getPrivatekey($parameters){
+ $login=OC_OCS::checkpassword();
+ if(OC_Group::inGroup($login, 'admin') or ($login==$parameters['user'])) {
+
+ if(OC_User::userExists($user)){
+ // calculate the disc space
+ $txt='this is the private key of '.$parameters['user'];
+ echo($txt);
+ }else{
+ echo self::generateXml('', 'fail', 300, 'User does not exist');
+ }
+ }else{
+ echo self::generateXml('', 'fail', 300, 'You donĀ“t have permission to access this ressource.');
+ }
+ }
+
+
+}
+
+?> \ No newline at end of file
diff --git a/lib/ocs/config.php b/lib/ocs/config.php
new file mode 100644
index 00000000000..b736abe3b9c
--- /dev/null
+++ b/lib/ocs/config.php
@@ -0,0 +1,16 @@
+<?php
+
+class OC_OCS_Config {
+
+ public static function apiConfig($parameters){
+ $xml['version'] = '1.7';
+ $xml['website'] = 'ownCloud';
+ $xml['host'] = OCP\Util::getServerHost();
+ $xml['contact'] = '';
+ $xml['ssl'] = 'false';
+ return $xml;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/lib/ocs/person.php b/lib/ocs/person.php
new file mode 100644
index 00000000000..f4e4be5ee09
--- /dev/null
+++ b/lib/ocs/person.php
@@ -0,0 +1,22 @@
+<?php
+
+class OC_OCS_Person {
+
+ public static function check($parameters){
+
+ if($parameters['login']<>''){
+ if(OC_User::login($parameters['login'],$parameters['password'])){
+ $xml['person']['personid'] = $parameters['login'];
+ return $xml;
+ }else{
+ return 102;
+ }
+ }else{
+ return 101;
+ }
+
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/lib/ocs/privatedata.php b/lib/ocs/privatedata.php
new file mode 100644
index 00000000000..cb62d60a8d3
--- /dev/null
+++ b/lib/ocs/privatedata.php
@@ -0,0 +1,37 @@
+<?php
+
+class OC_OCS_Privatedata {
+
+ public static function privatedataGet($parameters){
+ $user = OC_OCS::checkpassword();
+ $result = OC_OCS::getData($user,$app,$key);
+ $xml= array();
+ foreach($result as $i=>$log) {
+ $xml[$i]['key']=$log['key'];
+ $xml[$i]['app']=$log['app'];
+ $xml[$i]['value']=$log['value'];
+ }
+ return $xml;
+ //TODO: replace 'privatedata' with 'attribute' once a new libattice has been released that works with it
+ }
+
+ public static function privatedataSet($parameters){
+ $user = OC_OCS::checkpassword();
+ if(OC_OCS::setData($user,$app,$key,$value)){
+ return 100;
+ }
+ }
+
+ public static function privatedataDelete($parameteres){
+ $user = OC_OCS::checkpassword();
+ if($key=="" or $app==""){
+ return; //key and app are NOT optional here
+ }
+ if(OC_OCS::deleteData($user,$app,$key)){
+ return 100;
+ }
+ }
+
+}
+
+?> \ No newline at end of file