Skip to content

Conversation

mnocon
Copy link
Contributor

@mnocon mnocon commented Sep 17, 2025

No description provided.

Copy link

github-actions bot commented Sep 17, 2025

adriendupuis and others added 6 commits September 30, 2025 10:43
* IBX-9060: Document revamped notifications

* Add modified query examples

* Apply suggestion from @mnocon

Co-authored-by: Marek Nocoń <[email protected]>

---------

Co-authored-by: dabrt <[email protected]>
Co-authored-by: Marek Nocoń <[email protected]>
* Reworded section for updating LTS Updates

* [WIP] Updated Python

* Fixed EOLWhitespace

* Fixed Symbol attribute
@mnocon mnocon force-pushed the IBX-9737-installation-only-4.6 branch from 757d554 to fcf6262 Compare October 1, 2025 10:46
Copy link

github-actions bot commented Oct 2, 2025

code_samples/ change report

Before (on target branch)After (in current PR)

code_samples/collaboration/config/mysql/ibexa_share.sql


code_samples/collaboration/config/mysql/ibexa_share.sql

docs/content_management/collaborative_editing/install_collaborative_editing.md@93:    ``` sql
docs/content_management/collaborative_editing/install_collaborative_editing.md@94: [[= include_file('code_samples/collaboration/config/mysql/ibexa_share.sql', 0, None, ' ') =]]
docs/content_management/collaborative_editing/install_collaborative_editing.md@95: ```

