summaryrefslogtreecommitdiffstats
path: root/lib/ocs.php
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-07-25 17:51:36 +0200
committerBart Visscher <bartv@thisnet.nl>2012-07-25 17:51:36 +0200
commitd579defc668ff3354771c6bc346415d5ef6e2d73 (patch)
tree96b6f99717e1c8e14372d5116b5d359578465637 /lib/ocs.php
parentac9dbd4b83852d137d35cb87911ebd6b21c494db (diff)
parentd17eb2983f46b1a2e72f0c3c2d7cfce40f47f653 (diff)
downloadnextcloud-server-d579defc668ff3354771c6bc346415d5ef6e2d73.tar.gz
nextcloud-server-d579defc668ff3354771c6bc346415d5ef6e2d73.zip
Merge branch 'master' into routing
Diffstat (limited to 'lib/ocs.php')
-rw-r--r--lib/ocs.php85
1 files changed, 81 insertions, 4 deletions
diff --git a/lib/ocs.php b/lib/ocs.php
index 18f01518bdb..570f5ac3e59 100644
--- a/lib/ocs.php
+++ b/lib/ocs.php
@@ -176,6 +176,10 @@ class OC_OCS {
->requirements(array('format'=>'xml|json'));
// 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
$router->create('quota_get',
'/cloud/user/{user}.{format}')
@@ -199,6 +203,16 @@ class OC_OCS {
})
->requirements(array('format'=>'xml|json'));
+ // 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
@@ -581,6 +595,29 @@ class OC_OCS {
// CLOUD API #############################################
/**
+ * get a list of installed web apps
+ * @param string $format
+ * @return string xml/json
+ */
+ private static function systemWebApps($format) {
+ $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;
+ }
+
+ }
+ $txt=OC_OCS::generatexml($format, 'ok', 100, '', $values, 'cloud', '', 2, 0, 0);
+ echo($txt);
+
+ }
+
+
+ /**
* get the quota of a user
* @param string $format
* @param string $user
@@ -608,10 +645,10 @@ class OC_OCS {
$xml['used']=$used;
$xml['relative']=$relative;
- $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', 'full', 1, count($xml), 0);
+ $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0);
echo($txt);
}else{
- echo self::generateXml('', 'fail', 300, 'User does not exist');
+ echo self::generateXml('', 'fail', 300, 'User does not exist');
}
}else{
echo self::generateXml('', 'fail', 300, 'You don´t have permission to access this ressource.');
@@ -631,16 +668,56 @@ class OC_OCS {
// todo
// not yet implemented
- // edit logic here
+ // add logic here
error_log('OCS call: user:'.$user.' quota:'.$quota);
$xml=array();
- $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', 'full', 1, count($xml), 0);
+ $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0);
echo($txt);
}else{
echo self::generateXml('', 'fail', 300, 'You don´t have permission to access this ressource.');
}
}
+ /**
+ * get the public key of a user
+ * @param string $format
+ * @param string $user
+ * @return string xml/json
+ */
+ private static function publicKeyGet($format,$user) {
+ $login=OC_OCS::checkpassword();
+
+ if(OC_User::userExists($user)){
+ // calculate the disc space
+ $txt='this is the public key of '.$user;
+ echo($txt);
+ }else{
+ echo self::generateXml('', 'fail', 300, 'User does not exist');
+ }
+ }
+
+ /**
+ * get the private key of a user
+ * @param string $format
+ * @param string $user
+ * @return string xml/json
+ */
+ private static function privateKeyGet($format,$user) {
+ $login=OC_OCS::checkpassword();
+ if(OC_Group::inGroup($login, 'admin') or ($login==$user)) {
+
+ if(OC_User::userExists($user)){
+ // calculate the disc space
+ $txt='this is the private key of '.$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.');
+ }
+ }
+
}