Passed
Push — master ( 902645...6d7fee )
by Joas
15:37 queued 12s
created
lib/CalDAV/Reminder/NotificationProvider/ProviderNotAvailableException.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -25,15 +25,15 @@
 block discarded – undo
25 25
 
26 26
 class ProviderNotAvailableException extends \Exception {
27 27
 
28
-	/**
29
-	 * ProviderNotAvailableException constructor.
30
-	 *
31
-	 * @since 16.0.0
32
-	 *
33
-	 * @param string $type ReminderType
34
-	 */
35
-	public function __construct(string $type) {
36
-		parent::__construct("No notification provider for type $type available");
37
-	}
28
+    /**
29
+     * ProviderNotAvailableException constructor.
30
+     *
31
+     * @since 16.0.0
32
+     *
33
+     * @param string $type ReminderType
34
+     */
35
+    public function __construct(string $type) {
36
+        parent::__construct("No notification provider for type $type available");
37
+    }
38 38
 
39 39
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Reminder/NotificationProvider/AudioProvider.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,6 +32,6 @@
 block discarded – undo
32 32
  */
33 33
 class AudioProvider extends PushProvider {
34 34
 
35
-	/** @var string */
36
-	public const NOTIFICATION_TYPE = 'AUDIO';
35
+    /** @var string */
36
+    public const NOTIFICATION_TYPE = 'AUDIO';
37 37
 }
Please login to merge, or discard this patch.
apps/dav/lib/CalDAV/Reminder/Backend.php 1 patch
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -35,185 +35,185 @@
 block discarded – undo
35 35
  */
36 36
 class Backend {
37 37
 
38
-	/** @var IDBConnection */
39
-	protected $db;
40
-
41
-	/** @var ITimeFactory */
42
-	private $timeFactory;
43
-
44
-	/**
45
-	 * Backend constructor.
46
-	 *
47
-	 * @param IDBConnection $db
48
-	 * @param ITimeFactory $timeFactory
49
-	 */
50
-	public function __construct(IDBConnection $db,
51
-								ITimeFactory $timeFactory) {
52
-		$this->db = $db;
53
-		$this->timeFactory = $timeFactory;
54
-	}
55
-
56
-	/**
57
-	 * Get all reminders with a notification date before now
58
-	 *
59
-	 * @return array
60
-	 * @throws \Exception
61
-	 */
62
-	public function getRemindersToProcess():array {
63
-		$query = $this->db->getQueryBuilder();
64
-		$query->select(['cr.*', 'co.calendardata', 'c.displayname', 'c.principaluri'])
65
-			->from('calendar_reminders', 'cr')
66
-			->where($query->expr()->lte('cr.notification_date', $query->createNamedParameter($this->timeFactory->getTime())))
67
-			->leftJoin('cr', 'calendarobjects', 'co', $query->expr()->eq('cr.object_id', 'co.id'))
68
-			->leftJoin('cr', 'calendars', 'c', $query->expr()->eq('cr.calendar_id', 'c.id'));
69
-		$stmt = $query->execute();
70
-
71
-		return array_map(
72
-			[$this, 'fixRowTyping'],
73
-			$stmt->fetchAll()
74
-		);
75
-	}
76
-
77
-	/**
78
-	 * Get all scheduled reminders for an event
79
-	 *
80
-	 * @param int $objectId
81
-	 * @return array
82
-	 */
83
-	public function getAllScheduledRemindersForEvent(int $objectId):array {
84
-		$query = $this->db->getQueryBuilder();
85
-		$query->select('*')
86
-			->from('calendar_reminders')
87
-			->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)));
88
-		$stmt = $query->execute();
89
-
90
-		return array_map(
91
-			[$this, 'fixRowTyping'],
92
-			$stmt->fetchAll()
93
-		);
94
-	}
95
-
96
-	/**
97
-	 * Insert a new reminder into the database
98
-	 *
99
-	 * @param int $calendarId
100
-	 * @param int $objectId
101
-	 * @param string $uid
102
-	 * @param bool $isRecurring
103
-	 * @param int $recurrenceId
104
-	 * @param bool $isRecurrenceException
105
-	 * @param string $eventHash
106
-	 * @param string $alarmHash
107
-	 * @param string $type
108
-	 * @param bool $isRelative
109
-	 * @param int $notificationDate
110
-	 * @param bool $isRepeatBased
111
-	 * @return int The insert id
112
-	 */
113
-	public function insertReminder(int $calendarId,
114
-								   int $objectId,
115
-								   string $uid,
116
-								   bool $isRecurring,
117
-								   int $recurrenceId,
118
-								   bool $isRecurrenceException,
119
-								   string $eventHash,
120
-								   string $alarmHash,
121
-								   string $type,
122
-								   bool $isRelative,
123
-								   int $notificationDate,
124
-								   bool $isRepeatBased):int {
125
-		$query = $this->db->getQueryBuilder();
126
-		$query->insert('calendar_reminders')
127
-			->values([
128
-				'calendar_id' => $query->createNamedParameter($calendarId),
129
-				'object_id' => $query->createNamedParameter($objectId),
130
-				'uid' => $query->createNamedParameter($uid),
131
-				'is_recurring' => $query->createNamedParameter($isRecurring ? 1 : 0),
132
-				'recurrence_id' => $query->createNamedParameter($recurrenceId),
133
-				'is_recurrence_exception' => $query->createNamedParameter($isRecurrenceException ? 1 : 0),
134
-				'event_hash' => $query->createNamedParameter($eventHash),
135
-				'alarm_hash' => $query->createNamedParameter($alarmHash),
136
-				'type' => $query->createNamedParameter($type),
137
-				'is_relative' => $query->createNamedParameter($isRelative ? 1 : 0),
138
-				'notification_date' => $query->createNamedParameter($notificationDate),
139
-				'is_repeat_based' => $query->createNamedParameter($isRepeatBased ? 1 : 0),
140
-			])
141
-			->execute();
142
-
143
-		return $query->getLastInsertId();
144
-	}
145
-
146
-	/**
147
-	 * Sets a new notificationDate on an existing reminder
148
-	 *
149
-	 * @param int $reminderId
150
-	 * @param int $newNotificationDate
151
-	 */
152
-	public function updateReminder(int $reminderId,
153
-								   int $newNotificationDate):void {
154
-		$query = $this->db->getQueryBuilder();
155
-		$query->update('calendar_reminders')
156
-			->set('notification_date', $query->createNamedParameter($newNotificationDate))
157
-			->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
158
-			->execute();
159
-	}
160
-
161
-	/**
162
-	 * Remove a reminder by it's id
163
-	 *
164
-	 * @param integer $reminderId
165
-	 * @return void
166
-	 */
167
-	public function removeReminder(int $reminderId):void {
168
-		$query = $this->db->getQueryBuilder();
169
-
170
-		$query->delete('calendar_reminders')
171
-			->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
172
-			->execute();
173
-	}
174
-
175
-	/**
176
-	 * Cleans reminders in database
177
-	 *
178
-	 * @param int $objectId
179
-	 */
180
-	public function cleanRemindersForEvent(int $objectId):void {
181
-		$query = $this->db->getQueryBuilder();
182
-
183
-		$query->delete('calendar_reminders')
184
-			->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)))
185
-			->execute();
186
-	}
187
-
188
-	/**
189
-	 * Remove all reminders for a calendar
190
-	 *
191
-	 * @param int $calendarId
192
-	 * @return void
193
-	 */
194
-	public function cleanRemindersForCalendar(int $calendarId):void {
195
-		$query = $this->db->getQueryBuilder();
196
-
197
-		$query->delete('calendar_reminders')
198
-			->where($query->expr()->eq('calendar_id', $query->createNamedParameter($calendarId)))
199
-			->execute();
200
-	}
201
-
202
-	/**
203
-	 * @param array $row
204
-	 * @return array
205
-	 */
206
-	private function fixRowTyping(array $row): array {
207
-		$row['id'] = (int) $row['id'];
208
-		$row['calendar_id'] = (int) $row['calendar_id'];
209
-		$row['object_id'] = (int) $row['object_id'];
210
-		$row['is_recurring'] = (bool) $row['is_recurring'];
211
-		$row['recurrence_id'] = (int) $row['recurrence_id'];
212
-		$row['is_recurrence_exception'] = (bool) $row['is_recurrence_exception'];
213
-		$row['is_relative'] = (bool) $row['is_relative'];
214
-		$row['notification_date'] = (int) $row['notification_date'];
215
-		$row['is_repeat_based'] = (bool) $row['is_repeat_based'];
216
-
217
-		return $row;
218
-	}
38
+    /** @var IDBConnection */
39
+    protected $db;
40
+
41
+    /** @var ITimeFactory */
42
+    private $timeFactory;
43
+
44
+    /**
45
+     * Backend constructor.
46
+     *
47
+     * @param IDBConnection $db
48
+     * @param ITimeFactory $timeFactory
49
+     */
50
+    public function __construct(IDBConnection $db,
51
+                                ITimeFactory $timeFactory) {
52
+        $this->db = $db;
53
+        $this->timeFactory = $timeFactory;
54
+    }
55
+
56
+    /**
57
+     * Get all reminders with a notification date before now
58
+     *
59
+     * @return array
60
+     * @throws \Exception
61
+     */
62
+    public function getRemindersToProcess():array {
63
+        $query = $this->db->getQueryBuilder();
64
+        $query->select(['cr.*', 'co.calendardata', 'c.displayname', 'c.principaluri'])
65
+            ->from('calendar_reminders', 'cr')
66
+            ->where($query->expr()->lte('cr.notification_date', $query->createNamedParameter($this->timeFactory->getTime())))
67
+            ->leftJoin('cr', 'calendarobjects', 'co', $query->expr()->eq('cr.object_id', 'co.id'))
68
+            ->leftJoin('cr', 'calendars', 'c', $query->expr()->eq('cr.calendar_id', 'c.id'));
69
+        $stmt = $query->execute();
70
+
71
+        return array_map(
72
+            [$this, 'fixRowTyping'],
73
+            $stmt->fetchAll()
74
+        );
75
+    }
76
+
77
+    /**
78
+     * Get all scheduled reminders for an event
79
+     *
80
+     * @param int $objectId
81
+     * @return array
82
+     */
83
+    public function getAllScheduledRemindersForEvent(int $objectId):array {
84
+        $query = $this->db->getQueryBuilder();
85
+        $query->select('*')
86
+            ->from('calendar_reminders')
87
+            ->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)));
88
+        $stmt = $query->execute();
89
+
90
+        return array_map(
91
+            [$this, 'fixRowTyping'],
92
+            $stmt->fetchAll()
93
+        );
94
+    }
95
+
96
+    /**
97
+     * Insert a new reminder into the database
98
+     *
99
+     * @param int $calendarId
100
+     * @param int $objectId
101
+     * @param string $uid
102
+     * @param bool $isRecurring
103
+     * @param int $recurrenceId
104
+     * @param bool $isRecurrenceException
105
+     * @param string $eventHash
106
+     * @param string $alarmHash
107
+     * @param string $type
108
+     * @param bool $isRelative
109
+     * @param int $notificationDate
110
+     * @param bool $isRepeatBased
111
+     * @return int The insert id
112
+     */
113
+    public function insertReminder(int $calendarId,
114
+                                    int $objectId,
115
+                                    string $uid,
116
+                                    bool $isRecurring,
117
+                                    int $recurrenceId,
118
+                                    bool $isRecurrenceException,
119
+                                    string $eventHash,
120
+                                    string $alarmHash,
121
+                                    string $type,
122
+                                    bool $isRelative,
123
+                                    int $notificationDate,
124
+                                    bool $isRepeatBased):int {
125
+        $query = $this->db->getQueryBuilder();
126
+        $query->insert('calendar_reminders')
127
+            ->values([
128
+                'calendar_id' => $query->createNamedParameter($calendarId),
129
+                'object_id' => $query->createNamedParameter($objectId),
130
+                'uid' => $query->createNamedParameter($uid),
131
+                'is_recurring' => $query->createNamedParameter($isRecurring ? 1 : 0),
132
+                'recurrence_id' => $query->createNamedParameter($recurrenceId),
133
+                'is_recurrence_exception' => $query->createNamedParameter($isRecurrenceException ? 1 : 0),
134
+                'event_hash' => $query->createNamedParameter($eventHash),
135
+                'alarm_hash' => $query->createNamedParameter($alarmHash),
136
+                'type' => $query->createNamedParameter($type),
137
+                'is_relative' => $query->createNamedParameter($isRelative ? 1 : 0),
138
+                'notification_date' => $query->createNamedParameter($notificationDate),
139
+                'is_repeat_based' => $query->createNamedParameter($isRepeatBased ? 1 : 0),
140
+            ])
141
+            ->execute();
142
+
143
+        return $query->getLastInsertId();
144
+    }
145
+
146
+    /**
147
+     * Sets a new notificationDate on an existing reminder
148
+     *
149
+     * @param int $reminderId
150
+     * @param int $newNotificationDate
151
+     */
152
+    public function updateReminder(int $reminderId,
153
+                                    int $newNotificationDate):void {
154
+        $query = $this->db->getQueryBuilder();
155
+        $query->update('calendar_reminders')
156
+            ->set('notification_date', $query->createNamedParameter($newNotificationDate))
157
+            ->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
158
+            ->execute();
159
+    }
160
+
161
+    /**
162
+     * Remove a reminder by it's id
163
+     *
164
+     * @param integer $reminderId
165
+     * @return void
166
+     */
167
+    public function removeReminder(int $reminderId):void {
168
+        $query = $this->db->getQueryBuilder();
169
+
170
+        $query->delete('calendar_reminders')
171
+            ->where($query->expr()->eq('id', $query->createNamedParameter($reminderId)))
172
+            ->execute();
173
+    }
174
+
175
+    /**
176
+     * Cleans reminders in database
177
+     *
178
+     * @param int $objectId
179
+     */
180
+    public function cleanRemindersForEvent(int $objectId):void {
181
+        $query = $this->db->getQueryBuilder();
182
+
183
+        $query->delete('calendar_reminders')
184
+            ->where($query->expr()->eq('object_id', $query->createNamedParameter($objectId)))
185
+            ->execute();
186
+    }
187
+
188
+    /**
189
+     * Remove all reminders for a calendar
190
+     *
191
+     * @param int $calendarId
192
+     * @return void
193
+     */
194
+    public function cleanRemindersForCalendar(int $calendarId):void {
195
+        $query = $this->db->getQueryBuilder();
196
+
197
+        $query->delete('calendar_reminders')
198
+            ->where($query->expr()->eq('calendar_id', $query->createNamedParameter($calendarId)))
199
+            ->execute();
200
+    }
201
+
202
+    /**
203
+     * @param array $row
204
+     * @return array
205
+     */
206
+    private function fixRowTyping(array $row): array {
207
+        $row['id'] = (int) $row['id'];
208
+        $row['calendar_id'] = (int) $row['calendar_id'];
209
+        $row['object_id'] = (int) $row['object_id'];
210
+        $row['is_recurring'] = (bool) $row['is_recurring'];
211
+        $row['recurrence_id'] = (int) $row['recurrence_id'];
212
+        $row['is_recurrence_exception'] = (bool) $row['is_recurrence_exception'];
213
+        $row['is_relative'] = (bool) $row['is_relative'];
214
+        $row['notification_date'] = (int) $row['notification_date'];
215
+        $row['is_repeat_based'] = (bool) $row['is_repeat_based'];
216
+
217
+        return $row;
218
+    }
219 219
 }
