diff --git a/apps/files/appinfo/application.php b/apps/files/appinfo/application.php index c8aaf375d9661273d2b4b3337ed5b5d71390fa91..f121eb7a40146b62bbffeb061bd43addb63df6a6 100644 --- a/apps/files/appinfo/application.php +++ b/apps/files/appinfo/application.php @@ -1,6 +1,5 @@ <?php /** - * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> * @author Tobias Kaminsky <tobias@kaminsky.me> * @author Vincent Petry <pvince81@owncloud.com> @@ -21,13 +20,13 @@ * 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 OCP\AppFramework\App; use \OCA\Files\Service\TagService; use \OCP\IContainer; +use OCA\Files\Capabilities; class Application extends App { public function __construct(array $urlParams=array()) { @@ -68,5 +67,12 @@ class Application extends App { $homeFolder ); }); + + /* + * Register capabilities + */ + $server->getCapabilitiesManager()->registerCapability(function() { + return new Capabilities(); + }); } } diff --git a/apps/files/appinfo/routes.php b/apps/files/appinfo/routes.php index 5aa52f17a2979d8cf623edd6a703aa83052e4db7..d1b8954d5ceaf3c859c9654226845081a0a27fb4 100644 --- a/apps/files/appinfo/routes.php +++ b/apps/files/appinfo/routes.php @@ -1,9 +1,9 @@ <?php /** * @author Bart Visscher <bartv@thisnet.nl> - * @author Joas Schilling <nickvergessen@owncloud.com> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Roeland Jago Douma <roeland@famdouma.nl> * @author Tobias Kaminsky <tobias@kaminsky.me> * @author Tom Needham <tom@owncloud.com> * @author Vincent Petry <pvince81@owncloud.com> @@ -24,8 +24,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ - -namespace OCA\Files\Appinfo; +namespace OCA\Files\AppInfo; $application = new Application(); $application->registerRoutes( @@ -82,6 +81,4 @@ $this->create('files_ajax_upload', 'ajax/upload.php') $this->create('download', 'download{file}') ->requirements(array('file' => '.*')) ->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); + diff --git a/apps/files/lib/capabilities.php b/apps/files/lib/capabilities.php index 05d12864dcaa3fb149d743c0a09a519d20d2dbf3..2e19283e4d679ff8ae187e43236fbe99ec7185e3 100644 --- a/apps/files/lib/capabilities.php +++ b/apps/files/lib/capabilities.php @@ -1,7 +1,7 @@ <?php /** * @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> * * @copyright Copyright (c) 2015, ownCloud, Inc. @@ -20,19 +20,28 @@ * along with this program. If not, see <http://www.gnu.org/licenses/> * */ - -namespace OCA\Files; -class Capabilities { - - public static function getCapabilities() { - return new \OC_OCS_Result(array( - 'capabilities' => array( - 'files' => array( - 'bigfilechunking' => true, - ), - ), - )); +namespace OCA\Files; + +use OCP\Capabilities\ICapability; + +/** + * Class Capabilities + * + * @package OCA\Files + */ +class Capabilities implements ICapability { + + /** + * Return this classes capabilities + * + * @return array + */ + public function getCapabilities() { + return [ + 'files' => [ + 'bigfilechunking' => true, + ], + ]; } - } diff --git a/apps/files_external/appinfo/application.php b/apps/files_external/appinfo/application.php index 62d4d142ba69c3c8574106a638dd34fc88a5375d..d77a302466c919c433450e1ba51ec7373475d636 100644 --- a/apps/files_external/appinfo/application.php +++ b/apps/files_external/appinfo/application.php @@ -21,7 +21,7 @@ * */ -namespace OCA\Files_External\Appinfo; +namespace OCA\Files_External\AppInfo; use \OCA\Files_External\Controller\AjaxController; use \OCP\AppFramework\App; diff --git a/apps/files_external/appinfo/routes.php b/apps/files_external/appinfo/routes.php index 97eb1353b1e05cd5cbc265cbe9fd978fecba0f83..bc4b0e98c918a69b7d3c7d02bd8bbcfd7ca49ab9 100644 --- a/apps/files_external/appinfo/routes.php +++ b/apps/files_external/appinfo/routes.php @@ -23,7 +23,7 @@ * */ -namespace OCA\Files_External\Appinfo; +namespace OCA\Files_External\AppInfo; /** * @var $this \OC\Route\Router diff --git a/apps/files_sharing/appinfo/application.php b/apps/files_sharing/appinfo/application.php index b9c2844d78c819d1cf955000f05a3da4115b73bd..6ddd25acb5268f9cf30277578934e6e94b0b3159 100644 --- a/apps/files_sharing/appinfo/application.php +++ b/apps/files_sharing/appinfo/application.php @@ -2,6 +2,7 @@ /** * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <icewind@owncloud.com> + * @author Roeland Jago Douma <roeland@famdouma.nl> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @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\MountProvider; @@ -31,6 +32,7 @@ use OCA\Files_Sharing\Controllers\ExternalSharesController; use OCA\Files_Sharing\Controllers\ShareController; use OCA\Files_Sharing\Middleware\SharingCheckMiddleware; use \OCP\IContainer; +use OCA\Files_Sharing\Capabilities; class Application extends App { public function __construct(array $urlParams = array()) { @@ -122,6 +124,15 @@ class Application extends App { $server->getConfig() ); }); + + /* + * Register capabilities + */ + $server->getCapabilitiesManager()->registerCapability(function() use ($server) { + return new Capabilities( + $server->getConfig() + ); + }); } public function registerMountProviders() { diff --git a/apps/files_sharing/appinfo/routes.php b/apps/files_sharing/appinfo/routes.php index 21d21a83441481df27b940c6ccbc0a433c7be915..1e99267a43aba14c42a45ea33f842023ecb13afc 100644 --- a/apps/files_sharing/appinfo/routes.php +++ b/apps/files_sharing/appinfo/routes.php @@ -97,8 +97,3 @@ API::register('delete', array('\OCA\Files_Sharing\API\Remote', 'declineShare'), 'files_sharing'); -// Register with the capabilities API -API::register('get', - '/cloud/capabilities', - array('OCA\Files_Sharing\Capabilities', 'getCapabilities'), - 'files_sharing', API::USER_AUTH); diff --git a/apps/files_sharing/lib/capabilities.php b/apps/files_sharing/lib/capabilities.php index ac6454c3433f9a9fab56ab1028e677d1e6998e12..ef69a40078bccdf41af3583ec7caa8685e55280a 100644 --- a/apps/files_sharing/lib/capabilities.php +++ b/apps/files_sharing/lib/capabilities.php @@ -20,6 +20,7 @@ */ namespace OCA\Files_Sharing; +use OCP\Capabilities\ICapability; use \OCP\IConfig; /** @@ -27,32 +28,21 @@ use \OCP\IConfig; * * @package OCA\Files_Sharing */ -class Capabilities { +class Capabilities implements ICapability { /** @var IConfig */ private $config; - /** - * @param IConfig $config - */ public function __construct(IConfig $config) { $this->config = $config; } /** - * @return \OC_OCS_Result - */ - public static function getCapabilities() { - $config = \OC::$server->getConfig(); - $cap = new Capabilities($config); - return $cap->getCaps(); - } - - - /** - * @return \OC_OCS_Result + * Return this classes capabilities + * + * @return array */ - public function getCaps() { + public function getCapabilities() { $res = []; $public = []; @@ -76,12 +66,8 @@ class Capabilities { $res['resharing'] = $this->config->getAppValue('core', 'shareapi_allow_resharing', 'yes') === 'yes'; - - return new \OC_OCS_Result([ - 'capabilities' => [ - 'files_sharing' => $res - ], - ]); + return [ + 'files_sharing' => $res, + ]; } - } diff --git a/apps/files_sharing/tests/capabilities.php b/apps/files_sharing/tests/capabilities.php index a7c487bf589676852d1689f3efb7ae04be316c4c..b0f6390b0139426c4f58d77356486f78aa2a6af1 100644 --- a/apps/files_sharing/tests/capabilities.php +++ b/apps/files_sharing/tests/capabilities.php @@ -36,9 +36,8 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase { * @return string[] */ private function getFilesSharingPart(array $data) { - $this->assertArrayHasKey('capabilities', $data); - $this->assertArrayHasKey('files_sharing', $data['capabilities']); - return $data['capabilities']['files_sharing']; + $this->assertArrayHasKey('files_sharing', $data); + return $data['files_sharing']; } /** @@ -53,7 +52,7 @@ class FilesSharingCapabilitiesTest extends \Test\TestCase { $stub = $this->getMockBuilder('\OCP\IConfig')->disableOriginalConstructor()->getMock(); $stub->method('getAppValue')->will($this->returnValueMap($map)); $cap = new Capabilities($stub); - $result = $this->getFilesSharingPart($cap->getCaps()->getData()); + $result = $this->getFilesSharingPart($cap->getCapabilities()); return $result; } diff --git a/apps/files_trashbin/appinfo/application.php b/apps/files_trashbin/appinfo/application.php new file mode 100644 index 0000000000000000000000000000000000000000..851de142e5c43855fad14130e0c6ec23353577b1 --- /dev/null +++ b/apps/files_trashbin/appinfo/application.php @@ -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(); + }); + } +} diff --git a/apps/files_trashbin/appinfo/routes.php b/apps/files_trashbin/appinfo/routes.php index 99a03d6b969781a94beed6ce0552f625a4ad2c8d..cf3d7b77ec225791e2c7da65a7c08f01e8c9d454 100644 --- a/apps/files_trashbin/appinfo/routes.php +++ b/apps/files_trashbin/appinfo/routes.php @@ -1,9 +1,8 @@ <?php /** * @author Georg Ehrke <georg@owncloud.com> - * @author Joas Schilling <nickvergessen@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> * * @copyright Copyright (c) 2015, ownCloud, Inc. @@ -22,6 +21,11 @@ * 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') ->actionInclude('files_trashbin/ajax/preview.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') ->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); diff --git a/apps/files_trashbin/lib/capabilities.php b/apps/files_trashbin/lib/capabilities.php index 89b268489b56b7f9732d9e91b6c8be10decdd5c6..c991cc8be65078c6b0be0ef114365594e8fd63ef 100644 --- a/apps/files_trashbin/lib/capabilities.php +++ b/apps/files_trashbin/lib/capabilities.php @@ -2,6 +2,7 @@ /** * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Roeland Jago Douma <roeland@famdouma.nl> * * @copyright Copyright (c) 2015, ownCloud, Inc. * @license AGPL-3.0 @@ -22,25 +23,26 @@ namespace OCA\Files_Trashbin; +use OCP\Capabilities\ICapability; /** * Class Capabilities * * @package OCA\Files_Trashbin */ -class Capabilities { +class Capabilities implements ICapability { /** - * @return \OC_OCS_Result + * Return this classes capabilities + * + * @return array */ - public static function getCapabilities() { - return new \OC_OCS_Result(array( - 'capabilities' => array( - 'files' => array( - 'undelete' => true, - ), - ), - )); + public function getCapabilities() { + return [ + 'files' => [ + 'undelete' => true + ] + ]; } } diff --git a/apps/files_versions/appinfo/application.php b/apps/files_versions/appinfo/application.php new file mode 100644 index 0000000000000000000000000000000000000000..69485bc1f22b29b284968988fec0dde631290757 --- /dev/null +++ b/apps/files_versions/appinfo/application.php @@ -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(); + }); + } +} diff --git a/apps/files_versions/appinfo/routes.php b/apps/files_versions/appinfo/routes.php index 5dbed1f93eb00261c3c541b04c4a78dbebc6e878..9bab86d92249ab24a607de4895a9451f16eb9747 100644 --- a/apps/files_versions/appinfo/routes.php +++ b/apps/files_versions/appinfo/routes.php @@ -1,10 +1,10 @@ <?php /** * @author Björn Schießle <schiessle@owncloud.com> - * @author Joas Schilling <nickvergessen@owncloud.com> * @author Jörn Friedrich Dreyer <jfd@butonic.de> * @author Lukas Reschke <lukas@owncloud.com> * @author Morris Jobke <hey@morrisjobke.de> + * @author Roeland Jago Douma <roeland@famdouma.nl> * @author Thomas Müller <thomas.mueller@tmit.eu> * @author Tom Needham <tom@owncloud.com> * @@ -25,6 +25,10 @@ * */ +namespace OCA\Files_Versions\AppInfo; + +$application = new Application(); + /** @var $this \OCP\Route\IRouter */ $this->create('core_ajax_versions_preview', '/preview')->action( function() { @@ -38,5 +42,3 @@ $this->create('files_versions_ajax_getVersions', 'ajax/getVersions.php') $this->create('files_versions_ajax_rollbackVersion', '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); diff --git a/apps/files_versions/lib/capabilities.php b/apps/files_versions/lib/capabilities.php index aea31b25240cd02f25af121dc16ce1b95d4a20f2..11b98038f467ebf72d9520667c73a75430bfdf06 100644 --- a/apps/files_versions/lib/capabilities.php +++ b/apps/files_versions/lib/capabilities.php @@ -2,6 +2,7 @@ /** * @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> * * @copyright Copyright (c) 2015, ownCloud, Inc. @@ -23,16 +24,20 @@ namespace OCA\Files_Versions; -class Capabilities { +use OCP\Capabilities\ICapability; + +class Capabilities implements ICapability { - public static function getCapabilities() { - return new \OC_OCS_Result(array( - 'capabilities' => array( - 'files' => array( - 'versioning' => true, - ), - ), - )); + /** + * Return this classes capabilities + * + * @return array + */ + public function getCapabilities() { + return [ + 'files' => [ + 'versioning' => true + ] + ]; } - }