Passed
Push — master ( f1b940...81ea28 )
by Joas
14:36 queued 15s
created
lib/private/Collaboration/Resources/Resource.php 1 patch
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -31,129 +31,129 @@
 block discarded – undo
31 31
 
32 32
 class Resource implements IResource {
33 33
 
34
-	/** @var IManager */
35
-	protected $manager;
36
-
37
-	/** @var IDBConnection */
38
-	protected $connection;
39
-
40
-	/** @var string */
41
-	protected $type;
42
-
43
-	/** @var string */
44
-	protected $id;
45
-
46
-	/** @var IUser|null */
47
-	protected $userForAccess;
48
-
49
-	/** @var bool|null */
50
-	protected $access;
51
-
52
-	/** @var array|null */
53
-	protected $data;
54
-
55
-	public function __construct(
56
-		IManager $manager,
57
-		IDBConnection $connection,
58
-		string $type,
59
-		string $id,
60
-		?IUser $userForAccess = null,
61
-		?bool $access = null
62
-	) {
63
-		$this->manager = $manager;
64
-		$this->connection = $connection;
65
-		$this->type = $type;
66
-		$this->id = $id;
67
-		$this->userForAccess = $userForAccess;
68
-		$this->access = $access;
69
-	}
70
-
71
-	/**
72
-	 * @return string
73
-	 * @since 16.0.0
74
-	 */
75
-	public function getType(): string {
76
-		return $this->type;
77
-	}
78
-
79
-	/**
80
-	 * @return string
81
-	 * @since 16.0.0
82
-	 */
83
-	public function getId(): string {
84
-		return $this->id;
85
-	}
86
-
87
-	/**
88
-	 * @return array
89
-	 * @since 16.0.0
90
-	 */
91
-	public function getRichObject(): array {
92
-		if ($this->data === null) {
93
-			$this->data = $this->manager->getResourceRichObject($this);
94
-		}
95
-
96
-		return $this->data;
97
-	}
98
-
99
-	/**
100
-	 * Can a user/guest access the resource
101
-	 *
102
-	 * @param IUser|null $user
103
-	 * @return bool
104
-	 * @since 16.0.0
105
-	 */
106
-	public function canAccess(?IUser $user): bool {
107
-		if ($user instanceof IUser) {
108
-			return $this->canUserAccess($user);
109
-		}
110
-		return $this->canGuestAccess();
111
-	}
112
-
113
-	protected function canUserAccess(IUser $user): bool {
114
-		if (\is_bool($this->access) && $this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
115
-			return $this->access;
116
-		}
117
-
118
-		$access = $this->manager->canAccessResource($this, $user);
119
-		if ($this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
120
-			$this->access = $access;
121
-		}
122
-		return $access;
123
-	}
124
-
125
-	protected function canGuestAccess(): bool {
126
-		if (\is_bool($this->access) && !$this->userForAccess instanceof IUser) {
127
-			return $this->access;
128
-		}
129
-
130
-		$access = $this->manager->canAccessResource($this, null);
131
-		if (!$this->userForAccess instanceof IUser) {
132
-			$this->access = $access;
133
-		}
134
-		return $access;
135
-	}
136
-
137
-	/**
138
-	 * @return ICollection[]
139
-	 * @since 16.0.0
140
-	 */
141
-	public function getCollections(): array {
142
-		$collections = [];
143
-
144
-		$query = $this->connection->getQueryBuilder();
145
-
146
-		$query->select('collection_id')
147
-			->from('collres_resources')
148
-			->where($query->expr()->eq('resource_type', $query->createNamedParameter($this->getType())))
149
-			->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($this->getId())));
150
-
151
-		$result = $query->execute();
152
-		while ($row = $result->fetch()) {
153
-			$collections[] = $this->manager->getCollection((int) $row['collection_id']);
154
-		}
155
-		$result->closeCursor();
156
-
157
-		return $collections;
158
-	}
34
+    /** @var IManager */
35
+    protected $manager;
36
+
37
+    /** @var IDBConnection */
38
+    protected $connection;
39
+
40
+    /** @var string */
41
+    protected $type;
42
+
43
+    /** @var string */
44
+    protected $id;
45
+
46
+    /** @var IUser|null */
47
+    protected $userForAccess;
48
+
49
+    /** @var bool|null */
50
+    protected $access;
51
+
52
+    /** @var array|null */
53
+    protected $data;
54
+
55
+    public function __construct(
56
+        IManager $manager,
57
+        IDBConnection $connection,
58
+        string $type,
59
+        string $id,
60
+        ?IUser $userForAccess = null,
61
+        ?bool $access = null
62
+    ) {
63
+        $this->manager = $manager;
64
+        $this->connection = $connection;
65
+        $this->type = $type;
66
+        $this->id = $id;
67
+        $this->userForAccess = $userForAccess;
68
+        $this->access = $access;
69
+    }
70
+
71
+    /**
72
+     * @return string
73
+     * @since 16.0.0
74
+     */
75
+    public function getType(): string {
76
+        return $this->type;
77
+    }
78
+
79
+    /**
80
+     * @return string
81
+     * @since 16.0.0
82
+     */
83
+    public function getId(): string {
84
+        return $this->id;
85
+    }
86
+
87
+    /**
88
+     * @return array
89
+     * @since 16.0.0
90
+     */
91
+    public function getRichObject(): array {
92
+        if ($this->data === null) {
93
+            $this->data = $this->manager->getResourceRichObject($this);
94
+        }
95
+
96
+        return $this->data;
97
+    }
98
+
99
+    /**
100
+     * Can a user/guest access the resource
101
+     *
102
+     * @param IUser|null $user
103
+     * @return bool
104
+     * @since 16.0.0
105
+     */
106
+    public function canAccess(?IUser $user): bool {
107
+        if ($user instanceof IUser) {
108
+            return $this->canUserAccess($user);
109
+        }
110
+        return $this->canGuestAccess();
111
+    }
112
+
113
+    protected function canUserAccess(IUser $user): bool {
114
+        if (\is_bool($this->access) && $this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
115
+            return $this->access;
116
+        }
117
+
118
+        $access = $this->manager->canAccessResource($this, $user);
119
+        if ($this->userForAccess instanceof IUser && $user->getUID() === $this->userForAccess->getUID()) {
120
+            $this->access = $access;
121
+        }
122
+        return $access;
123
+    }
124
+
125
+    protected function canGuestAccess(): bool {
126
+        if (\is_bool($this->access) && !$this->userForAccess instanceof IUser) {
127
+            return $this->access;
128
+        }
129
+
130
+        $access = $this->manager->canAccessResource($this, null);
131
+        if (!$this->userForAccess instanceof IUser) {
132
+            $this->access = $access;
133
+        }
134
+        return $access;
135
+    }
136
+
137
+    /**
138
+     * @return ICollection[]
139
+     * @since 16.0.0
140
+     */
141
+    public function getCollections(): array {
142
+        $collections = [];
143
+
144
+        $query = $this->connection->getQueryBuilder();
145
+
146
+        $query->select('collection_id')
147
+            ->from('collres_resources')
148
+            ->where($query->expr()->eq('resource_type', $query->createNamedParameter($this->getType())))
149
+            ->andWhere($query->expr()->eq('resource_id', $query->createNamedParameter($this->getId())));
150
+
151
+        $result = $query->execute();
152
+        while ($row = $result->fetch()) {
153
+            $collections[] = $this->manager->getCollection((int) $row['collection_id']);
154
+        }
155
+        $result->closeCursor();
156
+
157
+        return $collections;
158
+    }
159 159
 }
Please login to merge, or discard this patch.
lib/public/Collaboration/Resources/IResource.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -29,36 +29,36 @@
 block discarded – undo
29 29
  */
30 30
 interface IResource {
31 31
 
32
-	/**
33
-	 * @return string
34
-	 * @since 16.0.0
35
-	 */
36
-	public function getType(): string;
32
+    /**
33
+     * @return string
34
+     * @since 16.0.0
35
+     */
36
+    public function getType(): string;
37 37
 
38
-	/**
39
-	 * @return string
40
-	 * @since 16.0.0
41
-	 */
42
-	public function getId(): string;
38
+    /**
39
+     * @return string
40
+     * @since 16.0.0
41
+     */
42
+    public function getId(): string;
43 43
 
44
-	/**
45
-	 * @return array
46
-	 * @since 16.0.0
47
-	 */
48
-	public function getRichObject(): array;
44
+    /**
45
+     * @return array
46
+     * @since 16.0.0
47
+     */
48
+    public function getRichObject(): array;
49 49
 
50
-	/**
51
-	 * Can a user/guest access the resource
52
-	 *
53
-	 * @param IUser|null $user
54
-	 * @return bool
55
-	 * @since 16.0.0
56
-	 */
57
-	public function canAccess(?IUser $user): bool;
50
+    /**
51
+     * Can a user/guest access the resource
52
+     *
53
+     * @param IUser|null $user
54
+     * @return bool
55
+     * @since 16.0.0
56
+     */
57
+    public function canAccess(?IUser $user): bool;
58 58
 
59
-	/**
60
-	 * @return ICollection[]
61
-	 * @since 16.0.0
62
-	 */
63
-	public function getCollections(): array;
59
+    /**
60
+     * @return ICollection[]
61
+     * @since 16.0.0
62
+     */
63
+    public function getCollections(): array;
64 64
 }
