Added capabilities whether a server allows public links

This fixes #13673.
It now lists link sharing, passwords enforced, and if public uploads are
allowed.
This commit is contained in:
Roeland Jago Douma 2015-01-26 16:09:14 +01:00
parent 77e9c212ed
commit b3ea849a87
2 changed files with 60 additions and 0 deletions

View file

@ -56,3 +56,10 @@ $this->create('sharing_external_test_remote', '/testremote')
'/apps/files_sharing/api/v1/shares/{id}',
array('\OCA\Files_Sharing\API\Local', 'deleteShare'),
'files_sharing');
// Register with the capabilities API
\OC_API::register('get',
'/cloud/capabilities',
array('OCA\Files_Sharing\Capabilities', 'getCapabilities'),
'files_sharing',
\OC_API::USER_AUTH);

View file

@ -0,0 +1,53 @@
<?php
/**
* Copyright (c) Roeland Jago Douma <roeland@famdouma.nl>
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCA\Files_Sharing;
/**
* Class Capabilities
*
* @package OCA\Files_Sharing
*/
class Capabilities {
/**
* @return \OC_OCS_Result
*/
public static function getCapabilities() {
$config = \OC::$server->getConfig();
$res = array();
if ($config->getAppValue('core', 'shareapi_allow_links', 'yes') === "yes") {
$res["allow_links"] = 1;
if ($config->getAppValue('core', 'shareapi_enforce_links_password', 'yes') === "yes") {
$res["enforce_links_password"] = 1;
} else {
$res["enforce_links_password"] = 0;
}
if ($config->getAppValue('core', 'shareapi_allow_public_upload', 'yes') === "yes") {
$res["allow_public_upload"] = 1;
} else {
$res["allow_public_upload"] = 0;
}
} else {
$res["allow_links"] = 0;
}
return new \OC_OCS_Result(array(
'capabilities' => array(
'files' => array(
'sharing' => $res
),
),
));
}
}