001⫶ CREATE TABLE ibexa_collaboration
002⫶ (
003⫶ id INT AUTO_INCREMENT NOT NULL,
004⫶ owner_id INT NOT NULL,
005⫶ token VARCHAR(160) NOT NULL,
006⫶ discriminator VARCHAR(190) NOT NULL,
007⫶ is_active TINYINT(1) NOT NULL,
008⫶ has_public_link TINYINT(1) NOT NULL,
009⫶ created_at DATETIME NOT NULL COMMENT '(DC2Type:datetimetz_immutable)',
010⫶ updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetimetz_immutable)',
011⫶ UNIQUE INDEX ibexa_collaboration_token_idx (token),
012⫶ INDEX ibexa_collaboration_owner_idx (owner_id),
013⫶ UNIQUE INDEX ibexa_collaboration_token_uc (token),
014⫶ PRIMARY KEY (id)
015⫶ ) DEFAULT CHARACTER SET utf8mb4
016⫶ COLLATE `utf8mb4_unicode_520_ci`
017⫶ ENGINE = InnoDB;
018⫶ CREATE TABLE ibexa_collaboration_participant
019⫶ (
020⫶ id INT AUTO_INCREMENT NOT NULL,
021⫶ session_id INT NOT NULL,
022⫶ discriminator VARCHAR(190) NOT NULL,
023⫶ scope VARCHAR(255) DEFAULT NULL,
024⫶ token VARCHAR(255) DEFAULT NULL,
025⫶ created_at DATETIME NOT NULL COMMENT '(DC2Type:datetimetz_immutable)',
026⫶ updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetimetz_immutable)',
027⫶ INDEX IDX_9C5C6401613FECDF (session_id),
028⫶ UNIQUE INDEX ibexa_collaboration_participant_token_idx (token),
029⫶ PRIMARY KEY (id)
030⫶ ) DEFAULT CHARACTER SET utf8mb4
031⫶ COLLATE `utf8mb4_unicode_520_ci`
032⫶ ENGINE = InnoDB;
033⫶ CREATE TABLE ibexa_collaboration_participant_internal
034⫶ (
035⫶ id INT NOT NULL,
036⫶ user_id INT NOT NULL,
037⫶ INDEX IDX_E838B79AA76ED395 (user_id),
038⫶ PRIMARY KEY (id)
039⫶ ) DEFAULT CHARACTER SET utf8mb4
040⫶ COLLATE `utf8mb4_unicode_520_ci`
041⫶ ENGINE = InnoDB;
042⫶ CREATE TABLE ibexa_collaboration_participant_external
043⫶ (
044⫶ id INT NOT NULL,
045⫶ email VARCHAR(255) NOT NULL,
046⫶ PRIMARY KEY (id)
047⫶ ) DEFAULT CHARACTER SET utf8mb4
048⫶ COLLATE `utf8mb4_unicode_520_ci`
049⫶ ENGINE = InnoDB;
050⫶ CREATE TABLE ibexa_collaboration_invitation
051⫶ (
052⫶ id INT AUTO_INCREMENT NOT NULL,
053⫶ session_id INT NOT NULL,
054⫶ participant_id INT NOT NULL,
055⫶ sender_id INT NOT NULL,
056⫶ status VARCHAR(64) NOT NULL,
057⫶ context LONGTEXT DEFAULT NULL COMMENT '(DC2Type:json)',
058⫶ created_at DATETIME NOT NULL COMMENT '(DC2Type:datetimetz_immutable)',
059⫶ updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetimetz_immutable)',
060⫶ INDEX IDX_36C63687613FECDF (session_id),
061⫶ INDEX IDX_36C636879D1C3019 (participant_id),
062⫶ INDEX IDX_36C63687F624B39D (sender_id),
063⫶ PRIMARY KEY (id)
064⫶ ) DEFAULT CHARACTER SET utf8mb4
065⫶ COLLATE `utf8mb4_unicode_520_ci`
066⫶ ENGINE = InnoDB;
067⫶ ALTER TABLE ibexa_collaboration
068⫶ ADD CONSTRAINT ibexa_collaboration_owner_id_fk FOREIGN KEY (owner_id) REFERENCES ezuser (contentobject_id) ON DELETE RESTRICT;
069⫶ ALTER TABLE ibexa_collaboration_participant
070⫶ ADD CONSTRAINT ibexa_collaboration_participant_session_id_fk FOREIGN KEY (session_id) REFERENCES ibexa_collaboration (id) ON UPDATE CASCADE ON DELETE CASCADE;
071⫶ ALTER TABLE ibexa_collaboration_participant_internal
072⫶ ADD CONSTRAINT ibexa_collaboration_participant_internal_pk FOREIGN KEY (id) REFERENCES ibexa_collaboration_participant (id) ON UPDATE CASCADE ON DELETE CASCADE;
073⫶ ALTER TABLE ibexa_collaboration_participant_internal
074⫶ ADD CONSTRAINT ibexa_collaboration_participant_internal_user_id_fk FOREIGN KEY (user_id) REFERENCES ezuser (contentobject_id) ON DELETE RESTRICT;
075⫶ ALTER TABLE ibexa_collaboration_participant_external
076⫶ ADD CONSTRAINT ibexa_collaboration_participant_external_pk FOREIGN KEY (id) REFERENCES ibexa_collaboration_participant (id) ON UPDATE CASCADE ON DELETE CASCADE;
077⫶ ALTER TABLE ibexa_collaboration_invitation
078⫶ ADD CONSTRAINT ibexa_collaboration_invitation_session_id_fk FOREIGN KEY (session_id) REFERENCES ibexa_collaboration (id) ON UPDATE CASCADE ON DELETE CASCADE;
079⫶ ALTER TABLE ibexa_collaboration_invitation
080⫶ ADD CONSTRAINT ibexa_collaboration_invitation_participant_id_fk FOREIGN KEY (participant_id) REFERENCES ibexa_collaboration_participant (id) ON UPDATE CASCADE ON DELETE CASCADE;
081⫶ ALTER TABLE ibexa_collaboration_invitation
082⫶ ADD CONSTRAINT ibexa_collaboration_invitation_sender_id_fk FOREIGN KEY (sender_id) REFERENCES ezuser (contentobject_id) ON DELETE RESTRICT;


code_samples/collaboration/config/postgresql/ibexa_share.sql


code_samples/collaboration/config/postgresql/ibexa_share.sql