Please login to merge, or discard this patch.
lib/public/Collaboration/Resources/IProvider.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -29,31 +29,31 @@
 block discarded – undo
29 29
  */
30 30
 interface IProvider {
31 31
 
32
-	/**
33
-	 * Get the resource type of the provider
34
-	 *
35
-	 * @return string
36
-	 * @since 16.0.0
37
-	 */
38
-	public function getType(): string;
32
+    /**
33
+     * Get the resource type of the provider
34
+     *
35
+     * @return string
36
+     * @since 16.0.0
37
+     */
38
+    public function getType(): string;
39 39
 
40
-	/**
41
-	 * Get the rich object data of a resource
42
-	 *
43
-	 * @param IResource $resource
44
-	 * @return array
45
-	 * @since 16.0.0
46
-	 */
47
-	public function getResourceRichObject(IResource $resource): array;
40
+    /**
41
+     * Get the rich object data of a resource
42
+     *
43
+     * @param IResource $resource
44
+     * @return array
45
+     * @since 16.0.0
46
+     */
47
+    public function getResourceRichObject(IResource $resource): array;
48 48
 
49
-	/**
50
-	 * Can a user/guest access the collection
51
-	 *
52
-	 * @param IResource $resource
53
-	 * @param IUser|null $user
54
-	 * @return bool
55
-	 * @since 16.0.0
56
-	 */
57
-	public function canAccessResource(IResource $resource, ?IUser $user): bool;
49
+    /**
50
+     * Can a user/guest access the collection
51
+     *
52
+     * @param IResource $resource
53
+     * @param IUser|null $user
54
+     * @return bool
55
+     * @since 16.0.0
56
+     */
57
+    public function canAccessResource(IResource $resource, ?IUser $user): bool;
58 58
 
59 59
 }
Please login to merge, or discard this patch.
lib/private/Collaboration/Resources/Manager.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 			->setFirstResult($start);
145 145
 
146 146
 		if ($filter !== '') {
147
-			$query->where($query->expr()->iLike('c.name', $query->createNamedParameter('%' . $this->connection->escapeLikeParameter($filter) . '%')));
147
+			$query->where($query->expr()->iLike('c.name', $query->createNamedParameter('%'.$this->connection->escapeLikeParameter($filter).'%')));
148 148
 		}
149 149
 
150 150
 		$result = $query->execute();
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 		while ($row = $result->fetch()) {
155 155
 			$foundResults++;
156 156
 			$access = $row['access'] === null ? null : (bool) $row['access'];
157
-			$collection = new Collection($this, $this->connection, (int)$row['id'], (string)$row['name'], $user, $access);
157
+			$collection = new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], $user, $access);
158 158
 			if ($collection->canAccess($user)) {
159 159
 				$collections[] = $collection;
160 160
 			}
Please login to merge, or discard this patch.
Indentation   +481 added lines, -481 removed lines patch added patch discarded remove patch
@@ -41,485 +41,485 @@
 block discarded – undo
41 41
 use Psr\Log\LoggerInterface;
42 42
 
