Moved core apps to the capabilities manager

* Files
* Files_Sharing
* Files_Trashbin
* Files_Versions
This commit is contained in:
Roeland Jago Douma 2015-03-21 20:12:55 +01:00
parent 7e6a2b71fd
commit e84cffc063
15 changed files with 179 additions and 86 deletions

View File

@ -1,6 +1,5 @@
<?php <?php
/** /**
* @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl> * @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Tobias Kaminsky <tobias@kaminsky.me> * @author Tobias Kaminsky <tobias@kaminsky.me>
* @author Vincent Petry <pvince81@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com>
@ -21,13 +20,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */
namespace OCA\Files\AppInfo;
namespace OCA\Files\Appinfo;
use OCA\Files\Controller\ApiController; use OCA\Files\Controller\ApiController;
use OCP\AppFramework\App; use OCP\AppFramework\App;
use \OCA\Files\Service\TagService; use \OCA\Files\Service\TagService;
use \OCP\IContainer; use \OCP\IContainer;
use OCA\Files\Capabilities;
class Application extends App { class Application extends App {
public function __construct(array $urlParams=array()) { public function __construct(array $urlParams=array()) {
@ -68,5 +67,12 @@ class Application extends App {
$homeFolder $homeFolder
); );
}); });
/*
* Register capabilities
*/
$server->getCapabilitiesManager()->registerCapability(function() {
return new Capabilities();
});
} }
} }

View File