Please login to merge, or discard this patch.
lib/private/Repair/NC16/ClearCollectionsAccessCache.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -30,29 +30,29 @@
 block discarded – undo
30 30
 
31 31
 class ClearCollectionsAccessCache implements IRepairStep {
32 32
 
33
-	/** @var IConfig */
34
-	private $config;
35
-
36
-	/** @var IManager|Manager */
37
-	private $manager;
38
-
39
-	public function __construct(IConfig $config, IManager $manager) {
40
-		$this->config = $config;
41
-		$this->manager = $manager;
42
-	}
43
-
44
-	public function getName(): string {
45
-		return 'Clear access cache of projects';
46
-	}
47
-
48
-	private function shouldRun(): bool {
49
-		$versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
50
-		return version_compare($versionFromBeforeUpdate, '17.0.0.3', '<=');
51
-	}
52
-
53
-	public function run(IOutput $output): void {
54
-		if ($this->shouldRun()) {
55
-			$this->manager->invalidateAccessCacheForAllCollections();
56
-		}
57
-	}
33
+    /** @var IConfig */
34
+    private $config;
35
+
36
+    /** @var IManager|Manager */
37
+    private $manager;
38
+
39
+    public function __construct(IConfig $config, IManager $manager) {
40
+        $this->config = $config;
41
+        $this->manager = $manager;
42
+    }
43
+
44
+    public function getName(): string {
45
+        return 'Clear access cache of projects';
46
+    }
47
+
48
+    private function shouldRun(): bool {
49
+        $versionFromBeforeUpdate = $this->config->getSystemValue('version', '0.0.0.0');
50
+        return version_compare($versionFromBeforeUpdate, '17.0.0.3', '<=');
51
+    }
52
+
53
+    public function run(IOutput $output): void {
54
+        if ($this->shouldRun()) {
55
+            $this->manager->invalidateAccessCacheForAllCollections();
56
+        }
57
+    }
58 58
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/FileSize.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -31,91 +31,91 @@
 block discarded – undo
31 31
 
32 32
 class FileSize implements ICheck {
33 33
 
34
-	/** @var int */
35
-	protected $size;
36
-
37
-	/** @var IL10N */
38
-	protected $l;
39
-
40
-	/** @var IRequest */
41
-	protected $request;
42
-
43
-	/**
44
-	 * @param IL10N $l
45
-	 * @param IRequest $request
46
-	 */
47
-	public function __construct(IL10N $l, IRequest $request) {
48
-		$this->l = $l;
49
-		$this->request = $request;
50
-	}
51
-
52
-	/**
53
-	 * @param string $operator
54
-	 * @param string $value
55
-	 * @return bool
56
-	 */
57
-	public function executeCheck($operator, $value) {
58
-		$size = $this->getFileSizeFromHeader();
59
-
60
-		$value = Util::computerFileSize($value);
61
-		if ($size !== false) {
62
-			switch ($operator) {
63
-				case 'less':
64
-					return $size < $value;
65
-				case '!less':
66
-					return $size >= $value;
67
-				case 'greater':
68
-					return $size > $value;
69
-				case '!greater':
70
-					return $size <= $value;
71
-			}
72
-		}
73
-		return false;
74
-	}
75
-
76
-	/**
77
-	 * @param string $operator
78
-	 * @param string $value
79
-	 * @throws \UnexpectedValueException
80
-	 */
81
-	public function validateCheck($operator, $value) {
82
-		if (!in_array($operator, ['less', '!less', 'greater', '!greater'])) {
83
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
84
-		}
85
-
86
-		if (!preg_match('/^[0-9]+[ ]?[kmgt]?b$/i', $value)) {
87
-			throw new \UnexpectedValueException($this->l->t('The given file size is invalid'), 2);
88
-		}
89
-	}
90
-
91
-	/**
92
-	 * @return string
93
-	 */
94
-	protected function getFileSizeFromHeader() {
95
-		if ($this->size !== null) {
96
-			return $this->size;
97
-		}
98
-
99
-		$size = $this->request->getHeader('OC-Total-Length');
100
-		if ($size === '') {
101
-			if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
102
-				$size = $this->request->getHeader('Content-Length');
103
-			}
104
-		}
105
-
106
-		if ($size === '') {
107
-			$size = false;
108
-		}
109
-
110
-		$this->size = $size;
111
-		return $this->size;
112
-	}
113
-
114
-	public function supportedEntities(): array {
115
-		return [ File::class ];
116
-	}
117
-
118
-	public function isAvailableForScope(int $scope): bool {
119
-		return true;
120
-	}
34
+    /** @var int */
35
+    protected $size;
36
+
37
+    /** @var IL10N */
38
+    protected $l;
39
+
40
+    /** @var IRequest */
41
+    protected $request;
42
+
43
+    /**
44
+     * @param IL10N $l
45
+     * @param IRequest $request
46
+     */
47
+    public function __construct(IL10N $l, IRequest $request) {
48
+        $this->l = $l;
49
+        $this->request = $request;
50
+    }
51
+
52
+    /**
53
+     * @param string $operator
54
+     * @param string $value
55
+     * @return bool
56
+     */
57
+    public function executeCheck($operator, $value) {
58
+        $size = $this->getFileSizeFromHeader();
59
+
60
+        $value = Util::computerFileSize($value);
61
+        if ($size !== false) {
62
+            switch ($operator) {
63
+                case 'less':
64
+                    return $size < $value;
65
+                case '!less':
66
+                    return $size >= $value;
67
+                case 'greater':
68
+                    return $size > $value;
69
+                case '!greater':
70
+                    return $size <= $value;
71
+            }
72
+        }
73
+        return false;
74
+    }
75
+
76
+    /**
77
+     * @param string $operator
78
+     * @param string $value
79
+     * @throws \UnexpectedValueException
80
+     */
81
+    public function validateCheck($operator, $value) {
82
+        if (!in_array($operator, ['less', '!less', 'greater', '!greater'])) {
83
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
84
+        }
85
+
86
+        if (!preg_match('/^[0-9]+[ ]?[kmgt]?b$/i', $value)) {
87
+            throw new \UnexpectedValueException($this->l->t('The given file size is invalid'), 2);
88
+        }
89
+    }
90
+
91
+    /**
92
+     * @return string
93
+     */
94
+    protected function getFileSizeFromHeader() {
95
+        if ($this->size !== null) {
96
+            return $this->size;
97
+        }
98
+
99
+        $size = $this->request->getHeader('OC-Total-Length');
100
+        if ($size === '') {
101
+            if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
102
+                $size = $this->request->getHeader('Content-Length');
103
+            }
104
+        }
105
+
106
+        if ($size === '') {
107
+            $size = false;
108
+        }
109
+
110
+        $this->size = $size;
111
+        return $this->size;
112
+    }
113
+
114
+    public function supportedEntities(): array {
115
+        return [ File::class ];
116
+    }
117
+
118
+    public function isAvailableForScope(int $scope): bool {
119
+        return true;
120
+    }
121 121
 }