docs/content_management/collaborative_editing/install_collaborative_editing.md@99:    ``` sql
docs/content_management/collaborative_editing/install_collaborative_editing.md@100: [[= include_file('code_samples/collaboration/config/postgresql/ibexa_share.sql', 0, None, ' ') =]]
docs/content_management/collaborative_editing/install_collaborative_editing.md@101: ```

001⫶ CREATE TABLE ibexa_collaboration
002⫶ (
003⫶ id SERIAL NOT NULL,
004⫶ owner_id INT NOT NULL,
005⫶ token VARCHAR(160) NOT NULL,
006⫶ discriminator VARCHAR(190) NOT NULL,
007⫶ is_active BOOLEAN NOT NULL,
008⫶ has_public_link BOOLEAN NOT NULL,
009⫶ created_at TIMESTAMP(0) WITH TIME ZONE NOT NULL,
010⫶ updated_at TIMESTAMP(0) WITH TIME ZONE NOT NULL,
011⫶ PRIMARY KEY (id)
012⫶ );
013⫶ CREATE UNIQUE INDEX ibexa_collaboration_token_idx ON ibexa_collaboration (token);
014⫶ CREATE INDEX ibexa_collaboration_owner_idx ON ibexa_collaboration (owner_id);
015⫶ CREATE UNIQUE INDEX ibexa_collaboration_token_uc ON ibexa_collaboration (token);
016⫶ COMMENT
017⫶ ON COLUMN ibexa_collaboration.created_at IS '(DC2Type:datetimetz_immutable)';
018⫶ COMMENT
019⫶ ON COLUMN ibexa_collaboration.updated_at IS '(DC2Type:datetimetz_immutable)';
020⫶ CREATE TABLE ibexa_collaboration_participant
021⫶ (
022⫶ id SERIAL NOT NULL,
023⫶ session_id INT NOT NULL,
024⫶ discriminator VARCHAR(190) NOT NULL,
025⫶ scope VARCHAR(255) DEFAULT NULL,
026⫶ token VARCHAR(255) DEFAULT NULL,
027⫶ created_at TIMESTAMP(0) WITH TIME ZONE NOT NULL,
028⫶ updated_at TIMESTAMP(0) WITH TIME ZONE NOT NULL,
029⫶ PRIMARY KEY (id)
030⫶ );
031⫶ CREATE INDEX ibexa_collaboration_participant_idx ON ibexa_collaboration_participant (session_id);
032⫶ CREATE UNIQUE INDEX ibexa_collaboration_participant_token_idx ON ibexa_collaboration_participant (token);
033⫶ COMMENT
034⫶ ON COLUMN ibexa_collaboration_participant.created_at IS '(DC2Type:datetimetz_immutable)';
035⫶ COMMENT
036⫶ ON COLUMN ibexa_collaboration_participant.updated_at IS '(DC2Type:datetimetz_immutable)';
037⫶ CREATE TABLE ibexa_collaboration_participant_internal
038⫶ (
039⫶ id INT NOT NULL,
040⫶ user_id INT NOT NULL,
041⫶ PRIMARY KEY (id)
042⫶ );
043⫶ CREATE INDEX ibexa_collaboration_participant_internal_idx ON ibexa_collaboration_participant_internal (user_id);
044⫶ CREATE TABLE ibexa_collaboration_participant_external
045⫶ (
046⫶ id INT NOT NULL,
047⫶ email VARCHAR(255) NOT NULL,
048⫶ PRIMARY KEY (id)
049⫶ );
050⫶ CREATE TABLE ibexa_collaboration_invitation
051⫶ (
052⫶ id SERIAL NOT NULL,
053⫶ session_id INT NOT NULL,
054⫶ participant_id INT NOT NULL,
055⫶ sender_id INT NOT NULL,
056⫶ status VARCHAR(64) NOT NULL,
057⫶ context JSON DEFAULT NULL,
058⫶ created_at TIMESTAMP(0) WITH TIME ZONE NOT NULL,
059⫶ updated_at TIMESTAMP(0) WITH TIME ZONE NOT NULL,
060⫶ PRIMARY KEY (id)
061⫶ );
062⫶ CREATE INDEX ibexa_collaboration_invitation_idx ON ibexa_collaboration_invitation (session_id);
063⫶ CREATE INDEX ibexa_collaboration_invitation_idx ON ibexa_collaboration_invitation (participant_id);
064⫶ CREATE INDEX ibexa_collaboration_invitation_idx ON ibexa_collaboration_invitation (sender_id);
065⫶ COMMENT
066⫶ ON COLUMN ibexa_collaboration_invitation.created_at IS '(DC2Type:datetimetz_immutable)';
067⫶ COMMENT
068⫶ ON COLUMN ibexa_collaboration_invitation.updated_at IS '(DC2Type:datetimetz_immutable)';
069⫶ ALTER TABLE ibexa_collaboration
070⫶ ADD CONSTRAINT ibexa_collaboration_owner_id_fk FOREIGN KEY (owner_id) REFERENCES ezuser (contentobject_id) ON DELETE RESTRICT NOT DEFERRABLE INITIALLY IMMEDIATE;
071⫶ ALTER TABLE ibexa_collaboration_participant
072⫶ ADD CONSTRAINT ibexa_collaboration_participant_session_id_fk FOREIGN KEY (session_id) REFERENCES ibexa_collaboration (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
073⫶ ALTER TABLE ibexa_collaboration_participant_internal
074⫶ ADD CONSTRAINT ibexa_collaboration_participant_internal_pk FOREIGN KEY (id) REFERENCES ibexa_collaboration_participant (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
075⫶ ALTER TABLE ibexa_collaboration_participant_internal
076⫶ ADD CONSTRAINT ibexa_collaboration_participant_internal_user_id_fk FOREIGN KEY (user_id) REFERENCES ezuser (contentobject_id) ON DELETE RESTRICT NOT DEFERRABLE INITIALLY IMMEDIATE;
077⫶ ALTER TABLE ibexa_collaboration_participant_external
078⫶ ADD CONSTRAINT ibexa_collaboration_participant_external_pk FOREIGN KEY (id) REFERENCES ibexa_collaboration_participant (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
079⫶ ALTER TABLE ibexa_collaboration_invitation
080⫶ ADD CONSTRAINT ibexa_collaboration_invitation_session_id_fk FOREIGN KEY (session_id) REFERENCES ibexa_collaboration (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
081⫶ ALTER TABLE ibexa_collaboration_invitation
082⫶ ADD CONSTRAINT ibexa_collaboration_invitation_participant_id_fk FOREIGN KEY (participant_id) REFERENCES ibexa_collaboration_participant (id) ON UPDATE CASCADE ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
083⫶ ALTER TABLE ibexa_collaboration_invitation
084⫶ ADD CONSTRAINT ibexa_collaboration_invitation_sender_id_fk FOREIGN KEY (sender_id) REFERENCES ezuser (contentobject_id) ON DELETE RESTRICT NOT DEFERRABLE INITIALLY IMMEDIATE;


code_samples/collaboration/src/Command/ManageSessionsCommand.php


code_samples/collaboration/src/Command/ManageSessionsCommand.php

docs/content_management/collaborative_editing/collaborative_editing_api.md@22:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@23:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 69, 81) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@24:```

001⫶ $versionInfo = $this->contentService->loadContent(52)->getVersionInfo();
002⫶ $createStruct = new ContentSessionCreateStruct(
003⫶ $versionInfo,
004⫶ $versionInfo->getInitialLanguage()
005⫶ );
006⫶ $createStruct->setHasPublicLink(false);
007⫶
008⫶ $token = 'my-secret-token-12345';
009⫶ $createStruct->setToken($token);
010⫶
011⫶ $sessionId = $this->sessionService->createSession($createStruct)->getId();

docs/content_management/collaborative_editing/collaborative_editing_api.md@32:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@33:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 82, 83) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@34:```

001⫶ $session = $this->sessionService->getSession($sessionId);

docs/content_management/collaborative_editing/collaborative_editing_api.md@38:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@39:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 83, 84) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@40:```

001⫶ $session = $this->sessionService->getSessionByToken($token);

docs/content_management/collaborative_editing/collaborative_editing_api.md@46:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@47:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 86, 89) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@48:```

001⫶ $sessionQuery = new SessionQuery(new Token($token));
002⫶ $session = $this->sessionService->findSessions($sessionQuery)->getFirst();

docs/content_management/collaborative_editing/collaborative_editing_api.md@54:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@55:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 90, 95) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@56:```

001⫶ $updateStruct = new ContentSessionUpdateStruct();
002⫶ $updateStruct->setHasPublicLink(true);
003⫶
004⫶ $this->sessionService->updateSession($session, $updateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@62:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@63:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 169, 170) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@64:```

001⫶ $this->sessionService->deleteSession($session);

docs/content_management/collaborative_editing/collaborative_editing_api.md@72:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@73:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 102, 116) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@74:```

001⫶ $user = $this->userService->loadUserByLogin('another_user');
002⫶ $internalParticipantCreateStruct = new InternalParticipantCreateStruct(
003⫶ $user,
004⫶ ContentSessionScope::VIEW
005⫶ );
006⫶ $externalParticipantCreateStruct = new ExternalParticipantCreateStruct(
007⫶ '[email protected]',
008⫶ ContentSessionScope::VIEW,
009⫶ 'personal-secret-token-12345'
010⫶ );
011⫶
012⫶ $internalParticipant = $this->sessionService->addParticipant($session, $internalParticipantCreateStruct);
013⫶ $externalParticipant = $this->sessionService->addParticipant($session, $externalParticipantCreateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@90:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@91:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 117, 125) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@92:```

