diff --git a/composer.lock b/composer.lock
index 9ec221467..d864024d0 100644
--- a/composer.lock
+++ b/composer.lock
@@ -254,12 +254,12 @@
"source": {
"type": "git",
"url": "https://github.com/nextcloud-deps/ocp.git",
- "reference": "439198343dcc5bce91a7ceeb981348df26529b71"
+ "reference": "f2c0daece24f6ff052ee17779a570a80336c275a"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/439198343dcc5bce91a7ceeb981348df26529b71",
- "reference": "439198343dcc5bce91a7ceeb981348df26529b71",
+ "url": "https://api.github.com/repos/nextcloud-deps/ocp/zipball/f2c0daece24f6ff052ee17779a570a80336c275a",
+ "reference": "f2c0daece24f6ff052ee17779a570a80336c275a",
"shasum": ""
},
"require": {
@@ -291,7 +291,7 @@
"issues": "https://github.com/nextcloud-deps/ocp/issues",
"source": "https://github.com/nextcloud-deps/ocp/tree/master"
},
- "time": "2024-02-29T00:31:54+00:00"
+ "time": "2024-03-05T14:50:12+00:00"
},
{
"name": "nikic/php-parser",
diff --git a/img/deck-current.svg b/img/deck-current.svg
new file mode 100644
index 000000000..58c1756d8
--- /dev/null
+++ b/img/deck-current.svg
@@ -0,0 +1,8 @@
+
diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php
index bd8e32e02..31761afae 100644
--- a/lib/AppInfo/Application.php
+++ b/lib/AppInfo/Application.php
@@ -62,6 +62,7 @@
use OCA\Deck\Service\PermissionService;
use OCA\Deck\Sharing\DeckShareProvider;
use OCA\Deck\Sharing\Listener;
+use OCA\Deck\Teams\DeckTeamResourceProvider;
use OCA\Text\Event\LoadEditor;
use OCP\AppFramework\App;
use OCP\AppFramework\Bootstrap\IBootContext;
@@ -179,6 +180,8 @@ public function register(IRegistrationContext $context): void {
$context->registerNotifierService(Notifier::class);
$context->registerEventListener(LoadAdditionalScriptsEvent::class, ResourceAdditionalScriptsListener::class);
+
+ $context->registerTeamResourceProvider(DeckTeamResourceProvider::class);
}
public function registerCommentsEntity(IEventDispatcher $eventDispatcher): void {
diff --git a/lib/Db/BoardMapper.php b/lib/Db/BoardMapper.php
index eec9ce901..e7b21103f 100644
--- a/lib/Db/BoardMapper.php
+++ b/lib/Db/BoardMapper.php
@@ -400,6 +400,51 @@ public function findAllByCircles(string $userId, ?int $limit = null, ?int $offse
return $entries;
}
+ public function findAllByTeam(string $teamId): array {
+ $qb = $this->db->getQueryBuilder();
+ $qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified')
+ ->from('deck_boards', 'b')
+ ->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id'))
+ ->where($qb->expr()->eq('acl.type', $qb->createNamedParameter(Acl::PERMISSION_TYPE_CIRCLE, IQueryBuilder::PARAM_INT)))
+ ->andWhere($qb->expr()->eq('acl.participant', $qb->createNamedParameter($teamId, IQueryBuilder::PARAM_STR)));
+ $entries = $this->findEntities($qb);
+ foreach ($entries as $entry) {
+ $entry->setShared(2);
+ }
+ return $entries;
+ }
+
+ public function findTeamsForBoard(int $boardId): array {
+ $qb = $this->db->getQueryBuilder();
+ $qb->select('acl.participant')
+ ->from('deck_boards', 'b')
+ ->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id'))
+ ->where($qb->expr()->eq('b.id', $qb->createNamedParameter($boardId, IQueryBuilder::PARAM_INT)))
+ ->andWhere($qb->expr()->eq('acl.type', $qb->createNamedParameter(Acl::PERMISSION_TYPE_CIRCLE, IQueryBuilder::PARAM_INT)));
+
+ $result = $qb->executeQuery();
+ return array_map(function ($entry) {
+ return $entry['participant'];
+ }, $result->fetchAll());
+ }
+
+ public function isSharedWithTeam(int $boardId, string $teamId): bool {
+ $qb = $this->db->getQueryBuilder();
+ $qb->select('b.id', 'title', 'owner', 'color', 'archived', 'deleted_at', 'last_modified')
+ ->from('deck_boards', 'b')
+ ->innerJoin('b', 'deck_board_acl', 'acl', $qb->expr()->eq('b.id', 'acl.board_id'))
+ ->where($qb->expr()->eq('b.id', $qb->createNamedParameter($boardId, IQueryBuilder::PARAM_INT)))
+ ->andWhere($qb->expr()->eq('acl.type', $qb->createNamedParameter(Acl::PERMISSION_TYPE_CIRCLE, IQueryBuilder::PARAM_INT)))
+ ->andWhere($qb->expr()->eq('acl.participant', $qb->createNamedParameter($teamId, IQueryBuilder::PARAM_STR)));
+ try {
+ $this->findEntity($qb);
+ return true;
+ } catch (DoesNotExistException $e) {
+ // Expected return falue
+ }
+ return false;
+ }
+
public function findAll(): array {
$qb = $this->db->getQueryBuilder();
$qb->select('id')
diff --git a/lib/Teams/DeckTeamResourceProvider.php b/lib/Teams/DeckTeamResourceProvider.php
new file mode 100644
index 000000000..8612f7dae
--- /dev/null
+++ b/lib/Teams/DeckTeamResourceProvider.php
@@ -0,0 +1,80 @@
+
+ *
+ * @author Julius Härtl
+ *
+ * @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 .
+ */
+
+class DeckTeamResourceProvider implements \OCP\Teams\ITeamResourceProvider {
+
+ public function __construct(
+ private BoardMapper $boardMapper,
+ private IURLGenerator $urlGenerator,
+ ) {
+ }
+
+
+ public function getId(): string {
+ return Application::APP_ID;
+ }
+
+ public function getName(): string {
+ return 'Deck';
+ }
+
+ public function getIconSvg(): string {
+ return file_get_contents(__DIR__ . '/../../img/deck-current.svg');
+ }
+
+ public function getSharedWith($teamId): array {
+ $boards = $this->boardMapper->findAllByTeam($teamId);
+ return array_map(function (Board $board) {
+ return new TeamResource(
+ $this,
+ (string)$board->getId(),
+ $board->getTitle(),
+ $this->urlGenerator->linkToRouteAbsolute('deck.page.index') . '#/board/' . $board->getId(),
+ $this->getBoardBulletIcon($board),
+ $this->urlGenerator->getAbsoluteURL($this->urlGenerator->imagePath('deck', 'deck-current.svg')),
+ );
+ }, $boards);
+ }
+
+ public function isSharedWithTeam(string $teamId, string $resourceId): bool {
+ return $this->boardMapper->isSharedWithTeam((int)$resourceId, $teamId);
+ }
+
+ public function getTeamsForResource(string $resourceId): array {
+ return $this->boardMapper->findTeamsForBoard((int)$resourceId);
+ }
+
+ public function getBoardBulletIcon(Board $board): string {
+ return '';
+ }
+}