diff --git a/lib/Controller/GroupController.php b/lib/Controller/GroupController.php
index 51bd7f3a4..98bc95990 100644
--- a/lib/Controller/GroupController.php
+++ b/lib/Controller/GroupController.php
@@ -26,11 +26,11 @@
namespace OCA\Workspace\Controller;
use OCA\Workspace\Service\Group\GroupFolder\GroupFolderManage;
-use OCA\Workspace\Service\Group\GroupFormatter;
-use OCA\Workspace\Service\Group\GroupsWorkspaceService;
+use OCA\Workspace\Groups\GroupFormatter;
+use OCA\Workspace\Groups\GroupManager;
use OCA\Workspace\Service\Group\ManagersWorkspace;
-use OCA\Workspace\Service\Group\UserGroup;
-use OCA\Workspace\Service\Group\WorkspaceManagerGroup;
+use OCA\Workspace\Groups\Workspace\UserGroup;
+use OCA\Workspace\Groups\Workspace\WorkspaceManagerGroup;
use OCA\Workspace\Service\User\UserFormatter;
use OCA\Workspace\Service\User\UserWorkspace;
use OCA\Workspace\Service\UserService;
@@ -48,13 +48,15 @@ class GroupController extends Controller {
];
public function __construct(
- private GroupsWorkspaceService $groupsWorkspace,
+ private GroupManager $groupWorkspaceManager,
private IGroupManager $groupManager,
- private LoggerInterface $logger,
private IUserManager $userManager,
+ private LoggerInterface $logger,
private UserFormatter $userFormatter,
private UserService $userService,
- private UserWorkspace $userWorkspace
+ private UserWorkspace $userWorkspace,
+ private UserGroup $userGroup,
+ private WorkspaceManagerGroup $workspaceManagerGroup
) {
}
@@ -207,7 +209,7 @@ public function addUser(string $spaceId, string $gid, string $user): JSONRespons
$NCGroup->addUser($NCUser);
// Adds the user to the application manager group when we are adding a workspace manager
- if ($gid === WorkspaceManagerGroup::get($spaceId)) {
+ if ($gid === $this->workspaceManagerGroup->get($spaceId)) {
$workspaceUsersGroup = $this->groupManager->get(ManagersWorkspace::WORKSPACES_MANAGERS);
if (!is_null($workspaceUsersGroup)) {
$workspaceUsersGroup->addUser($NCUser);
@@ -220,7 +222,7 @@ public function addUser(string $spaceId, string $gid, string $user): JSONRespons
// Adds user to workspace user group
// This must be the last action done, when all other previous actions have succeeded
- $UGroup = $this->groupManager->get(UserGroup::get($spaceId));
+ $UGroup = $this->groupManager->get($this->userGroup->get($spaceId));
$UGroup->addUser($NCUser);
return new JSONResponse(['message' => 'The user ' . $user . ' is added in the ' . $gid . ' group'], Http::STATUS_CREATED);
@@ -258,8 +260,8 @@ public function removeUser(array|string $space,
// Removes user from group(s)
$NCUser = $this->userManager->get($user);
$groups = [];
- if ($gid === WorkspaceManagerGroup::get($space['id'])
- || $gid === UserGroup::get($space['id'])) {
+ if ($gid === $this->workspaceManagerGroup->get($space['id'])
+ || $gid === $this->userGroup->get($space['id'])) {
// Removing user from a U- group
$this->logger->debug('Removing user from a workspace, removing it from all the workspace subgroups too.');
$users = (array)$space['users'];
@@ -268,7 +270,7 @@ public function removeUser(array|string $space,
$NCGroup->removeUser($NCUser);
$groups[] = $NCGroup->getGID();
$this->logger->debug('User removed from group: ' . $NCGroup->getDisplayName());
- if ($groupId === WorkspaceManagerGroup::get($space['id'])) {
+ if ($groupId === $this->workspaceManagerGroup->get($space['id'])) {
$this->logger->debug('Removing user from a workspace manager group, removing it from the WorkspacesManagers group if needed.');
$this->userService->removeGEFromWM($NCUser, $space);
}
@@ -278,7 +280,7 @@ public function removeUser(array|string $space,
$groups[] = $gid;
$NCGroup->removeUser($NCUser);
$this->logger->debug('User removed from group: ' . $NCGroup->getDisplayName());
- if ($gid === WorkspaceManagerGroup::get($space['id'])) {
+ if ($gid === $this->workspaceManagerGroup->get($space['id'])) {
// Removing user from a GE- group
$this->logger->debug('Removing user from a workspace manager group, removing it from the WorkspacesManagers group if needed.');
$this->userService->removeGEFromWM($NCUser, $space);
@@ -309,8 +311,8 @@ public function transferUsersToGroups(string $spaceId,
$groups = GroupFormatter::formatGroups(
array_merge(
[
- $this->groupsWorkspace->getWorkspaceManagerGroup($spaceId),
- $this->groupsWorkspace->getUserGroup($spaceId)
+ $this->groupWorkspaceManager->getWorkspaceManagerGroup($spaceId),
+ $this->groupWorkspaceManager->getUserGroup($spaceId)
],
array_map(function ($groupName) {
return $this->groupManager->get($groupName);
@@ -323,11 +325,11 @@ public function transferUsersToGroups(string $spaceId,
$allUsers = $this->userWorkspace->getUsersFromGroup($groupsName);
$usersFromAdvancedPermissions = $this->userWorkspace->getUsersFromGroup($groupsNameFromAdvancedPermissions);
- $this->groupsWorkspace
- ->transferUsersToGroup($allUsers, $this->groupsWorkspace->getUserGroup($spaceId));
- $this->groupsWorkspace
- ->transferUsersToGroup($usersFromAdvancedPermissions, $this->groupsWorkspace->getWorkspaceManagerGroup($spaceId));
- $this->groupsWorkspace
+ $this->groupWorkspaceManager
+ ->transferUsersToGroup($allUsers, $this->groupWorkspaceManager->getUserGroup($spaceId));
+ $this->groupWorkspaceManager
+ ->transferUsersToGroup($usersFromAdvancedPermissions, $this->groupWorkspaceManager->getWorkspaceManagerGroup($spaceId));
+ $this->groupWorkspaceManager
->transferUsersToGroup($usersFromAdvancedPermissions, $this->groupManager->get(ManagersWorkspace::WORKSPACES_MANAGERS));
$users = $this->userFormatter->formatUsers($allUsers, $groupfolder, $spaceId);
diff --git a/lib/Controller/WorkspaceController.php b/lib/Controller/WorkspaceController.php
index 4f0519f18..57ab9eefd 100644
--- a/lib/Controller/WorkspaceController.php
+++ b/lib/Controller/WorkspaceController.php
@@ -25,26 +25,27 @@
namespace OCA\Workspace\Controller;
+use OCP\IRequest;
+use OCP\IUserManager;
+use OCP\IGroupManager;
+use OCP\AppFramework\Http;
+use OCA\Workspace\Db\Space;
+use Psr\Log\LoggerInterface;
+use OCP\AppFramework\Controller;
+use OCA\Workspace\Db\SpaceMapper;
use OCA\Workspace\BadRequestException;
+use OCA\Workspace\Service\UserService;
use OCA\Workspace\CreateGroupException;
+use OCA\Workspace\Service\SpaceService;
+use OCP\AppFramework\Http\JSONResponse;
+use OCA\Workspace\Groups\Workspace\UserGroup;
use OCA\Workspace\CreateWorkspaceException;
-use OCA\Workspace\Db\Space;
-use OCA\Workspace\Db\SpaceMapper;
-use OCA\Workspace\Service\Group\GroupFormatter;
+use OCA\Workspace\Service\WorkspaceService;
+use OCA\Workspace\Groups\GroupFormatter;
+use OCA\Workspace\Service\Group\GroupsWorkspace;
use OCA\Workspace\Service\Group\ManagersWorkspace;
-use OCA\Workspace\Service\Group\UserGroup;
-use OCA\Workspace\Service\Group\WorkspaceManagerGroup;
-use OCA\Workspace\Service\SpaceService;
-use OCA\Workspace\Service\UserService;
+use OCA\Workspace\Groups\Workspace\WorkspaceManagerGroup;
use OCA\Workspace\Service\Workspace\WorkspaceCheckService;
-use OCA\Workspace\Service\WorkspaceService;
-use OCP\AppFramework\Controller;
-use OCP\AppFramework\Http;
-use OCP\AppFramework\Http\JSONResponse;
-use OCP\IGroupManager;
-use OCP\IRequest;
-use OCP\IUserManager;
-use Psr\Log\LoggerInterface;
class WorkspaceController extends Controller {
public function __construct(
@@ -54,12 +55,13 @@ public function __construct(
private LoggerInterface $logger,
private SpaceMapper $spaceMapper,
private SpaceService $spaceService,
+ private UserGroup $userGroup,
private UserService $userService,
private WorkspaceCheckService $workspaceCheck,
- private WorkspaceService $workspaceService,
- private UserGroup $userGroup,
private WorkspaceManagerGroup $workspaceManagerGroup,
- public $AppName
+ private WorkspaceService $workspaceService,
+ public $AppName,
+ private GroupsWorkspace $groupsWorkspace
) {
parent::__construct($AppName, $request);
}
@@ -107,8 +109,8 @@ public function createWorkspace(string $spaceName,
}
// #2 create groups
- $newSpaceManagerGroup = $this->workspaceManagerGroup->create($space);
- $newSpaceUsersGroup = $this->userGroup->create($space);
+ $newSpaceManagerGroup = $this->groupsWorkspace->create($this->workspaceManagerGroup, $space);
+ $newSpaceUsersGroup = $this->groupsWorkspace->create($this->userGroup, $space);
// #3 Returns result
return new JSONResponse([
@@ -135,7 +137,7 @@ public function createWorkspace(string $spaceName,
*/
public function destroy(array $workspace): JSONResponse {
$this->logger->debug('Removing GE users from the WorkspacesManagers group if needed.');
- $GEGroup = $this->groupManager->get(WorkspaceManagerGroup::get($workspace['id']));
+ $GEGroup = $this->groupManager->get($this->workspaceManagerGroup->get($workspace['id']));
foreach ($GEGroup->getUsers() as $user) {
$this->userService->removeGEFromWM($user, $workspace);
}
@@ -240,7 +242,7 @@ public function changeUserRole(array|string $space,
}
$user = $this->userManager->get($userId);
- $GEgroup = $this->groupManager->get(WorkspaceManagerGroup::get($space['id']));
+ $GEgroup = $this->groupManager->get($this->workspaceManagerGroup->get($space['id']));
if ($GEgroup->inGroup($user)) {
// Changing a user's role from admin to user
$GEgroup->removeUser($user);
@@ -248,7 +250,7 @@ public function changeUserRole(array|string $space,
$this->userService->removeGEFromWM($user, $space);
} else {
// Changing a user's role from user to admin
- $this->groupManager->get(WorkspaceManagerGroup::get($space['id']))->addUser($user);
+ $this->groupManager->get($this->workspaceManagerGroup->get($space['id']))->addUser($user);
$this->groupManager->get(ManagersWorkspace::WORKSPACES_MANAGERS)->addUser($user);
}
diff --git a/lib/Service/Group/GroupFormatter.php b/lib/Groups/GroupFormatter.php
similarity index 96%
rename from lib/Service/Group/GroupFormatter.php
rename to lib/Groups/GroupFormatter.php
index 4295a068e..9636b8353 100644
--- a/lib/Service/Group/GroupFormatter.php
+++ b/lib/Groups/GroupFormatter.php
@@ -22,7 +22,7 @@
*
*/
-namespace OCA\Workspace\Service\Group;
+namespace OCA\Workspace\Groups;
use OCP\IGroup;
diff --git a/lib/Service/Group/GroupsWorkspaceService.php b/lib/Groups/GroupManager.php
similarity index 86%
rename from lib/Service/Group/GroupsWorkspaceService.php
rename to lib/Groups/GroupManager.php
index 2b01c06bf..a0f798012 100644
--- a/lib/Service/Group/GroupsWorkspaceService.php
+++ b/lib/Groups/GroupManager.php
@@ -22,17 +22,19 @@
*
*/
-namespace OCA\Workspace\Service\Group;
+namespace OCA\Workspace\Groups;
-use OCA\Workspace\GroupException;
-use OCA\Workspace\UserGroup;
-use OCA\Workspace\WorkspaceManagerGroup;
+use OCP\IUser;
use OCP\IGroup;
use OCP\IGroupManager;
-use OCP\IUser;
+use OCA\Workspace\Exceptions\GroupException;
+use OCA\Workspace\Groups\Workspace\UserGroup;
+use OCA\Workspace\Groups\Workspace\WorkspaceManagerGroup;
-class GroupsWorkspaceService {
- public function __construct(private IGroupManager $groupManager) {
+class GroupManager {
+ public function __construct(private IGroupManager $groupManager,
+ private WorkspaceManagerGroup $workspaceManagerGroup,
+ private UserGroup $userGroup) {
}
/**
@@ -40,7 +42,7 @@ public function __construct(private IGroupManager $groupManager) {
*/
public function getWorkspaceManagerGroup(string $spaceId): IGroup {
$groupSpaceManager = $this->groupManager->get(
- WorkspaceManagerGroup::get($spaceId)
+ $this->workspaceManagerGroup->get($spaceId)
);
if (is_null($groupSpaceManager)) {
@@ -55,7 +57,7 @@ public function getWorkspaceManagerGroup(string $spaceId): IGroup {
*/
public function getUserGroup(string $spaceId): IGroup {
$groupUser = $this->groupManager->get(
- UserGroup::get($spaceId)
+ $this->userGroup->get($spaceId)
);
if (is_null($groupUser)) {
diff --git a/lib/Groups/GroupWorkspaceInterface.php b/lib/Groups/GroupWorkspaceInterface.php
new file mode 100644
index 000000000..aaae7e197
--- /dev/null
+++ b/lib/Groups/GroupWorkspaceInterface.php
@@ -0,0 +1,37 @@
+
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\Workspace\Groups;
+
+interface GroupWorkspaceInterface {
+
+ /**
+ * @return string - Just the GID with the spaceId.
+ */
+ public function get(int $spaceId): string;
+
+ public function getDisplayPrefix(): string;
+
+ public function getGidPrefix(): string;
+
+}
diff --git a/lib/Service/Group/UserGroup.php b/lib/Groups/Workspace/UserGroup.php
similarity index 52%
rename from lib/Service/Group/UserGroup.php
rename to lib/Groups/Workspace/UserGroup.php
index 6295757a2..6fbb9a7ce 100644
--- a/lib/Service/Group/UserGroup.php
+++ b/lib/Groups/Workspace/UserGroup.php
@@ -21,40 +21,32 @@
*
*/
-namespace OCA\Workspace\Service\Group;
+namespace OCA\Workspace\Groups\Workspace;
-use OCA\Workspace\CreateGroupException;
-use OCA\Workspace\Db\Space;
-use OCP\AppFramework\Http;
use OCP\AppFramework\Services\IAppConfig;
-use OCP\IGroup;
-use OCP\IGroupManager;
+use OCA\Workspace\Groups\GroupWorkspaceInterface;
-class UserGroup extends GroupsWorkspace {
- private IGroupManager $groupManager;
+class UserGroup implements GroupWorkspaceInterface {
- public function __construct(IGroupManager $groupManager, IAppConfig $appConfig) {
- parent::__construct($appConfig);
- $this->groupManager = $groupManager;
+ private const GID_SPACE = 'SPACE-';
+ private const PREFIX_GID_USERS = self::GID_SPACE . 'U-';
+ private string $DISPLAY_PREFIX_USER_GROUP;
+
+
+ public function __construct(IAppConfig $appConfig) {
+ $this->DISPLAY_PREFIX_USER_GROUP = $appConfig->getAppValue('DISPLAY_PREFIX_USER_GROUP');
}
- public static function get(int $spaceId): string {
+ public function get(int $spaceId): string {
return self::PREFIX_GID_USERS . $spaceId;
}
- public static function getPrefix(): string {
+ public function getGidPrefix(): string {
return self::PREFIX_GID_USERS;
}
- public function create(Space $space): IGroup {
- $group = $this->groupManager->createGroup(self::PREFIX_GID_USERS . $space->getId());
-
- if (is_null($group)) {
- throw new CreateGroupException('Error to create a Space Manager group.', Http::STATUS_CONFLICT);
- }
-
- $group->setDisplayName(self::getDisplayPrefixUserGroup() . $space->getSpaceName());
-
- return $group;
- }
+ public function getDisplayPrefix(): string
+ {
+ return $this->DISPLAY_PREFIX_USER_GROUP;
+ }
}
diff --git a/lib/Groups/Workspace/WorkspaceManagerGroup.php b/lib/Groups/Workspace/WorkspaceManagerGroup.php
new file mode 100644
index 000000000..e1d4a9b6a
--- /dev/null
+++ b/lib/Groups/Workspace/WorkspaceManagerGroup.php
@@ -0,0 +1,51 @@
+
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * 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
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\Workspace\Groups\Workspace;
+
+use OCP\AppFramework\Services\IAppConfig;
+use OCA\Workspace\Groups\GroupWorkspaceInterface;
+
+class WorkspaceManagerGroup implements GroupWorkspaceInterface {
+
+ private const GID_SPACE = 'SPACE-';
+ private const PREFIX_GID_MANAGERS = self::GID_SPACE . 'GE-';
+ private string $DISPLAY_PREFIX_MANAGER_GROUP;
+
+ public function __construct(IAppConfig $appConfig) {
+ $this->DISPLAY_PREFIX_MANAGER_GROUP = $appConfig->getAppValue('DISPLAY_PREFIX_MANAGER_GROUP');
+ }
+
+ public function get(int $spaceId): string {
+ return self::PREFIX_GID_MANAGERS . $spaceId;
+ }
+
+ public function getGidPrefix(): string {
+ return self::PREFIX_GID_MANAGERS;
+ }
+
+ public function getDisplayPrefix(): string
+ {
+ return $this->DISPLAY_PREFIX_MANAGER_GROUP;
+ }
+}
diff --git a/lib/Service/Group/GroupsWorkspace.php b/lib/Service/Group/GroupsWorkspace.php
index 39cf005e7..8bee1c22a 100644
--- a/lib/Service/Group/GroupsWorkspace.php
+++ b/lib/Service/Group/GroupsWorkspace.php
@@ -23,43 +23,33 @@
namespace OCA\Workspace\Service\Group;
+use OCA\Workspace\CreateGroupException;
use OCA\Workspace\Db\Space;
+use OCA\Workspace\Groups\GroupWorkspaceInterface;
+use OCP\AppFramework\Http;
use OCP\AppFramework\Services\IAppConfig;
use OCP\IGroup;
+use OCP\IGroupManager;
-abstract class GroupsWorkspace {
- private const GID_SPACE_MANAGER = 'GE-';
- private const GID_SPACE_USERS = 'U-';
- private const GID_SPACE = 'SPACE-';
-
- protected const PREFIX_GID_MANAGERS = self::GID_SPACE . self::GID_SPACE_MANAGER;
- protected const PREFIX_GID_USERS = self::GID_SPACE . self::GID_SPACE_USERS;
-
- protected static string $DISPLAY_PREFIX_MANAGER_GROUP;
- protected static string $DISPLAY_PREFIX_USER_GROUP;
-
- public function __construct(IAppConfig $appConfig) {
- self::$DISPLAY_PREFIX_MANAGER_GROUP = $appConfig->getAppValue('DISPLAY_PREFIX_MANAGER_GROUP');
- self::$DISPLAY_PREFIX_USER_GROUP = $appConfig->getAppValue('DISPLAY_PREFIX_USER_GROUP');
- }
-
- public static function getDisplayPrefixManagerGroup(): string {
- return self::$DISPLAY_PREFIX_MANAGER_GROUP;
- }
-
- public static function getDisplayPrefixUserGroup(): string {
- return self::$DISPLAY_PREFIX_USER_GROUP;
+class GroupsWorkspace {
+
+ public function __construct(private IAppConfig $appConfig,
+ private IGroupManager $groupManager) {
}
/**
- * @return string - Just the GID with the spaceId.
+ * Use the OCA\Workspace\Db\Space to get its spaceId and spaceName.
*/
- abstract public static function get(int $spaceId): string;
+ public function create(GroupWorkspaceInterface $groupWorkspace, Space $space): IGroup {
+ $group = $this->groupManager->createGroup($groupWorkspace->getGidPrefix() . $space->getId());
- abstract public static function getPrefix(): string;
+ if (is_null($group)) {
+ throw new CreateGroupException('Error to create a Space Manager group.', Http::STATUS_CONFLICT);
+ }
+
+ $group->setDisplayName($groupWorkspace->getDisplayPrefix() . $space->getSpaceName());
+
+ return $group;
+ }
- /**
- * Use the OCA\Workspace\Db\Space to get its spaceId and spaceName.
- */
- abstract public function create(Space $space): IGroup;
}
diff --git a/lib/Service/Group/WorkspaceManagerGroup.php b/lib/Service/Group/WorkspaceManagerGroup.php
deleted file mode 100644
index 6baf744c1..000000000
--- a/lib/Service/Group/WorkspaceManagerGroup.php
+++ /dev/null
@@ -1,60 +0,0 @@
-
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see .
- *
- */
-
-namespace OCA\Workspace\Service\Group;
-
-use OCA\Workspace\CreateGroupException;
-use OCA\Workspace\Db\Space;
-use OCP\AppFramework\Http;
-use OCP\AppFramework\Services\IAppConfig;
-use OCP\IGroup;
-use OCP\IGroupManager;
-
-class WorkspaceManagerGroup extends GroupsWorkspace {
- private IGroupManager $groupManager;
-
- public function __construct(IGroupManager $groupManager, IAppConfig $appConfig) {
- parent::__construct($appConfig);
- $this->groupManager = $groupManager;
- }
-
- public static function get(int $spaceId): string {
- return self::PREFIX_GID_MANAGERS . $spaceId;
- }
-
- public static function getPrefix(): string {
- return self::PREFIX_GID_MANAGERS;
- }
-
- public function create(Space $space): IGroup {
- $group = $this->groupManager->createGroup(self::PREFIX_GID_MANAGERS . $space->getId());
-
- if (is_null($group)) {
- throw new CreateGroupException('Error to create a Space Manager group.', Http::STATUS_CONFLICT);
- }
-
- $group->setDisplayName(self::getDisplayPrefixManagerGroup() . $space->getSpaceName());
-
- return $group;
- }
-}
diff --git a/lib/Service/User/UserFormatter.php b/lib/Service/User/UserFormatter.php
index a46970d56..e8e77e297 100644
--- a/lib/Service/User/UserFormatter.php
+++ b/lib/Service/User/UserFormatter.php
@@ -25,11 +25,11 @@
namespace OCA\Workspace\Service\User;
use OCA\Workspace\Roles;
-use OCA\Workspace\Service\Group\GroupsWorkspaceService;
+use OCA\Workspace\Groups\GroupManager;
use OCP\IUser;
class UserFormatter {
- public function __construct(private GroupsWorkspaceService $groupsWorkspace) {
+ public function __construct(private GroupManager $groupsWorkspace) {
}
/**
diff --git a/lib/Service/UserService.php b/lib/Service/UserService.php
index 585d3f6a3..ca20d6c87 100644
--- a/lib/Service/UserService.php
+++ b/lib/Service/UserService.php
@@ -26,8 +26,8 @@
namespace OCA\Workspace\Service;
use OCA\Workspace\Service\Group\ManagersWorkspace;
-use OCA\Workspace\Service\Group\UserGroup;
-use OCA\Workspace\Service\Group\WorkspaceManagerGroup;
+use OCA\Workspace\Groups\Workspace\UserGroup;
+use OCA\Workspace\Groups\Workspace\WorkspaceManagerGroup;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserSession;
@@ -37,7 +37,9 @@ class UserService {
public function __construct(
private IGroupManager $groupManager,
private IUserSession $userSession,
- private LoggerInterface $logger
+ private LoggerInterface $logger,
+ private UserGroup $userGroup,
+ private WorkspaceManagerGroup $workspaceManagerGroup
) {
}
@@ -92,7 +94,7 @@ public function isUserGeneralAdmin(): bool {
* @return boolean true if user is a space manager, false otherwise
*/
public function isSpaceManager(): bool {
- $workspaceAdminGroups = $this->groupManager->search(WorkspaceManagerGroup::getPrefix());
+ $workspaceAdminGroups = $this->groupManager->search($this->workspaceManagerGroup->getGidPrefix());
foreach ($workspaceAdminGroups as $group) {
if ($this->groupManager->isInGroup($this->userSession->getUser()->getUID(), $group->getGID())) {
return true;
@@ -117,7 +119,7 @@ public function canAccessApp(): bool {
* @return boolean true if user is space manager of the specified workspace, false otherwise
*/
public function isSpaceManagerOfSpace(array $space): bool {
- if ($this->groupManager->isInGroup($this->userSession->getUser()->getUID(), WorkspaceManagerGroup::get($space['id']))) {
+ if ($this->groupManager->isInGroup($this->userSession->getUser()->getUID(), $this->workspaceManagerGroup->get($space['id']))) {
return true;
}
return false;
@@ -133,8 +135,8 @@ public function removeGEFromWM(IUser $user, array|object $space): void {
// Checks if the user is member of the GE- group of another workspace
foreach ($groups as $group) {
$gid = $group->getGID();
- if (strpos($gid, WorkspaceManagerGroup::get($space['id'])) === 0 &&
- $gid !== UserGroup::get($space['id'])
+ if (strpos($gid, $this->workspaceManagerGroup->get($space['id'])) === 0 &&
+ $gid !== $this->userGroup->get($space['id'])
) {
$found = true;
break;
diff --git a/lib/Service/WorkspaceService.php b/lib/Service/WorkspaceService.php
index fe1071cf0..cf4d8b4d6 100644
--- a/lib/Service/WorkspaceService.php
+++ b/lib/Service/WorkspaceService.php
@@ -26,8 +26,8 @@
namespace OCA\Workspace\Service;
use OCA\Workspace\Db\SpaceMapper;
-use OCA\Workspace\Service\Group\UserGroup;
-use OCA\Workspace\Service\Group\WorkspaceManagerGroup;
+use OCA\Workspace\Groups\Workspace\UserGroup;
+use OCA\Workspace\Groups\Workspace\WorkspaceManagerGroup;
use OCP\IGroupManager;
use OCP\IUser;
use OCP\IUserManager;
@@ -43,7 +43,9 @@ public function __construct(
private IUserSession $userSession,
private LoggerInterface $logger,
private SpaceMapper $spaceMapper,
- private UserService $userService
+ private UserGroup $userGroup,
+ private UserService $userService,
+ private WorkspaceManagerGroup $workspaceManagerGroup
) {
}
@@ -133,7 +135,7 @@ public function autoComplete(string $term, array|string $space): array {
$role = 'user';
if ($this->groupManager->isInGroup(
$user->getUID(),
- WorkspaceManagerGroup::get($space['id']))
+ $this->workspaceManagerGroup->get($space['id']))
) {
$role = 'admin';
}
@@ -169,7 +171,7 @@ public function addUsersInfo(string|array $workspace): array {
// from the workspace's manager group, as users may be members of both groups
$this->logger->debug('Adding users information to workspace');
$users = array();
- $group = $this->groupManager->get(UserGroup::get($workspace['id']));
+ $group = $this->groupManager->get($this->userGroup->get($workspace['id']));
// TODO Handle is_null($group) better (remove workspace from list?)
if (!is_null($group)) {
foreach ($group->getUsers() as $user) {
@@ -177,7 +179,7 @@ public function addUsersInfo(string|array $workspace): array {
};
}
// TODO Handle is_null($group) better (remove workspace from list?)
- $group = $this->groupManager->get(WorkspaceManagerGroup::get($workspace['id']));
+ $group = $this->groupManager->get($this->workspaceManagerGroup->get($workspace['id']));
if (!is_null($group)) {
foreach ($group->getUsers() as $user) {
$users[$user->getUID()] = $this->userService->formatUser($user, $workspace, 'admin');
diff --git a/lib/Upgrade/UpgradeV300.php b/lib/Upgrade/UpgradeV300.php
index 174d29ad2..1b82b4936 100644
--- a/lib/Upgrade/UpgradeV300.php
+++ b/lib/Upgrade/UpgradeV300.php
@@ -26,8 +26,8 @@
use OCA\Workspace\Db\GroupFoldersGroupsMapper;
use OCA\Workspace\Db\SpaceMapper;
-use OCA\Workspace\Service\Group\UserGroup;
-use OCA\Workspace\Service\Group\WorkspaceManagerGroup;
+use OCA\Workspace\Groups\Workspace\UserGroup;
+use OCA\Workspace\Groups\Workspace\WorkspaceManagerGroup;
use OCP\AppFramework\Services\IAppConfig;
use OCP\IGroupManager;
@@ -36,16 +36,22 @@ class UpgradeV300 implements UpgradeInterface {
private IAppConfig $appConfig;
private IGroupManager $groupManager;
private SpaceMapper $spaceMapper;
+ private UserGroup $userGroup;
+ private WorkspaceManagerGroup $workspaceManagerGroup;
public function __construct(
GroupFoldersGroupsMapper $groupfoldersGroupsMapper,
IAppConfig $appConfig,
IGroupManager $groupManager,
- SpaceMapper $spaceMapper) {
+ SpaceMapper $spaceMapper,
+ UserGroup $userGroup,
+ WorkspaceManagerGroup $workspaceManagerGroup) {
$this->appConfig = $appConfig;
$this->groupfoldersGroupsMapper = $groupfoldersGroupsMapper;
$this->groupManager = $groupManager;
$this->spaceMapper = $spaceMapper;
+ $this->userGroup = $userGroup;
+ $this->workspaceManagerGroup = $workspaceManagerGroup;
}
public function upgrade(): void {
@@ -72,7 +78,7 @@ private function changeConventionForSubgroups(): void {
}
private function changePrefixForWorkspaceManagerGroups(): void {
- $workspaceManagerGroups = $this->groupManager->search(WorkspaceManagerGroup::getPrefix());
+ $workspaceManagerGroups = $this->groupManager->search($this->workspaceManagerGroup->getGidPrefix());
foreach ($workspaceManagerGroups as $group) {
$groupname = $group->getGID();
$groupnameSplitted = explode('-', $groupname);
@@ -85,7 +91,7 @@ private function changePrefixForWorkspaceManagerGroups(): void {
}
private function changePrefixForWorkspaceUserGroups(): void {
- $userGroups = $this->groupManager->search(UserGroup::getPrefix());
+ $userGroups = $this->groupManager->search($this->userGroup->getGidPrefix());
foreach ($userGroups as $group) {
$groupname = $group->getGID();
$groupnameSplitted = explode('-', $groupname);