001⫶ $participant = $this->sessionService
002⫶ ->getSession($session->getId())
003⫶ ->getParticipants()
004⫶ ->getByEmail($user->email);
005⫶
006⫶ $internalParticipantUpdateStruct = new InternalParticipantUpdateStruct(ContentSessionScope::EDIT);
007⫶ $this->sessionService->updateParticipant($session, $participant, $internalParticipantUpdateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@97:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@98:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 126, 127) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@99:```

001⫶ $this->sessionService->removeParticipant($session, $externalParticipant);

docs/content_management/collaborative_editing/collaborative_editing_api.md@105:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@106:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 129, 134) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@107:```

001⫶ $this->sessionService->isSessionOwner(
002⫶ $session,
003⫶ $this->userService->loadUserByLogin('another_user')
004⫶ );

docs/content_management/collaborative_editing/collaborative_editing_api.md@115:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@116:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 135, 140) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@117:```

001⫶ $this->sessionService->isSessionParticipant(
002⫶ $session,
003⫶ $this->permissionResolver->getCurrentUserReference()
004⫶ );

docs/content_management/collaborative_editing/collaborative_editing_api.md@126:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@127:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 141, 150) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@128:```

001⫶ $invitationQuery = new InvitationQuery(new Session($session));
002⫶ $invitations = $this->invitationService->findInvitations($invitationQuery)->getInvitations();
003⫶
004⫶ foreach ($invitations as $invitation) {
005⫶ $output->writeln('Invitation ID: ' . $invitation->getId() . ' Status: ' . $invitation->getStatus());
006⫶ }
007⫶
008⫶ $invitation = $this->invitationService->getInvitationByParticipant($participant);