43 43
 class Manager implements IManager {
44
-	public const TABLE_COLLECTIONS = 'collres_collections';
45
-	public const TABLE_RESOURCES = 'collres_resources';
46
-	public const TABLE_ACCESS_CACHE = 'collres_accesscache';
47
-
48
-	/** @var IDBConnection */
49
-	protected $connection;
50
-	/** @var IProviderManager */
51
-	protected $providerManager;
52
-	/** @var LoggerInterface */
53
-	protected $logger;
54
-
55
-	/** @var string[] */
56
-	protected $providers = [];
57
-
58
-
59
-	public function __construct(IDBConnection $connection, IProviderManager $providerManager, LoggerInterface $logger) {
60
-		$this->connection = $connection;
61
-		$this->providerManager = $providerManager;
62
-		$this->logger = $logger;
63
-	}
64
-
65
-	/**
66
-	 * @param int $id
67
-	 * @return ICollection
68
-	 * @throws CollectionException when the collection could not be found
69
-	 * @since 16.0.0
70
-	 */
71
-	public function getCollection(int $id): ICollection {
72
-		$query = $this->connection->getQueryBuilder();
73
-		$query->select('*')
74
-			->from(self::TABLE_COLLECTIONS)
75
-			->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
76
-		$result = $query->execute();
77
-		$row = $result->fetch();
78
-		$result->closeCursor();
79
-
80
-		if (!$row) {
81
-			throw new CollectionException('Collection not found');
82
-		}
83
-
84
-		return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name']);
85
-	}
86
-
87
-	/**
88
-	 * @param int $id
89
-	 * @param IUser|null $user
90
-	 * @return ICollection
91
-	 * @throws CollectionException when the collection could not be found
92
-	 * @since 16.0.0
93
-	 */
94
-	public function getCollectionForUser(int $id, ?IUser $user): ICollection {
95
-		$query = $this->connection->getQueryBuilder();
96
-		$userId = $user instanceof IUser ? $user->getUID() : '';
97
-
98
-		$query->select('*')
99
-			->from(self::TABLE_COLLECTIONS, 'c')
100
-			->leftJoin(
101
-				'c', self::TABLE_ACCESS_CACHE, 'a',
102
-				$query->expr()->andX(
103
-					$query->expr()->eq('c.id', 'a.collection_id'),
104
-					$query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
105
-				)
106
-			)
107
-			->where($query->expr()->eq('c.id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
108
-		$result = $query->execute();
109
-		$row = $result->fetch();
110
-		$result->closeCursor();
111
-
112
-		if (!$row) {
113
-			throw new CollectionException('Collection not found');
114
-		}
115
-
116
-		$access = $row['access'] === null ? null : (bool) $row['access'];
117
-		if ($user instanceof IUser) {
118
-			return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], $user, $access);
119
-		}
120
-
121
-		return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], $user, $access);
122
-	}
123
-
124
-	/**
125
-	 * @param IUser $user
126
-	 * @param string $filter
127
-	 * @param int $limit
128
-	 * @param int $start
129
-	 * @return ICollection[]
130
-	 * @since 16.0.0
131
-	 */
132
-	public function searchCollections(IUser $user, string $filter, int $limit = 50, int $start = 0): array {
133
-		$query = $this->connection->getQueryBuilder();
134
-		$userId = $user->getUID();
135
-
136
-		$query->select('c.*', 'a.access')
137
-			->from(self::TABLE_COLLECTIONS, 'c')
138
-			->leftJoin(
139
-				'c', self::TABLE_ACCESS_CACHE, 'a',
140
-				$query->expr()->andX(
141
-					$query->expr()->eq('c.id', 'a.collection_id'),
142
-					$query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
143
-				)
144
-			)
145
-			->where($query->expr()->eq('a.access', $query->createNamedParameter(1, IQueryBuilder::PARAM_INT)))
146
-			->orderBy('c.id')
147
-			->setMaxResults($limit)
148
-			->setFirstResult($start);
149
-
150
-		if ($filter !== '') {
151
-			$query->where($query->expr()->iLike('c.name', $query->createNamedParameter('%' . $this->connection->escapeLikeParameter($filter) . '%')));
152
-		}
153
-
154
-		$result = $query->execute();
155
-		$collections = [];
156
-
157
-		$foundResults = 0;
158
-		while ($row = $result->fetch()) {
159
-			$foundResults++;
160
-			$access = $row['access'] === null ? null : (bool) $row['access'];
161
-			$collection = new Collection($this, $this->connection, (int)$row['id'], (string)$row['name'], $user, $access);
162
-			if ($collection->canAccess($user)) {
163
-				$collections[] = $collection;
164
-			}
165
-		}
166
-		$result->closeCursor();
167
-
168
-		if (empty($collections) && $foundResults === $limit) {
169
-			return $this->searchCollections($user, $filter, $limit, $start + $limit);
170
-		}
171
-
172
-		return $collections;
173
-	}
174
-
175
-	/**
176
-	 * @param string $name
177
-	 * @return ICollection
178
-	 * @since 16.0.0
179
-	 */
180
-	public function newCollection(string $name): ICollection {
181
-		$query = $this->connection->getQueryBuilder();
182
-		$query->insert(self::TABLE_COLLECTIONS)
183
-			->values([
184
-				'name' => $query->createNamedParameter($name),
185
-			]);
186
-		$query->execute();
187
-
188
-		return new Collection($this, $this->connection, $query->getLastInsertId(), $name);
189
-	}
190
-
191
-	/**
192
-	 * @param string $type
193
-	 * @param string $id
194
-	 * @return IResource
195
-	 * @since 16.0.0
196
-	 */
197
-	public function createResource(string $type, string $id): IResource {
198
-		return new Resource($this, $this->connection, $type, $id);
199
-	}
200
-
201
-	/**
202
-	 * @param string $type
203
-	 * @param string $id
204
-	 * @param IUser|null $user
205
-	 * @return IResource
206
-	 * @throws ResourceException
207
-	 * @since 16.0.0
208
-	 */
209
-	public function getResourceForUser(string $type, string $id, ?IUser $user): IResource {
210
-		$query = $this->connection->getQueryBuilder();
211
-		$userId = $user instanceof IUser ? $user->getUID() : '';
212
-
213
-		$query->select('r.*', 'a.access')
214
-			->from(self::TABLE_RESOURCES, 'r')
215
-			->leftJoin(
216
-				'r', self::TABLE_ACCESS_CACHE, 'a',
217
-				$query->expr()->andX(
218
-					$query->expr()->eq('r.resource_id', 'a.resource_id'),
219
-					$query->expr()->eq('r.resource_type', 'a.resource_type'),
220
-					$query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
221
-				)
222
-			)
223
-			->where($query->expr()->eq('r.resource_type', $query->createNamedParameter($type, IQueryBuilder::PARAM_STR)))
224
-			->andWhere($query->expr()->eq('r.resource_id', $query->createNamedParameter($id, IQueryBuilder::PARAM_STR)));
225
-		$result = $query->execute();
226
-		$row = $result->fetch();
227
-		$result->closeCursor();
228
-
229
-		if (!$row) {
230
-			throw new ResourceException('Resource not found');
231
-		}
232
-
233
-		$access = $row['access'] === null ? null : (bool) $row['access'];
234
-		if ($user instanceof IUser) {
235
-			return new Resource($this, $this->connection, $type, $id, $user, $access);
236
-		}
237
-
238
-		return new Resource($this, $this->connection, $type, $id, null, $access);
239
-	}
240
-
241
-	/**
242
-	 * @param ICollection $collection
243
-	 * @param IUser|null $user
244
-	 * @return IResource[]
245
-	 * @since 16.0.0
246
-	 */
247
-	public function getResourcesByCollectionForUser(ICollection $collection, ?IUser $user): array {
248
-		$query = $this->connection->getQueryBuilder();
249
-		$userId = $user instanceof IUser ? $user->getUID() : '';
250
-
251
-		$query->select('r.*', 'a.access')
252
-			->from(self::TABLE_RESOURCES, 'r')
253
-			->leftJoin(
254
-				'r', self::TABLE_ACCESS_CACHE, 'a',
255
-				$query->expr()->andX(
256
-					$query->expr()->eq('r.resource_id', 'a.resource_id'),
257
-					$query->expr()->eq('r.resource_type', 'a.resource_type'),
258
-					$query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
259
-				)
260
-			)
261
-			->where($query->expr()->eq('r.collection_id', $query->createNamedParameter($collection->getId(), IQueryBuilder::PARAM_INT)));
262
-
263
-		$resources = [];
264
-		$result = $query->execute();
265
-		while ($row = $result->fetch()) {
266
-			$access = $row['access'] === null ? null : (bool) $row['access'];
267
-			$resources[] = new Resource($this, $this->connection, $row['resource_type'], $row['resource_id'], $user, $access);
268
-		}
269
-		$result->closeCursor();
270
-
271
-		return $resources;
272
-	}
273
-
274
-	/**
275
-	 * Get the rich object data of a resource
276
-	 *
277
-	 * @param IResource $resource
278
-	 * @return array
279
-	 * @since 16.0.0
280
-	 */
281
-	public function getResourceRichObject(IResource $resource): array {
282
-		foreach ($this->providerManager->getResourceProviders() as $provider) {
283
-			if ($provider->getType() === $resource->getType()) {
284
-				try {
285
-					return $provider->getResourceRichObject($resource);
286
-				} catch (ResourceException $e) {
287
-				}
288
-			}
289
-		}
290
-
291
-		return [];
292
-	}
293
-
294
-	/**
295
-	 * Can a user/guest access the collection
296
-	 *
297
-	 * @param IResource $resource
298
-	 * @param IUser|null $user
299
-	 * @return bool
300
-	 * @since 16.0.0
301
-	 */
302
-	public function canAccessResource(IResource $resource, ?IUser $user): bool {
303
-		$access = $this->checkAccessCacheForUserByResource($resource, $user);
304
-		if (\is_bool($access)) {
305
-			return $access;
306
-		}
307
-
308
-		$access = false;
309
-		foreach ($this->providerManager->getResourceProviders() as $provider) {
310
-			if ($provider->getType() === $resource->getType()) {
311
-				try {
312
-					if ($provider->canAccessResource($resource, $user)) {
313
-						$access = true;
314
-						break;
315
-					}
316
-				} catch (ResourceException $e) {
317
-				}
318
-			}
319
-		}
320
-
321
-		$this->cacheAccessForResource($resource, $user, $access);
322
-		return $access;
323
-	}
324
-
325
-	/**
326
-	 * Can a user/guest access the collection
327
-	 *
328
-	 * @param ICollection $collection
329
-	 * @param IUser|null $user
330
-	 * @return bool
331
-	 * @since 16.0.0
332
-	 */
333
-	public function canAccessCollection(ICollection $collection, ?IUser $user): bool {
334
-		$access = $this->checkAccessCacheForUserByCollection($collection, $user);
335
-		if (\is_bool($access)) {
336
-			return $access;
337
-		}
338
-
339
-		$access = null;
340
-		// Access is granted when a user can access all resources
341
-		foreach ($collection->getResources() as $resource) {
342
-			if (!$resource->canAccess($user)) {
343
-				$access = false;
344
-				break;
345
-			}
346
-
347
-			$access = true;
348
-		}
349
-
350
-		$this->cacheAccessForCollection($collection, $user, $access);
351
-		return $access;
352
-	}
353
-
354
-	protected function checkAccessCacheForUserByResource(IResource $resource, ?IUser $user): ?bool {
355
-		$query = $this->connection->getQueryBuilder();
356
-		$userId = $user instanceof IUser ? $user->getUID() : '';
357
-
358
-		$query->select('access')
359
-			->from(self::TABLE_ACCESS_CACHE)
360
-			->where($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId(), IQueryBuilder::PARAM_STR)))
361
-			->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType(), IQueryBuilder::PARAM_STR)))
362
-			->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR)))
363
-			->setMaxResults(1);
364
-
365
-		$hasAccess = null;
366
-		$result = $query->execute();
367
-		if ($row = $result->fetch()) {
368
-			$hasAccess = (bool) $row['access'];
369
-		}
370
-		$result->closeCursor();
371
-
372
-		return $hasAccess;
373
-	}
374
-
375
-	protected function checkAccessCacheForUserByCollection(ICollection $collection, ?IUser $user): ?bool {
376
-		$query = $this->connection->getQueryBuilder();
377
-		$userId = $user instanceof IUser ? $user->getUID() : '';
378
-
379
-		$query->select('access')
380
-			->from(self::TABLE_ACCESS_CACHE)
381
-			->where($query->expr()->eq('collection_id', $query->createNamedParameter($collection->getId(), IQueryBuilder::PARAM_INT)))
382
-			->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR)))
383
-			->setMaxResults(1);
384
-
385
-		$hasAccess = null;
386
-		$result = $query->execute();
387
-		if ($row = $result->fetch()) {
388
-			$hasAccess = (bool) $row['access'];
389
-		}
390
-		$result->closeCursor();
391
-
392
-		return $hasAccess;
393
-	}
394
-
395
-	public function cacheAccessForResource(IResource $resource, ?IUser $user, bool $access): void {
396
-		$query = $this->connection->getQueryBuilder();
397
-		$userId = $user instanceof IUser ? $user->getUID() : '';
398
-
399
-		$query->insert(self::TABLE_ACCESS_CACHE)
400
-			->values([
401
-				'user_id' => $query->createNamedParameter($userId),
402
-				'resource_id' => $query->createNamedParameter($resource->getId()),
403
-				'resource_type' => $query->createNamedParameter($resource->getType()),
404
-				'access' => $query->createNamedParameter($access, IQueryBuilder::PARAM_BOOL),
405
-			]);
406
-		try {
407
-			$query->execute();
408
-		} catch (UniqueConstraintViolationException $e) {
409
-		}
410
-	}
411
-
412
-	public function cacheAccessForCollection(ICollection $collection, ?IUser $user, bool $access): void {
413
-		$query = $this->connection->getQueryBuilder();
414
-		$userId = $user instanceof IUser ? $user->getUID() : '';
415
-
416
-		$query->insert(self::TABLE_ACCESS_CACHE)
417
-			->values([
418
-				'user_id' => $query->createNamedParameter($userId),
419
-				'collection_id' => $query->createNamedParameter($collection->getId()),
420
-				'access' => $query->createNamedParameter($access, IQueryBuilder::PARAM_BOOL),
421
-			]);
422
-		try {
423
-			$query->execute();
424
-		} catch (UniqueConstraintViolationException $e) {
425
-		}
426
-	}
427
-
428
-	public function invalidateAccessCacheForUser(?IUser $user): void {
429
-		$query = $this->connection->getQueryBuilder();
430
-		$userId = $user instanceof IUser ? $user->getUID() : '';
431
-
432
-		$query->delete(self::TABLE_ACCESS_CACHE)
433
-			->where($query->expr()->eq('user_id', $query->createNamedParameter($userId)));
434
-		$query->execute();
435
-	}
436
-
437
-	public function invalidateAccessCacheForResource(IResource $resource): void {
438
-		$query = $this->connection->getQueryBuilder();
439
-
440
-		$query->delete(self::TABLE_ACCESS_CACHE)
441
-			->where($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId())))
442
-			->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType(), IQueryBuilder::PARAM_STR)));
443
-		$query->execute();
444
-
445
-		foreach ($resource->getCollections() as $collection) {
446
-			$this->invalidateAccessCacheForCollection($collection);
447
-		}
448
-	}
449
-
450
-	public function invalidateAccessCacheForAllCollections(): void {
451
-		$query = $this->connection->getQueryBuilder();
452
-
453
-		$query->delete(self::TABLE_ACCESS_CACHE)
454
-			->where($query->expr()->neq('collection_id', $query->createNamedParameter(0)));
455
-		$query->execute();
456
-	}
457
-
458
-	public function invalidateAccessCacheForCollection(ICollection $collection): void {
459
-		$query = $this->connection->getQueryBuilder();
460
-
461
-		$query->delete(self::TABLE_ACCESS_CACHE)
462
-			->where($query->expr()->eq('collection_id', $query->createNamedParameter($collection->getId())));
463
-		$query->execute();
464
-	}
465
-
466
-	public function invalidateAccessCacheForProvider(IProvider $provider): void {
467
-		$query = $this->connection->getQueryBuilder();
468
-
469
-		$query->delete(self::TABLE_ACCESS_CACHE)
470
-			->where($query->expr()->eq('resource_type', $query->createNamedParameter($provider->getType(), IQueryBuilder::PARAM_STR)));
471
-		$query->execute();
472
-	}
473
-
474
-	public function invalidateAccessCacheForResourceByUser(IResource $resource, ?IUser $user): void {
475
-		$query = $this->connection->getQueryBuilder();
476
-		$userId = $user instanceof IUser ? $user->getUID() : '';
477
-
478
-		$query->delete(self::TABLE_ACCESS_CACHE)
479
-			->where($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId())))
480
-			->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId)));
481
-		$query->execute();
482
-
483
-		foreach ($resource->getCollections() as $collection) {
484
-			$this->invalidateAccessCacheForCollectionByUser($collection, $user);
485
-		}
486
-	}
487
-
488
-	protected function invalidateAccessCacheForCollectionByUser(ICollection $collection, ?IUser $user): void {
489
-		$query = $this->connection->getQueryBuilder();
490
-		$userId = $user instanceof IUser ? $user->getUID() : '';
491
-
492
-		$query->delete(self::TABLE_ACCESS_CACHE)
493
-			->where($query->expr()->eq('collection_id', $query->createNamedParameter($collection->getId())))
494
-			->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId)));
495
-		$query->execute();
496
-	}
497
-
498
-	public function invalidateAccessCacheForProviderByUser(IProvider $provider, ?IUser $user): void {
499
-		$query = $this->connection->getQueryBuilder();
500
-		$userId = $user instanceof IUser ? $user->getUID() : '';
501
-
502
-		$query->delete(self::TABLE_ACCESS_CACHE)
503
-			->where($query->expr()->eq('resource_type', $query->createNamedParameter($provider->getType(), IQueryBuilder::PARAM_STR)))
504
-			->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId)));
505
-		$query->execute();
506
-	}
507
-
508
-	/**
509
-	 * @param string $provider
510
-	 */
511
-	public function registerResourceProvider(string $provider): void {
512
-		$this->logger->debug('\OC\Collaboration\Resources\Manager::registerResourceProvider is deprecated', ['provider' => $provider]);
513
-		$this->providerManager->registerResourceProvider($provider);
514
-	}
515
-
516
-	/**
517
-	 * Get the resource type of the provider
518
-	 *
519
-	 * @return string
520
-	 * @since 16.0.0
521
-	 */
522
-	public function getType(): string {
523
-		return '';
524
-	}
44
+    public const TABLE_COLLECTIONS = 'collres_collections';
45
+    public const TABLE_RESOURCES = 'collres_resources';
46
+    public const TABLE_ACCESS_CACHE = 'collres_accesscache';
47
+
48
+    /** @var IDBConnection */
49
+    protected $connection;
50
+    /** @var IProviderManager */
51
+    protected $providerManager;
52
+    /** @var LoggerInterface */
53
+    protected $logger;
54
+
55
+    /** @var string[] */
56
+    protected $providers = [];
57
+
58
+
59
+    public function __construct(IDBConnection $connection, IProviderManager $providerManager, LoggerInterface $logger) {
60
+        $this->connection = $connection;
61
+        $this->providerManager = $providerManager;
62
+        $this->logger = $logger;
63
+    }
64
+
65
+    /**
66
+     * @param int $id
67
+     * @return ICollection
68
+     * @throws CollectionException when the collection could not be found
69
+     * @since 16.0.0
70
+     */
71
+    public function getCollection(int $id): ICollection {
72
+        $query = $this->connection->getQueryBuilder();
73
+        $query->select('*')
74
+            ->from(self::TABLE_COLLECTIONS)
75
+            ->where($query->expr()->eq('id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
76
+        $result = $query->execute();
77
+        $row = $result->fetch();
78
+        $result->closeCursor();
79
+
80
+        if (!$row) {
81
+            throw new CollectionException('Collection not found');
82
+        }
83
+
84
+        return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name']);
85
+    }
86
+
87
+    /**
88
+     * @param int $id
89
+     * @param IUser|null $user
90
+     * @return ICollection
91
+     * @throws CollectionException when the collection could not be found
92
+     * @since 16.0.0
93
+     */
94
+    public function getCollectionForUser(int $id, ?IUser $user): ICollection {
95
+        $query = $this->connection->getQueryBuilder();
96
+        $userId = $user instanceof IUser ? $user->getUID() : '';
97
+
98
+        $query->select('*')
99
+            ->from(self::TABLE_COLLECTIONS, 'c')
100
+            ->leftJoin(
101
+                'c', self::TABLE_ACCESS_CACHE, 'a',
102
+                $query->expr()->andX(
103
+                    $query->expr()->eq('c.id', 'a.collection_id'),
104
+                    $query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
105
+                )
106
+            )
107
+            ->where($query->expr()->eq('c.id', $query->createNamedParameter($id, IQueryBuilder::PARAM_INT)));
108
+        $result = $query->execute();
109
+        $row = $result->fetch();
110
+        $result->closeCursor();
111
+
112
+        if (!$row) {
113
+            throw new CollectionException('Collection not found');
114
+        }
115
+
116
+        $access = $row['access'] === null ? null : (bool) $row['access'];
117
+        if ($user instanceof IUser) {
118
+            return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], $user, $access);
119
+        }
120
+
121
+        return new Collection($this, $this->connection, (int) $row['id'], (string) $row['name'], $user, $access);
122
+    }
123
+
124
+    /**
125
+     * @param IUser $user
126
+     * @param string $filter
127
+     * @param int $limit
128
+     * @param int $start
129
+     * @return ICollection[]
130
+     * @since 16.0.0
131
+     */
132
+    public function searchCollections(IUser $user, string $filter, int $limit = 50, int $start = 0): array {
133
+        $query = $this->connection->getQueryBuilder();
134
+        $userId = $user->getUID();
135
+
136
+        $query->select('c.*', 'a.access')
137
+            ->from(self::TABLE_COLLECTIONS, 'c')
138
+            ->leftJoin(
139
+                'c', self::TABLE_ACCESS_CACHE, 'a',
140
+                $query->expr()->andX(
141
+                    $query->expr()->eq('c.id', 'a.collection_id'),
142
+                    $query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
143
+                )
144
+            )
145
+            ->where($query->expr()->eq('a.access', $query->createNamedParameter(1, IQueryBuilder::PARAM_INT)))
146
+            ->orderBy('c.id')
147
+            ->setMaxResults($limit)
148
+            ->setFirstResult($start);
149
+
150
+        if ($filter !== '') {
151
+            $query->where($query->expr()->iLike('c.name', $query->createNamedParameter('%' . $this->connection->escapeLikeParameter($filter) . '%')));
152
+        }
153
+
154
+        $result = $query->execute();
155
+        $collections = [];
156
+
157
+        $foundResults = 0;
158
+        while ($row = $result->fetch()) {
159
+            $foundResults++;
160
+            $access = $row['access'] === null ? null : (bool) $row['access'];
161
+            $collection = new Collection($this, $this->connection, (int)$row['id'], (string)$row['name'], $user, $access);
162
+            if ($collection->canAccess($user)) {
163
+                $collections[] = $collection;
164
+            }
165
+        }
166
+        $result->closeCursor();
167
+
168
+        if (empty($collections) && $foundResults === $limit) {
169
+            return $this->searchCollections($user, $filter, $limit, $start + $limit);
170
+        }
171
+
172
+        return $collections;
173
+    }
174
+
175
+    /**
176
+     * @param string $name
177
+     * @return ICollection
178
+     * @since 16.0.0
179
+     */
180
+    public function newCollection(string $name): ICollection {
181
+        $query = $this->connection->getQueryBuilder();
182
+        $query->insert(self::TABLE_COLLECTIONS)
183
+            ->values([
184
+                'name' => $query->createNamedParameter($name),
185
+            ]);
186
+        $query->execute();
187
+
188
+        return new Collection($this, $this->connection, $query->getLastInsertId(), $name);
189
+    }
190
+
191
+    /**
192
+     * @param string $type
193
+     * @param string $id
194
+     * @return IResource
195
+     * @since 16.0.0
196
+     */
197
+    public function createResource(string $type, string $id): IResource {
198
+        return new Resource($this, $this->connection, $type, $id);
199
+    }
200
+
201
+    /**
202
+     * @param string $type
203
+     * @param string $id
204
+     * @param IUser|null $user
205
+     * @return IResource
206
+     * @throws ResourceException
207
+     * @since 16.0.0
208
+     */
209
+    public function getResourceForUser(string $type, string $id, ?IUser $user): IResource {
210
+        $query = $this->connection->getQueryBuilder();
211
+        $userId = $user instanceof IUser ? $user->getUID() : '';
212
+
213
+        $query->select('r.*', 'a.access')
214
+            ->from(self::TABLE_RESOURCES, 'r')
215
+            ->leftJoin(
216
+                'r', self::TABLE_ACCESS_CACHE, 'a',
217
+                $query->expr()->andX(
218
+                    $query->expr()->eq('r.resource_id', 'a.resource_id'),
219
+                    $query->expr()->eq('r.resource_type', 'a.resource_type'),
220
+                    $query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
221
+                )
222
+            )
223
+            ->where($query->expr()->eq('r.resource_type', $query->createNamedParameter($type, IQueryBuilder::PARAM_STR)))
224
+            ->andWhere($query->expr()->eq('r.resource_id', $query->createNamedParameter($id, IQueryBuilder::PARAM_STR)));
225
+        $result = $query->execute();
226
+        $row = $result->fetch();
227
+        $result->closeCursor();
228
+
229
+        if (!$row) {
230
+            throw new ResourceException('Resource not found');
231
+        }
232
+
233
+        $access = $row['access'] === null ? null : (bool) $row['access'];
234
+        if ($user instanceof IUser) {
235
+            return new Resource($this, $this->connection, $type, $id, $user, $access);
236
+        }
237
+
238
+        return new Resource($this, $this->connection, $type, $id, null, $access);
239
+    }
240
+
241
+    /**
242
+     * @param ICollection $collection
243
+     * @param IUser|null $user
244
+     * @return IResource[]
245
+     * @since 16.0.0
246
+     */
247
+    public function getResourcesByCollectionForUser(ICollection $collection, ?IUser $user): array {
248
+        $query = $this->connection->getQueryBuilder();
249
+        $userId = $user instanceof IUser ? $user->getUID() : '';
250
+
251
+        $query->select('r.*', 'a.access')
252
+            ->from(self::TABLE_RESOURCES, 'r')
253
+            ->leftJoin(
254
+                'r', self::TABLE_ACCESS_CACHE, 'a',
255
+                $query->expr()->andX(
256
+                    $query->expr()->eq('r.resource_id', 'a.resource_id'),
257
+                    $query->expr()->eq('r.resource_type', 'a.resource_type'),
258
+                    $query->expr()->eq('a.user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR))
259
+                )
260
+            )
261
+            ->where($query->expr()->eq('r.collection_id', $query->createNamedParameter($collection->getId(), IQueryBuilder::PARAM_INT)));
262
+
263
+        $resources = [];
264
+        $result = $query->execute();
265
+        while ($row = $result->fetch()) {
266
+            $access = $row['access'] === null ? null : (bool) $row['access'];
267
+            $resources[] = new Resource($this, $this->connection, $row['resource_type'], $row['resource_id'], $user, $access);
268
+        }
269
+        $result->closeCursor();
270
+
271
+        return $resources;
272
+    }
273
+
274
+    /**
275
+     * Get the rich object data of a resource
276
+     *
277
+     * @param IResource $resource
278
+     * @return array
279
+     * @since 16.0.0
280
+     */
281
+    public function getResourceRichObject(IResource $resource): array {
282
+        foreach ($this->providerManager->getResourceProviders() as $provider) {
283
+            if ($provider->getType() === $resource->getType()) {
284
+                try {
285
+                    return $provider->getResourceRichObject($resource);
286
+                } catch (ResourceException $e) {
287
+                }
288
+            }
289
+        }
290
+
291
+        return [];
292
+    }
293
+
294
+    /**
295
+     * Can a user/guest access the collection
296
+     *
297
+     * @param IResource $resource
298
+     * @param IUser|null $user
299
+     * @return bool
300
+     * @since 16.0.0
301
+     */
302
+    public function canAccessResource(IResource $resource, ?IUser $user): bool {
303
+        $access = $this->checkAccessCacheForUserByResource($resource, $user);
304
+        if (\is_bool($access)) {
305
+            return $access;
306
+        }
307
+
308
+        $access = false;
309
+        foreach ($this->providerManager->getResourceProviders() as $provider) {
310
+            if ($provider->getType() === $resource->getType()) {
311
+                try {
312
+                    if ($provider->canAccessResource($resource, $user)) {
313
+                        $access = true;
314
+                        break;
315
+                    }
316
+                } catch (ResourceException $e) {
317
+                }
318
+            }
319
+        }
320
+
321
+        $this->cacheAccessForResource($resource, $user, $access);
322
+        return $access;
323
+    }
324
+
325
+    /**
326
+     * Can a user/guest access the collection
327
+     *
328
+     * @param ICollection $collection
329
+     * @param IUser|null $user
330
+     * @return bool
331
+     * @since 16.0.0
332
+     */
333
+    public function canAccessCollection(ICollection $collection, ?IUser $user): bool {
334
+        $access = $this->checkAccessCacheForUserByCollection($collection, $user);
335
+        if (\is_bool($access)) {
336
+            return $access;
337
+        }
338
+
339
+        $access = null;
340
+        // Access is granted when a user can access all resources
341
+        foreach ($collection->getResources() as $resource) {
342
+            if (!$resource->canAccess($user)) {
343
+                $access = false;
344
+                break;
345
+            }
346
+
347
+            $access = true;
348
+        }
349
+
350
+        $this->cacheAccessForCollection($collection, $user, $access);
351
+        return $access;
352
+    }
353
+
354
+    protected function checkAccessCacheForUserByResource(IResource $resource, ?IUser $user): ?bool {
355
+        $query = $this->connection->getQueryBuilder();
356
+        $userId = $user instanceof IUser ? $user->getUID() : '';
357
+
358
+        $query->select('access')
359
+            ->from(self::TABLE_ACCESS_CACHE)
360
+            ->where($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId(), IQueryBuilder::PARAM_STR)))
361
+            ->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType(), IQueryBuilder::PARAM_STR)))
362
+            ->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR)))
363
+            ->setMaxResults(1);
364
+
365
+        $hasAccess = null;
366
+        $result = $query->execute();
367
+        if ($row = $result->fetch()) {
368
+            $hasAccess = (bool) $row['access'];
369
+        }
370
+        $result->closeCursor();
371
+
372
+        return $hasAccess;
373
+    }
374
+
375
+    protected function checkAccessCacheForUserByCollection(ICollection $collection, ?IUser $user): ?bool {
376
+        $query = $this->connection->getQueryBuilder();
377
+        $userId = $user instanceof IUser ? $user->getUID() : '';
378
+
379
+        $query->select('access')
380
+            ->from(self::TABLE_ACCESS_CACHE)
381
+            ->where($query->expr()->eq('collection_id', $query->createNamedParameter($collection->getId(), IQueryBuilder::PARAM_INT)))
382
+            ->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId, IQueryBuilder::PARAM_STR)))
383
+            ->setMaxResults(1);
384
+
385
+        $hasAccess = null;
386
+        $result = $query->execute();
387
+        if ($row = $result->fetch()) {
388
+            $hasAccess = (bool) $row['access'];
389
+        }
390
+        $result->closeCursor();
391
+
392
+        return $hasAccess;
393
+    }
394
+
395
+    public function cacheAccessForResource(IResource $resource, ?IUser $user, bool $access): void {
396
+        $query = $this->connection->getQueryBuilder();
397
+        $userId = $user instanceof IUser ? $user->getUID() : '';
398
+
399
+        $query->insert(self::TABLE_ACCESS_CACHE)
400
+            ->values([
401
+                'user_id' => $query->createNamedParameter($userId),
402
+                'resource_id' => $query->createNamedParameter($resource->getId()),
403
+                'resource_type' => $query->createNamedParameter($resource->getType()),
404
+                'access' => $query->createNamedParameter($access, IQueryBuilder::PARAM_BOOL),
405
+            ]);
406
+        try {
407
+            $query->execute();
408
+        } catch (UniqueConstraintViolationException $e) {
409
+        }
410
+    }
411
+
412
+    public function cacheAccessForCollection(ICollection $collection, ?IUser $user, bool $access): void {
413
+        $query = $this->connection->getQueryBuilder();
414
+        $userId = $user instanceof IUser ? $user->getUID() : '';
415
+
416
+        $query->insert(self::TABLE_ACCESS_CACHE)
417
+            ->values([
418
+                'user_id' => $query->createNamedParameter($userId),
419
+                'collection_id' => $query->createNamedParameter($collection->getId()),
420
+                'access' => $query->createNamedParameter($access, IQueryBuilder::PARAM_BOOL),
421
+            ]);
422
+        try {
423
+            $query->execute();
424
+        } catch (UniqueConstraintViolationException $e) {
425
+        }
426
+    }
427
+
428
+    public function invalidateAccessCacheForUser(?IUser $user): void {
429
+        $query = $this->connection->getQueryBuilder();
430
+        $userId = $user instanceof IUser ? $user->getUID() : '';
431
+
432
+        $query->delete(self::TABLE_ACCESS_CACHE)
433
+            ->where($query->expr()->eq('user_id', $query->createNamedParameter($userId)));
434
+        $query->execute();
435
+    }
436
+
437
+    public function invalidateAccessCacheForResource(IResource $resource): void {
438
+        $query = $this->connection->getQueryBuilder();
439
+
440
+        $query->delete(self::TABLE_ACCESS_CACHE)
441
+            ->where($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId())))
442
+            ->andWhere($query->expr()->eq('resource_type', $query->createNamedParameter($resource->getType(), IQueryBuilder::PARAM_STR)));
443
+        $query->execute();
444
+
445
+        foreach ($resource->getCollections() as $collection) {
446
+            $this->invalidateAccessCacheForCollection($collection);
447
+        }
448
+    }
449
+
450
+    public function invalidateAccessCacheForAllCollections(): void {
451
+        $query = $this->connection->getQueryBuilder();
452
+
453
+        $query->delete(self::TABLE_ACCESS_CACHE)
454
+            ->where($query->expr()->neq('collection_id', $query->createNamedParameter(0)));
455
+        $query->execute();
456
+    }
457
+
458
+    public function invalidateAccessCacheForCollection(ICollection $collection): void {
459
+        $query = $this->connection->getQueryBuilder();
460
+
461
+        $query->delete(self::TABLE_ACCESS_CACHE)
462
+            ->where($query->expr()->eq('collection_id', $query->createNamedParameter($collection->getId())));
463
+        $query->execute();
464
+    }
465
+
466
+    public function invalidateAccessCacheForProvider(IProvider $provider): void {
467
+        $query = $this->connection->getQueryBuilder();
468
+
469
+        $query->delete(self::TABLE_ACCESS_CACHE)
470
+            ->where($query->expr()->eq('resource_type', $query->createNamedParameter($provider->getType(), IQueryBuilder::PARAM_STR)));
471
+        $query->execute();
472
+    }
473
+
474
+    public function invalidateAccessCacheForResourceByUser(IResource $resource, ?IUser $user): void {
475
+        $query = $this->connection->getQueryBuilder();
476
+        $userId = $user instanceof IUser ? $user->getUID() : '';
477
+
478
+        $query->delete(self::TABLE_ACCESS_CACHE)
479
+            ->where($query->expr()->eq('resource_id', $query->createNamedParameter($resource->getId())))
480
+            ->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId)));
481
+        $query->execute();
482
+
483
+        foreach ($resource->getCollections() as $collection) {
484
+            $this->invalidateAccessCacheForCollectionByUser($collection, $user);
485
+        }
486
+    }
487
+
488
+    protected function invalidateAccessCacheForCollectionByUser(ICollection $collection, ?IUser $user): void {
489
+        $query = $this->connection->getQueryBuilder();
490
+        $userId = $user instanceof IUser ? $user->getUID() : '';
491
+
492
+        $query->delete(self::TABLE_ACCESS_CACHE)
493
+            ->where($query->expr()->eq('collection_id', $query->createNamedParameter($collection->getId())))
494
+            ->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId)));
495
+        $query->execute();
496
+    }
497
+
498
+    public function invalidateAccessCacheForProviderByUser(IProvider $provider, ?IUser $user): void {
499
+        $query = $this->connection->getQueryBuilder();
500
+        $userId = $user instanceof IUser ? $user->getUID() : '';
501
+
502
+        $query->delete(self::TABLE_ACCESS_CACHE)
503
+            ->where($query->expr()->eq('resource_type', $query->createNamedParameter($provider->getType(), IQueryBuilder::PARAM_STR)))
504
+            ->andWhere($query->expr()->eq('user_id', $query->createNamedParameter($userId)));
505
+        $query->execute();
506
+    }
507
+
508
+    /**
509
+     * @param string $provider
510
+     */
511
+    public function registerResourceProvider(string $provider): void {
512
+        $this->logger->debug('\OC\Collaboration\Resources\Manager::registerResourceProvider is deprecated', ['provider' => $provider]);
513
+        $this->providerManager->registerResourceProvider($provider);
514
+    }
515
+
516
+    /**
517
+     * Get the resource type of the provider
518
+     *
519
+     * @return string
520
+     * @since 16.0.0
521
+     */
522
+    public function getType(): string {
523
+        return '';
524
+    }
525 525
 }
