From 9072106048265ce144227605c8919104acf6d746 Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Mon, 30 Jul 2012 12:42:18 +0000 Subject: Move OCS methods to lib/ocs/.php --- lib/ocs/config.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/ocs/config.php (limited to 'lib/ocs/config.php') 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 @@ + \ No newline at end of file -- cgit v1.2.3 From 28537037ae27a8e766d3c4ef129422dc02b45d5f Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Tue, 31 Jul 2012 22:19:11 +0200 Subject: Fixup OCS modules --- lib/ocs/activity.php | 3 --- lib/ocs/cloud.php | 53 ++++++++++++++++++++++++------------------------- lib/ocs/config.php | 3 --- lib/ocs/person.php | 4 ---- lib/ocs/privatedata.php | 22 +++++++++++--------- ocs/routes.php | 16 +++++++-------- 6 files changed, 47 insertions(+), 54 deletions(-) (limited to 'lib/ocs/config.php') diff --git a/lib/ocs/activity.php b/lib/ocs/activity.php index 3b090376e72..07b571665ec 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 d0cd72e98c5..2f2aad714a3 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 b736abe3b9c..06103cbeb4f 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 f4e4be5ee09..629a7c2e6c7 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 77214046911..1c781dece8a 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 a913254ebe8..95df0c7ec91 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'); ?> -- cgit v1.2.3 From 2a4b554ca67ba55c75bbff75777285e550dca84f Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Wed, 12 Dec 2012 17:35:58 +0000 Subject: API: OCS methods now use OC_OCS_Result to return data --- lib/ocs/cloud.php | 4 ++-- lib/ocs/config.php | 2 +- lib/ocs/person.php | 6 +++--- lib/ocs/privatedata.php | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) (limited to 'lib/ocs/config.php') diff --git a/lib/ocs/cloud.php b/lib/ocs/cloud.php index 2f2aad714a3..720cc0ade39 100644 --- a/lib/ocs/cloud.php +++ b/lib/ocs/cloud.php @@ -13,7 +13,7 @@ class OC_OCS_Cloud { $values[] = $newvalue; } } - return $values; + return new OC_OCS_Result($values); } public static function getUserQuota($parameters){ @@ -39,7 +39,7 @@ class OC_OCS_Cloud { $xml['used']=$used; $xml['relative']=$relative; - return $xml; + return new OC_OCS_Result($xml); }else{ return 300; } diff --git a/lib/ocs/config.php b/lib/ocs/config.php index 06103cbeb4f..eb9e470381a 100644 --- a/lib/ocs/config.php +++ b/lib/ocs/config.php @@ -8,6 +8,6 @@ class OC_OCS_Config { $xml['host'] = OCP\Util::getServerHost(); $xml['contact'] = ''; $xml['ssl'] = 'false'; - return $xml; + return new OC_OCS_Result($xml); } } diff --git a/lib/ocs/person.php b/lib/ocs/person.php index 23b8853533d..b5f07d88ae1 100644 --- a/lib/ocs/person.php +++ b/lib/ocs/person.php @@ -8,12 +8,12 @@ class OC_OCS_Person { if($login && $password){ if(OC_User::checkPassword($login,$password)){ $xml['person']['personid'] = $login; - return $xml; + return new OC_OCS_Result($xml); }else{ - return 102; + return new OC_OCS_Result(null, 102); } }else{ - return 101; + return new OC_OCS_Result(null, 101); } } diff --git a/lib/ocs/privatedata.php b/lib/ocs/privatedata.php index 1c781dece8a..02ca31f2d29 100644 --- a/lib/ocs/privatedata.php +++ b/lib/ocs/privatedata.php @@ -14,7 +14,7 @@ class OC_OCS_Privatedata { $xml[$i]['app']=$log['app']; $xml[$i]['value']=$log['value']; } - return $xml; + return new OC_OCS_Result($xml); //TODO: replace 'privatedata' with 'attribute' once a new libattice has been released that works with it } @@ -25,7 +25,7 @@ class OC_OCS_Privatedata { $key = addslashes(strip_tags($parameters['key'])); $value = OC_OCS::readData('post', 'value', 'text'); if(OC_OCS::setData($user,$app,$key,$value)){ - return 100; + return new OC_OCS_Result(null, 100); } } @@ -35,10 +35,10 @@ class OC_OCS_Privatedata { $app = addslashes(strip_tags($parameters['app'])); $key = addslashes(strip_tags($parameters['key'])); if($key=="" or $app==""){ - return; //key and app are NOT optional here + return new OC_OCS_Result(null, 101); //key and app are NOT optional here } if(OC_OCS::deleteData($user,$app,$key)){ - return 100; + return new OC_OCS_Result(null, 100); } } } -- cgit v1.2.3 From 3cc34055368114d81e722adea03a2118e78d2aac Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Wed, 12 Dec 2012 18:06:07 +0000 Subject: API: Remove old code. Move remaining methods to OC_OCS_Result. --- lib/ocs.php | 290 ------------------------------------------------ lib/ocs/cloud.php | 32 +----- lib/ocs/config.php | 1 + lib/ocs/privatedata.php | 6 +- ocs/routes.php | 8 +- 5 files changed, 17 insertions(+), 320 deletions(-) (limited to 'lib/ocs/config.php') diff --git a/lib/ocs.php b/lib/ocs.php index 1cec3ecc7c0..001965d45e3 100644 --- a/lib/ocs.php +++ b/lib/ocs.php @@ -103,44 +103,6 @@ class OC_OCS { return($txt); } - /** - * checks if the user is authenticated - * checks the IP whitlist, apikeys and login/password combination - * if $forceuser is true and the authentication failed it returns an 401 http response. - * if $forceuser is false and authentification fails it returns an empty username string - * @param bool $forceuser - * @return username string - */ - private static function checkPassword($forceuser=true) { - //valid user account ? - if(isset($_SERVER['PHP_AUTH_USER'])) $authuser=$_SERVER['PHP_AUTH_USER']; else $authuser=''; - if(isset($_SERVER['PHP_AUTH_PW'])) $authpw=$_SERVER['PHP_AUTH_PW']; else $authpw=''; - - if(empty($authuser)) { - if($forceuser) { - header('WWW-Authenticate: Basic realm="your valid user account or api key"'); - header('HTTP/1.0 401 Unauthorized'); - exit; - }else{ - $identifieduser=''; - } - }else{ - if(!OC_User::login($authuser, $authpw)) { - if($forceuser) { - header('WWW-Authenticate: Basic realm="your valid user account or api key"'); - header('HTTP/1.0 401 Unauthorized'); - exit; - }else{ - $identifieduser=''; - } - }else{ - $identifieduser=$authuser; - } - } - - return($identifieduser); - } - /** * generates the xml or json response for the API call from an multidimenional data array. @@ -261,130 +223,6 @@ class OC_OCS { } } - /** - * return the config data of this server - * @param string $format - * @return string xml/json - */ - public static function apiConfig($parameters) { - $format = $parameters['format']; - $user=OC_OCS::checkpassword(false); - $url=substr(OCP\Util::getServerHost().$_SERVER['SCRIPT_NAME'], 0, -11).''; - - $xml['version']='1.7'; - $xml['website']='ownCloud'; - $xml['host']=OCP\Util::getServerHost(); - $xml['contact']=''; - $xml['ssl']='false'; - echo(OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'config', '', 1)); - } - - /** - * check if the provided login/apikey/password is valid - * @param string $format - * @param string $login - * @param string $passwd - * @return string xml/json - */ - private static function personCheck($format,$login,$passwd) { - if($login<>'') { - if(OC_User::login($login, $passwd)) { - $xml['person']['personid']=$login; - echo(OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'person', 'check', 2)); - }else{ - echo(OC_OCS::generatexml($format, 'failed', 102, 'login not valid')); - } - }else{ - echo(OC_OCS::generatexml($format, 'failed', 101, 'please specify all mandatory fields')); - } - } - - // ACTIVITY API ############################################# - - /** - * get my activities - * @param string $format - * @param string $page - * @param string $pagesize - * @return string xml/json - */ - private static function activityGet($format, $page, $pagesize) { - $user=OC_OCS::checkpassword(); - - //TODO - - $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'activity', 'full', 2, $totalcount,$pagesize); - echo($txt); - } - - /** - * submit a activity - * @param string $format - * @param string $message - * @return string xml/json - */ - private static function activityPut($format,$message) { - // not implemented in ownCloud - $user=OC_OCS::checkpassword(); - echo(OC_OCS::generatexml($format, 'ok', 100, '')); - } - - // PRIVATEDATA API ############################################# - - /** - * get private data and create the xml for ocs - * @param string $format - * @param string $app - * @param string $key - * @return string xml/json - */ - private static function privateDataGet($format, $app="", $key="") { - $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']; - } - - - $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'privatedata', 'full', 2, count($xml), 0);//TODO: replace 'privatedata' with 'attribute' once a new libattice has been released that works with it - echo($txt); - } - - /** - * set private data referenced by $key to $value and generate the xml for ocs - * @param string $format - * @param string $app - * @param string $key - * @param string $value - * @return string xml/json - */ - private static function privateDataSet($format, $app, $key, $value) { - $user=OC_OCS::checkpassword(); - if(OC_OCS::setData($user, $app, $key, $value)) { - echo(OC_OCS::generatexml($format, 'ok', 100, '')); - } - } - - /** - * delete private data referenced by $key and generate the xml for ocs - * @param string $format - * @param string $app - * @param string $key - * @return string xml/json - */ - private static function privateDataDelete($format, $app, $key) { - if($key=="" or $app=="") { - return; //key and app are NOT optional here - } - $user=OC_OCS::checkpassword(); - if(OC_OCS::deleteData($user, $app, $key)) { - echo(OC_OCS::generatexml($format, 'ok', 100, '')); - } - } - /** * get private data * @param string $user @@ -416,93 +254,6 @@ class OC_OCS { return $result; } - /** - * set private data referenced by $key to $value - * @param string $user - * @param string $app - * @param string $key - * @param string $value - * @return bool - */ - public static function setData($user, $app, $key, $value) { - return OC_Preferences::setValue($user, $app, $key, $value); - } - - /** - * delete private data referenced by $key - * @param string $user - * @param string $app - * @param string $key - * @return string xml/json - */ - public static function deleteData($user, $app, $key) { - return OC_Preferences::deleteKey($user, $app, $key); - } - - - // 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 - * @return string xml/json - */ - private static function quotaGet($format,$user) { - $login=OC_OCS::checkpassword(); - if(OC_Group::inGroup($login, 'admin') or ($login==$user)) { - - if(OC_User::userExists($user)) { - // calculate the disc space - $user_dir = '/'.$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; - - $txt=OC_OCS::generatexml($format, 'ok', 100, '', $xml, 'cloud', '', 1, 0, 0); - 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.'); - } - } - /** * set the quota of a user * @param string $format @@ -527,45 +278,4 @@ class OC_OCS { } } - /** - * 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.'); - } - } - - } diff --git a/lib/ocs/cloud.php b/lib/ocs/cloud.php index 720cc0ade39..b5cfbc295e8 100644 --- a/lib/ocs/cloud.php +++ b/lib/ocs/cloud.php @@ -17,7 +17,6 @@ class OC_OCS_Cloud { } public static function getUserQuota($parameters){ - OC_Util::checkLoggedIn(); $user = OC_User::getUser(); if(OC_Group::inGroup($user, 'admin') or ($user==$parameters['user'])) { @@ -41,44 +40,25 @@ class OC_OCS_Cloud { return new OC_OCS_Result($xml); }else{ - return 300; + return new OC_OCS_Result(null, 300); } }else{ - return 300; - } - } - - public static function setUserQuota($parameters){ - OC_Util::checkLoggedIn(); - $user = OC_User::getUser(); - if(OC_Group::inGroup($user, '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; + return new OC_OCS_Result(null, 300); } } public static function getUserPublickey($parameters){ - OC_Util::checkLoggedIn(); if(OC_User::userExists($parameters['user'])){ // calculate the disc space // TODO - return array(); + return new OC_OCS_Result(array()); }else{ - return 300; + return new OC_OCS_Result(null, 300); } } public static function getUserPrivatekey($parameters){ - OC_Util::checkLoggedIn(); $user = OC_User::getUser(); if(OC_Group::inGroup($user, 'admin') or ($user==$parameters['user'])) { @@ -87,10 +67,10 @@ class OC_OCS_Cloud { $txt='this is the private key of '.$parameters['user']; echo($txt); }else{ - echo self::generateXml('', 'fail', 300, 'User does not exist'); + return new OC_OCS_Result(null, 300, 'User does not exist'); } }else{ - echo self::generateXml('', 'fail', 300, 'You don´t have permission to access this ressource.'); + return new OC_OCS_Result('null', 300, 'You don´t have permission to access this ressource.'); } } } diff --git a/lib/ocs/config.php b/lib/ocs/config.php index eb9e470381a..52affcd65ee 100644 --- a/lib/ocs/config.php +++ b/lib/ocs/config.php @@ -10,4 +10,5 @@ class OC_OCS_Config { $xml['ssl'] = 'false'; return new OC_OCS_Result($xml); } + } diff --git a/lib/ocs/privatedata.php b/lib/ocs/privatedata.php index 02ca31f2d29..09d636bd733 100644 --- a/lib/ocs/privatedata.php +++ b/lib/ocs/privatedata.php @@ -8,7 +8,7 @@ class OC_OCS_Privatedata { $app = addslashes(strip_tags($parameters['app'])); $key = addslashes(strip_tags($parameters['key'])); $result = OC_OCS::getData($user,$app,$key); - $xml= array(); + $xml = array(); foreach($result as $i=>$log) { $xml[$i]['key']=$log['key']; $xml[$i]['app']=$log['app']; @@ -24,7 +24,7 @@ class OC_OCS_Privatedata { $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)){ + if(OC_Preferences::setValue($user,$app,$key,$value)){ return new OC_OCS_Result(null, 100); } } @@ -37,7 +37,7 @@ class OC_OCS_Privatedata { if($key=="" or $app==""){ return new OC_OCS_Result(null, 101); //key and app are NOT optional here } - if(OC_OCS::deleteData($user,$app,$key)){ + if(OC_Preferences::deleteKey($user,$app,$key)){ return new OC_OCS_Result(null, 100); } } diff --git a/ocs/routes.php b/ocs/routes.php index 6b01abe31f2..033d9b79df2 100644 --- a/ocs/routes.php +++ b/ocs/routes.php @@ -10,7 +10,13 @@ OC_API::register('get', '/config', array('OC_OCS_Config', 'apiConfig'), 'ocs', O // Person OC_API::register('post', '/person/check', array('OC_OCS_Person', 'check'), 'ocs', OC_API::GUEST_AUTH); // Activity -OC_API::register('get', '/activity', array('OC_OCS_Activity', 'activityGet'), 'ocs', OC_API::USER_AUTH); +OC_API::register('get', '/activity', array('OC_OCS_Activity', 'activityGet'), 'ocs', OC_API::USER_AUTH); + + +//activity put, keygetpublic, keygetprivate + + + // Privatedata OC_API::register('get', '/privatedata/getattribute', array('OC_OCS_Privatedata', 'get'), 'ocs', OC_API::USER_AUTH, array('app' => '', 'key' => '')); OC_API::register('get', '/privatedata/getattribute/{app}', array('OC_OCS_Privatedata', 'get'), 'ocs', OC_API::USER_AUTH, array('key' => '')); -- cgit v1.2.3 From 9626d9ce31c6144583481e26763c6a59ca52cf7a Mon Sep 17 00:00:00 2001 From: Tom Needham Date: Mon, 31 Dec 2012 16:08:21 +0000 Subject: Code cleanup and add copyright info --- lib/ocs/config.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'lib/ocs/config.php') diff --git a/lib/ocs/config.php b/lib/ocs/config.php index 52affcd65ee..03c54aa2314 100644 --- a/lib/ocs/config.php +++ b/lib/ocs/config.php @@ -1,8 +1,30 @@ . +* +*/ class OC_OCS_Config { - public static function apiConfig($parameters){ + public static function apiConfig($parameters) { $xml['version'] = '1.7'; $xml['website'] = 'ownCloud'; $xml['host'] = OCP\Util::getServerHost(); -- cgit v1.2.3