diff options
Diffstat (limited to 'lib/public/IUserManager.php')
-rw-r--r-- | lib/public/IUserManager.php | 112 |
1 files changed, 76 insertions, 36 deletions
diff --git a/lib/public/IUserManager.php b/lib/public/IUserManager.php index e5c220af40c..dbd1e188bec 100644 --- a/lib/public/IUserManager.php +++ b/lib/public/IUserManager.php @@ -1,31 +1,9 @@ <?php + /** - * @copyright Copyright (c) 2016, ownCloud, Inc. - * - * @author Arthur Schiwon <blizzz@arthur-schiwon.de> - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Jörn Friedrich Dreyer <jfd@butonic.de> - * @author Lukas Reschke <lukas@statuscode.ch> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Robin Appelman <robin@icewind.nl> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Müller <thomas.mueller@tmit.eu> - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * + * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-FileCopyrightText: 2016 ownCloud, Inc. + * SPDX-License-Identifier: AGPL-3.0-only */ namespace OCP; @@ -47,16 +25,21 @@ namespace OCP; */ interface IUserManager { /** + * @since 26.0.0 + */ + public const MAX_PASSWORD_LENGTH = 469; + + /** * register a user backend * - * @param \OCP\UserInterface $backend * @since 8.0.0 + * @return void */ - public function registerBackend($backend); + public function registerBackend(UserInterface $backend); /** * Get the active backends - * @return \OCP\UserInterface[] + * @return UserInterface[] * @since 8.0.0 */ public function getBackends(); @@ -64,16 +47,17 @@ interface IUserManager { /** * remove a user backend * - * @param \OCP\UserInterface $backend * @since 8.0.0 + * @return void */ - public function removeBackend($backend); + public function removeBackend(UserInterface $backend); /** * remove all user backends * @since 8.0.0 + * @return void */ - public function clearBackends() ; + public function clearBackends(); /** * get a user by user id @@ -85,6 +69,15 @@ interface IUserManager { public function get($uid); /** + * Get the display name of a user + * + * @param string $uid + * @return string|null + * @since 25.0.0 + */ + public function getDisplayName(string $uid): ?string; + + /** * check if a user exists * * @param string $uid @@ -98,7 +91,7 @@ interface IUserManager { * * @param string $loginName * @param string $password - * @return mixed the User object on success, false otherwise + * @return IUser|false the User object on success, false otherwise * @since 8.0.0 */ public function checkPassword($loginName, $password); @@ -126,6 +119,13 @@ interface IUserManager { public function searchDisplayName($pattern, $limit = null, $offset = null); /** + * @return IUser[] + * @since 28.0.0 + * @since 30.0.0 $search parameter added + */ + public function getDisabledUsers(?int $limit = null, int $offset = 0, string $search = ''): array; + + /** * Search known users (from phonebook sync) by displayName * * @param string $searcher @@ -141,7 +141,7 @@ interface IUserManager { * @param string $uid * @param string $password * @throws \InvalidArgumentException - * @return bool|\OCP\IUser the created user or false + * @return false|\OCP\IUser the created user or false * @since 8.0.0 */ public function createUser($uid, $password); @@ -157,14 +157,24 @@ interface IUserManager { public function createUserFromBackend($uid, $password, UserInterface $backend); /** - * returns how many users per backend exist (if supported by backend) + * Get how many users per backend exist (if supported by backend) * - * @return array an array of backend class as key and count number as value + * @return array<string, int> an array of backend class name as key and count number as value * @since 8.0.0 */ public function countUsers(); /** + * Get how many users exists in total, whithin limit + * + * @param int $limit Limit the count to avoid resource waste. 0 to disable + * @param bool $onlyMappedUsers Count mapped users instead of all users for compatible backends + * + * @since 31.0.0 + */ + public function countUsersTotal(int $limit = 0, bool $onlyMappedUsers = false): int|false; + + /** * @param \Closure $callback * @psalm-param \Closure(\OCP\IUser):void $callback * @param string $search @@ -203,4 +213,34 @@ interface IUserManager { * @since 9.1.0 */ public function getByEmail($email); + + /** + * @param string $uid The user ID to validate + * @param bool $checkDataDirectory Whether it should be checked if files for the ID exist inside the data directory + * @throws \InvalidArgumentException Message is an already translated string with a reason why the ID is not valid + * @since 26.0.0 + */ + public function validateUserId(string $uid, bool $checkDataDirectory = false): void; + + /** + * Gets the list of users sorted by lastLogin, from most recent to least recent + * + * @param int|null $limit how many records to fetch + * @param int $offset from which offset to fetch + * @param string $search search users based on search params + * @return list<string> list of user IDs + * @since 30.0.0 + */ + public function getLastLoggedInUsers(?int $limit = null, int $offset = 0, string $search = ''): array; + + /** + * Gets the list of users. + * An iterator is returned allowing the caller to stop the iteration at any time. + * The offset argument allows the caller to continue the iteration at a specific offset. + * + * @param int $offset from which offset to fetch + * @return \Iterator<IUser> list of IUser object + * @since 32.0.0 + */ + public function getSeenUsers(int $offset = 0): \Iterator; } |