diff --git a/core/Controller/OCSController.php b/core/Controller/OCSController.php index a709ab7b07..35eac3a3d8 100644 --- a/core/Controller/OCSController.php +++ b/core/Controller/OCSController.php @@ -80,7 +80,8 @@ class OCSController extends \OCP\AppFramework\OCSController { } /** - * @NoAdminRequired + * @PublicPage + * * @return DataResponse */ public function getCapabilities() { @@ -94,7 +95,11 @@ class OCSController extends \OCP\AppFramework\OCSController { 'edition' => '', ); - $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); + if($this->userSession->isLoggedIn()) { + $result['capabilities'] = $this->capabilitiesManager->getCapabilities(); + } else { + $result['capabilities'] = $this->capabilitiesManager->getCapabilities(true); + } return new DataResponse($result); } diff --git a/lib/private/CapabilitiesManager.php b/lib/private/CapabilitiesManager.php index 159fa97c70..173760fe20 100644 --- a/lib/private/CapabilitiesManager.php +++ b/lib/private/CapabilitiesManager.php @@ -24,6 +24,7 @@ namespace OC; use OCP\AppFramework\QueryException; use OCP\Capabilities\ICapability; +use OCP\Capabilities\IPublicCapability; use OCP\ILogger; class CapabilitiesManager { @@ -41,10 +42,11 @@ class CapabilitiesManager { /** * Get an array of al the capabilities that are registered at this manager * + * @param bool $public get public capabilities only * @throws \InvalidArgumentException * @return array */ - public function getCapabilities() { + public function getCapabilities($public = false) { $capabilities = []; foreach($this->capabilities as $capability) { try { @@ -55,7 +57,9 @@ class CapabilitiesManager { } if ($c instanceof ICapability) { - $capabilities = array_replace_recursive($capabilities, $c->getCapabilities()); + if(!$public || ($public && $c instanceof IPublicCapability)) { + $capabilities = array_replace_recursive($capabilities, $c->getCapabilities()); + } } else { throw new \InvalidArgumentException('The given Capability (' . get_class($c) . ') does not implement the ICapability interface'); } diff --git a/lib/public/Capabilities/IPublicCapability.php b/lib/public/Capabilities/IPublicCapability.php new file mode 100644 index 0000000000..ded58f1208 --- /dev/null +++ b/lib/public/Capabilities/IPublicCapability.php @@ -0,0 +1,32 @@ + + * + * @author Julius Härtl + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see . + * + */ + +namespace OCP\Capabilities; + +/** + * @inheritdoc + * + * @since 13.0.0 + */ +interface IPublicCapability extends ICapability {} +