From 32279ed062b92e58c45cc87d0ecab41075cad3dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 6 Sep 2019 13:59:41 +0200 Subject: [PATCH] Extend missing check classes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- .../lib/Check/RequestRemoteAddress.php | 28 +++++++++++++++++++ apps/workflowengine/lib/Check/RequestTime.php | 13 +++++++++ .../lib/Check/RequestUserAgent.php | 2 ++ .../lib/Check/UserGroupMembership.php | 11 ++++++++ 4 files changed, 54 insertions(+) diff --git a/apps/workflowengine/lib/Check/RequestRemoteAddress.php b/apps/workflowengine/lib/Check/RequestRemoteAddress.php index 6fa4cfc880..c386168f59 100644 --- a/apps/workflowengine/lib/Check/RequestRemoteAddress.php +++ b/apps/workflowengine/lib/Check/RequestRemoteAddress.php @@ -151,4 +151,32 @@ class RequestRemoteAddress implements ICheck { } return str_pad($binaryIp, 128, '0', STR_PAD_RIGHT); } + + /** + * returns a list of Entities the checker supports. The values must match + * the class name of the entity. + * + * An empty result means the check is universally available. + * + * @since 18.0.0 + */ + public function supportedEntities(): array { + return []; + } + + /** + * returns whether the operation can be used in the requested scope. + * + * Scope IDs are defined as constants in OCP\WorkflowEngine\IManager. At + * time of writing these are SCOPE_ADMIN and SCOPE_USER. + * + * For possibly unknown future scopes the recommended behaviour is: if + * user scope is permitted, the default behaviour should return `true`, + * otherwise `false`. + * + * @since 18.0.0 + */ + public function isAvailableForScope(int $scope): bool { + return true; + } } diff --git a/apps/workflowengine/lib/Check/RequestTime.php b/apps/workflowengine/lib/Check/RequestTime.php index 0f5322b475..79696583cd 100644 --- a/apps/workflowengine/lib/Check/RequestTime.php +++ b/apps/workflowengine/lib/Check/RequestTime.php @@ -130,4 +130,17 @@ class RequestTime implements ICheck { public function isAvailableForScope(int $scope): bool { return true; } + + /** + * returns a list of Entities the checker supports. The values must match + * the class name of the entity. + * + * An empty result means the check is universally available. + * + * @since 18.0.0 + */ + public function supportedEntities(): array { + return []; + } + } diff --git a/apps/workflowengine/lib/Check/RequestUserAgent.php b/apps/workflowengine/lib/Check/RequestUserAgent.php index 2b2e301555..1abb56bbe2 100644 --- a/apps/workflowengine/lib/Check/RequestUserAgent.php +++ b/apps/workflowengine/lib/Check/RequestUserAgent.php @@ -24,6 +24,7 @@ namespace OCA\WorkflowEngine\Check; use OCP\IL10N; use OCP\IRequest; +use OCP\WorkflowEngine\IManager; class RequestUserAgent extends AbstractStringCheck { @@ -83,4 +84,5 @@ class RequestUserAgent extends AbstractStringCheck { public function isAvailableForScope(int $scope): bool { return true; } + } diff --git a/apps/workflowengine/lib/Check/UserGroupMembership.php b/apps/workflowengine/lib/Check/UserGroupMembership.php index fd6ba00d09..4b06dbd2da 100644 --- a/apps/workflowengine/lib/Check/UserGroupMembership.php +++ b/apps/workflowengine/lib/Check/UserGroupMembership.php @@ -28,6 +28,7 @@ use OCP\IL10N; use OCP\IUser; use OCP\IUserSession; use OCP\WorkflowEngine\ICheck; +use OCP\WorkflowEngine\IManager; class UserGroupMembership implements ICheck { @@ -111,4 +112,14 @@ class UserGroupMembership implements ICheck { return $this->cachedGroupMemberships; } + + public function supportedEntities(): array { + // universal by default + return []; + } + + public function isAvailableForScope(int $scope): bool { + // admin only by default + return $scope === IManager::SCOPE_ADMIN; + } }