diff options
author | Tom Needham <needham.thomas@gmail.com> | 2012-09-04 13:50:56 +0000 |
---|---|---|
committer | Tom Needham <needham.thomas@gmail.com> | 2012-09-04 13:50:56 +0000 |
commit | 4224eb88314bdece2a254decf7ebf9ffd7b57678 (patch) | |
tree | aea5bf53f78f0b6464c790c1e1447ee1ccb02c2d /lib/api.php | |
parent | 37bb16becb11caf80fd2e4f608e16f7642c76137 (diff) | |
download | nextcloud-server-4224eb88314bdece2a254decf7ebf9ffd7b57678.tar.gz nextcloud-server-4224eb88314bdece2a254decf7ebf9ffd7b57678.zip |
API: remove OAuth auth check, respond in ocs formatted xml/json
Diffstat (limited to 'lib/api.php')
-rw-r--r-- | lib/api.php | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/lib/api.php b/lib/api.php index 55de438f429..92fa05bd719 100644 --- a/lib/api.php +++ b/lib/api.php @@ -74,15 +74,15 @@ class OC_API { foreach(self::$actions[$name] as $action){ $app = $action['app']; // Check the consumer has permission to call this method. - if(OC_OAuth_Server::isAuthorised('app_'.$app)){ + //if(OC_OAuth_Server::isAuthorised('app_'.$app)){ if(is_callable($action['action'])){ $responses[] = array('app' => $app, 'response' => call_user_func($action['action'], $parameters)); } else { $responses[] = array('app' => $app, 'response' => 501); } - } else { - $responses[] = array('app' => $app, 'response' => 401); - } + //} else { + // $responses[] = array('app' => $app, 'response' => 401); + //} } // Merge the responses @@ -103,25 +103,39 @@ class OC_API { * @return array the final merged response */ private static function mergeResponses($responses){ - $finalresponse = array(); + $finalresponse = array( + 'meta' => array( + 'statuscode' => '', + ), + 'data' => array(), + ); $numresponses = count($responses); foreach($responses as $response){ - if(is_int($response['response']) && empty($finalresponse)){ - $finalresponse = $response['response']; + if(is_int($response['response']) && empty($finalresponse['meta']['statuscode'])){ + $finalresponse['meta']['statuscode'] = $response['response']; continue; } if(is_array($response['response'])){ // Shipped apps win if(OC_App::isShipped($response['app'])){ - $finalresponse = array_merge_recursive($finalresponse, $response['response']); + $finalresponse['data'] = array_merge_recursive($finalresponse['data'], $response['response']); } else { - $finalresponse = array_merge_recursive($response['response'], $finalresponse); + $finalresponse['data'] = array_merge_recursive($response['response'], $finalresponse['data']); } + $finalresponse['meta']['statuscode'] = 100; } } - - return $finalresponse; + //Some tidying up + if($finalresponse['meta']['statuscode']=='100'){ + $finalresponse['meta']['status'] = 'ok'; + } else { + $finalresponse['meta']['status'] = 'failure'; + } + if(empty($finalresponse['data'])){ + unset($finalresponse['data']); + } + return array('ocs' => $finalresponse); } /** |