@ -1,9 +1,9 @@
<?php <?php
/** /**
* @author Bart Visscher <bartv@thisnet.nl> * @author Bart Visscher <bartv@thisnet.nl>
* @author Joas Schilling <nickvergessen@owncloud.com>
* @author Lukas Reschke <lukas@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de> * @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Tobias Kaminsky <tobias@kaminsky.me> * @author Tobias Kaminsky <tobias@kaminsky.me>
* @author Tom Needham <tom@owncloud.com> * @author Tom Needham <tom@owncloud.com>
* @author Vincent Petry <pvince81@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com>
@ -24,8 +24,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */
namespace OCA\Files\AppInfo;
namespace OCA\Files\Appinfo;
$application = new Application(); $application = new Application();
$application->registerRoutes( $application->registerRoutes(
@ -82,6 +81,4 @@ $this->create('files_ajax_upload', 'ajax/upload.php')
$this->create('download', 'download{file}') $this->create('download', 'download{file}')
->requirements(array('file' => '.*')) ->requirements(array('file' => '.*'))
->actionInclude('files/download.php'); ->actionInclude('files/download.php');
// Register with the capabilities API
\OCP\API::register('get', '/cloud/capabilities', array('OCA\Files\Capabilities', 'getCapabilities'), 'files', \OCP\API::USER_AUTH);

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @author Christopher Schäpers <kondou@ts.unde.re> * @author Christopher Schäpers <kondou@ts.unde.re>
* @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Tom Needham <tom@owncloud.com> * @author Tom Needham <tom@owncloud.com>
* *
* @copyright Copyright (c) 2015, ownCloud, Inc. * @copyright Copyright (c) 2015, ownCloud, Inc.
@ -20,19 +20,28 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */
namespace OCA\Files;
class Capabilities { namespace OCA\Files;
public static function getCapabilities() { use OCP\Capabilities\ICapability;
return new \OC_OCS_Result(array(
'capabilities' => array( /**
'files' => array( * Class Capabilities
'bigfilechunking' => true, *
), * @package OCA\Files
), */
)); class Capabilities implements ICapability {
/**
* Return this classes capabilities
*
* @return array
*/
public function getCapabilities() {
return [
'files' => [
'bigfilechunking' => true,
],
];
} }
} }

View File

@ -21,7 +21,7 @@
* *
*/ */
namespace OCA\Files_External\Appinfo; namespace OCA\Files_External\AppInfo;
use \OCA\Files_External\Controller\AjaxController; use \OCA\Files_External\Controller\AjaxController;
use \OCP\AppFramework\App; use \OCP\AppFramework\App;

View File

@ -23,7 +23,7 @@
* *
*/ */
namespace OCA\Files_External\Appinfo; namespace OCA\Files_External\AppInfo;
/** /**
* @var $this \OC\Route\Router * @var $this \OC\Route\Router

View File

@ -2,6 +2,7 @@
/** /**
* @author Morris Jobke <hey@morrisjobke.de> * @author Morris Jobke <hey@morrisjobke.de>
* @author Robin Appelman <icewind@owncloud.com> * @author Robin Appelman <icewind@owncloud.com>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* *
* @copyright Copyright (c) 2015, ownCloud, Inc. * @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0 * @license AGPL-3.0
@ -20,7 +21,7 @@
* *
*/ */
namespace OCA\Files_Sharing\Appinfo; namespace OCA\Files_Sharing\AppInfo;
use OCA\Files_Sharing\Helper; use OCA\Files_Sharing\Helper;
use OCA\Files_Sharing\MountProvider; use OCA\Files_Sharing\MountProvider;
@ -31,6 +32,7 @@ use OCA\Files_Sharing\Controllers\ExternalSharesController;
use OCA\Files_Sharing\Controllers\ShareController; use OCA\Files_Sharing\Controllers\ShareController;
use OCA\Files_Sharing\Middleware\SharingCheckMiddleware; use OCA\Files_Sharing\Middleware\SharingCheckMiddleware;
use \OCP\IContainer; use \OCP\IContainer;
use OCA\Files_Sharing\Capabilities;
class Application extends App { class Application extends App {
public function __construct(array $urlParams = array()) { public function __construct(array $urlParams = array()) {
@ -122,6 +124,15 @@ class Application extends App {
$server->getConfig() $server->getConfig()
); );
}); });
/*
* Register capabilities
*/
$server->getCapabilitiesManager()->registerCapability(function() use ($server) {
return new Capabilities(
$server->getConfig()
);
});
} }
public function registerMountProviders() { public function registerMountProviders() {

View File

@ -97,8 +97,3 @@ API::register('delete',
array('\OCA\Files_Sharing\API\Remote', 'declineShare'), array('\OCA\Files_Sharing\API\Remote', 'declineShare'),
'files_sharing'); 'files_sharing');
// Register with the capabilities API
API::register('get',
'/cloud/capabilities',
array('OCA\Files_Sharing\Capabilities', 'getCapabilities'),
'files_sharing', API::USER_AUTH);

View File

@ -20,6 +20,7 @@
*/ */
namespace OCA\Files_Sharing; namespace OCA\Files_Sharing;
use OCP\Capabilities\ICapability;
use \OCP\IConfig; use \OCP\IConfig;
/** /**
@ -27,32 +28,21 @@ use \OCP\IConfig;
* *
* @package OCA\Files_Sharing * @package OCA\Files_Sharing
*/ */
class Capabilities { class Capabilities implements ICapability {
/** @var IConfig */ /** @var IConfig */
private $config; private $config;
/**
* @param IConfig $config
*/
public function __construct(IConfig $config) { public function __construct(IConfig $config) {
$this->config = $config; $this->config = $config;
} }
/** /**
* @return \OC_OCS_Result * Return this classes capabilities
*
* @return array
*/ */
public static function getCapabilities() { public function getCapabilities() {
$config = \OC::$server->getConfig();
$cap = new Capabilities($config);
return $cap->getCaps();
}
/**
* @return \OC_OCS_Result
*/
public function getCaps() {
$res = []; $res = [];
$public = []; $public = [];
@ -76,12 +66,8 @@ class Capabilities {
$res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes'; $res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes';
return [
return new \OC_OCS_Result([ 'files_sharing' => $res,
'capabilities' => [ ];
'files_sharing' => $res
],
]);
} }
} }

View File

@ -36,9 +36,8 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
* @return string[] * @return string[]
*/ */
private function getFilesSharingPart(array $data) { private function getFilesSharingPart(array $data) {
$this->assertArrayHasKey('capabilities', $data); $this->assertArrayHasKey('files_sharing', $data);
$this->assertArrayHasKey('files_sharing', $data['capabilities']); return $data['files_sharing'];
return $data['capabilities']['files_sharing'];
} }
/** /**
@ -53,7 +52,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase {
$stub = $this->getMockBuilder('\OCP\IConfig')->disableOriginalConstructor()->getMock(); $stub = $this->getMockBuilder('\OCP\IConfig')->disableOriginalConstructor()->getMock();
$stub->method('getAppValue')->will($this->returnValueMap($map)); $stub->method('getAppValue')->will($this->returnValueMap($map));
$cap = new Capabilities($stub); $cap = new Capabilities($stub);
$result = $this->getFilesSharingPart($cap->getCaps()->getData()); $result = $this->getFilesSharingPart($cap->getCapabilities());
return $result; return $result;
} }

View File

@ -0,0 +1,40 @@
<?php
/**
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\Files_Trashbin\AppInfo;
use OCP\AppFramework\App;
use OCA\Files_Trashbin\Capabilities;
class Application extends App {
public function __construct(array $urlParams = array()) {
parent::__construct('files_trashbin', $urlParams);
$container = $this->getContainer();
/*
* Register capabilities
*/
$server->getCapabilitiesManager()->registerCapability(function() {
return new Capabilities();
});
}
}