Please login to merge, or discard this patch.
lib/public/FullTextSearch/IFullTextSearchManager.php 1 patch
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -51,145 +51,145 @@
 block discarded – undo
51 51
 interface IFullTextSearchManager {
52 52
 
53 53
 
54
-	/**
55
-	 * Register a IProviderService.
56
-	 *
57
-	 * @since 15.0.0
58
-	 *
59
-	 * @param IProviderService $providerService
60
-	 */
61
-	public function registerProviderService(IProviderService $providerService);
62
-
63
-	/**
64
-	 * Register a IIndexService.
65
-	 *
66
-	 * @since 15.0.0
67
-	 *
68
-	 * @param IIndexService $indexService
69
-	 */
70
-	public function registerIndexService(IIndexService $indexService);
71
-
72
-	/**
73
-	 * Register a ISearchService.
74
-	 *
75
-	 * @since 15.0.0
76
-	 *
77
-	 * @param ISearchService $searchService
78
-	 */
79
-	public function registerSearchService(ISearchService $searchService);
80
-
81
-	/**
82
-	 * returns true is Full Text Search is available (app is present and Service
83
-	 * are registered)
84
-	 *
85
-	 * @since 16.0.0
86
-	 *
87
-	 * @return bool
88
-	 */
89
-	public function isAvailable(): bool;
90
-
91
-
92
-	/**
93
-	 * Add the Javascript API in the navigation page of an app.
94
-	 * Needed to replace the default search.
95
-	 *
96
-	 * @since 15.0.0
97
-	 */
98
-	public function addJavascriptAPI();
99
-
100
-
101
-	/**
102
-	 * Check if the provider $providerId is already indexed.
103
-	 *
104
-	 * @since 15.0.0
105
-	 *
106
-	 * @param string $providerId
107
-	 *
108
-	 * @return bool
109
-	 */
110
-	public function isProviderIndexed(string $providerId): bool;
111
-
112
-
113
-	/**
114
-	 * Retrieve an Index from the database, based on the Id of the Provider
115
-	 * and the Id of the Document
116
-	 *
117
-	 * @since 15.0.0
118
-	 *
119
-	 * @param string $providerId
120
-	 * @param string $documentId
121
-	 *
122
-	 * @return IIndex
123
-	 */
124
-	public function getIndex(string $providerId, string $documentId): IIndex;
125
-
126
-
127
-	/**
128
-	 * Create a new Index.
129
-	 *
130
-	 * This method must be called when a new document is created.
131
-	 *
132
-	 * @since 15.0.0
133
-	 *
134
-	 * @param string $providerId
135
-	 * @param string $documentId
136
-	 * @param string $userId
137
-	 * @param int $status
138
-	 *
139
-	 * @return IIndex
140
-	 */
141
-	public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex;
142
-
143
-
144
-	/**
145
-	 * Update the status of an Index. status is a bitflag, setting $reset to
146
-	 * true will reset the status to the value defined in the parameter.
147
-	 *
148
-	 * @since 15.0.0
149
-	 *
150
-	 * @param string $providerId
151
-	 * @param string $documentId
152
-	 * @param int $status
153
-	 * @param bool $reset
154
-	 */
155
-	public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false);
156
-
157
-
158
-	/**
159
-	 * Update the status of an array of Index. status is a bit flag, setting $reset to
160
-	 * true will reset the status to the value defined in the parameter.
161
-	 *
162
-	 * @since 15.0.0
163
-	 *
164
-	 * @param string $providerId
165
-	 * @param array $documentIds
166
-	 * @param int $status
167
-	 * @param bool $reset
168
-	 */
169
-	public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false);
170
-
171
-	/**
172
-	 * Update an array of Index.
173
-	 *
174
-	 * @since 15.0.0
175
-	 *
176
-	 * @param IIndex[] $indexes
177
-	 */
178
-	public function updateIndexes(array $indexes);
179
-
180
-	/**
181
-	 * Search using an array as request. If $userId is empty, will use the
182
-	 * current session.
183
-	 *
184
-	 * @see ISearchService::generateSearchRequest
185
-	 *
186
-	 * @since 15.0.0
187
-	 *
188
-	 * @param array $request
189
-	 * @param string $userId
190
-	 * @return ISearchResult[]
191
-	 */
192
-	public function search(array $request, string $userId = ''): array;
54
+    /**
55
+     * Register a IProviderService.
56
+     *
57
+     * @since 15.0.0
58
+     *
59
+     * @param IProviderService $providerService
60
+     */
61
+    public function registerProviderService(IProviderService $providerService);
62
+
63
+    /**
64
+     * Register a IIndexService.
65
+     *
66
+     * @since 15.0.0
67
+     *
68
+     * @param IIndexService $indexService
69
+     */
70
+    public function registerIndexService(IIndexService $indexService);
71
+
72
+    /**
73
+     * Register a ISearchService.
74
+     *
75
+     * @since 15.0.0
76
+     *
77
+     * @param ISearchService $searchService
78
+     */
79
+    public function registerSearchService(ISearchService $searchService);
80
+
81
+    /**
82
+     * returns true is Full Text Search is available (app is present and Service
83
+     * are registered)
84
+     *
85
+     * @since 16.0.0
86
+     *
87
+     * @return bool
88
+     */
89
+    public function isAvailable(): bool;
90
+
91
+
92
+    /**
93
+     * Add the Javascript API in the navigation page of an app.
94
+     * Needed to replace the default search.
95
+     *
96
+     * @since 15.0.0
97
+     */
98
+    public function addJavascriptAPI();
99
+
100
+
101
+    /**
102
+     * Check if the provider $providerId is already indexed.
103
+     *
104
+     * @since 15.0.0
105
+     *
106
+     * @param string $providerId
107
+     *
108
+     * @return bool
109
+     */
110
+    public function isProviderIndexed(string $providerId): bool;
111
+
112
+
113
+    /**
114
+     * Retrieve an Index from the database, based on the Id of the Provider
115
+     * and the Id of the Document
116
+     *
117
+     * @since 15.0.0
118
+     *
119
+     * @param string $providerId
120
+     * @param string $documentId
121
+     *
122
+     * @return IIndex
123
+     */
124
+    public function getIndex(string $providerId, string $documentId): IIndex;
125
+
126
+
127
+    /**
128
+     * Create a new Index.
129
+     *
130
+     * This method must be called when a new document is created.
131
+     *
132
+     * @since 15.0.0
133
+     *
134
+     * @param string $providerId
135
+     * @param string $documentId
136
+     * @param string $userId
137
+     * @param int $status
138
+     *
139
+     * @return IIndex
140
+     */
141
+    public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex;
142
+
143
+
144
+    /**
145
+     * Update the status of an Index. status is a bitflag, setting $reset to
146
+     * true will reset the status to the value defined in the parameter.
147
+     *
148
+     * @since 15.0.0
149
+     *
150
+     * @param string $providerId
151
+     * @param string $documentId
152
+     * @param int $status
153
+     * @param bool $reset
154
+     */
155
+    public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false);
156
+
157
+
158
+    /**
159
+     * Update the status of an array of Index. status is a bit flag, setting $reset to
160
+     * true will reset the status to the value defined in the parameter.
161
+     *
162
+     * @since 15.0.0
163
+     *
164
+     * @param string $providerId
165
+     * @param array $documentIds
166
+     * @param int $status
167
+     * @param bool $reset
168
+     */
169
+    public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false);
170
+
171
+    /**
172
+     * Update an array of Index.
173
+     *
174
+     * @since 15.0.0
175
+     *
176
+     * @param IIndex[] $indexes
177
+     */
178
+    public function updateIndexes(array $indexes);
179
+
180
+    /**
181
+     * Search using an array as request. If $userId is empty, will use the
182
+     * current session.
183
+     *
184
+     * @see ISearchService::generateSearchRequest
185
+     *
186
+     * @since 15.0.0
187
+     *
188
+     * @param array $request
189
+     * @param string $userId
190
+     * @return ISearchResult[]
191
+     */
192
+    public function search(array $request, string $userId = ''): array;
193 193
 