Please login to merge, or discard this patch.
apps/workflowengine/lib/Check/UserGroupMembership.php 1 patch
Indentation   +82 added lines, -82 removed lines patch added patch discarded remove patch
@@ -31,86 +31,86 @@
 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 string $operator
62
-	 * @param string $value
63
-	 * @return bool
64
-	 */
65
-	public function executeCheck($operator, $value) {
66
-		$user = $this->userSession->getUser();
67
-
68
-		if ($user instanceof IUser) {
69
-			$groupIds = $this->getUserGroups($user);
70
-			return ($operator === 'is') === in_array($value, $groupIds);
71
-		} else {
72
-			return $operator !== 'is';
73
-		}
74
-	}
75
-
76
-
77
-	/**
78
-	 * @param string $operator
79
-	 * @param string $value
80
-	 * @throws \UnexpectedValueException
81
-	 */
82
-	public function validateCheck($operator, $value) {
83
-		if (!in_array($operator, ['is', '!is'])) {
84
-			throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
85
-		}
86
-
87
-		if (!$this->groupManager->groupExists($value)) {
88
-			throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2);
89
-		}
90
-	}
91
-
92
-	/**
93
-	 * @param IUser $user
94
-	 * @return string[]
95
-	 */
96
-	protected function getUserGroups(IUser $user) {
97
-		$uid = $user->getUID();
98
-
99
-		if ($this->cachedUser !== $uid) {
100
-			$this->cachedUser = $uid;
101
-			$this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user);
102
-		}
103
-
104
-		return $this->cachedGroupMemberships;
105
-	}
106
-
107
-	public function supportedEntities(): array {
108
-		// universal by default
109
-		return [];
110
-	}
111
-
112
-	public function isAvailableForScope(int $scope): bool {
113
-		// admin only by default
114
-		return $scope === IManager::SCOPE_ADMIN;
115
-	}
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 string $operator
62
+     * @param string $value
63
+     * @return bool
64
+     */
65
+    public function executeCheck($operator, $value) {
66
+        $user = $this->userSession->getUser();
67
+
68
+        if ($user instanceof IUser) {
69
+            $groupIds = $this->getUserGroups($user);
70
+            return ($operator === 'is') === in_array($value, $groupIds);
71
+        } else {
72
+            return $operator !== 'is';
73
+        }
74
+    }
75
+
76
+
77
+    /**
78
+     * @param string $operator
79
+     * @param string $value
80
+     * @throws \UnexpectedValueException
81
+     */
82
+    public function validateCheck($operator, $value) {
83
+        if (!in_array($operator, ['is', '!is'])) {
84
+            throw new \UnexpectedValueException($this->l->t('The given operator is invalid'), 1);
85
+        }
86
+
87
+        if (!$this->groupManager->groupExists($value)) {
88
+            throw new \UnexpectedValueException($this->l->t('The given group does not exist'), 2);
89
+        }
90
+    }
91
+
92
+    /**
93
+     * @param IUser $user
94
+     * @return string[]
95
+     */
96
+    protected function getUserGroups(IUser $user) {
97
+        $uid = $user->getUID();
98
+
99
+        if ($this->cachedUser !== $uid) {
100
+            $this->cachedUser = $uid;
101
+            $this->cachedGroupMemberships = $this->groupManager->getUserGroupIds($user);
102
+        }
103
+
104
+        return $this->cachedGroupMemberships;
105
+    }
106
+
107
+    public function supportedEntities(): array {
108
+        // universal by default
109
+        return [];
110
+    }
111
+
112
+    public function isAvailableForScope(int $scope): bool {
113
+        // admin only by default
114
+        return $scope === IManager::SCOPE_ADMIN;
115
+    }
116 116
 }