docs/content_management/collaborative_editing/collaborative_editing_api.md@160:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@161:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 151, 158) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@162:```

001⫶ $invitationCreateStruct = new InvitationCreateStruct(
002⫶ $session,
003⫶ $internalParticipant
004⫶ );
005⫶
006⫶ $this->invitationService->createInvitation($invitationCreateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@170:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@171:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 159, 164) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@172:```

001⫶ $invitationUpdateStruct = new InvitationUpdateStruct();
002⫶ $invitationUpdateStruct->setStatus(InvitationStatus::STATUS_REJECTED);
003⫶
004⫶ $this->invitationService->updateInvitation($invitation, $invitationUpdateStruct);

docs/content_management/collaborative_editing/collaborative_editing_api.md@178:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@179:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php', 165, 168) =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@180:```

001⫶ $invitation = $this->invitationService->getInvitation(2);
002⫶ $this->invitationService->deleteInvitation($invitation);

docs/content_management/collaborative_editing/collaborative_editing_api.md@192:``` php
docs/content_management/collaborative_editing/collaborative_editing_api.md@193:[[= include_file('code_samples/collaboration/src/Command/ManageSessionsCommand.php') =]]
docs/content_management/collaborative_editing/collaborative_editing_api.md@194:```

001⫶<?php
002⫶
003⫶/**
004⫶ * @copyright Copyright (C) Ibexa AS. All rights reserved.
005⫶ * @license For full copyright and license information view LICENSE file distributed with this source code.
006⫶ */
007⫶declare(strict_types=1);
008⫶
009⫶namespace App\Command;
010⫶
011⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationCreateStruct;
012⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationQuery;
013⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationStatus;
014⫶use Ibexa\Contracts\Collaboration\Invitation\InvitationUpdateStruct;
015⫶use Ibexa\Contracts\Collaboration\Invitation\Query\Criterion\Session;
016⫶use Ibexa\Contracts\Collaboration\InvitationServiceInterface;
017⫶use Ibexa\Contracts\Collaboration\Participant\ExternalParticipantCreateStruct;
018⫶use Ibexa\Contracts\Collaboration\Participant\InternalParticipantCreateStruct;
019⫶use Ibexa\Contracts\Collaboration\Participant\InternalParticipantUpdateStruct;
020⫶use Ibexa\Contracts\Collaboration\Session\Query\Criterion\Token;
021⫶use Ibexa\Contracts\Collaboration\Session\SessionQuery;
022⫶use Ibexa\Contracts\Collaboration\SessionServiceInterface;
023⫶use Ibexa\Contracts\Core\Repository\ContentService;
024⫶use Ibexa\Contracts\Core\Repository\PermissionResolver;
025⫶use Ibexa\Contracts\Core\Repository\UserService;
026⫶use Ibexa\Contracts\Share\Collaboration\ContentSessionCreateStruct;
027⫶use Ibexa\Contracts\Share\Collaboration\ContentSessionScope;
028⫶use Ibexa\Contracts\Share\Collaboration\ContentSessionUpdateStruct;
029⫶use Symfony\Component\Console\Command\Command;
030⫶use Symfony\Component\Console\Input\InputInterface;
031⫶use Symfony\Component\Console\Output\OutputInterface;
032⫶
033⫶final class ManageSessionsCommand extends Command
034⫶{
035⫶ protected static $defaultName = 'app:manage-sessions';
036⫶
037⫶ private InvitationServiceInterface $invitationService;
038⫶
039⫶ private SessionServiceInterface $sessionService;
040⫶
041⫶ private ContentService $contentService;
042⫶
043⫶ private UserService $userService;
044⫶
045⫶ private PermissionResolver $permissionResolver;
046⫶
047⫶ public function __construct(
048⫶ InvitationServiceInterface $invitationService,
049⫶ SessionServiceInterface $sessionService,
050⫶ ContentService $contentService,
051⫶ UserService $userService,
052⫶ PermissionResolver $permissionResolver
053⫶ ) {
054⫶ parent::__construct(self::$defaultName);
055⫶
056⫶ $this->invitationService = $invitationService;
057⫶ $this->sessionService = $sessionService;
058⫶ $this->contentService = $contentService;
059⫶ $this->userService = $userService;
060⫶ $this->permissionResolver = $permissionResolver;
061⫶ }
062⫶
063⫶ public function execute(InputInterface $input, OutputInterface $output): int
064⫶ {
065⫶ $this->permissionResolver->setCurrentUserReference(
066⫶ $this->userService->loadUserByLogin('admin')
067⫶ );
068⫶
069⫶ // Create a sharing session for Content
070⫶ $versionInfo = $this->contentService->loadContent(52)->getVersionInfo();
071⫶ $createStruct = new ContentSessionCreateStruct(
072⫶ $versionInfo,
073⫶ $versionInfo->getInitialLanguage()
074⫶ );
075⫶ $createStruct->setHasPublicLink(false);
076⫶
077⫶ $token = 'my-secret-token-12345';
078⫶ $createStruct->setToken($token);
079⫶
080⫶ $sessionId = $this->sessionService->createSession($createStruct)->getId();
081⫶
082⫶ // Get a session by ID or token
083⫶ $session = $this->sessionService->getSession($sessionId);
084⫶ $session = $this->sessionService->getSessionByToken($token);
085⫶
086⫶ // Find sessions
087⫶ $sessionQuery = new SessionQuery(new Token($token));
088⫶ $session = $this->sessionService->findSessions($sessionQuery)->getFirst();
089⫶
090⫶ // Update a session
091⫶ $updateStruct = new ContentSessionUpdateStruct();
092⫶ $updateStruct->setHasPublicLink(true);
093⫶
094⫶ $this->sessionService->updateSession($session, $updateStruct);
095⫶
096⫶ // Deactivate a session
097⫶ $updateStruct = new ContentSessionUpdateStruct();
098⫶ $updateStruct->setIsActive(false);
099⫶
100⫶ $this->sessionService->updateSession($session, $updateStruct);
101⫶
102⫶ // Manage participants
103⫶ $user = $this->userService->loadUserByLogin('another_user');
104⫶ $internalParticipantCreateStruct = new InternalParticipantCreateStruct(
105⫶ $user,
106⫶ ContentSessionScope::VIEW
107⫶ );
108⫶ $externalParticipantCreateStruct = new ExternalParticipantCreateStruct(
109⫶ '[email protected]',
110⫶ ContentSessionScope::VIEW,
111⫶ 'personal-secret-token-12345'
112⫶ );
113⫶
114⫶ $internalParticipant = $this->sessionService->addParticipant($session, $internalParticipantCreateStruct);
115⫶ $externalParticipant = $this->sessionService->addParticipant($session, $externalParticipantCreateStruct);
116⫶
117⫶ // Get and update participants
118⫶ $participant = $this->sessionService
119⫶ ->getSession($session->getId())
120⫶ ->getParticipants()
121⫶ ->getByEmail($user->email);
122⫶
123⫶ $internalParticipantUpdateStruct = new InternalParticipantUpdateStruct(ContentSessionScope::EDIT);
124⫶ $this->sessionService->updateParticipant($session, $participant, $internalParticipantUpdateStruct);
125⫶
126⫶ // Remove participant
127⫶ $this->sessionService->removeParticipant($session, $externalParticipant);
128⫶
129⫶ // Check ownerships. If no user is provided, current user is used.
130⫶ $this->sessionService->isSessionOwner(
131⫶ $session,
132⫶ $this->userService->loadUserByLogin('another_user')
133⫶ );
134⫶
135⫶ // Check participation
136⫶ $this->sessionService->isSessionParticipant(
137⫶ $session,
138⫶ $this->permissionResolver->getCurrentUserReference()
139⫶ );
140⫶
141⫶ // Manage invitations
142⫶ $invitationQuery = new InvitationQuery(new Session($session));
143⫶ $invitations = $this->invitationService->findInvitations($invitationQuery)->getInvitations();
144⫶
145⫶ foreach ($invitations as $invitation) {
146⫶ $output->writeln('Invitation ID: ' . $invitation->getId() . ' Status: ' . $invitation->getStatus());
147⫶ }
148⫶
149⫶ $invitation = $this->invitationService->getInvitationByParticipant($participant);
150⫶
151⫶ // Create invitation - use when auto-inviting participants is not enabled
152⫶ $invitationCreateStruct = new InvitationCreateStruct(
153⫶ $session,
154⫶ $internalParticipant
155⫶ );
156⫶
157⫶ $this->invitationService->createInvitation($invitationCreateStruct);
158⫶
159⫶ // Update invitation
160⫶ $invitationUpdateStruct = new InvitationUpdateStruct();
161⫶ $invitationUpdateStruct->setStatus(InvitationStatus::STATUS_REJECTED);
162⫶
163⫶ $this->invitationService->updateInvitation($invitation, $invitationUpdateStruct);
164⫶
165⫶ // Delete invitation
166⫶ $invitation = $this->invitationService->getInvitation(2);
167⫶ $this->invitationService->deleteInvitation($invitation);
168⫶
169⫶ // Delete a session
170⫶ $this->sessionService->deleteSession($session);
171⫶
172⫶ return Command::SUCCESS;
173⫶ }
174⫶}

