diff --git a/lib/ocs/activity.php b/lib/ocs/activity.php index 3b090376e7..07b571665e 100644 --- a/lib/ocs/activity.php +++ b/lib/ocs/activity.php @@ -5,7 +5,4 @@ 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 index d0cd72e98c..2f2aad714a 100644 --- a/lib/ocs/cloud.php +++ b/lib/ocs/cloud.php @@ -2,8 +2,8 @@ class OC_OCS_Cloud { - public static function systemwebapps($parameters){ - $login = OC_OCS::checkpassword(); + public static function getSystemWebApps($parameters){ + OC_Util::checkLoggedIn(); $apps = OC_App::getEnabledApps(); $values = array(); foreach($apps as $app) { @@ -16,9 +16,10 @@ class OC_OCS_Cloud { return $values; } - public static function getQuota($parameters){ - $login=OC_OCS::checkpassword(); - if(OC_Group::inGroup($login, 'admin') or ($login==$parameters['user'])) { + public static function getUserQuota($parameters){ + OC_Util::checkLoggedIn(); + $user = OC_User::getUser(); + if(OC_Group::inGroup($user, 'admin') or ($user==$parameters['user'])) { if(OC_User::userExists($parameters['user'])){ // calculate the disc space @@ -47,9 +48,10 @@ class OC_OCS_Cloud { } } - public static function setQuota($parameters){ - $login=OC_OCS::checkpassword(); - if(OC_Group::inGroup($login, 'admin')) { + public static function setUserQuota($parameters){ + OC_Util::checkLoggedIn(); + $user = OC_User::getUser(); + if(OC_Group::inGroup($user, 'admin')) { // todo // not yet implemented @@ -63,8 +65,8 @@ class OC_OCS_Cloud { } } - public static function getPublickey($parameters){ - $login=OC_OCS::checkpassword(); + public static function getUserPublickey($parameters){ + OC_Util::checkLoggedIn(); if(OC_User::userExists($parameters['user'])){ // calculate the disc space @@ -75,23 +77,20 @@ class OC_OCS_Cloud { } } - public static function getPrivatekey($parameters){ - $login=OC_OCS::checkpassword(); - if(OC_Group::inGroup($login, 'admin') or ($login==$parameters['user'])) { + public static function getUserPrivatekey($parameters){ + OC_Util::checkLoggedIn(); + $user = OC_User::getUser(); + if(OC_Group::inGroup($user, 'admin') or ($user==$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.'); - } + 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 index b736abe3b9..06103cbeb4 100644 --- a/lib/ocs/config.php +++ b/lib/ocs/config.php @@ -10,7 +10,4 @@ class OC_OCS_Config { $xml['ssl'] = 'false'; return $xml; } - } - -?> \ No newline at end of file diff --git a/lib/ocs/person.php b/lib/ocs/person.php index f4e4be5ee0..629a7c2e6c 100644 --- a/lib/ocs/person.php +++ b/lib/ocs/person.php @@ -14,9 +14,5 @@ class OC_OCS_Person { }else{ return 101; } - } - } - -?> \ No newline at end of file diff --git a/lib/ocs/privatedata.php b/lib/ocs/privatedata.php index 7721404691..1c781dece8 100644 --- a/lib/ocs/privatedata.php +++ b/lib/ocs/privatedata.php @@ -2,8 +2,8 @@ class OC_OCS_Privatedata { - public static function privatedataGet($parameters){ - // TODO check user auth + public static function get($parameters){ + OC_Util::checkLoggedIn(); $user = OC_User::getUser(); $app = addslashes(strip_tags($parameters['app'])); $key = addslashes(strip_tags($parameters['key'])); @@ -18,15 +18,22 @@ class OC_OCS_Privatedata { //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(); + public static function set($parameters){ + OC_Util::checkLoggedIn(); + $user = OC_User::getUser(); + $app = addslashes(strip_tags($parameters['app'])); + $key = addslashes(strip_tags($parameters['key'])); + $value = OC_OCS::readData('post', 'value', 'text'); if(OC_OCS::setData($user,$app,$key,$value)){ return 100; } } - public static function privatedataDelete($parameteres){ - $user = OC_OCS::checkpassword(); + public static function delete($parameters){ + OC_Util::checkLoggedIn(); + $user = OC_User::getUser(); + $app = addslashes(strip_tags($parameters['app'])); + $key = addslashes(strip_tags($parameters['key'])); if($key=="" or $app==""){ return; //key and app are NOT optional here } @@ -34,7 +41,4 @@ class OC_OCS_Privatedata { return 100; } } - } - -?> diff --git a/ocs/routes.php b/ocs/routes.php index a913254ebe..95df0c7ec9 100644 --- a/ocs/routes.php +++ b/ocs/routes.php @@ -12,14 +12,14 @@ OC_API::register('post', '/person/check', array('OC_OCS_Person', 'check'), 'ocs' // Activity OC_API::register('get', '/activity', array('OC_OCS_Activity', 'activityGet'), 'ocs'); // Privatedata -OC_API::register('get', '/privatedata/getattribute/{app}/{key}', array('OC_OCS_Privatedata', 'privatedataGet'), 'ocs'); -OC_API::register('post', '/privatedata/setattribute/{app}/{key}', array('OC_OCS_Privatedata', 'privatedataPut'), 'ocs'); -OC_API::register('post', '/privatedata/deleteattribute/{app}/{key}', array('OC_OCS_Privatedata', 'privatedataDelete'), 'ocs'); +OC_API::register('get', '/privatedata/getattribute/{app}/{key}', array('OC_OCS_Privatedata', 'get'), 'ocs'); +OC_API::register('post', '/privatedata/setattribute/{app}/{key}', array('OC_OCS_Privatedata', 'set'), 'ocs'); +OC_API::register('post', '/privatedata/deleteattribute/{app}/{key}', array('OC_OCS_Privatedata', 'delete'), 'ocs'); // Cloud -OC_API::register('get', '/cloud/system/webapps', array('OC_OCS_Cloud', 'systemwebapps'), 'ocs'); -OC_API::register('get', '/cloud/user/{user}', array('OC_OCS_Cloud', 'getQuota'), 'ocs'); -OC_API::register('post', '/cloud/user/{user}', array('OC_OCS_Cloud', 'setQuota'), 'ocs'); -OC_API::register('get', '/cloud/user/{user}/publickey', array('OC_OCS_Cloud', 'getPublicKey'), 'ocs'); -OC_API::register('get', '/cloud/user/{user}/privatekey', array('OC_OCS_Cloud', 'getPrivateKey'), 'ocs'); +OC_API::register('get', '/cloud/system/webapps', array('OC_OCS_Cloud', 'getSystemWebApps'), 'ocs'); +OC_API::register('get', '/cloud/user/{user}', array('OC_OCS_Cloud', 'getUserQuota'), 'ocs'); +OC_API::register('post', '/cloud/user/{user}', array('OC_OCS_Cloud', 'setUserQuota'), 'ocs'); +OC_API::register('get', '/cloud/user/{user}/publickey', array('OC_OCS_Cloud', 'getUserPublicKey'), 'ocs'); +OC_API::register('get', '/cloud/user/{user}/privatekey', array('OC_OCS_Cloud', 'getUserPrivateKey'), 'ocs'); ?>