Completed
Push — stable10 ( d1b390...0bd063 )
by Lukas
27:03 queued 26:40
created
apps/files_trashbin/appinfo/app.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -32,10 +32,10 @@
 block discarded – undo
32 32
 
33 33
 \OCA\Files\App::getNavigationManager()->add(
34 34
 array(
35
-	"id" => 'trashbin',
36
-	"appname" => 'files_trashbin',
37
-	"script" => 'list.php',
38
-	"order" => 50,
39
-	"name" => $l->t('Deleted files')
35
+    "id" => 'trashbin',
36
+    "appname" => 'files_trashbin',
37
+    "script" => 'list.php',
38
+    "order" => 50,
39
+    "name" => $l->t('Deleted files')
40 40
 )
41 41
 );
Please login to merge, or discard this patch.
apps/workflowengine/templates/admin.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 
28 28
 	<?php if (!empty($_['docs'])): ?>
29 29
 		<a target="_blank" rel="noreferrer" class="icon-info svg"
30
-		   title="<?php p($l->t('Open documentation'));?>"
30
+		   title="<?php p($l->t('Open documentation')); ?>"
31 31
 		   href="<?php p(link_to_docs($_['docs'])); ?>">
32 32
 		</a>
33 33
 	<?php endif; ?>
Please login to merge, or discard this patch.
apps/workflowengine/lib/Controller/RequestTime.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -26,27 +26,27 @@
 block discarded – undo
26 26
 
