summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJulius Härtl <jus@bitgrid.net>2017-06-30 11:08:04 +0200
committerJulius Härtl <jus@bitgrid.net>2017-06-30 11:08:04 +0200
commit51a0741005bc815a547d3cbbd9317dc317f03952 (patch)
treeb18d864379b997dd0b2313f75dcd9c58edb26d6b /lib
parent2afb4857cca4ca5eb48af63ab814727cfe77b1bd (diff)
downloadnextcloud-server-51a0741005bc815a547d3cbbd9317dc317f03952.tar.gz
nextcloud-server-51a0741005bc815a547d3cbbd9317dc317f03952.zip
Add public capabilities API
Signed-off-by: Julius Härtl <jus@bitgrid.net>
Diffstat (limited to 'lib')
-rw-r--r--lib/private/CapabilitiesManager.php8
-rw-r--r--lib/public/Capabilities/IPublicCapability.php32
2 files changed, 38 insertions, 2 deletions
diff --git a/lib/private/CapabilitiesManager.php b/lib/private/CapabilitiesManager.php
index 159fa97c708..173760fe20f 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 00000000000..ded58f1208b
--- /dev/null
+++ b/lib/public/Capabilities/IPublicCapability.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * @copyright Copyright (c) 2017 Julius Härtl <jus@bitgrid.net>
+ *
+ * @author Julius Härtl <jus@bitgrid.net>
+ *
+ * @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 <http://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace OCP\Capabilities;
+
+/**
+ * @inheritdoc
+ *
+ * @since 13.0.0
+ */
+interface IPublicCapability extends ICapability {}
+