Passed
Push — master ( c56a27...645109 )
by Christoph
13:24 queued 10s
created
lib/private/Group/Group.php 2 patches
Indentation   +357 added lines, -357 removed lines patch added patch discarded remove patch
@@ -45,361 +45,361 @@
 block discarded – undo
45 45
 use Symfony\Component\EventDispatcher\GenericEvent;
46 46
 
47 47
 class Group implements IGroup {
48
-	/** @var null|string  */
49
-	protected $displayName;
50
-
51
-	/** @var string */
52
-	private $gid;
53
-
54
-	/** @var \OC\User\User[] */
55
-	private $users = [];
56
-
57
-	/** @var bool */
58
-	private $usersLoaded;
59
-
60
-	/** @var Backend[] */
61
-	private $backends;
62
-	/** @var EventDispatcherInterface */
63
-	private $dispatcher;
64
-	/** @var \OC\User\Manager|IUserManager  */
65
-	private $userManager;
66
-	/** @var PublicEmitter */
67
-	private $emitter;
68
-
69
-
70
-	/**
71
-	 * @param string $gid
72
-	 * @param Backend[] $backends
73
-	 * @param EventDispatcherInterface $dispatcher
74
-	 * @param IUserManager $userManager
75
-	 * @param PublicEmitter $emitter
76
-	 * @param string $displayName
77
-	 */
78
-	public function __construct(string $gid, array $backends, EventDispatcherInterface $dispatcher, IUserManager $userManager, PublicEmitter $emitter = null, ?string $displayName = null) {
79
-		$this->gid = $gid;
80
-		$this->backends = $backends;
81
-		$this->dispatcher = $dispatcher;
82
-		$this->userManager = $userManager;
83
-		$this->emitter = $emitter;
84
-		$this->displayName = $displayName;
85
-	}
86
-
87
-	public function getGID() {
88
-		return $this->gid;
89
-	}
90
-
91
-	public function getDisplayName() {
92
-		if (is_null($this->displayName)) {
93
-			foreach ($this->backends as $backend) {
94
-				if ($backend instanceof IGetDisplayNameBackend) {
95
-					$displayName = $backend->getDisplayName($this->gid);
96
-					if (trim($displayName) !== '') {
97
-						$this->displayName = $displayName;
98
-						return $this->displayName;
99
-					}
100
-				}
101
-			}
102
-			return $this->gid;
103
-		}
104
-		return $this->displayName;
105
-	}
106
-
107
-	public function setDisplayName(string $displayName): bool {
108
-		$displayName = trim($displayName);
109
-		if ($displayName !== '') {
110
-			foreach ($this->backends as $backend) {
111
-				if (($backend instanceof ISetDisplayNameBackend)
112
-					&& $backend->setDisplayName($this->gid, $displayName)) {
113
-					$this->displayName = $displayName;
114
-					return true;
115
-				}
116
-			}
117
-		}
118
-		return false;
119
-	}
120
-
121
-	/**
122
-	 * get all users in the group
123
-	 *
124
-	 * @return \OC\User\User[]
125
-	 */
126
-	public function getUsers() {
127
-		if ($this->usersLoaded) {
128
-			return $this->users;
129
-		}
130
-
131
-		$userIds = [];
132
-		foreach ($this->backends as $backend) {
133
-			$diff = array_diff(
134
-				$backend->usersInGroup($this->gid),
135
-				$userIds
136
-			);
137
-			if ($diff) {
138
-				$userIds = array_merge($userIds, $diff);
139
-			}
140
-		}
141
-
142
-		$this->users = $this->getVerifiedUsers($userIds);
143
-		$this->usersLoaded = true;
144
-		return $this->users;
145
-	}
146
-
147
-	/**
148
-	 * check if a user is in the group
149
-	 *
150
-	 * @param IUser $user
151
-	 * @return bool
152
-	 */
153
-	public function inGroup(IUser $user) {
154
-		if (isset($this->users[$user->getUID()])) {
155
-			return true;
156
-		}
157
-		foreach ($this->backends as $backend) {
158
-			if ($backend->inGroup($user->getUID(), $this->gid)) {
159
-				$this->users[$user->getUID()] = $user;
160
-				return true;
161
-			}
162
-		}
163
-		return false;
164
-	}
165
-
166
-	/**
167
-	 * add a user to the group
168
-	 *
169
-	 * @param IUser $user
170
-	 */
171
-	public function addUser(IUser $user) {
172
-		if ($this->inGroup($user)) {
173
-			return;
174
-		}
175
-
176
-		$this->dispatcher->dispatch(IGroup::class . '::preAddUser', new GenericEvent($this, [
177
-			'user' => $user,
178
-		]));
179
-
180
-		if ($this->emitter) {
181
-			$this->emitter->emit('\OC\Group', 'preAddUser', [$this, $user]);
182
-		}
183
-		foreach ($this->backends as $backend) {
184
-			if ($backend->implementsActions(\OC\Group\Backend::ADD_TO_GROUP)) {
185
-				$backend->addToGroup($user->getUID(), $this->gid);
186
-				if ($this->users) {
187
-					$this->users[$user->getUID()] = $user;
188
-				}
189
-
190
-				$this->dispatcher->dispatch(IGroup::class . '::postAddUser', new GenericEvent($this, [
191
-					'user' => $user,
192
-				]));
193
-
194
-				if ($this->emitter) {
195
-					$this->emitter->emit('\OC\Group', 'postAddUser', [$this, $user]);
196
-				}
197
-				return;
198
-			}
199
-		}
200
-	}
201
-
202
-	/**
203
-	 * remove a user from the group
204
-	 *
205
-	 * @param \OC\User\User $user
206
-	 */
207
-	public function removeUser($user) {
208
-		$result = false;
209
-		$this->dispatcher->dispatch(IGroup::class . '::preRemoveUser', new GenericEvent($this, [
210
-			'user' => $user,
211
-		]));
212
-		if ($this->emitter) {
213
-			$this->emitter->emit('\OC\Group', 'preRemoveUser', [$this, $user]);
214
-		}
215
-		foreach ($this->backends as $backend) {
216
-			if ($backend->implementsActions(\OC\Group\Backend::REMOVE_FROM_GOUP) and $backend->inGroup($user->getUID(), $this->gid)) {
217
-				$backend->removeFromGroup($user->getUID(), $this->gid);
218
-				$result = true;
219
-			}
220
-		}
221
-		if ($result) {
222
-			$this->dispatcher->dispatch(IGroup::class . '::postRemoveUser', new GenericEvent($this, [
223
-				'user' => $user,
224
-			]));
225
-			if ($this->emitter) {
226
-				$this->emitter->emit('\OC\Group', 'postRemoveUser', [$this, $user]);
227
-			}
228
-			if ($this->users) {
229
-				foreach ($this->users as $index => $groupUser) {
230
-					if ($groupUser->getUID() === $user->getUID()) {
231
-						unset($this->users[$index]);
232
-						return;
233
-					}
234
-				}
235
-			}
236
-		}
237
-	}
238
-
239
-	/**
240
-	 * search for users in the group by userid
241
-	 *
242
-	 * @param string $search
243
-	 * @param int $limit
244
-	 * @param int $offset
245
-	 * @return \OC\User\User[]
246
-	 */
247
-	public function searchUsers($search, $limit = null, $offset = null) {
248
-		$users = [];
249
-		foreach ($this->backends as $backend) {
250
-			$userIds = $backend->usersInGroup($this->gid, $search, $limit, $offset);
251
-			$users += $this->getVerifiedUsers($userIds);
252
-			if (!is_null($limit) and $limit <= 0) {
253
-				return $users;
254
-			}
255
-		}
256
-		return $users;
257
-	}
258
-
259
-	/**
260
-	 * returns the number of users matching the search string
261
-	 *
262
-	 * @param string $search
263
-	 * @return int|bool
264
-	 */
265
-	public function count($search = '') {
266
-		$users = false;
267
-		foreach ($this->backends as $backend) {
268
-			if($backend->implementsActions(\OC\Group\Backend::COUNT_USERS)) {
269
-				if($users === false) {
270
-					//we could directly add to a bool variable, but this would
271
-					//be ugly
272
-					$users = 0;
273
-				}
274
-				$users += $backend->countUsersInGroup($this->gid, $search);
275
-			}
276
-		}
277
-		return $users;
278
-	}
279
-
280
-	/**
281
-	 * returns the number of disabled users
282
-	 *
283
-	 * @return int|bool
284
-	 */
285
-	public function countDisabled() {
286
-		$users = false;
287
-		foreach ($this->backends as $backend) {
288
-			if($backend instanceof ICountDisabledInGroup) {
289
-				if($users === false) {
290
-					//we could directly add to a bool variable, but this would
291
-					//be ugly
292
-					$users = 0;
293
-				}
294
-				$users += $backend->countDisabledInGroup($this->gid);
295
-			}
296
-		}
297
-		return $users;
298
-	}
299
-
300
-	/**
301
-	 * search for users in the group by displayname
302
-	 *
303
-	 * @param string $search
304
-	 * @param int $limit
305
-	 * @param int $offset
306
-	 * @return \OC\User\User[]
307
-	 */
308
-	public function searchDisplayName($search, $limit = null, $offset = null) {
309
-		$users = [];
310
-		foreach ($this->backends as $backend) {
311
-			$userIds = $backend->usersInGroup($this->gid, $search, $limit, $offset);
312
-			$users = $this->getVerifiedUsers($userIds);
313
-			if (!is_null($limit) and $limit <= 0) {
314
-				return array_values($users);
315
-			}
316
-		}
317
-		return array_values($users);
318
-	}
319
-
320
-	/**
321
-	 * delete the group
322
-	 *
323
-	 * @return bool
324
-	 */
325
-	public function delete() {
326
-		// Prevent users from deleting group admin
327
-		if ($this->getGID() === 'admin') {
328
-			return false;
329
-		}
330
-
331
-		$result = false;
332
-		$this->dispatcher->dispatch(IGroup::class . '::preDelete', new GenericEvent($this));
333
-		if ($this->emitter) {
334
-			$this->emitter->emit('\OC\Group', 'preDelete', [$this]);
335
-		}
336
-		foreach ($this->backends as $backend) {
337
-			if ($backend->implementsActions(\OC\Group\Backend::DELETE_GROUP)) {
338
-				$result = true;
339
-				$backend->deleteGroup($this->gid);
340
-			}
341
-		}
342
-		if ($result) {
343
-			$this->dispatcher->dispatch(IGroup::class . '::postDelete', new GenericEvent($this));
344
-			if ($this->emitter) {
345
-				$this->emitter->emit('\OC\Group', 'postDelete', [$this]);
346
-			}
347
-		}
348
-		return $result;
349
-	}
350
-
351
-	/**
352
-	 * returns all the Users from an array that really exists
353
-	 * @param string[] $userIds an array containing user IDs
354
-	 * @return \OC\User\User[] an Array with the userId as Key and \OC\User\User as value
355
-	 */
356
-	private function getVerifiedUsers($userIds) {
357
-		if (!is_array($userIds)) {
358
-			return [];
359
-		}
360
-		$users = [];
361
-		foreach ($userIds as $userId) {
362
-			$user = $this->userManager->get($userId);
363
-			if (!is_null($user)) {
364
-				$users[$userId] = $user;
365
-			}
366
-		}
367
-		return $users;
368
-	}
369
-
370
-	/**
371
-	 * @return bool
372
-	 * @since 14.0.0
373
-	 */
374
-	public function canRemoveUser() {
375
-		foreach ($this->backends as $backend) {
376
-			if ($backend->implementsActions(GroupInterface::REMOVE_FROM_GOUP)) {
377
-				return true;
378
-			}
379
-		}
380
-		return false;
381
-	}
382
-
383
-	/**
384
-	 * @return bool
385
-	 * @since 14.0.0
386
-	 */
387
-	public function canAddUser() {
388
-		foreach ($this->backends as $backend) {
389
-			if ($backend->implementsActions(GroupInterface::ADD_TO_GROUP)) {
390
-				return true;
391
-			}
392
-		}
393
-		return false;
394
-	}
395
-
396
-	/**
397
-	 * @return bool
398
-	 * @since 16.0.0
399
-	 */
400
-	public function hideFromCollaboration(): bool {
401
-		return array_reduce($this->backends, function (bool $hide, GroupInterface $backend) {
402
-			return $hide | ($backend instanceof IHideFromCollaborationBackend && $backend->hideGroup($this->gid));
403
-		}, false);
404
-	}
48
+    /** @var null|string  */
49
+    protected $displayName;
50
+
51
+    /** @var string */
52
+    private $gid;
53
+
54
+    /** @var \OC\User\User[] */
55
+    private $users = [];
56
+
57
+    /** @var bool */
58
+    private $usersLoaded;
59
+
60
+    /** @var Backend[] */
61
+    private $backends;
62
+    /** @var EventDispatcherInterface */
63
+    private $dispatcher;
64
+    /** @var \OC\User\Manager|IUserManager  */
65
+    private $userManager;
66
+    /** @var PublicEmitter */
67
+    private $emitter;
68
+
69
+
70
+    /**
71
+     * @param string $gid
72
+     * @param Backend[] $backends
73
+     * @param EventDispatcherInterface $dispatcher
74
+     * @param IUserManager $userManager
75
+     * @param PublicEmitter $emitter
76
+     * @param string $displayName
77
+     */
78
+    public function __construct(string $gid, array $backends, EventDispatcherInterface $dispatcher, IUserManager $userManager, PublicEmitter $emitter = null, ?string $displayName = null) {
79
+        $this->gid = $gid;
80
+        $this->backends = $backends;
81
+        $this->dispatcher = $dispatcher;
82
+        $this->userManager = $userManager;
83
+        $this->emitter = $emitter;
84
+        $this->displayName = $displayName;
85
+    }
86
+
87
+    public function getGID() {
88
+        return $this->gid;
89
+    }
90
+
91
+    public function getDisplayName() {
92
+        if (is_null($this->displayName)) {
93
+            foreach ($this->backends as $backend) {
94
+                if ($backend instanceof IGetDisplayNameBackend) {
95
+                    $displayName = $backend->getDisplayName($this->gid);
96
+                    if (trim($displayName) !== '') {
97
+                        $this->displayName = $displayName;
98
+                        return $this->displayName;
99
+                    }
100
+                }
101
+            }
102
+            return $this->gid;
103
+        }
104
+        return $this->displayName;
105
+    }
106
+
107
+    public function setDisplayName(string $displayName): bool {
108
+        $displayName = trim($displayName);
109
+        if ($displayName !== '') {
110
+            foreach ($this->backends as $backend) {
111
+                if (($backend instanceof ISetDisplayNameBackend)
112
+                    && $backend->setDisplayName($this->gid, $displayName)) {
113
+                    $this->displayName = $displayName;
114
+                    return true;
115
+                }
116
+            }
117
+        }
118
+        return false;
119
+    }
120
+
121
+    /**
122
+     * get all users in the group
123
+     *
124
+     * @return \OC\User\User[]
125
+     */
126
+    public function getUsers() {
127
+        if ($this->usersLoaded) {
128
+            return $this->users;
129
+        }
130
+
131
+        $userIds = [];
132
+        foreach ($this->backends as $backend) {
133
+            $diff = array_diff(
134
+                $backend->usersInGroup($this->gid),
135
+                $userIds
136
+            );
137
+            if ($diff) {
138
+                $userIds = array_merge($userIds, $diff);
139
+            }
140
+        }
141
+
142
+        $this->users = $this->getVerifiedUsers($userIds);
143
+        $this->usersLoaded = true;
144
+        return $this->users;
145
+    }
146
+
147
+    /**
148
+     * check if a user is in the group
149
+     *
150
+     * @param IUser $user
151
+     * @return bool
152
+     */
153
+    public function inGroup(IUser $user) {
154
+        if (isset($this->users[$user->getUID()])) {
155
+            return true;
156
+        }
157
+        foreach ($this->backends as $backend) {
158
+            if ($backend->inGroup($user->getUID(), $this->gid)) {
159
+                $this->users[$user->getUID()] = $user;
160
+                return true;
161
+            }
162
+        }
163
+        return false;
164
+    }
165
+
166
+    /**
167
+     * add a user to the group
168
+     *
169
+     * @param IUser $user
170
+     */
171
+    public function addUser(IUser $user) {
172
+        if ($this->inGroup($user)) {
173
+            return;
174
+        }
175
+
176
+        $this->dispatcher->dispatch(IGroup::class . '::preAddUser', new GenericEvent($this, [
177
+            'user' => $user,
178
+        ]));
179
+
180
+        if ($this->emitter) {
181
+            $this->emitter->emit('\OC\Group', 'preAddUser', [$this, $user]);
182
+        }
183
+        foreach ($this->backends as $backend) {
184
+            if ($backend->implementsActions(\OC\Group\Backend::ADD_TO_GROUP)) {
185
+                $backend->addToGroup($user->getUID(), $this->gid);
186
+                if ($this->users) {
187
+                    $this->users[$user->getUID()] = $user;
188
+                }
189
+
190
+                $this->dispatcher->dispatch(IGroup::class . '::postAddUser', new GenericEvent($this, [
191
+                    'user' => $user,
192
+                ]));
193
+
194
+                if ($this->emitter) {
195
+                    $this->emitter->emit('\OC\Group', 'postAddUser', [$this, $user]);
196
+                }
197
+                return;
198
+            }
199
+        }
200
+    }
201
+
202
+    /**
203
+     * remove a user from the group
204
+     *
205
+     * @param \OC\User\User $user
206
+     */
207
+    public function removeUser($user) {
208
+        $result = false;
209
+        $this->dispatcher->dispatch(IGroup::class . '::preRemoveUser', new GenericEvent($this, [
210
+            'user' => $user,
211
+        ]));
212
+        if ($this->emitter) {
213
+            $this->emitter->emit('\OC\Group', 'preRemoveUser', [$this, $user]);
214
+        }
215
+        foreach ($this->backends as $backend) {
216
+            if ($backend->implementsActions(\OC\Group\Backend::REMOVE_FROM_GOUP) and $backend->inGroup($user->getUID(), $this->gid)) {
217
+                $backend->removeFromGroup($user->getUID(), $this->gid);
218
+                $result = true;
219
+            }
220
+        }
221
+        if ($result) {
222
+            $this->dispatcher->dispatch(IGroup::class . '::postRemoveUser', new GenericEvent($this, [
223
+                'user' => $user,
224
+            ]));
225
+            if ($this->emitter) {
226
+                $this->emitter->emit('\OC\Group', 'postRemoveUser', [$this, $user]);
227
+            }
228
+            if ($this->users) {
229
+                foreach ($this->users as $index => $groupUser) {
230
+                    if ($groupUser->getUID() === $user->getUID()) {
231
+                        unset($this->users[$index]);
232
+                        return;
233
+                    }
234
+                }
235
+            }
236
+        }
237
+    }
238
+
239
+    /**
240
+     * search for users in the group by userid
241
+     *
242
+     * @param string $search
243
+     * @param int $limit
244
+     * @param int $offset
245
+     * @return \OC\User\User[]
246
+     */
247
+    public function searchUsers($search, $limit = null, $offset = null) {
248
+        $users = [];
249
+        foreach ($this->backends as $backend) {
250
+            $userIds = $backend->usersInGroup($this->gid, $search, $limit, $offset);
251
+            $users += $this->getVerifiedUsers($userIds);
252
+            if (!is_null($limit) and $limit <= 0) {
253
+                return $users;
254
+            }
255
+        }
256
+        return $users;
257
+    }
258
+
259
+    /**
260
+     * returns the number of users matching the search string
261
+     *
262
+     * @param string $search
263
+     * @return int|bool
264
+     */
265
+    public function count($search = '') {
266
+        $users = false;
267
+        foreach ($this->backends as $backend) {
268
+            if($backend->implementsActions(\OC\Group\Backend::COUNT_USERS)) {
269
+                if($users === false) {
270
+                    //we could directly add to a bool variable, but this would
271
+                    //be ugly
272
+                    $users = 0;
273
+                }
274
+                $users += $backend->countUsersInGroup($this->gid, $search);
275
+            }
276
+        }
277
+        return $users;
278
+    }
279
+
280
+    /**
281
+     * returns the number of disabled users
282
+     *
283
+     * @return int|bool
284
+     */
285
+    public function countDisabled() {
286
+        $users = false;
287
+        foreach ($this->backends as $backend) {
288
+            if($backend instanceof ICountDisabledInGroup) {
289
+                if($users === false) {
290
+                    //we could directly add to a bool variable, but this would
291
+                    //be ugly
292
+                    $users = 0;
293
+                }
294
+                $users += $backend->countDisabledInGroup($this->gid);
295
+            }
296
+        }
297
+        return $users;
298
+    }
299
+
300
+    /**
301
+     * search for users in the group by displayname
302
+     *
303
+     * @param string $search
304
+     * @param int $limit
305
+     * @param int $offset
306
+     * @return \OC\User\User[]
307
+     */
308
+    public function searchDisplayName($search, $limit = null, $offset = null) {
309
+        $users = [];
310
+        foreach ($this->backends as $backend) {
311
+            $userIds = $backend->usersInGroup($this->gid, $search, $limit, $offset);
312
+            $users = $this->getVerifiedUsers($userIds);
313
+            if (!is_null($limit) and $limit <= 0) {
314
+                return array_values($users);
315
+            }
316
+        }
317
+        return array_values($users);
318
+    }
319
+
320
+    /**
321
+     * delete the group
322
+     *
323
+     * @return bool
324
+     */
325
+    public function delete() {
326
+        // Prevent users from deleting group admin
327
+        if ($this->getGID() === 'admin') {
328
+            return false;
329
+        }
330
+
331
+        $result = false;
332
+        $this->dispatcher->dispatch(IGroup::class . '::preDelete', new GenericEvent($this));
333
+        if ($this->emitter) {
334
+            $this->emitter->emit('\OC\Group', 'preDelete', [$this]);
335
+        }
336
+        foreach ($this->backends as $backend) {
337
+            if ($backend->implementsActions(\OC\Group\Backend::DELETE_GROUP)) {
338
+                $result = true;
339
+                $backend->deleteGroup($this->gid);
340
+            }
341
+        }
342
+        if ($result) {
343
+            $this->dispatcher->dispatch(IGroup::class . '::postDelete', new GenericEvent($this));
344
+            if ($this->emitter) {
345
+                $this->emitter->emit('\OC\Group', 'postDelete', [$this]);
346
+            }
347
+        }
348
+        return $result;
349
+    }
350
+
351
+    /**
352
+     * returns all the Users from an array that really exists
353
+     * @param string[] $userIds an array containing user IDs
354
+     * @return \OC\User\User[] an Array with the userId as Key and \OC\User\User as value
355
+     */
356
+    private function getVerifiedUsers($userIds) {
357
+        if (!is_array($userIds)) {
358
+            return [];
359
+        }
360
+        $users = [];
361
+        foreach ($userIds as $userId) {
362
+            $user = $this->userManager->get($userId);
363
+            if (!is_null($user)) {
364
+                $users[$userId] = $user;
365
+            }
366
+        }
367
+        return $users;
368
+    }
369
+
370
+    /**
371
+     * @return bool
372
+     * @since 14.0.0
373
+     */
374
+    public function canRemoveUser() {
375
+        foreach ($this->backends as $backend) {
376
+            if ($backend->implementsActions(GroupInterface::REMOVE_FROM_GOUP)) {
377
+                return true;
378
+            }
379
+        }
380
+        return false;
381
+    }
382
+
383
+    /**
384
+     * @return bool
385
+     * @since 14.0.0
386
+     */
387
+    public function canAddUser() {
388
+        foreach ($this->backends as $backend) {
389
+            if ($backend->implementsActions(GroupInterface::ADD_TO_GROUP)) {
390
+                return true;
391
+            }
392
+        }
393
+        return false;
394
+    }
395
+
396
+    /**
397
+     * @return bool
398
+     * @since 16.0.0
399
+     */
400
+    public function hideFromCollaboration(): bool {
401
+        return array_reduce($this->backends, function (bool $hide, GroupInterface $backend) {
402
+            return $hide | ($backend instanceof IHideFromCollaborationBackend && $backend->hideGroup($this->gid));
403
+        }, false);
404
+    }
405 405
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 			return;
174 174
 		}