View File

@ -1,9 +1,8 @@
<?php <?php
/** /**
* @author Georg Ehrke <georg@owncloud.com> * @author Georg Ehrke <georg@owncloud.com>
* @author Joas Schilling <nickvergessen@owncloud.com>
* @author Lukas Reschke <lukas@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Vincent Petry <pvince81@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com>
* *
* @copyright Copyright (c) 2015, ownCloud, Inc. * @copyright Copyright (c) 2015, ownCloud, Inc.
@ -22,6 +21,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/> * along with this program. If not, see <http://www.gnu.org/licenses/>
* *
*/ */
namespace OCA\Files_Trashbin\AppInfo;
$application = new Application();
$this->create('core_ajax_trashbin_preview', 'ajax/preview.php') $this->create('core_ajax_trashbin_preview', 'ajax/preview.php')
->actionInclude('files_trashbin/ajax/preview.php'); ->actionInclude('files_trashbin/ajax/preview.php');
$this->create('files_trashbin_ajax_delete', 'ajax/delete.php') $this->create('files_trashbin_ajax_delete', 'ajax/delete.php')
@ -33,6 +37,3 @@ $this->create('files_trashbin_ajax_list', 'ajax/list.php')
$this->create('files_trashbin_ajax_undelete', 'ajax/undelete.php') $this->create('files_trashbin_ajax_undelete', 'ajax/undelete.php')
->actionInclude('files_trashbin/ajax/undelete.php'); ->actionInclude('files_trashbin/ajax/undelete.php');
// Register with the capabilities API
\OCP\API::register('get', '/cloud/capabilities', array('OCA\Files_Trashbin\Capabilities', 'getCapabilities'), 'files_trashbin', \OCP\API::USER_AUTH);

View File

@ -2,6 +2,7 @@
/** /**
* @author Lukas Reschke <lukas@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de> * @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* *
* @copyright Copyright (c) 2015, ownCloud, Inc. * @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0 * @license AGPL-3.0
@ -22,25 +23,26 @@
namespace OCA\Files_Trashbin; namespace OCA\Files_Trashbin;
use OCP\Capabilities\ICapability;
/** /**
* Class Capabilities * Class Capabilities
* *
* @package OCA\Files_Trashbin * @package OCA\Files_Trashbin
*/ */
class Capabilities { class Capabilities implements ICapability {
/** /**
* @return \OC_OCS_Result * Return this classes capabilities
*
* @return array
*/ */
public static function getCapabilities() { public function getCapabilities() {
return new \OC_OCS_Result(array( return [
'capabilities' => array( 'files' => [
'files' => array( 'undelete' => true
'undelete' => true, ]
), ];
),
));
} }
} }

