diff options
Diffstat (limited to 'lib/public/Group')
29 files changed, 1103 insertions, 0 deletions
diff --git a/lib/public/Group/Backend/ABackend.php b/lib/public/Group/Backend/ABackend.php new file mode 100644 index 00000000000..95af1b85d9b --- /dev/null +++ b/lib/public/Group/Backend/ABackend.php @@ -0,0 +1,76 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +use OCP\GroupInterface; + +/** + * @since 14.0.0 + */ +abstract class ABackend implements GroupInterface, IBatchMethodsBackend { + /** + * @deprecated 14.0.0 + * @since 14.0.0 + * + * @param int $actions The action to check for + * @return bool + */ + public function implementsActions($actions): bool { + $implements = 0; + + if ($this instanceof IAddToGroupBackend) { + $implements |= GroupInterface::ADD_TO_GROUP; + } + if ($this instanceof ICountUsersBackend) { + $implements |= GroupInterface::COUNT_USERS; + } + if ($this instanceof ICreateGroupBackend || $this instanceof ICreateNamedGroupBackend) { + $implements |= GroupInterface::CREATE_GROUP; + } + if ($this instanceof IDeleteGroupBackend) { + $implements |= GroupInterface::DELETE_GROUP; + } + if ($this instanceof IGroupDetailsBackend) { + $implements |= GroupInterface::GROUP_DETAILS; + } + if ($this instanceof IIsAdminBackend) { + $implements |= GroupInterface::IS_ADMIN; + } + if ($this instanceof IRemoveFromGroupBackend) { + $implements |= GroupInterface::REMOVE_FROM_GOUP; + } + + return (bool)($actions & $implements); + } + + /** + * @since 28.0.0 + */ + public function groupsExists(array $gids): array { + return array_values(array_filter( + $gids, + fn (string $gid): bool => $this->groupExists($gid), + )); + } + + /** + * @since 28.0.0 + */ + public function getGroupsDetails(array $gids): array { + if (!($this instanceof IGroupDetailsBackend || $this->implementsActions(GroupInterface::GROUP_DETAILS))) { + throw new \Exception('Should not have been called'); + } + /** @var IGroupDetailsBackend $this */ + $groupData = []; + foreach ($gids as $gid) { + $groupData[$gid] = $this->getGroupDetails($gid); + } + return $groupData; + } +} diff --git a/lib/public/Group/Backend/IAddToGroupBackend.php b/lib/public/Group/Backend/IAddToGroupBackend.php new file mode 100644 index 00000000000..011cd438bd7 --- /dev/null +++ b/lib/public/Group/Backend/IAddToGroupBackend.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 14.0.0 + */ +interface IAddToGroupBackend { + /** + * @since 14.0.0 + */ + public function addToGroup(string $uid, string $gid): bool; +} diff --git a/lib/public/Group/Backend/IBatchMethodsBackend.php b/lib/public/Group/Backend/IBatchMethodsBackend.php new file mode 100644 index 00000000000..5853447d5e9 --- /dev/null +++ b/lib/public/Group/Backend/IBatchMethodsBackend.php @@ -0,0 +1,42 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @brief Optional interface for group backends + * @since 28.0.0 + */ +interface IBatchMethodsBackend { + /** + * @brief Batch method to check if a list of groups exists + * + * The default implementation in ABackend will just call groupExists in + * a loop. But a GroupBackend implementation should provides a more optimized + * override this method to provide a more optimized way to execute this operation. + * + * @param list<string> $gids + * @return list<string> the list of group that exists + * @since 28.0.0 + */ + public function groupsExists(array $gids): array; + + /** + * @brief Batch method to get the group details of a list of groups + * + * The default implementation in ABackend will just call getGroupDetails in + * a loop. But a GroupBackend implementation should override this method + * to provide a more optimized way to execute this operation. + * + * @throws \RuntimeException if called on a backend that doesn't implements IGroupDetailsBackend + * + * @return array<string, array{displayName?: string}> + * @since 28.0.0 + */ + public function getGroupsDetails(array $gids): array; +} diff --git a/lib/public/Group/Backend/ICountDisabledInGroup.php b/lib/public/Group/Backend/ICountDisabledInGroup.php new file mode 100644 index 00000000000..021ebcf9612 --- /dev/null +++ b/lib/public/Group/Backend/ICountDisabledInGroup.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 14.0.0 + */ +interface ICountDisabledInGroup { + /** + * @since 14.0.0 + */ + public function countDisabledInGroup(string $gid): int; +} diff --git a/lib/public/Group/Backend/ICountUsersBackend.php b/lib/public/Group/Backend/ICountUsersBackend.php new file mode 100644 index 00000000000..6afa49a8b4d --- /dev/null +++ b/lib/public/Group/Backend/ICountUsersBackend.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 14.0.0 + */ +interface ICountUsersBackend { + /** + * @since 14.0.0 + */ + public function countUsersInGroup(string $gid, string $search = ''): int; +} diff --git a/lib/public/Group/Backend/ICreateGroupBackend.php b/lib/public/Group/Backend/ICreateGroupBackend.php new file mode 100644 index 00000000000..405d0f0a853 --- /dev/null +++ b/lib/public/Group/Backend/ICreateGroupBackend.php @@ -0,0 +1,20 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 14.0.0 + * @deprecated 30.0.0 Use ICreateNamedGroupBackend instead + */ +interface ICreateGroupBackend { + /** + * @since 14.0.0 + */ + public function createGroup(string $gid): bool; +} diff --git a/lib/public/Group/Backend/ICreateNamedGroupBackend.php b/lib/public/Group/Backend/ICreateNamedGroupBackend.php new file mode 100644 index 00000000000..25cef4f8687 --- /dev/null +++ b/lib/public/Group/Backend/ICreateNamedGroupBackend.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 30.0.0 + */ +interface ICreateNamedGroupBackend { + /** + * Tries to create a group from its name. + * + * If group name already exists, null is returned. + * Otherwise, new group ID is returned. + * + * @param string $name Group name + * @return ?string Group ID in case of success, null in case of failure + * @since 30.0.0 + */ + public function createGroup(string $name): ?string; +} diff --git a/lib/public/Group/Backend/IDeleteGroupBackend.php b/lib/public/Group/Backend/IDeleteGroupBackend.php new file mode 100644 index 00000000000..5e2d3f5e52b --- /dev/null +++ b/lib/public/Group/Backend/IDeleteGroupBackend.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 14.0.0 + */ +interface IDeleteGroupBackend { + /** + * @since 14.0.0 + */ + public function deleteGroup(string $gid): bool; +} diff --git a/lib/public/Group/Backend/IGetDisplayNameBackend.php b/lib/public/Group/Backend/IGetDisplayNameBackend.php new file mode 100644 index 00000000000..0f11dd67bb7 --- /dev/null +++ b/lib/public/Group/Backend/IGetDisplayNameBackend.php @@ -0,0 +1,21 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 17.0.0 + */ +interface IGetDisplayNameBackend { + /** + * @param string $gid + * @return string + * @since 17.0.0 + */ + public function getDisplayName(string $gid): string; +} diff --git a/lib/public/Group/Backend/IGroupDetailsBackend.php b/lib/public/Group/Backend/IGroupDetailsBackend.php new file mode 100644 index 00000000000..a2830849f6c --- /dev/null +++ b/lib/public/Group/Backend/IGroupDetailsBackend.php @@ -0,0 +1,26 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @brief Optional interface for group backends + * @since 14.0.0 + */ +interface IGroupDetailsBackend { + /** + * @brief Get additional details for a group, for example the display name. + * + * The array returned can be empty when no additional information is available + * for the group. + * + * @return array{displayName?: string} + * @since 14.0.0 + */ + public function getGroupDetails(string $gid): array; +} diff --git a/lib/public/Group/Backend/IHideFromCollaborationBackend.php b/lib/public/Group/Backend/IHideFromCollaborationBackend.php new file mode 100644 index 00000000000..605de213c28 --- /dev/null +++ b/lib/public/Group/Backend/IHideFromCollaborationBackend.php @@ -0,0 +1,25 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 16.0.0 + * + * Allow the backend to mark groups to be excluded from being shown in search dialogs + */ +interface IHideFromCollaborationBackend { + /** + * Check if a group should be hidden from search dialogs + * + * @param string $groupId + * @return bool + * @since 16.0.0 + */ + public function hideGroup(string $groupId): bool; +} diff --git a/lib/public/Group/Backend/IIsAdminBackend.php b/lib/public/Group/Backend/IIsAdminBackend.php new file mode 100644 index 00000000000..ed299961dc2 --- /dev/null +++ b/lib/public/Group/Backend/IIsAdminBackend.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 14.0.0 + */ +interface IIsAdminBackend { + /** + * @since 14.0.0 + */ + public function isAdmin(string $uid): bool; +} diff --git a/lib/public/Group/Backend/INamedBackend.php b/lib/public/Group/Backend/INamedBackend.php new file mode 100644 index 00000000000..d98cc8cdb83 --- /dev/null +++ b/lib/public/Group/Backend/INamedBackend.php @@ -0,0 +1,19 @@ +<?php + +/** + * SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 22.0.0 + */ +interface INamedBackend { + /** + * Backend name to be shown in group management + * @return string the name of the backend to be shown + * @since 22.0.0 + */ + public function getBackendName(): string; +} diff --git a/lib/public/Group/Backend/IRemoveFromGroupBackend.php b/lib/public/Group/Backend/IRemoveFromGroupBackend.php new file mode 100644 index 00000000000..e4862feb2f2 --- /dev/null +++ b/lib/public/Group/Backend/IRemoveFromGroupBackend.php @@ -0,0 +1,19 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 14.0.0 + */ +interface IRemoveFromGroupBackend { + /** + * @since 14.0.0 + */ + public function removeFromGroup(string $uid, string $gid); +} diff --git a/lib/public/Group/Backend/ISearchableGroupBackend.php b/lib/public/Group/Backend/ISearchableGroupBackend.php new file mode 100644 index 00000000000..e9909fcdba0 --- /dev/null +++ b/lib/public/Group/Backend/ISearchableGroupBackend.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +use OCP\IUser; + +/** + * @since 27.0.0 + */ +interface ISearchableGroupBackend { + /** + * @brief Get a list of users matching the given search parameters. + * + * Implementations of this method should return lazy evaluated user objects and + * preload if possible the display name. + * + * <code> + * $users = $groupBackend->searchInGroup('admin', 'John', 10, 0); + * </code> + * + * @param string $gid The group id of the user we want to search + * @param string $search The part of the display name or user id of the users we + * want to search. This can be empty to get all the users. + * @param int $limit The limit of results + * @param int $offset The offset of the results + * @return array<string,IUser> Users indexed by uid + * @since 27.0.0 + */ + public function searchInGroup(string $gid, string $search = '', int $limit = -1, int $offset = 0): array; +} diff --git a/lib/public/Group/Backend/ISetDisplayNameBackend.php b/lib/public/Group/Backend/ISetDisplayNameBackend.php new file mode 100644 index 00000000000..d0875e84768 --- /dev/null +++ b/lib/public/Group/Backend/ISetDisplayNameBackend.php @@ -0,0 +1,22 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Backend; + +/** + * @since 18.0.0 + */ +interface ISetDisplayNameBackend { + /** + * @param string $gid + * @param string $displayName + * @return bool + * @since 18.0.0 + */ + public function setDisplayName(string $gid, string $displayName): bool; +} diff --git a/lib/public/Group/Events/BeforeGroupChangedEvent.php b/lib/public/Group/Events/BeforeGroupChangedEvent.php new file mode 100644 index 00000000000..7fb46b8ce6d --- /dev/null +++ b/lib/public/Group/Events/BeforeGroupChangedEvent.php @@ -0,0 +1,77 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; + +/** + * @since 26.0.0 + */ +class BeforeGroupChangedEvent extends Event { + private IGroup $group; + private string $feature; + /** @var mixed */ + private $value; + /** @var mixed */ + private $oldValue; + + /** + * @since 26.0.0 + */ + public function __construct(IGroup $group, + string $feature, + $value, + $oldValue = null) { + parent::__construct(); + $this->group = $group; + $this->feature = $feature; + $this->value = $value; + $this->oldValue = $oldValue; + } + + /** + * + * @since 26.0.0 + * + * @return IGroup + */ + public function getGroup(): IGroup { + return $this->group; + } + + /** + * + * @since 26.0.0 + * + * @return string + */ + public function getFeature(): string { + return $this->feature; + } + + /** + * @since 26.0.0 + * + * @return mixed + */ + public function getValue() { + return $this->value; + } + + /** + * + * @since 26.0.0 + * + * @return mixed + */ + public function getOldValue() { + return $this->oldValue; + } +} diff --git a/lib/public/Group/Events/BeforeGroupCreatedEvent.php b/lib/public/Group/Events/BeforeGroupCreatedEvent.php new file mode 100644 index 00000000000..2f197d6a088 --- /dev/null +++ b/lib/public/Group/Events/BeforeGroupCreatedEvent.php @@ -0,0 +1,35 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; + +/** + * @since 18.0.0 + */ +class BeforeGroupCreatedEvent extends Event { + /** @var string */ + private $name; + + /** + * @since 18.0.0 + */ + public function __construct(string $name) { + parent::__construct(); + $this->name = $name; + } + + /** + * @return string + * @since 18.0.0 + */ + public function getName(): string { + return $this->name; + } +} diff --git a/lib/public/Group/Events/BeforeGroupDeletedEvent.php b/lib/public/Group/Events/BeforeGroupDeletedEvent.php new file mode 100644 index 00000000000..3c8f83440c7 --- /dev/null +++ b/lib/public/Group/Events/BeforeGroupDeletedEvent.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; + +/** + * @since 18.0.0 + */ +class BeforeGroupDeletedEvent extends Event { + /** @var IGroup */ + private $group; + + /** + * @since 18.0.0 + */ + public function __construct(IGroup $group) { + parent::__construct(); + $this->group = $group; + } + + /** + * @return IGroup + * @since 18.0.0 + */ + public function getGroup(): IGroup { + return $this->group; + } +} diff --git a/lib/public/Group/Events/BeforeUserAddedEvent.php b/lib/public/Group/Events/BeforeUserAddedEvent.php new file mode 100644 index 00000000000..09198112539 --- /dev/null +++ b/lib/public/Group/Events/BeforeUserAddedEvent.php @@ -0,0 +1,49 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; +use OCP\IUser; + +/** + * @since 18.0.0 + */ +class BeforeUserAddedEvent extends Event { + /** @var IGroup */ + private $group; + + /*** @var IUser */ + private $user; + + /** + * @since 18.0.0 + */ + public function __construct(IGroup $group, IUser $user) { + parent::__construct(); + $this->group = $group; + $this->user = $user; + } + + /** + * @return IGroup + * @since 18.0.0 + */ + public function getGroup(): IGroup { + return $this->group; + } + + /** + * @return IUser + * @since 18.0.0 + */ + public function getUser(): IUser { + return $this->user; + } +} diff --git a/lib/public/Group/Events/BeforeUserRemovedEvent.php b/lib/public/Group/Events/BeforeUserRemovedEvent.php new file mode 100644 index 00000000000..50d34e0c7cf --- /dev/null +++ b/lib/public/Group/Events/BeforeUserRemovedEvent.php @@ -0,0 +1,56 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; +use OCP\IUser; + +/** + * @since 18.0.0 + * @deprecated 20.0.0 - it can't be guaranteed that this event is triggered in + * all case (e.g. for LDAP users this isn't possible) - if there is a valid use + * case please reach out in the issue tracker at + * https://github.com/nextcloud/server/issues + */ +class BeforeUserRemovedEvent extends Event { + /** @var IGroup */ + private $group; + + /*** @var IUser */ + private $user; + + /** + * @since 18.0.0 + * @deprecated 20.0.0 + */ + public function __construct(IGroup $group, IUser $user) { + parent::__construct(); + $this->group = $group; + $this->user = $user; + } + + /** + * @return IGroup + * @since 18.0.0 + * @deprecated 20.0.0 + */ + public function getGroup(): IGroup { + return $this->group; + } + + /** + * @return IUser + * @since 18.0.0 + * @deprecated 20.0.0 + */ + public function getUser(): IUser { + return $this->user; + } +} diff --git a/lib/public/Group/Events/GroupChangedEvent.php b/lib/public/Group/Events/GroupChangedEvent.php new file mode 100644 index 00000000000..c9fd12b8c3a --- /dev/null +++ b/lib/public/Group/Events/GroupChangedEvent.php @@ -0,0 +1,77 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; + +/** + * @since 26.0.0 + */ +class GroupChangedEvent extends Event { + private IGroup $group; + private string $feature; + /** @var mixed */ + private $value; + /** @var mixed */ + private $oldValue; + + /** + * @since 26.0.0 + */ + public function __construct(IGroup $group, + string $feature, + $value, + $oldValue = null) { + parent::__construct(); + $this->group = $group; + $this->feature = $feature; + $this->value = $value; + $this->oldValue = $oldValue; + } + + /** + * + * @since 26.0.0 + * + * @return IGroup + */ + public function getGroup(): IGroup { + return $this->group; + } + + /** + * + * @since 26.0.0 + * + * @return string + */ + public function getFeature(): string { + return $this->feature; + } + + /** + * @since 26.0.0 + * + * @return mixed + */ + public function getValue() { + return $this->value; + } + + /** + * + * @since 26.0.0 + * + * @return mixed + */ + public function getOldValue() { + return $this->oldValue; + } +} diff --git a/lib/public/Group/Events/GroupCreatedEvent.php b/lib/public/Group/Events/GroupCreatedEvent.php new file mode 100644 index 00000000000..106f57c7154 --- /dev/null +++ b/lib/public/Group/Events/GroupCreatedEvent.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; + +/** + * @since 18.0.0 + */ +class GroupCreatedEvent extends Event { + /** @var IGroup */ + private $group; + + /** + * @since 18.0.0 + */ + public function __construct(IGroup $group) { + parent::__construct(); + $this->group = $group; + } + + /** + * @return IGroup + * @since 18.0.0 + */ + public function getGroup(): IGroup { + return $this->group; + } +} diff --git a/lib/public/Group/Events/GroupDeletedEvent.php b/lib/public/Group/Events/GroupDeletedEvent.php new file mode 100644 index 00000000000..b651f5cdfa9 --- /dev/null +++ b/lib/public/Group/Events/GroupDeletedEvent.php @@ -0,0 +1,36 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; + +/** + * @since 18.0.0 + */ +class GroupDeletedEvent extends Event { + /** @var IGroup */ + private $group; + + /** + * @since 18.0.0 + */ + public function __construct(IGroup $group) { + parent::__construct(); + $this->group = $group; + } + + /** + * @return IGroup + * @since 18.0.0 + */ + public function getGroup(): IGroup { + return $this->group; + } +} diff --git a/lib/public/Group/Events/SubAdminAddedEvent.php b/lib/public/Group/Events/SubAdminAddedEvent.php new file mode 100644 index 00000000000..cb1caebdb77 --- /dev/null +++ b/lib/public/Group/Events/SubAdminAddedEvent.php @@ -0,0 +1,47 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; +use OCP\IUser; + +/** + * @since 21.0.0 + */ +class SubAdminAddedEvent extends Event { + /** @var IGroup */ + private $group; + + /*** @var IUser */ + private $user; + + /** + * @since 21.0.0 + */ + public function __construct(IGroup $group, IUser $user) { + parent::__construct(); + $this->group = $group; + $this->user = $user; + } + + /** + * @since 21.0.0 + */ + public function getGroup(): IGroup { + return $this->group; + } + + /** + * @since 21.0.0 + */ + public function getUser(): IUser { + return $this->user; + } +} diff --git a/lib/public/Group/Events/SubAdminRemovedEvent.php b/lib/public/Group/Events/SubAdminRemovedEvent.php new file mode 100644 index 00000000000..1d76d05cc58 --- /dev/null +++ b/lib/public/Group/Events/SubAdminRemovedEvent.php @@ -0,0 +1,47 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; +use OCP\IUser; + +/** + * @since 21.0.0 + */ +class SubAdminRemovedEvent extends Event { + /** @var IGroup */ + private $group; + + /*** @var IUser */ + private $user; + + /** + * @since 21.0.0 + */ + public function __construct(IGroup $group, IUser $user) { + parent::__construct(); + $this->group = $group; + $this->user = $user; + } + + /** + * @since 21.0.0 + */ + public function getGroup(): IGroup { + return $this->group; + } + + /** + * @since 21.0.0 + */ + public function getUser(): IUser { + return $this->user; + } +} diff --git a/lib/public/Group/Events/UserAddedEvent.php b/lib/public/Group/Events/UserAddedEvent.php new file mode 100644 index 00000000000..0c15d2b5c05 --- /dev/null +++ b/lib/public/Group/Events/UserAddedEvent.php @@ -0,0 +1,49 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; +use OCP\IUser; + +/** + * @since 18.0.0 + */ +class UserAddedEvent extends Event { + /** @var IGroup */ + private $group; + + /*** @var IUser */ + private $user; + + /** + * @since 18.0.0 + */ + public function __construct(IGroup $group, IUser $user) { + parent::__construct(); + $this->group = $group; + $this->user = $user; + } + + /** + * @return IGroup + * @since 18.0.0 + */ + public function getGroup(): IGroup { + return $this->group; + } + + /** + * @return IUser + * @since 18.0.0 + */ + public function getUser(): IUser { + return $this->user; + } +} diff --git a/lib/public/Group/Events/UserRemovedEvent.php b/lib/public/Group/Events/UserRemovedEvent.php new file mode 100644 index 00000000000..c1d6bb3cda2 --- /dev/null +++ b/lib/public/Group/Events/UserRemovedEvent.php @@ -0,0 +1,49 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group\Events; + +use OCP\EventDispatcher\Event; +use OCP\IGroup; +use OCP\IUser; + +/** + * @since 18.0.0 + */ +class UserRemovedEvent extends Event { + /** @var IGroup */ + private $group; + + /*** @var IUser */ + private $user; + + /** + * @since 18.0.0 + */ + public function __construct(IGroup $group, IUser $user) { + parent::__construct(); + $this->group = $group; + $this->user = $user; + } + + /** + * @return IGroup + * @since 18.0.0 + */ + public function getGroup(): IGroup { + return $this->group; + } + + /** + * @return IUser + * @since 18.0.0 + */ + public function getUser(): IUser { + return $this->user; + } +} diff --git a/lib/public/Group/ISubAdmin.php b/lib/public/Group/ISubAdmin.php new file mode 100644 index 00000000000..ed4ef1fa926 --- /dev/null +++ b/lib/public/Group/ISubAdmin.php @@ -0,0 +1,82 @@ +<?php + +declare(strict_types=1); + +/** + * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later + */ +namespace OCP\Group; + +use OCP\IGroup; +use OCP\IUser; + +/** + * @since 16.0.0 + */ +interface ISubAdmin { + /** + * add a SubAdmin + * @param IUser $user user to be SubAdmin + * @param IGroup $group group $user becomes subadmin of + * + * @since 16.0.0 + */ + public function createSubAdmin(IUser $user, IGroup $group): void; + + /** + * delete a SubAdmin + * @param IUser $user the user that is the SubAdmin + * @param IGroup $group the group + * + * @since 16.0.0 + */ + public function deleteSubAdmin(IUser $user, IGroup $group): void; + + /** + * get groups of a SubAdmin + * @param IUser $user the SubAdmin + * @return IGroup[] + * + * @since 16.0.0 + */ + public function getSubAdminsGroups(IUser $user): array; + + /** + * get SubAdmins of a group + * @param IGroup $group the group + * @return IUser[] + * + * @since 16.0.0 + */ + public function getGroupsSubAdmins(IGroup $group): array; + + /** + * checks if a user is a SubAdmin of a group + * @param IUser $user + * @param IGroup $group + * @return bool + * + * @since 16.0.0 + */ + public function isSubAdminOfGroup(IUser $user, IGroup $group): bool; + + /** + * checks if a user is a SubAdmin + * @param IUser $user + * @return bool + * + * @since 16.0.0 + */ + public function isSubAdmin(IUser $user): bool; + + /** + * checks if a user is a accessible by a subadmin + * @param IUser $subadmin + * @param IUser $user + * @return bool + * + * @since 16.0.0 + */ + public function isUserAccessible(IUser $subadmin, IUser $user): bool; +} |