194 194
 
195 195
 }
Please login to merge, or discard this patch.
lib/private/FullTextSearch/FullTextSearchManager.php 1 patch
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -48,194 +48,194 @@
 block discarded – undo
48 48
 class FullTextSearchManager implements IFullTextSearchManager {
49 49
 
50 50
 
51
-	/** @var IProviderService */
52
-	private $providerService;
53
-
54
-	/** @var IIndexService */
55
-	private $indexService;
56
-
57
-	/** @var ISearchService */
58
-	private $searchService;
59
-
60
-
61
-	/**
62
-	 * @since 15.0.0
63
-	 *
64
-	 * @param IProviderService $providerService
65
-	 */
66
-	public function registerProviderService(IProviderService $providerService) {
67
-		$this->providerService = $providerService;
68
-	}
69
-
70
-	/**
71
-	 * @since 15.0.0
72
-	 *
73
-	 * @param IIndexService $indexService
74
-	 */
75
-	public function registerIndexService(IIndexService $indexService) {
76
-		$this->indexService = $indexService;
77
-	}
78
-
79
-	/**
80
-	 * @since 15.0.0
81
-	 *
82
-	 * @param ISearchService $searchService
83
-	 */
84
-	public function registerSearchService(ISearchService $searchService) {
85
-		$this->searchService = $searchService;
86
-	}
87
-
88
-	/**
89
-	 * @since 16.0.0
90
-	 *
91
-	 * @return bool
92
-	 */
93
-	public function isAvailable(): bool {
94
-		if ($this->indexService === null ||
95
-			$this->providerService === null ||
96
-			$this->searchService === null) {
97
-			return false;
98
-		}
99
-
100
-		return true;
101
-	}
102
-
103
-
104
-	/**
105
-	 * @return IProviderService
106
-	 * @throws FullTextSearchAppNotAvailableException
107
-	 */
108
-	private function getProviderService(): IProviderService {
109
-		if ($this->providerService === null) {
110
-			throw new FullTextSearchAppNotAvailableException('No IProviderService registered');
111
-		}
112
-
113
-		return $this->providerService;
114
-	}
115
-
116
-
117
-	/**
118
-	 * @return IIndexService
119
-	 * @throws FullTextSearchAppNotAvailableException
120
-	 */
121
-	private function getIndexService(): IIndexService {
122
-		if ($this->indexService === null) {
123
-			throw new FullTextSearchAppNotAvailableException('No IIndexService registered');
124
-		}
125
-
126
-		return $this->indexService;
127
-	}
128
-
129
-
130
-	/**
131
-	 * @return ISearchService
132
-	 * @throws FullTextSearchAppNotAvailableException
133
-	 */
134
-	private function getSearchService(): ISearchService {
135
-		if ($this->searchService === null) {
136
-			throw new FullTextSearchAppNotAvailableException('No ISearchService registered');
137
-		}
138
-
139
-		return $this->searchService;
140
-	}
141
-
142
-
143
-	/**
144
-	 * @throws FullTextSearchAppNotAvailableException
145
-	 */
146
-	public function addJavascriptAPI() {
147
-		$this->getProviderService()->addJavascriptAPI();
148
-	}
149
-
150
-
151
-	/**
152
-	 * @param string $providerId
153
-	 *
154
-	 * @return bool
155
-	 * @throws FullTextSearchAppNotAvailableException
156
-	 */
157
-	public function isProviderIndexed(string $providerId): bool {
158
-		return $this->getProviderService()->isProviderIndexed($providerId);
159
-	}
160
-
161
-
162
-	/**
163
-	 * @param string $providerId
164
-	 * @param string $documentId
165
-	 * @return IIndex
166
-	 * @throws FullTextSearchAppNotAvailableException
167
-	 */
168
-	public function getIndex(string $providerId, string $documentId): IIndex {
169
-		return $this->getIndexService()->getIndex($providerId, $documentId);
170
-	}
171
-
172
-	/**
173
-	 * @param string $providerId
174
-	 * @param string $documentId
175
-	 * @param string $userId
176
-	 * @param int $status
177
-	 *
178
-	 * @see IIndex for available value for $status.
179
-	 *
180
-	 * @return IIndex
181
-	 * @throws FullTextSearchAppNotAvailableException
182
-	 */
183
-	public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex {
184
-		return $this->getIndexService()->createIndex($providerId, $documentId, $userId, $status);
185
-	}
186
-
187
-
188
-	/**
189
-	 * @param string $providerId
190
-	 * @param string $documentId
191
-	 * @param int $status
192
-	 * @param bool $reset
193
-	 *
194
-	 * @see IIndex for available value for $status.
195
-	 *
196
-	 * @throws FullTextSearchAppNotAvailableException
197
-	 */
198
-	public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false) {
199
-		$this->getIndexService()->updateIndexStatus($providerId, $documentId, $status, $reset);
200
-	}
201
-
202
-	/**
203
-	 * @param string $providerId
204
-	 * @param array $documentIds
205
-	 * @param int $status
206
-	 * @param bool $reset
207
-	 *
208
-	 * @see IIndex for available value for $status.
209
-	 *
210
-	 * @throws FullTextSearchAppNotAvailableException
211
-	 */
212
-	public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false) {
213
-		$this->getIndexService()->updateIndexesStatus($providerId, $documentIds, $status, $reset);
214
-	}
215
-
216
-
217
-	/**
218
-	 * @param IIndex[] $indexes
219
-	 *
220
-	 * @throws FullTextSearchAppNotAvailableException
221
-	 */
222
-	public function updateIndexes(array $indexes) {
223
-		$this->getIndexService()->updateIndexes($indexes);
224
-	}
225
-
226
-
227
-	/**
228
-	 * @param array $request
229
-	 * @param string $userId
230
-	 *
231
-	 * @return ISearchResult[]
232
-	 * @throws FullTextSearchAppNotAvailableException
233
-	 */
234
-	public function search(array $request, string $userId = ''): array {
235
-		$searchRequest = $this->getSearchService()->generateSearchRequest($request);
236
-
237
-		return $this->getSearchService()->search($userId, $searchRequest);
238
-	}
51
+    /** @var IProviderService */
52
+    private $providerService;
53
+
54
+    /** @var IIndexService */
55
+    private $indexService;
56
+
57
+    /** @var ISearchService */
58
+    private $searchService;
59
+
60
+
61
+    /**
62
+     * @since 15.0.0
63
+     *
64
+     * @param IProviderService $providerService
65
+     */
66
+    public function registerProviderService(IProviderService $providerService) {
67
+        $this->providerService = $providerService;
68
+    }
69
+
70
+    /**
71
+     * @since 15.0.0
72
+     *
73
+     * @param IIndexService $indexService
74
+     */
75
+    public function registerIndexService(IIndexService $indexService) {
76
+        $this->indexService = $indexService;
77
+    }
78
+
79
+    /**
80
+     * @since 15.0.0
81
+     *
82
+     * @param ISearchService $searchService
83
+     */
84
+    public function registerSearchService(ISearchService $searchService) {
85
+        $this->searchService = $searchService;
86
+    }
87
+
88
+    /**
89
+     * @since 16.0.0
90
+     *
91
+     * @return bool
92
+     */
93
+    public function isAvailable(): bool {
94
+        if ($this->indexService === null ||
95
+            $this->providerService === null ||
96
+            $this->searchService === null) {
97
+            return false;
98
+        }
99
+
100
+        return true;
101
+    }
102
+
103
+
104
+    /**
105
+     * @return IProviderService
106
+     * @throws FullTextSearchAppNotAvailableException
107
+     */
108
+    private function getProviderService(): IProviderService {
109
+        if ($this->providerService === null) {
110
+            throw new FullTextSearchAppNotAvailableException('No IProviderService registered');
111
+        }
112
+
113
+        return $this->providerService;
114
+    }
115
+
116
+
117
+    /**
118
+     * @return IIndexService
119
+     * @throws FullTextSearchAppNotAvailableException
120
+     */
121
+    private function getIndexService(): IIndexService {
122
+        if ($this->indexService === null) {
123
+            throw new FullTextSearchAppNotAvailableException('No IIndexService registered');
124
+        }
125
+
126
+        return $this->indexService;
127
+    }
128
+
129
+
130
+    /**
131
+     * @return ISearchService
132
+     * @throws FullTextSearchAppNotAvailableException
133
+     */
134
+    private function getSearchService(): ISearchService {
135
+        if ($this->searchService === null) {
136
+            throw new FullTextSearchAppNotAvailableException('No ISearchService registered');
137
+        }
138
+
139
+        return $this->searchService;
140
+    }
141
+
142
+
143
+    /**
144
+     * @throws FullTextSearchAppNotAvailableException
145
+     */
146
+    public function addJavascriptAPI() {
147
+        $this->getProviderService()->addJavascriptAPI();
148
+    }
149
+
150
+
151
+    /**
152
+     * @param string $providerId
153
+     *
154
+     * @return bool
155
+     * @throws FullTextSearchAppNotAvailableException
156
+     */
157
+    public function isProviderIndexed(string $providerId): bool {
158
+        return $this->getProviderService()->isProviderIndexed($providerId);
159
+    }
160
+
161
+
162
+    /**
163
+     * @param string $providerId
164
+     * @param string $documentId
165
+     * @return IIndex
166
+     * @throws FullTextSearchAppNotAvailableException
167
+     */
168
+    public function getIndex(string $providerId, string $documentId): IIndex {
169
+        return $this->getIndexService()->getIndex($providerId, $documentId);
170
+    }
171
+
172
+    /**
173
+     * @param string $providerId
174
+     * @param string $documentId
175
+     * @param string $userId
176
+     * @param int $status
177
+     *
178
+     * @see IIndex for available value for $status.
179
+     *
180
+     * @return IIndex
181
+     * @throws FullTextSearchAppNotAvailableException
182
+     */
183
+    public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex {
184
+        return $this->getIndexService()->createIndex($providerId, $documentId, $userId, $status);
185
+    }
186
+
187
+
188
+    /**
189
+     * @param string $providerId
190
+     * @param string $documentId
191
+     * @param int $status
192
+     * @param bool $reset
193
+     *
194
+     * @see IIndex for available value for $status.
195
+     *
196
+     * @throws FullTextSearchAppNotAvailableException
197
+     */
198
+    public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false) {
199
+        $this->getIndexService()->updateIndexStatus($providerId, $documentId, $status, $reset);
200
+    }
201
+
202
+    /**
203
+     * @param string $providerId
204
+     * @param array $documentIds
205
+     * @param int $status
206
+     * @param bool $reset
207
+     *
208
+     * @see IIndex for available value for $status.
209
+     *
210
+     * @throws FullTextSearchAppNotAvailableException
211
+     */
212
+    public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false) {
213
+        $this->getIndexService()->updateIndexesStatus($providerId, $documentIds, $status, $reset);
214
+    }
215
+
216
+
217
+    /**
218
+     * @param IIndex[] $indexes
219
+     *
220
+     * @throws FullTextSearchAppNotAvailableException
221
+     */
222
+    public function updateIndexes(array $indexes) {
223
+        $this->getIndexService()->updateIndexes($indexes);
224
+    }
225
+
226
+
227
+    /**
228
+     * @param array $request
229
+     * @param string $userId
230
+     *
231
+     * @return ISearchResult[]
232
+     * @throws FullTextSearchAppNotAvailableException
233
+     */
234
+    public function search(array $request, string $userId = ''): array {
235
+        $searchRequest = $this->getSearchService()->generateSearchRequest($request);
236
+
237
+        return $this->getSearchService()->search($userId, $searchRequest);
238
+    }
239 239
 
