mirror of
https://github.com/nextcloud/server.git
synced 2026-05-24 02:56:57 -04:00
style(provisioning_api): apply php-cs-fixer
-e Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
This commit is contained in:
parent
9fe75f3502
commit
cf67d29c91
2 changed files with 41 additions and 67 deletions
|
|
@ -58,8 +58,7 @@ use Psr\Log\LoggerInterface;
|
|||
* @psalm-import-type Provisioning_APIGroupDetails from ResponseDefinitions
|
||||
* @psalm-import-type Provisioning_APIUserDetails from ResponseDefinitions
|
||||
*/
|
||||
class UsersController extends AUserDataOCSController
|
||||
{
|
||||
class UsersController extends AUserDataOCSController {
|
||||
|
||||
private IL10N $l10n;
|
||||
|
||||
|
|
@ -112,8 +111,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: Users returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getUsers(string $search = '', ?int $limit = null, int $offset = 0): DataResponse
|
||||
{
|
||||
public function getUsers(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
|
||||
$user = $this->userSession->getUser();
|
||||
$users = [];
|
||||
|
||||
|
|
@ -155,8 +153,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: Users details returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getUsersDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse
|
||||
{
|
||||
public function getUsersDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
|
||||
$currentUser = $this->userSession->getUser();
|
||||
$users = [];
|
||||
|
||||
|
|
@ -183,7 +180,7 @@ class UsersController extends AUserDataOCSController
|
|||
|
||||
$usersDetails = [];
|
||||
foreach ($users as $userId) {
|
||||
$userId = (string) $userId;
|
||||
$userId = (string)$userId;
|
||||
try {
|
||||
$userData = $this->getUserData($userId);
|
||||
} catch (OCSNotFoundException $e) {
|
||||
|
|
@ -218,8 +215,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: Disabled users details returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getDisabledUsersDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse
|
||||
{
|
||||
public function getDisabledUsersDetails(string $search = '', ?int $limit = null, int $offset = 0): DataResponse {
|
||||
$currentUser = $this->userSession->getUser();
|
||||
if ($currentUser === null) {
|
||||
return new DataResponse(['users' => []]);
|
||||
|
|
@ -240,7 +236,7 @@ class UsersController extends AUserDataOCSController
|
|||
$isDelegatedAdmin = $this->groupManager->isDelegatedAdmin($uid);
|
||||
if ($isAdmin || $isDelegatedAdmin) {
|
||||
$users = $this->userManager->getDisabledUsers($limit, $offset, $search);
|
||||
$users = array_map(fn(IUser $user): string => $user->getUID(), $users);
|
||||
$users = array_map(fn (IUser $user): string => $user->getUID(), $users);
|
||||
} elseif ($subAdminManager->isSubAdmin($currentUser)) {
|
||||
$subAdminOfGroups = $subAdminManager->getSubAdminsGroups($currentUser);
|
||||
|
||||
|
|
@ -251,10 +247,10 @@ class UsersController extends AUserDataOCSController
|
|||
$users = array_unique(array_merge(
|
||||
$users,
|
||||
array_map(
|
||||
fn(IUser $user): string => $user->getUID(),
|
||||
fn (IUser $user): string => $user->getUID(),
|
||||
array_filter(
|
||||
$group->searchUsers($search),
|
||||
fn(IUser $user): bool => !$user->isEnabled()
|
||||
fn (IUser $user): bool => !$user->isEnabled()
|
||||
)
|
||||
)
|
||||
));
|
||||
|
|
@ -362,8 +358,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 400: Invalid location
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function searchByPhoneNumbers(string $location, array $search): DataResponse
|
||||
{
|
||||
public function searchByPhoneNumbers(string $location, array $search): DataResponse {
|
||||
if ($this->phoneNumberUtil->getCountryCodeForRegion($location) === null) {
|
||||
// Not a valid region code
|
||||
return new DataResponse([], Http::STATUS_BAD_REQUEST);
|
||||
|
|
@ -379,7 +374,7 @@ class UsersController extends AUserDataOCSController
|
|||
foreach ($phoneNumbers as $phone) {
|
||||
$normalizedNumber = $this->phoneNumberUtil->convertToStandardFormat($phone, $location);
|
||||
if ($normalizedNumber !== null) {
|
||||
$normalizedNumberToKey[$normalizedNumber] = (string) $key;
|
||||
$normalizedNumberToKey[$normalizedNumber] = (string)$key;
|
||||
}
|
||||
|
||||
if ($defaultPhoneRegion !== '' && $defaultPhoneRegion !== $location && str_starts_with($phone, '0')) {
|
||||
|
|
@ -388,7 +383,7 @@ class UsersController extends AUserDataOCSController
|
|||
// when it's different to the user's given region.
|
||||
$normalizedNumber = $this->phoneNumberUtil->convertToStandardFormat($phone, $defaultPhoneRegion);
|
||||
if ($normalizedNumber !== null) {
|
||||
$normalizedNumberToKey[$normalizedNumber] = (string) $key;
|
||||
$normalizedNumberToKey[$normalizedNumber] = (string)$key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -429,8 +424,7 @@ class UsersController extends AUserDataOCSController
|
|||
/**
|
||||
* @throws OCSException
|
||||
*/
|
||||
private function createNewUserId(): string
|
||||
{
|
||||
private function createNewUserId(): string {
|
||||
$attempts = 0;
|
||||
do {
|
||||
$uidCandidate = $this->secureRandom->generate(10, ISecureRandom::CHAR_HUMAN_READABLE);
|
||||
|
|
@ -670,8 +664,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: User returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getUser(string $userId): DataResponse
|
||||
{
|
||||
public function getUser(string $userId): DataResponse {
|
||||
$includeScopes = false;
|
||||
$currentUser = $this->userSession->getUser();
|
||||
if ($currentUser && $currentUser->getUID() === $userId) {
|
||||
|
|
@ -697,8 +690,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: Current user returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getCurrentUser(): DataResponse
|
||||
{
|
||||
public function getCurrentUser(): DataResponse {
|
||||
$user = $this->userSession->getUser();
|
||||
if ($user) {
|
||||
/** @var Provisioning_APIUserDetails $data */
|
||||
|
|
@ -720,8 +712,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: Editable fields returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getEditableFields(): DataResponse
|
||||
{
|
||||
public function getEditableFields(): DataResponse {
|
||||
$currentLoggedInUser = $this->userSession->getUser();
|
||||
if (!$currentLoggedInUser instanceof IUser) {
|
||||
throw new OCSException('', OCSController::RESPOND_NOT_FOUND);
|
||||
|
|
@ -738,8 +729,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: Enabled apps returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getEnabledApps(): DataResponse
|
||||
{
|
||||
public function getEnabledApps(): DataResponse {
|
||||
$currentLoggedInUser = $this->userSession->getUser();
|
||||
return new DataResponse(['apps' => $this->appManager->getEnabledAppsForUser($currentLoggedInUser)]);
|
||||
}
|
||||
|
|
@ -756,8 +746,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: Editable fields for user returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getEditableFieldsForUser(string $userId): DataResponse
|
||||
{
|
||||
public function getEditableFieldsForUser(string $userId): DataResponse {
|
||||
$currentLoggedInUser = $this->userSession->getUser();
|
||||
if (!$currentLoggedInUser instanceof IUser) {
|
||||
throw new OCSException('', OCSController::RESPOND_NOT_FOUND);
|
||||
|
|
@ -1013,7 +1002,7 @@ class UsersController extends AUserDataOCSController
|
|||
$errors['quota'] = $this->l10n->t('Insufficient permissions to change quota');
|
||||
} elseif ($quota !== 'none' && $quota !== 'default') {
|
||||
if (is_numeric($quota)) {
|
||||
$quota = (float) $quota;
|
||||
$quota = (float)$quota;
|
||||
} else {
|
||||
$quota = Util::computerFileSize($quota);
|
||||
}
|
||||
|
|
@ -1106,7 +1095,7 @@ class UsersController extends AUserDataOCSController
|
|||
|
||||
if ($groups !== null && ($isAdmin || $isDelegatedAdmin)) {
|
||||
$currentGroups = $this->groupManager->getUserGroups($targetUser);
|
||||
$currentGroupIds = array_map(fn(IGroup $g) => $g->getGID(), $currentGroups);
|
||||
$currentGroupIds = array_map(fn (IGroup $g) => $g->getGID(), $currentGroups);
|
||||
foreach (array_diff($currentGroupIds, $groups) as $gid) {
|
||||
$this->groupManager->get($gid)?->removeUser($targetUser);
|
||||
}
|
||||
|
|
@ -1125,7 +1114,7 @@ class UsersController extends AUserDataOCSController
|
|||
|
||||
if ($subadminGroups !== null && ($isAdmin || $isDelegatedAdmin)) {
|
||||
$currentSubAdminGroups = $subAdminManager->getSubAdminsGroups($targetUser);
|
||||
$currentSubAdminGroupIds = array_map(fn(IGroup $g) => $g->getGID(), $currentSubAdminGroups);
|
||||
$currentSubAdminGroupIds = array_map(fn (IGroup $g) => $g->getGID(), $currentSubAdminGroups);
|
||||
foreach (array_diff($currentSubAdminGroupIds, $subadminGroups) as $gid) {
|
||||
$group = $this->groupManager->get($gid);
|
||||
if ($group !== null) {
|
||||
|
|
@ -1163,8 +1152,7 @@ class UsersController extends AUserDataOCSController
|
|||
#[PasswordConfirmationRequired]
|
||||
#[NoAdminRequired]
|
||||
#[UserRateLimit(limit: 50, period: 600)]
|
||||
public function editUser(string $userId, string $key, string $value): DataResponse
|
||||
{
|
||||
public function editUser(string $userId, string $key, string $value): DataResponse {
|
||||
$currentLoggedInUser = $this->userSession->getUser();
|
||||
|
||||
$targetUser = $this->userManager->get($userId);
|
||||
|
|
@ -1279,7 +1267,7 @@ class UsersController extends AUserDataOCSController
|
|||
$quota = $value;
|
||||
if ($quota !== 'none' && $quota !== 'default') {
|
||||
if (is_numeric($quota)) {
|
||||
$quota = (float) $quota;
|
||||
$quota = (float)$quota;
|
||||
} else {
|
||||
$quota = Util::computerFileSize($quota);
|
||||
}
|
||||
|
|
@ -1289,7 +1277,7 @@ class UsersController extends AUserDataOCSController
|
|||
if ($quota === -1) {
|
||||
$quota = 'none';
|
||||
} else {
|
||||
$maxQuota = (int) $this->config->getAppValue('files', 'max_quota', '-1');
|
||||
$maxQuota = (int)$this->config->getAppValue('files', 'max_quota', '-1');
|
||||
if ($maxQuota !== -1 && $quota > $maxQuota) {
|
||||
throw new OCSException($this->l10n->t('Invalid quota value. %1$s is exceeding the maximum quota', [$value]), 101);
|
||||
}
|
||||
|
|
@ -1341,7 +1329,7 @@ class UsersController extends AUserDataOCSController
|
|||
$this->config->setUserValue($targetUser->getUID(), 'core', 'timezone', $value);
|
||||
break;
|
||||
case self::USER_FIELD_FIRST_DAY_OF_WEEK:
|
||||
$intValue = (int) $value;
|
||||
$intValue = (int)$value;
|
||||
if ($intValue < -1 || $intValue > 6) {
|
||||
throw new OCSException($this->l10n->t('Invalid first day of week'), 101);
|
||||
}
|
||||
|
|
@ -1488,8 +1476,7 @@ class UsersController extends AUserDataOCSController
|
|||
*/
|
||||
#[PasswordConfirmationRequired]
|
||||
#[NoAdminRequired]
|
||||
public function wipeUserDevices(string $userId): DataResponse
|
||||
{
|
||||
public function wipeUserDevices(string $userId): DataResponse {
|
||||
/** @var IUser $currentLoggedInUser */
|
||||
$currentLoggedInUser = $this->userSession->getUser();
|
||||
|
||||
|
|
@ -1527,8 +1514,7 @@ class UsersController extends AUserDataOCSController
|
|||
*/
|
||||
#[PasswordConfirmationRequired]
|
||||
#[NoAdminRequired]
|
||||
public function deleteUser(string $userId): DataResponse
|
||||
{
|
||||
public function deleteUser(string $userId): DataResponse {
|
||||
$currentLoggedInUser = $this->userSession->getUser();
|
||||
|
||||
$targetUser = $this->userManager->get($userId);
|
||||
|
|
@ -1568,8 +1554,7 @@ class UsersController extends AUserDataOCSController
|
|||
*/
|
||||
#[PasswordConfirmationRequired]
|
||||
#[NoAdminRequired]
|
||||
public function disableUser(string $userId): DataResponse
|
||||
{
|
||||
public function disableUser(string $userId): DataResponse {
|
||||
return $this->setEnabled($userId, false);
|
||||
}
|
||||
|
||||
|
|
@ -1584,8 +1569,7 @@ class UsersController extends AUserDataOCSController
|
|||
*/
|
||||
#[PasswordConfirmationRequired]
|
||||
#[NoAdminRequired]
|
||||
public function enableUser(string $userId): DataResponse
|
||||
{
|
||||
public function enableUser(string $userId): DataResponse {
|
||||
return $this->setEnabled($userId, true);
|
||||
}
|
||||
|
||||
|
|
@ -1595,8 +1579,7 @@ class UsersController extends AUserDataOCSController
|
|||
* @return DataResponse<Http::STATUS_OK, list<empty>, array{}>
|
||||
* @throws OCSException
|
||||
*/
|
||||
private function setEnabled(string $userId, bool $value): DataResponse
|
||||
{
|
||||
private function setEnabled(string $userId, bool $value): DataResponse {
|
||||
$currentLoggedInUser = $this->userSession->getUser();
|
||||
|
||||
$targetUser = $this->userManager->get($userId);
|
||||
|
|
@ -1629,8 +1612,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: Users groups returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getUsersGroups(string $userId): DataResponse
|
||||
{
|
||||
public function getUsersGroups(string $userId): DataResponse {
|
||||
$loggedInUser = $this->userSession->getUser();
|
||||
|
||||
$targetUser = $this->userManager->get($userId);
|
||||
|
|
@ -1652,7 +1634,7 @@ class UsersController extends AUserDataOCSController
|
|||
if ($subAdminManager->isUserAccessible($loggedInUser, $targetUser)) {
|
||||
// Return the group that the method caller is subadmin of for the user in question
|
||||
$groups = array_values(array_intersect(
|
||||
array_map(static fn(IGroup $group) => $group->getGID(), $subAdminManager->getSubAdminsGroups($loggedInUser)),
|
||||
array_map(static fn (IGroup $group) => $group->getGID(), $subAdminManager->getSubAdminsGroups($loggedInUser)),
|
||||
$this->groupManager->getUserGroupIds($targetUser)
|
||||
));
|
||||
return new DataResponse(['groups' => $groups]);
|
||||
|
|
@ -1675,8 +1657,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: Users groups returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getUsersGroupsDetails(string $userId): DataResponse
|
||||
{
|
||||
public function getUsersGroupsDetails(string $userId): DataResponse {
|
||||
$loggedInUser = $this->userSession->getUser();
|
||||
|
||||
$targetUser = $this->userManager->get($userId);
|
||||
|
|
@ -1712,7 +1693,7 @@ class UsersController extends AUserDataOCSController
|
|||
// Return the group that the method caller is subadmin of for the user in question
|
||||
$gids = array_values(array_intersect(
|
||||
array_map(
|
||||
static fn(IGroup $group) => $group->getGID(),
|
||||
static fn (IGroup $group) => $group->getGID(),
|
||||
$subAdminManager->getSubAdminsGroups($loggedInUser),
|
||||
),
|
||||
$this->groupManager->getUserGroupIds($targetUser)
|
||||
|
|
@ -1753,8 +1734,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: Users subadmin groups returned
|
||||
*/
|
||||
#[NoAdminRequired]
|
||||
public function getUserSubAdminGroupsDetails(string $userId): DataResponse
|
||||
{
|
||||
public function getUserSubAdminGroupsDetails(string $userId): DataResponse {
|
||||
$loggedInUser = $this->userSession->getUser();
|
||||
|
||||
$targetUser = $this->userManager->get($userId);
|
||||
|
|
@ -1798,8 +1778,7 @@ class UsersController extends AUserDataOCSController
|
|||
*/
|
||||
#[PasswordConfirmationRequired]
|
||||
#[NoAdminRequired]
|
||||
public function addToGroup(string $userId, string $groupid = ''): DataResponse
|
||||
{
|
||||
public function addToGroup(string $userId, string $groupid = ''): DataResponse {
|
||||
if ($groupid === '') {
|
||||
throw new OCSException('', 101);
|
||||
}
|
||||
|
|
@ -1839,8 +1818,7 @@ class UsersController extends AUserDataOCSController
|
|||
*/
|
||||
#[PasswordConfirmationRequired]
|
||||
#[NoAdminRequired]
|
||||
public function removeFromGroup(string $userId, string $groupid): DataResponse
|
||||
{
|
||||
public function removeFromGroup(string $userId, string $groupid): DataResponse {
|
||||
$loggedInUser = $this->userSession->getUser();
|
||||
|
||||
if ($groupid === null || trim($groupid) === '') {
|
||||
|
|
@ -1907,8 +1885,7 @@ class UsersController extends AUserDataOCSController
|
|||
*/
|
||||
#[AuthorizedAdminSetting(settings: Users::class)]
|
||||
#[PasswordConfirmationRequired]
|
||||
public function addSubAdmin(string $userId, string $groupid): DataResponse
|
||||
{
|
||||
public function addSubAdmin(string $userId, string $groupid): DataResponse {
|
||||
$group = $this->groupManager->get($groupid);
|
||||
$user = $this->userManager->get($userId);
|
||||
|
||||
|
|
@ -1948,8 +1925,7 @@ class UsersController extends AUserDataOCSController
|
|||
*/
|
||||
#[AuthorizedAdminSetting(settings: Users::class)]
|
||||
#[PasswordConfirmationRequired]
|
||||
public function removeSubAdmin(string $userId, string $groupid): DataResponse
|
||||
{
|
||||
public function removeSubAdmin(string $userId, string $groupid): DataResponse {
|
||||
$group = $this->groupManager->get($groupid);
|
||||
$user = $this->userManager->get($userId);
|
||||
$subAdminManager = $this->groupManager->getSubAdmin();
|
||||
|
|
@ -1982,8 +1958,7 @@ class UsersController extends AUserDataOCSController
|
|||
* 200: User subadmin groups returned
|
||||
*/
|
||||
#[AuthorizedAdminSetting(settings: Users::class)]
|
||||
public function getUserSubAdminGroups(string $userId): DataResponse
|
||||
{
|
||||
public function getUserSubAdminGroups(string $userId): DataResponse {
|
||||
$groups = $this->getUserSubAdminGroupsData($userId);
|
||||
return new DataResponse($groups);
|
||||
}
|
||||
|
|
@ -1999,8 +1974,7 @@ class UsersController extends AUserDataOCSController
|
|||
*/
|
||||
#[PasswordConfirmationRequired]
|
||||
#[NoAdminRequired]
|
||||
public function resendWelcomeMessage(string $userId): DataResponse
|
||||
{
|
||||
public function resendWelcomeMessage(string $userId): DataResponse {
|
||||
$currentLoggedInUser = $this->userSession->getUser();
|
||||
|
||||
$targetUser = $this->userManager->get($userId);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ use OCP\Accounts\IAccountManager;
|
|||
use OCP\Accounts\IAccountProperty;
|
||||
use OCP\Accounts\IAccountPropertyCollection;
|
||||
use OCP\App\IAppManager;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\OCS\OCSException;
|
||||
|
|
@ -30,6 +29,7 @@ use OCP\AppFramework\OCSController;
|
|||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\Files\IRootFolder;
|
||||
use OCP\Group\ISubAdmin;
|
||||
use OCP\IAppConfig;
|
||||
use OCP\IConfig;
|
||||
use OCP\IGroup;
|
||||
use OCP\IL10N;
|
||||
|
|
|
|||
Loading…
Reference in a new issue