Code Duplication    Length = 7-13 lines in 4 locations

apps/dav/lib/SystemTag/SystemTagsByIdCollection.php 1 location

@@ 74-80 (lines=7) @@
71
	 *
72
	 * @return bool true if the user is an admin
73
	 */
74
	private function isAdmin() {
75
		$user = $this->userSession->getUser();
76
		if ($user !== null) {
77
			return $this->groupManager->isAdmin($user->getUID());
78
		}
79
		return false;
80
	}
81
82
	/**
83
	 * @param string $name

lib/private/NavigationManager.php 1 location

@@ 209-215 (lines=7) @@
206
		}
207
	}
208
209
	private function isAdmin() {
210
		$user = $this->userSession->getUser();
211
		if ($user !== null) {
212
			return $this->groupManager->isAdmin($user->getUID());
213
		}
214
		return false;
215
	}
216
217
	private function isSubAdmin() {
218
		$user = $this->userSession->getUser();

apps/dav/lib/Connector/Sabre/FilesReportPlugin.php 1 location

@@ 388-394 (lines=7) @@
385
	/**
386
	 * Returns whether the currently logged in user is an administrator
387
	 */
388
	private function isAdmin() {
389
		$user = $this->userSession->getUser();
390
		if ($user !== null) {
391
			return $this->groupManager->isAdmin($user->getUID());
392
		}
393
		return false;
394
	}
395
}
396

lib/private/User/Service/CreateUser.php 1 location

@@ 187-199 (lines=13) @@
184
		throw new CannotCreateUserException('Unable to create user.');
185
	}
186
187
	private function isAdmin() {
188
		// Check if current user (active and not in incognito mode)
189
		// is an admin
190
		$activeUser = $this->userSession->getUser();
191
		if ($activeUser !== null) {
192
			return $this->groupManager->isAdmin($activeUser->getUID());
193
		}
194
		// Check if it is triggered from command line
195
		if (\OC::$CLI) {
196
			return true;
197
		}
198
		return false;
199
	}
200
}