175 175
 
176
-		$this->dispatcher->dispatch(IGroup::class . '::preAddUser', new GenericEvent($this, [
176
+		$this->dispatcher->dispatch(IGroup::class.'::preAddUser', new GenericEvent($this, [
177 177
 			'user' => $user,
178 178
 		]));
179 179
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 					$this->users[$user->getUID()] = $user;
188 188
 				}
189 189
 
190
-				$this->dispatcher->dispatch(IGroup::class . '::postAddUser', new GenericEvent($this, [
190
+				$this->dispatcher->dispatch(IGroup::class.'::postAddUser', new GenericEvent($this, [
191 191
 					'user' => $user,
192 192
 				]));
193 193
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	 */
207 207
 	public function removeUser($user) {
208 208
 		$result = false;
209
-		$this->dispatcher->dispatch(IGroup::class . '::preRemoveUser', new GenericEvent($this, [
209
+		$this->dispatcher->dispatch(IGroup::class.'::preRemoveUser', new GenericEvent($this, [
210 210
 			'user' => $user,
211 211
 		]));
212 212
 		if ($this->emitter) {
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 			}
220 220
 		}
221 221
 		if ($result) {
222
-			$this->dispatcher->dispatch(IGroup::class . '::postRemoveUser', new GenericEvent($this, [
222
+			$this->dispatcher->dispatch(IGroup::class.'::postRemoveUser', new GenericEvent($this, [
223 223
 				'user' => $user,
224 224
 			]));
225 225
 			if ($this->emitter) {
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	public function count($search = '') {
266 266
 		$users = false;
267 267
 		foreach ($this->backends as $backend) {
268
-			if($backend->implementsActions(\OC\Group\Backend::COUNT_USERS)) {
269
-				if($users === false) {
268
+			if ($backend->implementsActions(\OC\Group\Backend::COUNT_USERS)) {
269
+				if ($users === false) {
270 270
 					//we could directly add to a bool variable, but this would
271 271
 					//be ugly
272 272
 					$users = 0;
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 	public function countDisabled() {
286 286
 		$users = false;
287 287
 		foreach ($this->backends as $backend) {
288
-			if($backend instanceof ICountDisabledInGroup) {
289
-				if($users === false) {
288
+			if ($backend instanceof ICountDisabledInGroup) {
289
+				if ($users === false) {
290 290
 					//we could directly add to a bool variable, but this would
291 291
 					//be ugly
292 292
 					$users = 0;
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 		}
330 330
 
331 331
 		$result = false;
332
-		$this->dispatcher->dispatch(IGroup::class . '::preDelete', new GenericEvent($this));
332
+		$this->dispatcher->dispatch(IGroup::class.'::preDelete', new GenericEvent($this));
333 333
 		if ($this->emitter) {
334 334
 			$this->emitter->emit('\OC\Group', 'preDelete', [$this]);
335 335
 		}
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 			}
341 341
 		}
342 342
 		if ($result) {
343
-			$this->dispatcher->dispatch(IGroup::class . '::postDelete', new GenericEvent($this));
343
+			$this->dispatcher->dispatch(IGroup::class.'::postDelete', new GenericEvent($this));
344 344
 			if ($this->emitter) {
345 345
 				$this->emitter->emit('\OC\Group', 'postDelete', [$this]);
346 346
 			}
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 * @since 16.0.0
399 399
 	 */
400 400
 	public function hideFromCollaboration(): bool {
401
-		return array_reduce($this->backends, function (bool $hide, GroupInterface $backend) {
401
+		return array_reduce($this->backends, function(bool $hide, GroupInterface $backend) {
402 402
 			return $hide | ($backend instanceof IHideFromCollaborationBackend && $backend->hideGroup($this->gid));
403 403
 		}, false);
404 404
 	}
Please login to merge, or discard this patch.
lib/private/Group/Backend.php 2 patches
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -29,107 +29,107 @@
 block discarded – undo
29 29
  * Abstract base class for user management
30 30
  */
31 31
 abstract class Backend implements \OCP\GroupInterface {
32
-	/**
33
-	 * error code for functions not provided by the group backend
34
-	 */
35
-	const NOT_IMPLEMENTED = -501;
32
+    /**
33
+     * error code for functions not provided by the group backend
34
+     */
35
+    const NOT_IMPLEMENTED = -501;
36 36
 
37
-	protected $possibleActions = [
38
-		self::CREATE_GROUP => 'createGroup',
39
-		self::DELETE_GROUP => 'deleteGroup',
40
-		self::ADD_TO_GROUP => 'addToGroup',
41
-		self::REMOVE_FROM_GOUP => 'removeFromGroup',
42
-		self::COUNT_USERS => 'countUsersInGroup',
43
-		self::GROUP_DETAILS => 'getGroupDetails',
44
-		self::IS_ADMIN => 'isAdmin',
45
-	];
37
+    protected $possibleActions = [
38
+        self::CREATE_GROUP => 'createGroup',
39
+        self::DELETE_GROUP => 'deleteGroup',
40
+        self::ADD_TO_GROUP => 'addToGroup',
41
+        self::REMOVE_FROM_GOUP => 'removeFromGroup',
42
+        self::COUNT_USERS => 'countUsersInGroup',
43
+        self::GROUP_DETAILS => 'getGroupDetails',
44
+        self::IS_ADMIN => 'isAdmin',
45
+    ];
46 46
 
47
-	/**
48
-	 * Get all supported actions
49
-	 * @return int bitwise-or'ed actions
50
-	 *
51
-	 * Returns the supported actions as int to be
52
-	 * compared with \OC\Group\Backend::CREATE_GROUP etc.
53
-	 */
54
-	public function getSupportedActions() {
55
-		$actions = 0;
56
-		foreach($this->possibleActions as $action => $methodName) {
57
-			if(method_exists($this, $methodName)) {
58
-				$actions |= $action;
59
-			}
60
-		}
47
+    /**
48
+     * Get all supported actions
49
+     * @return int bitwise-or'ed actions
50
+     *
51
+     * Returns the supported actions as int to be
52
+     * compared with \OC\Group\Backend::CREATE_GROUP etc.
53
+     */
54
+    public function getSupportedActions() {
55
+        $actions = 0;
56
+        foreach($this->possibleActions as $action => $methodName) {
57
+            if(method_exists($this, $methodName)) {
58
+                $actions |= $action;
59
+            }
60
+        }
61 61
 
62
-		return $actions;
63
-	}
62
+        return $actions;
63
+    }
64 64
 
65
-	/**
66
-	 * Check if backend implements actions
67
-	 * @param int $actions bitwise-or'ed actions
68
-	 * @return bool
69
-	 *
70
-	 * Returns the supported actions as int to be
71
-	 * compared with \OC\Group\Backend::CREATE_GROUP etc.
72
-	 */
73
-	public function implementsActions($actions) {
74
-		return (bool)($this->getSupportedActions() & $actions);
75
-	}
65
+    /**
66
+     * Check if backend implements actions
67
+     * @param int $actions bitwise-or'ed actions
68
+     * @return bool
69
+     *
70
+     * Returns the supported actions as int to be
71
+     * compared with \OC\Group\Backend::CREATE_GROUP etc.
72
+     */
73
+    public function implementsActions($actions) {
74
+        return (bool)($this->getSupportedActions() & $actions);
75
+    }
76 76
 
77
-	/**
78
-	 * is user in group?
79
-	 * @param string $uid uid of the user
80
-	 * @param string $gid gid of the group
81
-	 * @return bool
82
-	 *
83
-	 * Checks whether the user is member of a group or not.
84
-	 */
85
-	public function inGroup($uid, $gid) {
86
-		return in_array($gid, $this->getUserGroups($uid));
87
-	}
77
+    /**
78
+     * is user in group?
79
+     * @param string $uid uid of the user
80
+     * @param string $gid gid of the group
81
+     * @return bool
82
+     *
83
+     * Checks whether the user is member of a group or not.
84
+     */
85
+    public function inGroup($uid, $gid) {
86
+        return in_array($gid, $this->getUserGroups($uid));
87
+    }
88 88
 
89
-	/**
90
-	 * Get all groups a user belongs to
91
-	 * @param string $uid Name of the user
92
-	 * @return array an array of group names
93
-	 *
94
-	 * This function fetches all groups a user belongs to. It does not check
95
-	 * if the user exists at all.
96
-	 */
97
-	public function getUserGroups($uid) {
98
-		return [];
99
-	}
89
+    /**
90
+     * Get all groups a user belongs to
91
+     * @param string $uid Name of the user
92
+     * @return array an array of group names
93
+     *
94
+     * This function fetches all groups a user belongs to. It does not check
95
+     * if the user exists at all.
96
+     */
97
+    public function getUserGroups($uid) {
98
+        return [];
99
+    }
100 100
 
101
-	/**
102
-	 * get a list of all groups
103
-	 * @param string $search
104
-	 * @param int $limit
105
-	 * @param int $offset
106
-	 * @return array an array of group names
107
-	 *
108
-	 * Returns a list with all groups
109
-	 */
101
+    /**
102
+     * get a list of all groups
103
+     * @param string $search
104
+     * @param int $limit
105
+     * @param int $offset
106
+     * @return array an array of group names
107
+     *
108
+     * Returns a list with all groups
109
+     */
110 110
 
111
-	public function getGroups($search = '', $limit = -1, $offset = 0) {
112
-		return [];
113
-	}
111
+    public function getGroups($search = '', $limit = -1, $offset = 0) {
112
+        return [];
113
+    }
114 114
 
115
-	/**
116
-	 * check if a group exists
117
-	 * @param string $gid
118
-	 * @return bool
119
-	 */
120
-	public function groupExists($gid) {
121
-		return in_array($gid, $this->getGroups($gid, 1));
122
-	}
115
+    /**
116
+     * check if a group exists
117
+     * @param string $gid
118
+     * @return bool
119
+     */
120
+    public function groupExists($gid) {
121
+        return in_array($gid, $this->getGroups($gid, 1));
122
+    }
123 123
 
124
-	/**
125
-	 * get a list of all users in a group
126
-	 * @param string $gid
127
-	 * @param string $search
128
-	 * @param int $limit
129
-	 * @param int $offset
130
-	 * @return array an array of user ids
131
-	 */
132
-	public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
133
-		return [];
134
-	}
124
+    /**
125
+     * get a list of all users in a group
126
+     * @param string $gid
127
+     * @param string $search
128
+     * @param int $limit
129
+     * @param int $offset
130
+     * @return array an array of user ids
131
+     */
132
+    public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) {
133
+        return [];
134
+    }
135 135
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	public function getSupportedActions() {
55 55
 		$actions = 0;
56
-		foreach($this->possibleActions as $action => $methodName) {
57
-			if(method_exists($this, $methodName)) {
56
+		foreach ($this->possibleActions as $action => $methodName) {
57
+			if (method_exists($this, $methodName)) {
58 58
 				$actions |= $action;
59 59
 			}
60 60
 		}
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * compared with \OC\Group\Backend::CREATE_GROUP etc.
72 72
 	 */
73 73
 	public function implementsActions($actions) {
74
-		return (bool)($this->getSupportedActions() & $actions);
74
+		return (bool) ($this->getSupportedActions() & $actions);
75 75
 	}
76 76
 
77 77
 	/**
Please login to merge, or discard this patch.