View File

@ -0,0 +1,40 @@
<?php
/**
* @author Roeland Jago Douma <roeland@famdouma.nl>
*
* @copyright Copyright (c) 2015, ownCloud, Inc.
* @license AGPL-3.0
*
* This code is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License, version 3,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License, version 3,
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*/
namespace OCA\Files_Versions\AppInfo;
use OCP\AppFramework\App;
use OCA\Files_Versions\Capabilities;
class Application extends App {
public function __construct(array $urlParams = array()) {
parent::__construct('files_versions', $urlParams);
$container = $this->getContainer();
/*
* Register capabilities
*/
$server->getCapabilitiesManager()->registerCapability(function() {
return new Capabilities();
});
}
}

View File

@ -1,10 +1,10 @@
<?php <?php
/** /**
* @author Björn Schießle <schiessle@owncloud.com> * @author Björn Schießle <schiessle@owncloud.com>
* @author Joas Schilling <nickvergessen@owncloud.com>
* @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Jörn Friedrich Dreyer <jfd@butonic.de>
* @author Lukas Reschke <lukas@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com>
* @author Morris Jobke <hey@morrisjobke.de> * @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Thomas Müller <thomas.mueller@tmit.eu> * @author Thomas Müller <thomas.mueller@tmit.eu>
* @author Tom Needham <tom@owncloud.com> * @author Tom Needham <tom@owncloud.com>
* *
@ -25,6 +25,10 @@
* *
*/ */
namespace OCA\Files_Versions\AppInfo;
$application = new Application();
/** @var $this \OCP\Route\IRouter */ /** @var $this \OCP\Route\IRouter */
$this->create('core_ajax_versions_preview', '/preview')->action( $this->create('core_ajax_versions_preview', '/preview')->action(
function() { function() {
@ -38,5 +42,3 @@ $this->create('files_versions_ajax_getVersions', 'ajax/getVersions.php')
$this->create('files_versions_ajax_rollbackVersion', 'ajax/rollbackVersion.php') $this->create('files_versions_ajax_rollbackVersion', 'ajax/rollbackVersion.php')
->actionInclude('files_versions/ajax/rollbackVersion.php'); ->actionInclude('files_versions/ajax/rollbackVersion.php');
// Register with the capabilities API
\OCP\API::register('get', '/cloud/capabilities', array('OCA\Files_Versions\Capabilities', 'getCapabilities'), 'files_versions', \OCP\API::USER_AUTH);

View File

@ -2,6 +2,7 @@
/** /**
* @author Christopher Schäpers <kondou@ts.unde.re> * @author Christopher Schäpers <kondou@ts.unde.re>
* @author Morris Jobke <hey@morrisjobke.de> * @author Morris Jobke <hey@morrisjobke.de>
* @author Roeland Jago Douma <roeland@famdouma.nl>
* @author Tom Needham <tom@owncloud.com> * @author Tom Needham <tom@owncloud.com>
* *
* @copyright Copyright (c) 2015, ownCloud, Inc. * @copyright Copyright (c) 2015, ownCloud, Inc.
@ -23,16 +24,20 @@
namespace OCA\Files_Versions; namespace OCA\Files_Versions;
class Capabilities { use OCP\Capabilities\ICapability;
class Capabilities implements ICapability {
public static function getCapabilities() { /**
return new \OC_OCS_Result(array( * Return this classes capabilities
'capabilities' => array( *
'files' => array( * @return array
'versioning' => true, */
), public function getCapabilities() {
), return [
)); 'files' => [
'versioning' => true
]
];
} }
} }