27 27
 class RequestTime extends Controller {
28 28
 
29
-	/**
30
-	 * @NoAdminRequired
31
-	 *
32
-	 * @param string $search
33
-	 * @return JSONResponse
34
-	 */
35
-	public function getTimezones($search = '') {
36
-		$timezones = \DateTimeZone::listIdentifiers();
29
+    /**
30
+     * @NoAdminRequired
31
+     *
32
+     * @param string $search
33
+     * @return JSONResponse
34
+     */
35
+    public function getTimezones($search = '') {
36
+        $timezones = \DateTimeZone::listIdentifiers();
37 37
 
38
-		if ($search !== '') {
39
-			$timezones = array_filter($timezones, function ($timezone) use ($search) {
40
-				return strpos(strtolower($timezone), strtolower($search)) !== false;
41
-			});
42
-		}
38
+        if ($search !== '') {
39
+            $timezones = array_filter($timezones, function ($timezone) use ($search) {
40
+                return strpos(strtolower($timezone), strtolower($search)) !== false;
41
+            });
42
+        }
43 43
 
44
-		$timezones = array_slice($timezones, 0, 10);
44
+        $timezones = array_slice($timezones, 0, 10);
45 45
 
46
-		$response = [];
47
-		foreach ($timezones as $timezone) {
48
-			$response[$timezone] = $timezone;
49
-		}
50
-		return new JSONResponse($response);
51
-	}
46
+        $response = [];
47
+        foreach ($timezones as $timezone) {
48
+            $response[$timezone] = $timezone;
49
+        }
50
+        return new JSONResponse($response);
51
+    }
52 52
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 		$timezones = \DateTimeZone::listIdentifiers();
37 37
 
38 38
 		if ($search !== '') {
39
-			$timezones = array_filter($timezones, function ($timezone) use ($search) {
39
+			$timezones = array_filter($timezones, function($timezone) use ($search) {
40 40
 				return strpos(strtolower($timezone), strtolower($search)) !== false;
41 41
 			});
42 42
 		}
Please login to merge, or discard this patch.
apps/workflowengine/lib/AppInfo/Application.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -23,54 +23,54 @@
 block discarded – undo
23 23
 
24 24
 class Application extends \OCP\AppFramework\App {
25 25
 
26
-	public function __construct() {
27
-		parent::__construct('workflowengine');
26
+    public function __construct() {
27
+        parent::__construct('workflowengine');
28 28
 
29
-		$this->getContainer()->registerAlias('FlowOperationsController', 'OCA\WorkflowEngine\Controller\FlowOperations');
30
-		$this->getContainer()->registerAlias('RequestTimeController', 'OCA\WorkflowEngine\Controller\RequestTime');
31
-	}
29
+        $this->getContainer()->registerAlias('FlowOperationsController', 'OCA\WorkflowEngine\Controller\FlowOperations');
30
+        $this->getContainer()->registerAlias('RequestTimeController', 'OCA\WorkflowEngine\Controller\RequestTime');
31
+    }
32 32
 
33
-	/**
34
-	 * Register all hooks and listeners
35
-	 */
36
-	public function registerHooksAndListeners() {
37
-		$dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
38
-		$dispatcher->addListener(
39
-			'OCP\WorkflowEngine::loadAdditionalSettingScripts',
40
-			function() {
41
-				if (!function_exists('style')) {
42
-					// This is hacky, but we need to load the template class
43
-					class_exists('OCP\Template', true);
44
-				}
33
+    /**
34
+     * Register all hooks and listeners
35
+     */
36
+    public function registerHooksAndListeners() {
37
+        $dispatcher = $this->getContainer()->getServer()->getEventDispatcher();
38
+        $dispatcher->addListener(
39
+            'OCP\WorkflowEngine::loadAdditionalSettingScripts',
40
+            function() {
41
+                if (!function_exists('style')) {
42
+                    // This is hacky, but we need to load the template class
43
+                    class_exists('OCP\Template', true);
44
+                }
45 45
 
46
-				style('workflowengine', [
47
-					'admin',
48
-				]);
46
+                style('workflowengine', [
47
+                    'admin',
48
+                ]);
49 49
 
50
-				script('core', [
51
-					'oc-backbone-webdav',
52
-					'systemtags/systemtags',
53
-					'systemtags/systemtagmodel',
54
-					'systemtags/systemtagscollection',
55
-				]);
50
+                script('core', [
51
+                    'oc-backbone-webdav',
52
+                    'systemtags/systemtags',
53
+                    'systemtags/systemtagmodel',
54
+                    'systemtags/systemtagscollection',
55
+                ]);
56 56
 
57
-				vendor_script('jsTimezoneDetect/jstz');
57
+                vendor_script('jsTimezoneDetect/jstz');
58 58
 
59
-				script('workflowengine', [
60
-					'admin',
59
+                script('workflowengine', [
60
+                    'admin',
61 61
 
62
-					// Check plugins
63
-					'filemimetypeplugin',
64
-					'filesizeplugin',
65
-					'filesystemtagsplugin',
66
-					'requestremoteaddressplugin',
67
-					'requesttimeplugin',
68
-					'requesturlplugin',
69
-					'requestuseragentplugin',
70
-					'usergroupmembershipplugin',
71
-				]);
72
-			},
73
-			-100
74
-		);
75
-	}
62
+                    // Check plugins
63
+                    'filemimetypeplugin',
64
+                    'filesizeplugin',
65
+                    'filesystemtagsplugin',
66
+                    'requestremoteaddressplugin',
67
+                    'requesttimeplugin',
68
+                    'requesturlplugin',
69
+                    'requestuseragentplugin',
70
+                    'usergroupmembershipplugin',
71
+                ]);
72
+            },
73
+            -100
74
+        );
75
+    }
76 76
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/FileMimeType.php 1 patch
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -29,134 +29,134 @@
 block discarded – undo
29 29
 
30 30
 class FileMimeType extends AbstractStringCheck {
31 31
 
32
-	/** @var array */
33
-	protected $mimeType;
34
-
35
-	/** @var IRequest */
36
-	protected $request;
37
-
38
-	/** @var IMimeTypeDetector */
39
-	protected $mimeTypeDetector;
40
-
41
-	/** @var IStorage */
42
-	protected $storage;
43
-
44
-	/** @var string */
45
-	protected $path;
46
-
47
-	/**
48
-	 * @param IL10N $l
49
-	 * @param IRequest $request
50
-	 * @param IMimeTypeDetector $mimeTypeDetector
51
-	 */
52
-	public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mimeTypeDetector) {
53
-		parent::__construct($l);
54
-		$this->request = $request;
55
-		$this->mimeTypeDetector = $mimeTypeDetector;
56
-	}
57
-
58
-	/**
59
-	 * @param IStorage $storage
60
-	 * @param string $path
61
-	 */
62
-	public function setFileInfo(IStorage $storage, $path) {
63
-		$this->storage = $storage;
64
-		$this->path = $path;
65
-		if (!isset($this->mimeType[$this->storage->getId()][$this->path])
66
-			|| $this->mimeType[$this->storage->getId()][$this->path] === '') {
67
-			$this->mimeType[$this->storage->getId()][$this->path] = null;
68
-		}
69
-	}
70
-
71
-	/**
72
-	 * @return string
73
-	 */
74
-	protected function getActualValue() {
75
-		if ($this->mimeType[$this->storage->getId()][$this->path] !== null) {
76
-			return $this->mimeType[$this->storage->getId()][$this->path];
77
-		}
78
-
79
-		$this->mimeType[$this->storage->getId()][$this->path] = '';
80
-		if ($this->isWebDAVRequest()) {
81
-			if ($this->request->getMethod() === 'PUT') {
82
-				$path = $this->request->getPathInfo();
83
-				$this->mimeType[$this->storage->getId()][$this->path] = $this->mimeTypeDetector->detectPath($path);
84
-				return $this->mimeType[$this->storage->getId()][$this->path];
85
-			}
86
-		}
87
-
88
-		if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
89
-			$files = $this->request->getUploadedFile('files');
90
-			if (isset($files['type'][0])) {
91
-				$mimeType = $files['type'][0];
92
-				if ($this->mimeType === 'application/octet-stream') {
93
-					// Maybe not...
94
-					$mimeTypeTest = $this->mimeTypeDetector->detectPath($files['name'][0]);
95
-					if ($mimeTypeTest !== 'application/octet-stream' && $mimeTypeTest !== false) {
96
-						$mimeType = $mimeTypeTest;
97
-					} else {
98
-						$mimeTypeTest = $this->mimeTypeDetector->detect($files['tmp_name'][0]);
99
-						if ($mimeTypeTest !== 'application/octet-stream' && $mimeTypeTest !== false) {
100
-							$mimeType = $mimeTypeTest;
101
-						}
102
-					}
103
-				}
104
-				$this->mimeType[$this->storage->getId()][$this->path] = $mimeType;
105
-				return $mimeType;
106
-			}
107
-		}
108
-
109
-		$this->mimeType[$this->storage->getId()][$this->path] = $this->storage->getMimeType($this->path);
110
-		if ($this->mimeType[$this->storage->getId()][$this->path] === 'application/octet-stream') {
111
-			$this->mimeType[$this->storage->getId()][$this->path] = $this->detectMimetypeFromPath();
112
-		}
113
-
114
-		return $this->mimeType[$this->storage->getId()][$this->path];
115
-	}
116
-
117
-	/**
118
-	 * @return string
119
-	 */
120
-	protected function detectMimetypeFromPath() {
121
-		$mimeType = $this->mimeTypeDetector->detectPath($this->path);
122
-		if ($mimeType !== 'application/octet-stream' && $mimeType !== false) {
123
-			return $mimeType;
124
-		}
125
-
126
-		if ($this->storage->instanceOfStorage('\OC\Files\Storage\Local')
127
-			|| $this->storage->instanceOfStorage('\OC\Files\Storage\Home')
128
-			|| $this->storage->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage')) {
129
-			$localFile = $this->storage->getLocalFile($this->path);
130
-			if ($localFile !== false) {
131
-				$mimeType = $this->mimeTypeDetector->detect($localFile);
132
-				if ($mimeType !== false) {
133
-					return $mimeType;
134
-				}
135
-			}
136
-
137
-			return 'application/octet-stream';
138
-		} else {
139
-			$handle = $this->storage->fopen($this->path, 'r');
140
-			$data = fread($handle, 8024);
141
-			fclose($handle);
142
-			$mimeType = $this->mimeTypeDetector->detectString($data);
143
-			if ($mimeType !== false) {
144
-				return $mimeType;
145
-			}
146
-
147
-			return 'application/octet-stream';
148
-		}
149
-	}
150
-
151
-	/**
152
-	 * @return bool
153
-	 */
154
-	protected function isWebDAVRequest() {
155
-		return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && (
156
-			$this->request->getPathInfo() === '/webdav' ||
157
-			strpos($this->request->getPathInfo(), '/webdav/') === 0 ||
158
-			$this->request->getPathInfo() === '/dav/files' ||
159
-			strpos($this->request->getPathInfo(), '/dav/files/') === 0
160
-		);
161
-	}
32
+    /** @var array */
33
+    protected $mimeType;
34
+
35
+    /** @var IRequest */
36
+    protected $request;
37
+
38
+    /** @var IMimeTypeDetector */
39
+    protected $mimeTypeDetector;
40
+
41
+    /** @var IStorage */
42
+    protected $storage;
43
+
44
+    /** @var string */
45
+    protected $path;
46
+
47
+    /**
48
+     * @param IL10N $l
49
+     * @param IRequest $request
50
+     * @param IMimeTypeDetector $mimeTypeDetector
51
+     */
52
+    public function __construct(IL10N $l, IRequest $request, IMimeTypeDetector $mimeTypeDetector) {
53
+        parent::__construct($l);
54
+        $this->request = $request;
55
+        $this->mimeTypeDetector = $mimeTypeDetector;
56
+    }
57
+
58
+    /**
59
+     * @param IStorage $storage
60
+     * @param string $path
61
+     */
62
+    public function setFileInfo(IStorage $storage, $path) {
63
+        $this->storage = $storage;
64
+        $this->path = $path;
65
+        if (!isset($this->mimeType[$this->storage->getId()][$this->path])
66
+            || $this->mimeType[$this->storage->getId()][$this->path] === '') {
67
+            $this->mimeType[$this->storage->getId()][$this->path] = null;
68
+        }
69
+    }
70
+
71
+    /**
72
+     * @return string
73
+     */
74
+    protected function getActualValue() {
75
+        if ($this->mimeType[$this->storage->getId()][$this->path] !== null) {
76
+            return $this->mimeType[$this->storage->getId()][$this->path];
77
+        }
78
+
79
+        $this->mimeType[$this->storage->getId()][$this->path] = '';
80
+        if ($this->isWebDAVRequest()) {
81
+            if ($this->request->getMethod() === 'PUT') {
82
+                $path = $this->request->getPathInfo();
83
+                $this->mimeType[$this->storage->getId()][$this->path] = $this->mimeTypeDetector->detectPath($path);
84
+                return $this->mimeType[$this->storage->getId()][$this->path];
85
+            }
86
+        }
87
+
88
+        if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
89
+            $files = $this->request->getUploadedFile('files');
90
+            if (isset($files['type'][0])) {
91
+                $mimeType = $files['type'][0];
92
+                if ($this->mimeType === 'application/octet-stream') {
93
+                    // Maybe not...
94
+                    $mimeTypeTest = $this->mimeTypeDetector->detectPath($files['name'][0]);
95
+                    if ($mimeTypeTest !== 'application/octet-stream' && $mimeTypeTest !== false) {
96
+                        $mimeType = $mimeTypeTest;
97
+                    } else {
98
+                        $mimeTypeTest = $this->mimeTypeDetector->detect($files['tmp_name'][0]);
99
+                        if ($mimeTypeTest !== 'application/octet-stream' && $mimeTypeTest !== false) {
100
+                            $mimeType = $mimeTypeTest;
101
+                        }
102
+                    }
103
+                }
104
+                $this->mimeType[$this->storage->getId()][$this->path] = $mimeType;
105
+                return $mimeType;
106
+            }
107
+        }
108
+
109
+        $this->mimeType[$this->storage->getId()][$this->path] = $this->storage->getMimeType($this->path);
110
+        if ($this->mimeType[$this->storage->getId()][$this->path] === 'application/octet-stream') {
111
+            $this->mimeType[$this->storage->getId()][$this->path] = $this->detectMimetypeFromPath();
112
+        }
113
+
114
+        return $this->mimeType[$this->storage->getId()][$this->path];
115
+    }
116
+
117
+    /**
118
+     * @return string
119
+     */
120
+    protected function detectMimetypeFromPath() {
121
+        $mimeType = $this->mimeTypeDetector->detectPath($this->path);
122
+        if ($mimeType !== 'application/octet-stream' && $mimeType !== false) {
123
+            return $mimeType;
124
+        }
125
+
126
+        if ($this->storage->instanceOfStorage('\OC\Files\Storage\Local')
127
+            || $this->storage->instanceOfStorage('\OC\Files\Storage\Home')
128
+            || $this->storage->instanceOfStorage('\OC\Files\ObjectStore\HomeObjectStoreStorage')) {
129
+            $localFile = $this->storage->getLocalFile($this->path);
130
+            if ($localFile !== false) {
131
+                $mimeType = $this->mimeTypeDetector->detect($localFile);
132
+                if ($mimeType !== false) {
133
+                    return $mimeType;
134
+                }
135
+            }
136
+
137
+            return 'application/octet-stream';
138
+        } else {
139
+            $handle = $this->storage->fopen($this->path, 'r');
140
+            $data = fread($handle, 8024);
141
+            fclose($handle);
142
+            $mimeType = $this->mimeTypeDetector->detectString($data);
143
+            if ($mimeType !== false) {
144
+                return $mimeType;
145
+            }
146
+
147
+            return 'application/octet-stream';
148
+        }
149
+    }
150
+
151
+    /**
152
+     * @return bool
153
+     */
154
+    protected function isWebDAVRequest() {
155
+        return substr($this->request->getScriptName(), 0 - strlen('/remote.php')) === '/remote.php' && (
156
+            $this->request->getPathInfo() === '/webdav' ||
157
+            strpos($this->request->getPathInfo(), '/webdav/') === 0 ||
158
+            $this->request->getPathInfo() === '/dav/files' ||
159
+            strpos($this->request->getPathInfo(), '/dav/files/') === 0
160
+        );
161
+    }
162 162
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/AbstractStringCheck.php 2 patches
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -28,94 +28,94 @@
 block discarded – undo
28 28
 
29 29
 abstract class AbstractStringCheck implements ICheck {
30 30
 
31
-	/** @var array[] Nested array: [Pattern => [ActualValue => Regex Result]] */
32
-	protected $matches;
31
+    /** @var array[] Nested array: [Pattern => [ActualValue => Regex Result]] */
32
+    protected $matches;
33 33
 
34
-	/** @var IL10N */
35
-	protected $l;
34
+    /** @var IL10N */
35
+    protected $l;
36 36
 
37
-	/**
38
-	 * @param IL10N $l
39
-	 */
40
-	public function __construct(IL10N $l) {
41
-		$this->l = $l;
42
-	}
37
+    /**
38
+     * @param IL10N $l
39
+     */
40
+    public function __construct(IL10N $l) {
41
+        $this->l = $l;
42
+    }
43 43
 
44
-	/**
45
-	 * @param IStorage $storage
46
-	 * @param string $path
47
-	 */
48
-	public function setFileInfo(IStorage $storage, $path) {
49
-		// Nothing changes here with a different path
50
-	}
44
+    /**
45
+     * @param IStorage $storage
46
+     * @param string $path
47
+     */
48
+    public function setFileInfo(IStorage $storage, $path) {
49
+        // Nothing changes here with a different path
50
+    }
51 51
 
52
-	/**
53
-	 * @return string
54
-	 */
55
-	abstract protected function getActualValue();
52
+    /**
53
+     * @return string
54
+     */
55
+    abstract protected function getActualValue();
56 56
 
57
-	/**
58
-	 * @param string $operator
59
-	 * @param string $value
60
-	 * @return bool
61
-	 */
62
-	public function executeCheck($operator, $value)  {
63
-		$actualValue = $this->getActualValue();
64
-		return $this->executeStringCheck($operator, $value, $actualValue);
65
-	}
57
+    /**
58
+     * @param string $operator
59
+     * @param string $value
60
+     * @return bool
61
+     */
62
+    public function executeCheck($operator, $value)  {
63
+        $actualValue = $this->getActualValue();
64
+        return $this->executeStringCheck($operator, $value, $actualValue);
65
+    }
66 66
 
67
-	/**
68
-	 * @param string $operator
69
-	 * @param string $checkValue
70
-	 * @param string $actualValue
71
-	 * @return bool
72
-	 */
73
-	protected function executeStringCheck($operator, $checkValue, $actualValue) {
74
-		if ($operator === 'is') {
75
-			return $checkValue === $actualValue;
76
-		} else if ($operator === '!is') {
77
-			return $checkValue !== $actualValue;
78
-		} else {
79
-			$match = $this->match($checkValue, $actualValue);
80
-			if ($operator === 'matches') {
81
-				return $match === 1;
82
-			} else {
83
-				return $match === 0;
84
-			}
85
-		}
86
-	}
67
+    /**
68
+     * @param string $operator
69
+     * @param string $checkValue
70
+     * @param string $actualValue
71
+     * @return bool
72
+     */
73
+    protected function executeStringCheck($operator, $checkValue, $actualValue) {
74
+        if ($operator === 'is') {
75
+            return $checkValue === $actualValue;
76
+        } else if ($operator === '!is') {
77
+            return $checkValue !== $actualValue;
78
+        } else {
79
+            $match = $this->match($checkValue, $actualValue);
80
+            if ($operator === 'matches') {
81
+                return $match === 1;
82
+            } else {
83
+                return $match === 0;
84
+            }
85
+        }
86
+    }
87 87
 
88
-	/**
89
-	 * @param string $operator
90
-	 * @param string $value
91
-	 * @throws \UnexpectedValueException
92
-	 */
93
-	public function validateCheck($operator, $value) {
94
-		if (!in_array($operator, ['is', '!is', 'matches', '!matches'])) {
95
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
96
-		}
88
+    /**
89
+     * @param string $operator
90
+     * @param string $value
91
+     * @throws \UnexpectedValueException
92
+     */
93
+    public function validateCheck($operator, $value) {
94
+        if (!in_array($operator, ['is', '!is', 'matches', '!matches'])) {
95
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
96
+        }
97 97
 
98
-		if (in_array($operator, ['matches', '!matches']) &&
99
-			  @preg_match($value, null) === false) {
100
-			throw new \UnexpectedValueException($this->l->t('The given regular expression is invalid'), 2);
101
-		}
102
-	}
98
+        if (in_array($operator, ['matches', '!matches']) &&
99
+              @preg_match($value, null) === false) {
100
+            throw new \UnexpectedValueException($this->l->t('The given regular expression is invalid'), 2);
101
+        }
102
+    }
103 103
 
104
-	/**
105
-	 * @param string $pattern
106
-	 * @param string $subject
107
-	 * @return int|bool
108
-	 */
109
-	protected function match($pattern, $subject) {
110
-		$patternHash = md5($pattern);
111
-		$subjectHash = md5($subject);
112
-		if (isset($this->matches[$patternHash][$subjectHash])) {
113
-			return $this->matches[$patternHash][$subjectHash];
114
-		}
115
-		if (!isset($this->matches[$patternHash])) {
116
-			$this->matches[$patternHash] = [];
117
-		}
118
-		$this->matches[$patternHash][$subjectHash] = preg_match($pattern, $subject);
119
-		return $this->matches[$patternHash][$subjectHash];
120
-	}
104
+    /**
105
+     * @param string $pattern
106
+     * @param string $subject
107
+     * @return int|bool
108
+     */
109
+    protected function match($pattern, $subject) {
110
+        $patternHash = md5($pattern);
111
+        $subjectHash = md5($subject);
112
+        if (isset($this->matches[$patternHash][$subjectHash])) {
113
+            return $this->matches[$patternHash][$subjectHash];
114
+        }
115
+        if (!isset($this->matches[$patternHash])) {
116
+            $this->matches[$patternHash] = [];
117
+        }
118
+        $this->matches[$patternHash][$subjectHash] = preg_match($pattern, $subject);
119
+        return $this->matches[$patternHash][$subjectHash];
120
+    }
121 121
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@
 block discarded – undo
59 59
 	 * @param string $value
60 60
 	 * @return bool
61 61
 	 */
62
-	public function executeCheck($operator, $value)  {
62
+	public function executeCheck($operator, $value) {
63 63
 		$actualValue = $this->getActualValue();
64 64
 		return $this->executeStringCheck($operator, $value, $actualValue);
65 65
 	}
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/FileSize.php 1 patch
Indentation   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -30,90 +30,90 @@
 block discarded – undo
30 30
 
31 31
 class FileSize implements ICheck {
32 32
 
33
-	/** @var int */
34
-	protected $size;
35
-
36
-	/** @var IL10N */
37
-	protected $l;
38
-
39
-	/** @var IRequest */
40
-	protected $request;
41
-
42
-	/**
43
-	 * @param IL10N $l
44
-	 * @param IRequest $request
45
-	 */
46
-	public function __construct(IL10N $l, IRequest $request) {
47
-		$this->l = $l;
48
-		$this->request = $request;
49
-	}
50
-
51
-	/**
52
-	 * @param IStorage $storage
53
-	 * @param string $path
54
-	 */
55
-	public function setFileInfo(IStorage $storage, $path) {
56
-	}
57
-
58
-	/**
59
-	 * @param string $operator
60
-	 * @param string $value
61
-	 * @return bool
62
-	 */
63
-	public function executeCheck($operator, $value) {
64
-		$size = $this->getFileSizeFromHeader();
65
-
66
-		$value = Util::computerFileSize($value);
67
-		if ($size !== false) {
68
-			switch ($operator) {
69
-				case 'less':
70
-					return $size < $value;
71
-				case '!less':
72
-					return $size >= $value;
73
-				case 'greater':
74
-					return $size > $value;
75
-				case '!greater':
76
-					return $size <= $value;
77
-			}
78
-		}
79
-		return false;
80
-	}
81
-
82
-	/**
83
-	 * @param string $operator
84
-	 * @param string $value
85
-	 * @throws \UnexpectedValueException
86
-	 */
87
-	public function validateCheck($operator, $value) {
88
-		if (!in_array($operator, ['less', '!less', 'greater', '!greater'])) {
89
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
90
-		}
91
-
92
-		if (!preg_match('/^[0-9]+[ ]?[kmgt]?b$/i', $value)) {
93
-			throw new \UnexpectedValueException($this->l->t('The given file size is invalid'), 2);
94
-		}
95
-	}
96
-
97
-	/**
98
-	 * @return string
99
-	 */
100
-	protected function getFileSizeFromHeader() {
101
-		if ($this->size !== null) {
102
-			return $this->size;
103
-		}
104
-
105
-		$size = $this->request->getHeader('OC-Total-Length');
106
-		if ($size === null) {
107
-			if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
108
-				$size = $this->request->getHeader('Content-Length');
109
-			}
110
-		}
111
-
112
-		if ($size === null) {
113
-			$size = false;
114
-		}
115
-
116
-		$this->size = $size;
117
-		return $this->size;
118
-	}
33
+    /** @var int */
34
+    protected $size;
35
+
36
+    /** @var IL10N */
37
+    protected $l;
38
+
39
+    /** @var IRequest */
40
+    protected $request;
41
+
42
+    /**
43
+     * @param IL10N $l
44
+     * @param IRequest $request
45
+     */
46
+    public function __construct(IL10N $l, IRequest $request) {
47
+        $this->l = $l;
48
+        $this->request = $request;
49
+    }
50
+
51
+    /**
52
+     * @param IStorage $storage
53
+     * @param string $path
54
+     */
55
+    public function setFileInfo(IStorage $storage, $path) {
56
+    }
57
+
58
+    /**
59
+     * @param string $operator
60
+     * @param string $value
61
+     * @return bool
62
+     */
63
+    public function executeCheck($operator, $value) {
64
+        $size = $this->getFileSizeFromHeader();
65
+
66
+        $value = Util::computerFileSize($value);
67
+        if ($size !== false) {
68
+            switch ($operator) {
69
+                case 'less':
70
+                    return $size < $value;
71
+                case '!less':
72
+                    return $size >= $value;
73
+                case 'greater':
74
+                    return $size > $value;
75
+                case '!greater':
76
+                    return $size <= $value;
77
+            }
78
+        }
79
+        return false;
80
+    }
81
+
82
+    /**
83
+     * @param string $operator
84
+     * @param string $value
85
+     * @throws \UnexpectedValueException
86
+     */
87
+    public function validateCheck($operator, $value) {
88
+        if (!in_array($operator, ['less', '!less', 'greater', '!greater'])) {
89
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
90
+        }
91
+
92
+        if (!preg_match('/^[0-9]+[ ]?[kmgt]?b$/i', $value)) {
93
+            throw new \UnexpectedValueException($this->l->t('The given file size is invalid'), 2);
94
+        }
95
+    }
96
+
97
+    /**
98
+     * @return string
99
+     */
100
+    protected function getFileSizeFromHeader() {
101
+        if ($this->size !== null) {
102
+            return $this->size;
103
+        }
104
+
105
+        $size = $this->request->getHeader('OC-Total-Length');
106
+        if ($size === null) {
107
+            if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
108
+                $size = $this->request->getHeader('Content-Length');
109
+            }
110
+        }
111
+
112
+        if ($size === null) {
113
+            $size = false;
114
+        }
115
+
116
+        $this->size = $size;
117
+        return $this->size;
118
+    }
119 119
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/RequestTime.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -29,101 +29,101 @@
 block discarded – undo
29 29
 
30 30
 class RequestTime implements ICheck {
31 31
 
32
-	const REGEX_TIME = '([0-1][0-9]|2[0-3]):([0-5][0-9])';
33
-	const REGEX_TIMEZONE = '([a-zA-Z]+(?:\\/[a-zA-Z\-\_]+)+)';
34
-
35
-	/** @var bool[] */
36
-	protected $cachedResults;
37
-
38
-	/** @var IL10N */
39
-	protected $l;
40
-
41
-	/** @var ITimeFactory */
42
-	protected $timeFactory;
43
-
44
-	/**
45
-	 * @param ITimeFactory $timeFactory
46
-	 */
47
-	public function __construct(IL10N $l, ITimeFactory $timeFactory) {
48
-		$this->l = $l;
49
-		$this->timeFactory = $timeFactory;
50
-	}
51
-
52
-	/**
53
-	 * @param IStorage $storage
54
-	 * @param string $path
55
-	 */
56
-	public function setFileInfo(IStorage $storage, $path) {
57
-		// A different path doesn't change time, so nothing to do here.
58
-	}
59
-
60
-	/**
61
-	 * @param string $operator
62
-	 * @param string $value
63
-	 * @return bool
64
-	 */
65
-	public function executeCheck($operator, $value) {
66
-		$valueHash = md5($value);
67
-
68
-		if (isset($this->cachedResults[$valueHash])) {
69
-			return $this->cachedResults[$valueHash];
70
-		}
71
-
72
-		$timestamp = $this->timeFactory->getTime();
73
-
74
-		$values = json_decode($value, true);
75
-		$timestamp1 = $this->getTimestamp($timestamp, $values[0]);
76
-		$timestamp2 = $this->getTimestamp($timestamp, $values[1]);
77
-
78
-		if ($timestamp1 < $timestamp2) {
79
-			$in = $timestamp1 <= $timestamp && $timestamp <= $timestamp2;
80
-		} else {
81
-			$in = $timestamp1 <= $timestamp || $timestamp <= $timestamp2;
82
-		}
83
-
84
-		return ($operator === 'in') ? $in : !$in;
85
-	}
86
-
87
-	/**
88
-	 * @param int $currentTimestamp
89
-	 * @param string $value Format: "H:i e"
90
-	 * @return int
91
-	 */
92
-	protected function getTimestamp($currentTimestamp, $value) {
93
-		list($time1, $timezone1) = explode(' ', $value);
94
-		list($hour1, $minute1) = explode(':', $time1);
95
-		$date1 = new \DateTime('now', new \DateTimeZone($timezone1));
96
-		$date1->setTimestamp($currentTimestamp);
97
-		$date1->setTime($hour1, $minute1);
98
-
99
-		return $date1->getTimestamp();
100
-	}
101
-
102
-	/**
103
-	 * @param string $operator
104
-	 * @param string $value
105
-	 * @throws \UnexpectedValueException
106
-	 */
107
-	public function validateCheck($operator, $value) {
108
-		if (!in_array($operator, ['in', '!in'])) {
109
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
110
-		}
111
-
112
-		$regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"';
113
-		$result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches);
114
-		if (!$result) {
115
-			throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2);
116
-		}
117
-
118
-		$values = json_decode($value, true);
119
-		$time1 = \DateTime::createFromFormat('H:i e', $values[0]);
120
-		if ($time1 === false) {
121
-			throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3);
122
-		}
123
-
124
-		$time2 = \DateTime::createFromFormat('H:i e', $values[1]);
125
-		if ($time2 === false) {
126
-			throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4);
127
-		}
128
-	}
32
+    const REGEX_TIME = '([0-1][0-9]|2[0-3]):([0-5][0-9])';
33
+    const REGEX_TIMEZONE = '([a-zA-Z]+(?:\\/[a-zA-Z\-\_]+)+)';
34
+
35
+    /** @var bool[] */
36
+    protected $cachedResults;
37
+
38
+    /** @var IL10N */
39
+    protected $l;
40
+
41
+    /** @var ITimeFactory */
42
+    protected $timeFactory;
43
+
44
+    /**
45
+     * @param ITimeFactory $timeFactory
46
+     */
47
+    public function __construct(IL10N $l, ITimeFactory $timeFactory) {
48
+        $this->l = $l;
49
+        $this->timeFactory = $timeFactory;
50
+    }
51
+
52
+    /**
53
+     * @param IStorage $storage
54
+     * @param string $path
55
+     */
56
+    public function setFileInfo(IStorage $storage, $path) {
57
+        // A different path doesn't change time, so nothing to do here.
58
+    }
59
+
60
+    /**
61
+     * @param string $operator
62
+     * @param string $value
63
+     * @return bool
64
+     */
65
+    public function executeCheck($operator, $value) {
66
+        $valueHash = md5($value);
67
+
68
+        if (isset($this->cachedResults[$valueHash])) {
69
+            return $this->cachedResults[$valueHash];
70
+        }
71
+
72
+        $timestamp = $this->timeFactory->getTime();
73
+
74
+        $values = json_decode($value, true);
75
+        $timestamp1 = $this->getTimestamp($timestamp, $values[0]);
76
+        $timestamp2 = $this->getTimestamp($timestamp, $values[1]);
77
+
78
+        if ($timestamp1 < $timestamp2) {
79
+            $in = $timestamp1 <= $timestamp && $timestamp <= $timestamp2;
80
+        } else {
81
+            $in = $timestamp1 <= $timestamp || $timestamp <= $timestamp2;
82
+        }
83
+
84
+        return ($operator === 'in') ? $in : !$in;
85
+    }
86
+
87
+    /**
88
+     * @param int $currentTimestamp
89
+     * @param string $value Format: "H:i e"
90
+     * @return int
91
+     */
92
+    protected function getTimestamp($currentTimestamp, $value) {
93
+        list($time1, $timezone1) = explode(' ', $value);
94
+        list($hour1, $minute1) = explode(':', $time1);
95
+        $date1 = new \DateTime('now', new \DateTimeZone($timezone1));
96
+        $date1->setTimestamp($currentTimestamp);
97
+        $date1->setTime($hour1, $minute1);
98
+
99
+        return $date1->getTimestamp();
100
+    }
101
+
102
+    /**
103
+     * @param string $operator
104
+     * @param string $value
105
+     * @throws \UnexpectedValueException
106
+     */
107
+    public function validateCheck($operator, $value) {
108
+        if (!in_array($operator, ['in', '!in'])) {
109
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
110
+        }
111
+
112
+        $regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"';
113
+        $result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches);
114
+        if (!$result) {
115
+            throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2);
116
+        }
117
+
118
+        $values = json_decode($value, true);
119
+        $time1 = \DateTime::createFromFormat('H:i e', $values[0]);
120
+        if ($time1 === false) {
121
+            throw new \UnexpectedValueException($this->l->t('The given start time is invalid'), 3);
122
+        }
123
+
124
+        $time2 = \DateTime::createFromFormat('H:i e', $values[1]);
125
+        if ($time2 === false) {
126
+            throw new \UnexpectedValueException($this->l->t('The given end time is invalid'), 4);
127
+        }
128
+    }
129 129
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -109,8 +109,8 @@
 block discarded – undo
