Skip to content

Commit

Permalink
style: composer run cs:fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zak39 committed Dec 11, 2024
1 parent 4725c50 commit 00530ee
Show file tree
Hide file tree
Showing 15 changed files with 90 additions and 79 deletions.
22 changes: 11 additions & 11 deletions lib/Controller/ConnectedGroupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(
private SpaceManager $spaceManager,
private UserGroup $userGroup,
private UserService $userService,
private WorkspaceService $workspaceService
private WorkspaceService $workspaceService,
) {
}

Expand All @@ -46,8 +46,8 @@ public function __construct(
*/
public function addGroup(int $spaceId, string $gid): JSONResponse {

if(!$this->groupManager->groupExists($gid)) {
$message = sprintf("The group %s does not exist", $gid);
if (!$this->groupManager->groupExists($gid)) {
$message = sprintf('The group %s does not exist', $gid);

$this->logger->error($message);

Expand All @@ -63,7 +63,7 @@ public function addGroup(int $spaceId, string $gid): JSONResponse {
$group = $this->groupManager->get($gid);

if (str_starts_with($group->getGID(), 'SPACE-')) {
$message = sprintf("The group %s cannot be added, as it is already a workspace group", $gid);
$message = sprintf('The group %s cannot be added, as it is already a workspace group', $gid);

$this->logger->error($message);

Expand Down Expand Up @@ -98,12 +98,12 @@ public function addGroup(int $spaceId, string $gid): JSONResponse {
}
}

$message = sprintf("The %s group is added to the %s workspace.", $group->getGID(), $space->getSpaceName());
$message = sprintf('The %s group is added to the %s workspace.', $group->getGID(), $space->getSpaceName());

$this->logger->info($message);

return new JSONResponse([
'message' => sprintf("The %s group is added to the %s workspace.", $group->getGID(), $space->getSpaceName()),
'message' => sprintf('The %s group is added to the %s workspace.', $group->getGID(), $space->getSpaceName()),
'success' => true,
'users' => $users,
'slug' => Slugger::slugger($gid),
Expand All @@ -117,8 +117,8 @@ public function addGroup(int $spaceId, string $gid): JSONResponse {
* @SpaceAdminRequired
*/
public function removeGroup(int $spaceId, string $gid) {
if(!$this->groupManager->groupExists($gid)) {
$message = sprintf("The group %s does not exist", $gid);
if (!$this->groupManager->groupExists($gid)) {
$message = sprintf('The group %s does not exist', $gid);

$this->logger->error($message);

Expand All @@ -135,7 +135,7 @@ public function removeGroup(int $spaceId, string $gid) {

if (str_starts_with($group->getGID(), 'SPACE-')) {

$message = sprintf("The %s group is not authorized to remove.", $gid);
$message = sprintf('The %s group is not authorized to remove.', $gid);

$this->logger->error($message);

Expand All @@ -155,12 +155,12 @@ public function removeGroup(int $spaceId, string $gid) {
$group->getGID()
);

$message = sprintf("The group %s is removed from the workspace %s", $group->getGID(), $space->getSpaceName());
$message = sprintf('The group %s is removed from the workspace %s', $group->getGID(), $space->getSpaceName());

$this->logger->info($message);

return new JSONResponse([
'message' => sprintf("The group %s is removed from the workspace %s", $group->getGID(), $space->getSpaceName()),
'message' => sprintf('The group %s is removed from the workspace %s', $group->getGID(), $space->getSpaceName()),
'success' => true
]);
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function __construct(
private UserFormatter $userFormatter,
private WorkspaceManagerGroup $workspaceManagerGroup,
private SpaceManager $spaceManager,
public $AppName
public $AppName,
) {
parent::__construct($AppName, $request);
}
Expand Down Expand Up @@ -186,7 +186,7 @@ public function findAll(): JSONResponse {
$this->logger->warning(
"Be careful, the $gid group is not exist in the oc_groups table."
. " But, it's present in the oc_group_folders_groups table."
. "It necessary to recreate it with the occ command."
. 'It necessary to recreate it with the occ command.'
);
continue;
}
Expand All @@ -201,11 +201,11 @@ public function findAll(): JSONResponse {
$space['users'] = $this->userFormatter->formatUsers($users, $folderInfo, (string)$space['id']);
}

$space['users'] = (object)$space['users'];
$space['users'] = (object)$space['users'];
}

$addedGroups = [];
foreach($gids as $gid) {
foreach ($gids as $gid) {
$addedToGroup = $this->connectedGroups->getConnectedGroupsToSpaceGroup($gid);
if ($addedToGroup !== null) {
$addedGroups = array_merge($addedGroups, $addedToGroup);
Expand Down
40 changes: 20 additions & 20 deletions lib/Db/GroupFoldersGroupsMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ public function __construct(IDBConnection $db) {

/**
* @return array [
* [
* 'space_name' => 'Space01',
* 'group_id' => 'Mars-9',
* ],
* [
* 'space_name' => 'Space02',
* 'group_id' => 'Moon-10',
* ],
* ]
* [
* 'space_name' => 'Space01',
* 'group_id' => 'Mars-9',
* ],
* [
* 'space_name' => 'Space02',
* 'group_id' => 'Moon-10',
* ],
* ]
*/
public function getSpacenamesGroupIds() {
$qb = $this->db->getQueryBuilder();
Expand Down Expand Up @@ -93,18 +93,18 @@ public function findAllAddedGroups() : array {
return $this->findEntities($query);
}

public function isUserConnectedGroup(string $uid): mixed {
$qb = $this->db->getQueryBuilder();
public function isUserConnectedGroup(string $uid): mixed {
$qb = $this->db->getQueryBuilder();

$query = $qb
->select('*')
->from('group_user')
->where('uid = :uid')
->setParameter('uid', $uid)
;
$query = $qb
->select('*')
->from('group_user')
->where('uid = :uid')
->setParameter('uid', $uid)
;

$res = $query->executeQuery();
$res = $query->executeQuery();

return $res->fetch();
}
return $res->fetch();
}
}
4 changes: 2 additions & 2 deletions lib/Group/AddedGroups/AddedGroups.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
class AddedGroups {

public function __construct(
private ConnectedGroupsService $connectedGroupsService
private ConnectedGroupsService $connectedGroupsService,
) {
}

public function get(array $gids): array {
$addedGroups = [];
foreach($gids as $gid) {
foreach ($gids as $gid) {
$addedToGroup = $this->connectedGroupsService->getConnectedGroupsToSpaceGroup($gid);
if ($addedToGroup !== null) {
$addedGroups = array_merge($addedGroups, $addedToGroup);
Expand Down
8 changes: 5 additions & 3 deletions lib/Group/Admin/AdminGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
class AdminGroup {
public const GID_PREFIX = 'SPACE-GE-';

public function __construct(private AdminUserGroup $adminUserGroup,
public function __construct(
private AdminUserGroup $adminUserGroup,
private AdminGroupManager $adminGroupManager,
private LoggerInterface $logger,
private UserFormatter $userFormatter,
private IGroupManager $groupManager) {
private IGroupManager $groupManager,
) {
}

public function addUser(IUser $user, int $spaceId): bool {
Expand All @@ -54,7 +56,7 @@ public function addUser(IUser $user, int $spaceId): bool {
public function removeUser(IUser $user, int $spaceId): void {
$group = $this->groupManager->get(self::GID_PREFIX . $spaceId);
$group->removeUser($user);
}
}

/**
* @return IUser[]
Expand Down
11 changes: 8 additions & 3 deletions lib/Group/GroupBackend.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @copyright Copyright (c) 2024 Arawa
*
Expand Down Expand Up @@ -38,7 +39,11 @@ class GroupBackend extends ABackend implements GroupInterface, INamedBackend, IC
/**
* @param IGroupManager $groupManager parent group manager
*/
public function __construct(protected IGroupManager $groupManager, protected IUserManager $userManager, private ConnectedGroupsService $connectedGroups) {
public function __construct(
protected IGroupManager $groupManager,
protected IUserManager $userManager,
private ConnectedGroupsService $connectedGroups,
) {
$this->avoidRecurse_users = $this->avoidRecurse_groups = false;
}

Expand Down Expand Up @@ -81,7 +86,7 @@ public function getUserGroups($uid) {
return [];
}
$userGroups = [];
foreach($groupIds as $gid) {
foreach ($groupIds as $gid) {
$connectedGids = $this->connectedGroups->getConnectedSpaceToGroupIds($gid);
if ($connectedGids !== null) {
$userGroups = array_merge($userGroups, $connectedGids);
Expand Down Expand Up @@ -166,7 +171,7 @@ public function countUsersInGroup(string $gid, string $search = ''): int {
$this->avoidRecurse_users = false;

$nbUsers = 0;
foreach($users as $userId) {
foreach ($users as $userId) {
if (!isset($usersDb[$userId])) {
$usersDb[$userId] = true;
$nbUsers ++;
Expand Down
7 changes: 5 additions & 2 deletions lib/Group/SubGroups/SubGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
use Psr\Log\LoggerInterface;

class SubGroup {
public function __construct(private IGroupManager $groupManager, private LoggerInterface $logger) {
public function __construct(
private IGroupManager $groupManager,
private LoggerInterface $logger,
) {
}

public function get(array $gids): array {
Expand All @@ -40,7 +43,7 @@ public function get(array $gids): array {
$this->logger->warning(
"Be careful, the $gid group is not exist in the oc_groups table."
. " But, it's present in the oc_group_folders_groups table."
. "It necessary to recreate it with the occ command."
. 'It necessary to recreate it with the occ command.'
);
continue;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Group/User/UserGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
class UserGroup {
public const GID_PREFIX = 'SPACE-U-';

public function __construct(private UserGroupManager $userGroupManager,
public function __construct(
private UserGroupManager $userGroupManager,
private IGroupManager $groupManager,
) {
}
Expand Down
13 changes: 6 additions & 7 deletions lib/Service/Group/ConnectedGroupsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ConnectedGroupsService {
public function __construct(
private IGroupManager $groupManager,
private GroupFoldersGroupsMapper $mapper,
private SpaceMapper $spaceMapper
private SpaceMapper $spaceMapper,
) {
}

Expand All @@ -60,7 +60,7 @@ private function initLinkedSpaceGroups(): void {
}

$data = [];
foreach($connectedGroups as $connectedGroup) {
foreach ($connectedGroups as $connectedGroup) {
$gid = 'SPACE-U-' . $connectedGroup->getSpaceId();
$linked_gid = $connectedGroup->getGid();
$data[$gid][] = $linked_gid;
Expand Down Expand Up @@ -156,9 +156,8 @@ public function add(IGroup $group, Space $space): bool {
return true;
}

public function isUserConnectedGroup(string $uid): bool
{
$res = $this->mapper->isUserConnectedGroup($uid);
return empty($res);
}
public function isUserConnectedGroup(string $uid): bool {
$res = $this->mapper->isUserConnectedGroup($uid);
return empty($res);
}
}
10 changes: 5 additions & 5 deletions lib/Service/Group/GroupFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class GroupFormatter {
/**
* @param IGroup[] $groups
* @return array [
* 'gid' => string,
* 'displayName' => string,
* 'types' => string[],
* 'is_ldap' => boolean
* ]
* 'gid' => string,
* 'displayName' => string,
* 'types' => string[],
* 'is_ldap' => boolean
* ]
*/
public static function formatGroups(array $groups): array {
$groupsFormat = [];
Expand Down
13 changes: 7 additions & 6 deletions lib/Service/User/UserFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@

class UserFormatter {
public function __construct(
private GroupsWorkspaceService $groupsWorkspace,
private ConnectedGroupsService $connectedGroupsService,
private IURLGenerator $urlGenerator) {
private GroupsWorkspaceService $groupsWorkspace,
private ConnectedGroupsService $connectedGroupsService,
private IURLGenerator $urlGenerator,
) {
}

/**
Expand All @@ -57,9 +58,9 @@ public function formatUsers(array $users, array $groupfolder, string $spaceId):
'email' => $user->getEmailAddress(),
'subtitle' => $user->getEmailAddress(),
'groups' => $this->groupsWorkspace->getGroupsUserFromGroupfolder($user, $groupfolder, $spaceId),
'is_connected' => $this->connectedGroupsService->isUserConnectedGroup($user->getUID()),
'profile' => $this->urlGenerator->linkToRouteAbsolute('core.ProfilePage.index', ['targetUserId' => $user->getUID()]),
'role' => $role
'is_connected' => $this->connectedGroupsService->isUserConnectedGroup($user->getUID()),
'profile' => $this->urlGenerator->linkToRouteAbsolute('core.ProfilePage.index', ['targetUserId' => $user->getUID()]),
'role' => $role
];
}

Expand Down
4 changes: 2 additions & 2 deletions lib/Service/UserService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(
*
*/

public function formatUser(IUser $user, array $space, string $role): array|null {
public function formatUser(IUser $user, array $space, string $role): ?array {
if (is_null($user)) {
return null;
}
Expand Down Expand Up @@ -86,7 +86,7 @@ public function formatUser(IUser $user, array $space, string $role): array|null
'subtitle' => $user->getEmailAddress(),
'groups' => $groups,
'role' => $role,
'is_connected' => $this->connectedGroups->isUserConnectedGroup($user->getUID()),
'is_connected' => $this->connectedGroups->isUserConnectedGroup($user->getUID()),
'profile' => $this->urlGenerator->linkToRouteAbsolute('core.ProfilePage.index', ['targetUserId' => $user->getUID()])
];
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Service/WorkspaceService.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public function addUsersInfo(string|array $workspace): \stdClass {
};
}

return (object) $users;
return (object)$users;
}

/**
Expand All @@ -206,7 +206,7 @@ public function addGroupsInfo(array|string $workspace): array {
array_keys($workspace['groups'])
);
$addedGroups = [];
foreach(array_keys($workspace['groups']) as $gid) {
foreach (array_keys($workspace['groups']) as $gid) {
$addedToGroup = $this->connectedGroups->getConnectedGroupsToSpaceGroup($gid);
if ($addedToGroup !== null) {
$addedGroups = array_merge($addedGroups, $addedToGroup);
Expand Down
2 changes: 1 addition & 1 deletion lib/Space/SpaceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public function create(string $spacename): array {
'size' => $groupfolder['size'],
'acl' => $groupfolder['acl'],
'manage' => $groupfolder['manage'],
'userCount' => 0
'userCount' => 0
];
}

Expand Down
Loading

0 comments on commit 00530ee

Please sign in to comment.