Please login to merge, or discard this patch.
lib/public/WorkflowEngine/IEntityCheck.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -34,21 +34,21 @@
 block discarded – undo
34 34
  * @since 18.0.0
35 35
  */
36 36
 interface IEntityCheck {
37
-	/**
38
-	 * Equips the check with a subject fitting the Entity. For instance, an
39
-	 * entity of File will receive an instance of OCP\Files\Node, or a comment
40
-	 * entity might get an IComment.
41
-	 *
42
-	 * The implementing check must be aware of the incoming type.
43
-	 *
44
-	 * If an unsupported subject is passed the implementation MAY throw an
45
-	 * \UnexpectedValueException.
46
-	 *
47
-	 * @param IEntity $entity
48
-	 * @param mixed $subject
49
-	 * @throws \UnexpectedValueException
50
-	 * @since 18.0.0
51
-	 */
52
-	public function setEntitySubject(IEntity $entity, $subject): void;
37
+    /**
38
+     * Equips the check with a subject fitting the Entity. For instance, an
39
+     * entity of File will receive an instance of OCP\Files\Node, or a comment
40
+     * entity might get an IComment.
41
+     *
42
+     * The implementing check must be aware of the incoming type.
43
+     *
44
+     * If an unsupported subject is passed the implementation MAY throw an
45
+     * \UnexpectedValueException.
46
+     *
47
+     * @param IEntity $entity
48
+     * @param mixed $subject
49
+     * @throws \UnexpectedValueException
50
+     * @since 18.0.0
51
+     */
52
+    public function setEntitySubject(IEntity $entity, $subject): void;
53 53
 
54 54
 }