109 109
 			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
110 110
 		}
111 111
 
112
-		$regexValue = '\"' . self::REGEX_TIME . ' ' . self::REGEX_TIMEZONE . '\"';
113
-		$result = preg_match('/^\[' . $regexValue . ',' . $regexValue . '\]$/', $value, $matches);
112
+		$regexValue = '\"'.self::REGEX_TIME.' '.self::REGEX_TIMEZONE.'\"';
113
+		$result = preg_match('/^\['.$regexValue.','.$regexValue.'\]$/', $value, $matches);
114 114
 		if (!$result) {
115 115
 			throw new \UnexpectedValueException($this->l->t('The given time span is invalid'), 2);
116 116
 		}
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/UserGroupMembership.php 1 patch
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -31,84 +31,84 @@
 block discarded – undo
31 31
 
32 32
 class UserGroupMembership implements ICheck {
33 33
 
34
-	/** @var string */
35
-	protected $cachedUser;
36
-
37
-	/** @var string[] */
38
-	protected $cachedGroupMemberships;
39
-
40
-	/** @var IUserSession */
41
-	protected $userSession;
42
-
43
-	/** @var IGroupManager */
44
-	protected $groupManager;
45
-
46
-	/** @var IL10N */
47
-	protected $l;
48
-
49
-	/**
50
-	 * @param IUserSession $userSession
51
-	 * @param IGroupManager $groupManager
52
-	 * @param IL10N $l
53
-	 */
54
-	public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) {
55
-		$this->userSession = $userSession;
56
-		$this->groupManager = $groupManager;
57
-		$this->l = $l;
58
-	}
59
-
60
-	/**
61
-	 * @param IStorage $storage
62
-	 * @param string $path
63
-	 */
64
-	public function setFileInfo(IStorage $storage, $path) {
65
-		// A different path doesn't change group memberships, so nothing to do here.
66
-	}
67
-
68
-	/**
69
-	 * @param string $operator
70
-	 * @param string $value
71
-	 * @return bool
72
-	 */
73
-	public function executeCheck($operator, $value) {
74
-		$user = $this->userSession->getUser();
75
-
76
-		if ($user instanceof IUser) {
77
-			$groupIds = $this->getUserGroups($user);
78
-			return ($operator === 'is') === in_array($value, $groupIds);
79
-		} else {
80
-			return $operator !== 'is';
81
-		}
82
-	}
83
-
84
-
85
-	/**
86
-	 * @param string $operator
87
-	 * @param string $value
88
-	 * @throws \UnexpectedValueException
89
-	 */
90
-	public function validateCheck($operator, $value) {
91
-		if (!in_array($operator, ['is', '!is'])) {
92
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
93
-		}
94
-
95
-		if (!$this->groupManager->groupExists($value)) {
96
-			throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2);
97
-		}
98
-	}
99
-
100
-	/**
101
-	 * @param IUser $user
102
-	 * @return string[]
103
-	 */
104
-	protected function getUserGroups(IUser $user) {
105
-		$uid = $user->getUID();
106
-
107
-		if ($this->cachedUser !== $uid) {
108
-			$this->cachedUser = $uid;
109
-			$this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user);
110
-		}
111
-
112
-		return $this->cachedGroupMemberships;
113
-	}
34
+    /** @var string */
35
+    protected $cachedUser;
36
+
37
+    /** @var string[] */
38
+    protected $cachedGroupMemberships;
39
+
40
+    /** @var IUserSession */
41
+    protected $userSession;
42
+
43
+    /** @var IGroupManager */
44
+    protected $groupManager;
45
+
46
+    /** @var IL10N */
47
+    protected $l;
48
+
49
+    /**
50
+     * @param IUserSession $userSession
51
+     * @param IGroupManager $groupManager
52
+     * @param IL10N $l
53
+     */
54
+    public function __construct(IUserSession $userSession, IGroupManager $groupManager, IL10N $l) {
55
+        $this->userSession = $userSession;
56
+        $this->groupManager = $groupManager;
57
+        $this->l = $l;
58
+    }
59
+
60
+    /**
61
+     * @param IStorage $storage
62
+     * @param string $path
63
+     */
64
+    public function setFileInfo(IStorage $storage, $path) {
65
+        // A different path doesn't change group memberships, so nothing to do here.
66
+    }
67
+
68
+    /**
69
+     * @param string $operator
70
+     * @param string $value
71
+     * @return bool
72
+     */
73
+    public function executeCheck($operator, $value) {
74
+        $user = $this->userSession->getUser();
75
+
76
+        if ($user instanceof IUser) {
77
+            $groupIds = $this->getUserGroups($user);
78
+            return ($operator === 'is') === in_array($value, $groupIds);
79
+        } else {
80
+            return $operator !== 'is';
81
+        }
82
+    }
83
+
84
+
85
+    /**
86
+     * @param string $operator
87
+     * @param string $value
88
+     * @throws \UnexpectedValueException
89
+     */
90
+    public function validateCheck($operator, $value) {
91
+        if (!in_array($operator, ['is', '!is'])) {
92
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
93
+        }
94
+
95
+        if (!$this->groupManager->groupExists($value)) {
96
+            throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2);
97
+        }
98
+    }
99
+
100
+    /**
101
+     * @param IUser $user
102
+     * @return string[]
103
+     */
104
+    protected function getUserGroups(IUser $user) {
105
+        $uid = $user->getUID();
106
+
107
+        if ($this->cachedUser !== $uid) {
108
+            $this->cachedUser = $uid;
109
+            $this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user);
110
+        }
111
+
112
+        return $this->cachedGroupMemberships;
113
+    }
114 114
 }
Please login to merge, or discard this patch.