Download colorized diff

Comment on lines +130 to +154
You can select the property that you can read from an invitation:

- Invitation ID:

``` php
$invitation->getId();
```

- Session ID:

``` php
$invitation->getSession()->getId();
```

- Participant ID:

``` php
$invitation->getParticipant()->getId();
```

- Invitation status:

``` php
$invitation->getStatus();
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can select the property that you can read from an invitation:
- Invitation ID:
``` php
$invitation->getId();
```
- Session ID:
``` php
$invitation->getSession()->getId();
```
- Participant ID:
``` php
$invitation->getParticipant()->getId();
```
- Invitation status:
``` php
$invitation->getStatus();
```

This granularity probably is not relevant. It was skipped for Session object.

Comment on lines +86 to +142
### Add tables to the database

Add the tables to the database:
Create the `ibexa_share.sql` file that contains the following code:

=== "MySQL"

``` sql
[[= include_file('code_samples/collaboration/config/mysql/ibexa_share.sql', 0, None, ' ') =]]
```

=== "PostgreSQL"

``` sql
[[= include_file('code_samples/collaboration/config/postgresql/ibexa_share.sql', 0, None, ' ') =]]
```

Then, run the following command, where `<database_name>` is the same name that you defined when you [installed](install_ibexa_dxp.md#change-installation-parameters) [[= product_name =]]:

=== “MySQL”

```bash
mysql -u <username> -p <password> <database_name> < ibexa_share.sql
```

=== “PostgreSQL”

```bash
psql <database_name> < ibexa_share.sql
```

This command modifies the existing database schema by adding database configuration required for using Collaborative editing.

### Modify the bundles file

Then, if not using Symfony Flex, add the following code to the `config/bundles.php` file:

``` php
<?php

