aboutsummaryrefslogtreecommitdiffstats
path: root/apps/workflowengine/lib/Check
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2019-09-05 15:52:11 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2019-09-09 22:56:04 +0200
commitc2a52813e2cfadc43b096927ee9d9db3d9ac5c84 (patch)
treefffa2234b146bd5fbda576ad1a73b7b01575de4f /apps/workflowengine/lib/Check
parentd2c8b939d58239a99163445b83d80873932a5514 (diff)
downloadnextcloud-server-c2a52813e2cfadc43b096927ee9d9db3d9ac5c84.tar.gz
nextcloud-server-c2a52813e2cfadc43b096927ee9d9db3d9ac5c84.zip
extends ICheck with scope and entity support, provide them as initialState
Signed-off-by: Arthur Schiwon <blizzz@arthur-schiwon.de>
Diffstat (limited to 'apps/workflowengine/lib/Check')
-rw-r--r--apps/workflowengine/lib/Check/AbstractStringCheck.php11
-rw-r--r--apps/workflowengine/lib/Check/FileMimeType.php5
-rw-r--r--apps/workflowengine/lib/Check/FileName.php9
-rw-r--r--apps/workflowengine/lib/Check/FileSize.php9
-rw-r--r--apps/workflowengine/lib/Check/FileSystemTags.php9
-rw-r--r--apps/workflowengine/lib/Check/RequestTime.php4
-rw-r--r--apps/workflowengine/lib/Check/RequestUserAgent.php4
7 files changed, 51 insertions, 0 deletions
diff --git a/apps/workflowengine/lib/Check/AbstractStringCheck.php b/apps/workflowengine/lib/Check/AbstractStringCheck.php
index 0fd728e3496..7a385729e09 100644
--- a/apps/workflowengine/lib/Check/AbstractStringCheck.php
+++ b/apps/workflowengine/lib/Check/AbstractStringCheck.php
@@ -25,6 +25,7 @@ namespace OCA\WorkflowEngine\Check;
use OCP\Files\Storage\IStorage;
use OCP\IL10N;
use OCP\WorkflowEngine\ICheck;
+use OCP\WorkflowEngine\IManager;
abstract class AbstractStringCheck implements ICheck {
@@ -101,6 +102,16 @@ abstract class AbstractStringCheck implements ICheck {
}
}
+ public function supportedEntities(): array {
+ // universal by default
+ return [];
+ }
+
+ public function isAvailableForScope(int $scope): bool {
+ // admin only by default
+ return $scope === IManager::SCOPE_ADMIN;
+ }
+
/**
* @param string $pattern
* @param string $subject
diff --git a/apps/workflowengine/lib/Check/FileMimeType.php b/apps/workflowengine/lib/Check/FileMimeType.php
index 5f572f5aa9d..6d51992fdd0 100644
--- a/apps/workflowengine/lib/Check/FileMimeType.php
+++ b/apps/workflowengine/lib/Check/FileMimeType.php
@@ -22,6 +22,7 @@
namespace OCA\WorkflowEngine\Check;
+use OCA\WorkflowEngine\Entity\File;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\Storage\IStorage;
use OCP\IL10N;
@@ -195,4 +196,8 @@ class FileMimeType extends AbstractStringCheck {
strpos($this->request->getPathInfo(), '/webdav/') === 0
);
}
+
+ public function supportedEntities(): array {
+ return [ File::class ];
+ }
}
diff --git a/apps/workflowengine/lib/Check/FileName.php b/apps/workflowengine/lib/Check/FileName.php
index c6afbf7afad..d9b63ebfed1 100644
--- a/apps/workflowengine/lib/Check/FileName.php
+++ b/apps/workflowengine/lib/Check/FileName.php
@@ -22,6 +22,7 @@ declare(strict_types=1);
namespace OCA\WorkflowEngine\Check;
+use OCA\WorkflowEngine\Entity\File;
use OCP\Files\Storage\IStorage;
use OCP\IL10N;
use OCP\IRequest;
@@ -75,4 +76,12 @@ class FileName extends AbstractStringCheck {
}
return parent::executeStringCheck($operator, $checkValue, $actualValue);
}
+
+ public function supportedEntities(): array {
+ return [ File::class ];
+ }
+
+ public function isAvailableForScope(int $scope): bool {
+ return true;
+ }
}
diff --git a/apps/workflowengine/lib/Check/FileSize.php b/apps/workflowengine/lib/Check/FileSize.php
index 7e48f0f6038..06a45bdcd41 100644
--- a/apps/workflowengine/lib/Check/FileSize.php
+++ b/apps/workflowengine/lib/Check/FileSize.php
@@ -22,6 +22,7 @@
namespace OCA\WorkflowEngine\Check;
+use OCA\WorkflowEngine\Entity\File;
use OCP\Files\Storage\IStorage;
use OCP\IL10N;
use OCP\IRequest;
@@ -116,4 +117,12 @@ class FileSize implements ICheck {
$this->size = $size;
return $this->size;
}
+
+ public function supportedEntities(): array {
+ return [ File::class ];
+ }
+
+ public function isAvailableForScope(int $scope): bool {
+ return true;
+ }
}
diff --git a/apps/workflowengine/lib/Check/FileSystemTags.php b/apps/workflowengine/lib/Check/FileSystemTags.php
index 4a2b87fd53e..12285c9b33e 100644
--- a/apps/workflowengine/lib/Check/FileSystemTags.php
+++ b/apps/workflowengine/lib/Check/FileSystemTags.php
@@ -22,6 +22,7 @@
namespace OCA\WorkflowEngine\Check;
+use OCA\WorkflowEngine\Entity\File;
use OCP\Files\Cache\ICache;
use OCP\Files\IHomeStorage;
use OCP\Files\Storage\IStorage;
@@ -166,4 +167,12 @@ class FileSystemTags implements ICheck {
$dir = dirname($path);
return $dir === '.' ? '' : $dir;
}
+
+ public function supportedEntities(): array {
+ return [ File::class ];
+ }
+
+ 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 2aa79e77673..0f5322b4759 100644
--- a/apps/workflowengine/lib/Check/RequestTime.php
+++ b/apps/workflowengine/lib/Check/RequestTime.php
@@ -126,4 +126,8 @@ class RequestTime implements ICheck {
throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4);
}
}
+
+ public function isAvailableForScope(int $scope): bool {
+ return true;
+ }
}
diff --git a/apps/workflowengine/lib/Check/RequestUserAgent.php b/apps/workflowengine/lib/Check/RequestUserAgent.php
index 4191a2f3412..2b2e3015557 100644
--- a/apps/workflowengine/lib/Check/RequestUserAgent.php
+++ b/apps/workflowengine/lib/Check/RequestUserAgent.php
@@ -79,4 +79,8 @@ class RequestUserAgent extends AbstractStringCheck {
protected function getActualValue() {
return (string) $this->request->getHeader('User-Agent');
}
+
+ public function isAvailableForScope(int $scope): bool {
+ return true;
+ }
}