Please login to merge, or discard this patch.
lib/public/WorkflowEngine/IComplexOperation.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -42,15 +42,15 @@
 block discarded – undo
42 42
  */
43 43
 interface IComplexOperation extends IOperation {
44 44
 
45
-	/**
46
-	 * As IComplexOperation chooses the triggering events itself, a hint has
47
-	 * to be shown to the user so make clear when this operation is becoming
48
-	 * active. This method returns such a translated string.
49
-	 *
50
-	 * Example: "When a file is accessed" (en)
51
-	 *
52
-	 * @since 18.0.0
53
-	 */
54
-	public function getTriggerHint(): string;
45
+    /**
46
+     * As IComplexOperation chooses the triggering events itself, a hint has
47
+     * to be shown to the user so make clear when this operation is becoming
48
+     * active. This method returns such a translated string.
49
+     *
50
+     * Example: "When a file is accessed" (en)
51
+     *
52
+     * @since 18.0.0
53
+     */
54
+    public function getTriggerHint(): string;
55 55
 
56 56
 }
Please login to merge, or discard this patch.
lib/public/WorkflowEngine/ICheck.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -31,43 +31,43 @@
 block discarded – undo
31 31
  * @since 9.1
32 32
  */
33 33
 interface ICheck {
34
-	/**
35
-	 * @param string $operator
36
-	 * @param string $value
37
-	 * @return bool
38
-	 * @since 9.1
39
-	 */
40
-	public function executeCheck($operator, $value);
34
+    /**
35
+     * @param string $operator
36
+     * @param string $value
37
+     * @return bool
38
+     * @since 9.1
39
+     */
40
+    public function executeCheck($operator, $value);
41 41
 
42
-	/**
43
-	 * @param string $operator
44
-	 * @param string $value
45
-	 * @throws \UnexpectedValueException
46
-	 * @since 9.1
47
-	 */
48
-	public function validateCheck($operator, $value);
42
+    /**
43
+     * @param string $operator
44
+     * @param string $value
45
+     * @throws \UnexpectedValueException
46
+     * @since 9.1
47
+     */
48
+    public function validateCheck($operator, $value);
49 49
 
50
-	/**
51
-	 * returns a list of Entities the checker supports. The values must match
52
-	 * the class name of the entity.
53
-	 *
54
-	 * An empty result means the check is universally available.
55
-	 *
56
-	 * @since 18.0.0
57
-	 */
58
-	public function supportedEntities(): array;
50
+    /**
51
+     * returns a list of Entities the checker supports. The values must match
52
+     * the class name of the entity.
53
+     *
54
+     * An empty result means the check is universally available.
55
+     *
56
+     * @since 18.0.0
57
+     */
58
+    public function supportedEntities(): array;
59 59
 
60
-	/**
61
-	 * returns whether the operation can be used in the requested scope.
62
-	 *
63
-	 * Scope IDs are defined as constants in OCP\WorkflowEngine\IManager. At
64
-	 * time of writing these are SCOPE_ADMIN and SCOPE_USER.
65
-	 *
66
-	 * For possibly unknown future scopes the recommended behaviour is: if
67
-	 * user scope is permitted, the default behaviour should return `true`,
68
-	 * otherwise `false`.
69
-	 *
70
-	 * @since 18.0.0
71
-	 */
72
-	public function isAvailableForScope(int $scope): bool;
60
+    /**
61
+     * returns whether the operation can be used in the requested scope.
62
+     *
63
+     * Scope IDs are defined as constants in OCP\WorkflowEngine\IManager. At
64
+     * time of writing these are SCOPE_ADMIN and SCOPE_USER.
65
+     *
66
+     * For possibly unknown future scopes the recommended behaviour is: if
67
+     * user scope is permitted, the default behaviour should return `true`,
68
+     * otherwise `false`.
69
+     *
70
+     * @since 18.0.0
71
+     */
72
+    public function isAvailableForScope(int $scope): bool;
73 73
 }
Please login to merge, or discard this patch.