return [
// A lot of bundles…
Ibexa\Bundle\Collaboration\IbexaCollaborationBundle::class => ['all' => true],
Ibexa\Bundle\Share\IbexaShareBundle::class => ['all' => true],
Ibexa\Bundle\FieldTypeRichTextRTE\IbexaFieldTypeRichTextRTEBundle::class => ['all' => true],
Ibexa\Bundle\CkeditorPremium\IbexaCkeditorPremiumBundle::class => [‘all’ => true],
];
```

### Add migration file and execute migration

Last step is to add migration file and execute migration with the following commands:

``` bash
php bin/console ibexa:migrations:import vendor/ibexa/collaboration/src/bundle/Resources/migrations/2025_08_26_10_14_shareable_user.yaml
php bin/console ibexa:migrations:migrate --file=2025_08_26_10_14_shareable_user.yaml
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO this should be moved up, because it's not part of configuration. It's related to installation.

Comment on lines +144 to +172
### Security configuration

After an installation process is finished, go to `config/packages/security.yaml` and make following changes:

- uncomment following lines with `shared` user provider under the `providers` key:

```yaml
```suggestion
security:
providers:
# ...
shared:
id: Ibexa\Collaboration\Security\User\ShareableLinkUserProvider
```

- uncomment following lines under the `ibexa_shareable_link` key:

```yaml
security:
# ...
ibexa_shareable_link:
request_matcher: Ibexa\Collaboration\Security\RequestMatcher\ShareableLinkRequestMatcher
pattern: ^/
provider: shared
stateless: true
user_checker: Ibexa\Core\MVC\Symfony\Security\UserChecker
guard:
authenticator: Ibexa\Collaboration\Security\Authenticator\ShareableLinkAuthenticator
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configuration section could be start from this security configuration as it is very important

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants