Fix api result merging.

This commit is contained in:
Tom Needham 2013-02-09 12:50:19 +00:00
parent 5d14a2cc46
commit 5ad1b63f76
5 changed files with 10 additions and 9 deletions

View File

@ -3,8 +3,7 @@
//require_once 'files_versions/versions.php'; //require_once 'files_versions/versions.php';
OC::$CLASSPATH['OCA\Files_Versions\Storage'] = 'apps/files_versions/lib/versions.php'; OC::$CLASSPATH['OCA\Files_Versions\Storage'] = 'apps/files_versions/lib/versions.php';
OC::$CLASSPATH['OCA\Files_Versions\Hooks'] = 'apps/files_versions/lib/hooks.php'; OC::$CLASSPATH['OCA\Files_Versions\Hooks'] = 'apps/files_versions/lib/hooks.php';
OC::$CLASSPATH['OCA\Files_Versions\Capabiltiies'] = 'apps/files_versions/lib/capabilities.php'; OC::$CLASSPATH['OCA\Files_Versions\Capabilities'] = 'apps/files_versions/lib/capabilities.php';
OCP\App::registerAdmin('files_versions', 'settings'); OCP\App::registerAdmin('files_versions', 'settings');
OCP\App::registerPersonal('files_versions', 'settings-personal'); OCP\App::registerPersonal('files_versions', 'settings-personal');

View File

@ -6,4 +6,4 @@
*/ */
// Register with the capabilities API // Register with the capabilities API
OC_API::register('get', '/cloud/capabilities', array('OC_Files_Versions_Capabiltiies', 'getCapabilities'), 'ocs', OC_API::USER_AUTH); OC_API::register('get', '/cloud/capabilities', array('OCA\Files_Versions\Capabilities', 'getCapabilities'), 'ocs', OC_API::USER_AUTH);

View File

@ -6,10 +6,12 @@
* See the COPYING-README file. * See the COPYING-README file.
*/ */
class OC_Files_Versions_Capabilities { namespace OCA\Files_Versions;
class Capabilities {
public static function getCapabilities() { public static function getCapabilities() {
return OC_OCS_Result(array( return new \OC_OCS_Result(array(
'capabilities' => array( 'capabilities' => array(
'files_versions' => array( 'files_versions' => array(
'versioning' => true, 'versioning' => true,

View File

@ -118,7 +118,6 @@ class OC_API {
); );
} }
$response = self::mergeResponses($responses); $response = self::mergeResponses($responses);
$formats = array('json', 'xml'); $formats = array('json', 'xml');
$format = !empty($_GET['format']) && in_array($_GET['format'], $formats) ? $_GET['format'] : 'xml'; $format = !empty($_GET['format']) && in_array($_GET['format'], $formats) ? $_GET['format'] : 'xml';
@ -134,7 +133,7 @@ class OC_API {
$response = array(); $response = array();
// Sort into shipped and thirdparty // Sort into shipped and thirdparty
$shipped = array( $shipped = array(
'succeded' => array(), 'succeeded' => array(),
'failed' => array(), 'failed' => array(),
); );
$thirdparty = array( $thirdparty = array(
@ -143,7 +142,7 @@ class OC_API {
); );
foreach($responses as $response) { foreach($responses as $response) {
if(OC_App::isShipped($response['app'])) { if(OC_App::isShipped($response['app']) || ($response['app'] === 'core')) {
if($response['response']->succeeded()) { if($response['response']->succeeded()) {
$shipped['succeeded'][$response['app']] = $response['response']; $shipped['succeeded'][$response['app']] = $response['response'];
} else { } else {
@ -250,6 +249,7 @@ class OC_API {
*/ */
private static function respond($result, $format='xml') { private static function respond($result, $format='xml') {
// Send 401 headers if unauthorised // Send 401 headers if unauthorised
die(var_dump($result));
if($result->getStatusCode() === self::RESPOND_UNAUTHORISED) { if($result->getStatusCode() === self::RESPOND_UNAUTHORISED) {
header('WWW-Authenticate: Basic realm="Authorisation Required"'); header('WWW-Authenticate: Basic realm="Authorisation Required"');
header('HTTP/1.0 401 Unauthorized'); header('HTTP/1.0 401 Unauthorized');

View File

@ -18,4 +18,4 @@ OC_API::register('get', '/privatedata/getattribute/{app}/{key}', array('OC_OCS_P
OC_API::register('post', '/privatedata/setattribute/{app}/{key}', array('OC_OCS_Privatedata', 'set'), 'ocs', OC_API::USER_AUTH); OC_API::register('post', '/privatedata/setattribute/{app}/{key}', array('OC_OCS_Privatedata', 'set'), 'ocs', OC_API::USER_AUTH);
OC_API::register('post', '/privatedata/deleteattribute/{app}/{key}', array('OC_OCS_Privatedata', 'delete'), 'ocs', OC_API::USER_AUTH); OC_API::register('post', '/privatedata/deleteattribute/{app}/{key}', array('OC_OCS_Privatedata', 'delete'), 'ocs', OC_API::USER_AUTH);
// cloud // cloud
OC_API::register('get', '/cloud/capabilities', array('OC_OCS_Cloud', 'getCapabilities'), 'ocs', OC_API::USER_AUTH); OC_API::register('get', '/cloud/capabilities', array('OC_OCS_Cloud', 'getCapabilities'), 'core', OC_API::USER_AUTH);