240 240
 
241 241
 }
Please login to merge, or discard this patch.
apps/oauth2/lib/Db/AccessToken.php 1 patch
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -34,20 +34,20 @@
 block discarded – undo
34 34
  * @method void setHashedCode(string $token)
35 35
  */
36 36
 class AccessToken extends Entity {
37
-	/** @var int */
38
-	protected $tokenId;
39
-	/** @var int */
40
-	protected $clientId;
41
-	/** @var string */
42
-	protected $hashedCode;
43
-	/** @var string */
44
-	protected $encryptedToken;
37
+    /** @var int */
38
+    protected $tokenId;
39
+    /** @var int */
40
+    protected $clientId;
41
+    /** @var string */
42
+    protected $hashedCode;
43
+    /** @var string */
44
+    protected $encryptedToken;
45 45
 
46
-	public function __construct() {
47
-		$this->addType('id', 'int');
48
-		$this->addType('tokenId', 'int');
49
-		$this->addType('clientId', 'int');
50
-		$this->addType('hashedCode', 'string');
51
-		$this->addType('encryptedToken', 'string');
52
-	}
46
+    public function __construct() {
47
+        $this->addType('id', 'int');
48
+        $this->addType('tokenId', 'int');
49
+        $this->addType('clientId', 'int');
50
+        $this->addType('hashedCode', 'string');
51
+        $this->addType('encryptedToken', 'string');
52
+    }
53 53
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Login/ClearLostPasswordTokensCommand.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -29,24 +29,24 @@
 block discarded – undo
29 29
 
30 30
 class ClearLostPasswordTokensCommand extends ALoginCommand {
31 31
 
32
-	/** @var IConfig */
33
-	private $config;
34
-
35
-	public function __construct(IConfig $config) {
36
-		$this->config = $config;
37
-	}
38
-
39
-	/**
40
-	 * User has successfully logged in, now remove the password reset link, when it is available
41
-	 */
42
-	public function process(LoginData $loginData): LoginResult {
43
-		$this->config->deleteUserValue(
44
-			$loginData->getUser()->getUID(),
45
-			'core',
46
-			'lostpassword'
47
-		);
48
-
49
-		return $this->processNextOrFinishSuccessfully($loginData);
50
-	}
32
+    /** @var IConfig */
33
+    private $config;
34
+
35
+    public function __construct(IConfig $config) {
36
+        $this->config = $config;
37
+    }
38
+
39
+    /**
40
+     * User has successfully logged in, now remove the password reset link, when it is available
41
+     */
42
+    public function process(LoginData $loginData): LoginResult {
43
+        $this->config->deleteUserValue(
44
+            $loginData->getUser()->getUID(),
45
+            'core',
46
+            'lostpassword'
47
+        );
48
+
49
+        return $this->processNextOrFinishSuccessfully($loginData);
50
+    }
51 51
 
52 52
 }
Please login to merge, or discard this patch.
lib/private/Authentication/Login/UidLoginCommand.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -30,28 +30,28 @@
 block discarded – undo
30 30
 
31 31
 class UidLoginCommand extends ALoginCommand {
32 32
 
33
-	/** @var Manager */
34
-	private $userManager;
35
-
36
-	public function __construct(Manager $userManager) {
37
-		$this->userManager = $userManager;
38
-	}
39
-
40
-	/**
41
-	 * @param LoginData $loginData
42
-	 *
43
-	 * @return LoginResult
44
-	 */
45
-	public function process(LoginData $loginData): LoginResult {
46
-		/* @var $loginResult IUser */
47
-		$user = $this->userManager->checkPasswordNoLogging(
48
-			$loginData->getUsername(),
49
-			$loginData->getPassword()
50
-		);
51
-
52
-		$loginData->setUser($user);
53
-
54
-		return $this->processNextOrFinishSuccessfully($loginData);
55
-	}
33
+    /** @var Manager */
34
+    private $userManager;
35
+
36
+    public function __construct(Manager $userManager) {
37
+        $this->userManager = $userManager;
38
+    }
39
+
40
+    /**
41
+     * @param LoginData $loginData
42
+     *
43
+     * @return LoginResult
44
+     */
45
+    public function process(LoginData $loginData): LoginResult {
46
+        /* @var $loginResult IUser */
47
+        $user = $this->userManager->checkPasswordNoLogging(
48
+            $loginData->getUsername(),
49
+            $loginData->getPassword()
50
+        );
51
+
52
+        $loginData->setUser($user);
53
+
54
+        return $this->processNextOrFinishSuccessfully($loginData);
55
+    }
56 56
 
57 57
 }
Please login to merge, or discard this patch.