Compare commits

..

10 Commits

Author SHA1 Message Date
5463146925 Eslint fix 2025-12-01 19:02:03 +01:00
9375580907 Do not suggest a user that is no longer active within the activity form 2025-12-01 18:59:55 +01:00
0caad2b7cd Update chill bundles to v4.8.2 2025-11-26 14:17:13 +01:00
7a80307de9 Fix template parameter for update_multiple route on event participations 2025-11-26 14:15:27 +01:00
0d32810d0d Change position and color of confirm parcours button 2025-11-24 15:13:16 +01:00
b221ad1621 Merge branch '466-set-main-user-activity' into 'master'
Associate activity's creator as a participant by default, and retro-actively append the creator to each activity

Closes #466

See merge request Chill-Projet/chill-bundles!924
2025-11-24 09:23:12 +00:00
a96e9d5377 Associate activity's creator as a participant by default, and retro-actively append the creator to each activity 2025-11-24 09:23:12 +00:00
54b73128c3 Merge branch '470-alphabetical-order-admin' into 'master'
Alphabetically order userJobs and mainLocations within user creation form

Closes #470

See merge request Chill-Projet/chill-bundles!926
2025-11-24 09:18:03 +00:00
5c0cb01fdc Alphabetically order userJobs and mainLocations within user creation form 2025-11-24 09:18:03 +00:00
26d9b55c6d Update to v4.8.1 2025-11-20 16:19:52 +01:00
39 changed files with 353 additions and 1169 deletions

View File

@@ -1,6 +0,0 @@
kind: Fixed
body: Insert name of file as the document title when uploading
time: 2025-11-19T13:33:24.778116633+01:00
custom:
Issue: ""
SchemaChange: No schema change

View File

@@ -1,6 +0,0 @@
kind: Fixed
body: Add missing path paramater 'id' for editing multiple participations
time: 2025-11-19T13:48:02.078949572+01:00
custom:
Issue: ""
SchemaChange: No schema change

View File

@@ -1,7 +0,0 @@
kind: Fixed
body: |
Hide the display of inactive user groups in the api
time: 2025-11-19T16:12:33.803084517+01:00
custom:
Issue: "471"
SchemaChange: No schema change

View File

@@ -0,0 +1,6 @@
kind: Fixed
body: Do not suggest a user that is no longer active in the activity form.
time: 2025-12-01T18:58:59.410998029+01:00
custom:
Issue: "475"
SchemaChange: No schema change

6
.changes/v4.8.1.md Normal file
View File

@@ -0,0 +1,6 @@
## v4.8.1 - 2025-11-20
### Fixed
* Insert name of file as the document title when uploading
* Add missing path paramater 'id' for editing multiple participations
* ([#471](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/471)) Hide the display of inactive user groups in the api

10
.changes/v4.8.2.md Normal file
View File

@@ -0,0 +1,10 @@
## v4.8.2 - 2025-11-26
### Fixed
* ([#466](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/466)) Associate activity's creator as a participant by default, and retro-actively append the creator to each activity
**Schema Change**: Add columns or tables
* Fix template parameter for update_multiple route on event participations
### UX
* ([#470](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/470)) Alphabetically order userJobs and mainLocations within user creation form
* ([#437](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/437)) Change position and color of confirm parcours button

View File

@@ -14,7 +14,6 @@ $finder = PhpCsFixer\Finder::create();
$finder
->in(__DIR__.'/src')
->in(__DIR__.'/utils')
->in(__DIR__.'/packages')
->append([__FILE__])
->exclude(['docs/', 'tests/app'])
->notPath('tests/app')

View File

@@ -6,6 +6,22 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
and is generated by [Changie](https://github.com/miniscruff/changie).
## v4.8.2 - 2025-11-26
### Fixed
* ([#466](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/466)) Associate activity's creator as a participant by default, and retro-actively append the creator to each activity
**Schema Change**: Add columns or tables
* Fix template parameter for update_multiple route on event participations
### UX
* ([#470](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/470)) Alphabetically order userJobs and mainLocations within user creation form
* ([#437](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/437)) Change position and color of confirm parcours button
## v4.8.1 - 2025-11-20
### Fixed
* Insert name of file as the document title when uploading
* Add missing path paramater 'id' for editing multiple participations
* ([#471](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/471)) Hide the display of inactive user groups in the api
## v4.8.0 - 2025-11-17
### Feature
* ([#461](https://gitlab.com/Chill-Projet/chill-bundles/-/issues/461)) Make a calendar item on the 'mes rendez-vous' page clickable. Clicking will navigate to the edit page of the calendar item.

View File

@@ -7,13 +7,6 @@
"chill",
"social worker"
],
"repositories": [{
"type": "path",
"url": "./packages/ChillZimbraBundle",
"options": {
"symlink": true
}
}],
"require": {
"php": "^8.2",
"ext-dom": "*",
@@ -21,7 +14,6 @@
"ext-openssl": "*",
"ext-redis": "*",
"ext-zlib": "*",
"chill-project/chill-zimbra-bundle": "@dev",
"champs-libres/wopi-bundle": "dev-symfony-v5@dev",
"champs-libres/wopi-lib": "dev-master@dev",
"doctrine/data-fixtures": "^1.8",

View File

@@ -37,5 +37,4 @@ return [
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
Symfony\UX\Translator\UxTranslatorBundle::class => ['all' => true],
loophp\PsrHttpMessageBridgeBundle\PsrHttpMessageBridgeBundle::class => ['all' => true],
Chill\ZimbraBundle\ChillZimbraBundle::class => ['all' => true],
];

View File

@@ -11,7 +11,6 @@
"@hotwired/stimulus": "^3.0.0",
"@luminateone/eslint-baseline": "^1.0.9",
"@symfony/stimulus-bridge": "^3.2.0",
"@symfony/ux-translator": "file:vendor/symfony/ux-translator/assets",
"@symfony/webpack-encore": "^4.1.0",
"@tsconfig/node20": "^20.1.4",
"@types/dompurify": "^3.0.5",

View File

@@ -1,22 +0,0 @@
{
"name": "chill-project/chill-zimbra-bundle",
"description": "Provide connection between Zimbra agenda and Chill",
"minimum-stability": "stable",
"license": "AGPL-3.0",
"type": "library",
"keywords": [
"chill",
"social worker"
],
"require": {
"chill-project/chill-bundles": "dev-master@dev",
"zimbra-api/soap-api": "^3.2.2",
"psr/http-client": "^1.0",
"nyholm/psr7": "^1.0"
},
"autoload": {
"psr-4": {
"Chill\\ZimbraBundle\\": "src/"
}
}
}

View File

@@ -1,95 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle\Calendar\Connector;
use Chill\CalendarBundle\Entity\Calendar;
use Chill\CalendarBundle\Entity\CalendarRange;
use Chill\CalendarBundle\Entity\Invite;
use Chill\CalendarBundle\RemoteCalendar\Connector\RemoteCalendarConnectorInterface;
use Chill\MainBundle\Entity\User;
use Chill\ZimbraBundle\Calendar\Connector\ZimbraConnector\CreateEvent;
use Chill\ZimbraBundle\Calendar\Connector\ZimbraConnector\UpdateEvent;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Response;
final readonly class ZimbraConnector implements RemoteCalendarConnectorInterface
{
private const LOG_PREFIX = '[ZimbraConnector] ';
public function __construct(
private CreateEvent $createEvent,
private UpdateEvent $updateEvent,
private LoggerInterface $logger,
) {}
public function countEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate): int
{
return 0;
}
public function getMakeReadyResponse(string $returnPath): Response
{
throw new \BadMethodCallException('Zimbra connector is always ready');
}
public function isReady(): bool
{
return true;
}
public function listEventsForUser(User $user, \DateTimeImmutable $startDate, \DateTimeImmutable $endDate, ?int $offset = 0, ?int $limit = 50): array
{
return [];
}
public function removeCalendar(string $remoteId, array $remoteAttributes, User $user, ?CalendarRange $associatedCalendarRange = null): void
{
// TODO: Implement removeCalendar() method.
}
public function removeCalendarRange(string $remoteId, array $remoteAttributes, User $user): void
{
// TODO: Implement removeCalendarRange() method.
}
public function syncCalendar(Calendar $calendar, string $action, ?CalendarRange $previousCalendarRange, ?User $previousMainUser, ?array $oldInvites, ?array $newInvites): void
{
if (!$calendar->hasRemoteId()) {
$calItemId = ($this->createEvent)($calendar);
$this->logger->info(self::LOG_PREFIX.'Calendar synced with Zimbra', ['calendar_id' => $calendar->getId(), 'action' => $action, 'calItemId' => $calItemId]);
$calendar->setRemoteId($calItemId);
return;
}
throw new \RuntimeException('Update of calendar: to be implemented');
}
public function syncCalendarRange(CalendarRange $calendarRange): void
{
if (!$calendarRange->hasRemoteId()) {
$calItemId = ($this->createEvent)($calendarRange);
$this->logger->info(self::LOG_PREFIX.'Calendar range created with Zimbra', ['calendar_range_id' => $calendarRange->getId(), 'calItemId' => $calItemId]);
$calendarRange->setRemoteId($calItemId);
} else {
($this->updateEvent)($calendarRange);
$this->logger->info(self::LOG_PREFIX.'Calendar range updated against zimbra', ['old_cal_remote_id' => $calendarRange->getRemoteId(), 'calendar_range_id' => $calendarRange->getId()]);
}
}
public function syncInvite(Invite $invite): void
{
// TODO: Implement syncInvite() method.
}
}

View File

@@ -1,97 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle\Calendar\Connector\ZimbraConnector;
use Chill\CalendarBundle\Entity\Calendar;
use Chill\CalendarBundle\Entity\CalendarRange;
use Chill\ZimbraBundle\Exception\CalendarWithoutMainUserException;
use Symfony\Contracts\Translation\TranslatorInterface;
use Zimbra\Mail\Struct\InvitationInfo;
use Zimbra\Mail\Struct\InviteComponent;
use Zimbra\Mail\Struct\MimePartInfo;
use Zimbra\Mail\Struct\Msg;
/**
* Creates a new calendar event in Zimbra.
*
* This class handles the creation of new calendar events in the Zimbra system.
* It uses the Zimbra SOAP API to create events and returns a serialized ID that
* can be used as remoteId for Calendar and CalendarRange.
*/
final readonly class CreateEvent
{
public function __construct(
private SoapClientBuilder $soapClientBuilder,
private CreateZimbraComponent $createEvent,
private TranslatorInterface $translator,
private ZimbraIdSerializer $zimbraIdSerializer,
) {}
/**
* Creates a new calendar event in Zimbra.
*
* @param Calendar|CalendarRange $calendar The calendar event to create
*
* @return string The serialized Zimbra ID for the created event
*
* @throws CalendarWithoutMainUserException When the calendar has no associated user email
*/
public function __invoke(Calendar|CalendarRange $calendar): string
{
if ($calendar instanceof Calendar) {
$organizerEmail = $calendar->getMainUser()->getEmail();
$organizerLang = $calendar->getMainUser()->getLocale();
} else {
$organizerEmail = $calendar->getUser()->getEmail();
$organizerLang = $calendar->getUser()->getLocale();
}
if (null === $organizerEmail) {
throw new CalendarWithoutMainUserException();
}
$api = $this->soapClientBuilder->getApiForAccount($organizerEmail);
$comp = $this->createEvent->createZimbraInviteComponentFromCalendar($calendar);
$inv = new InvitationInfo();
$inv->setInviteComponent($comp);
$mp = new MimePartInfo();
$mp->addMimePart(new MimePartInfo('text/plain', $this->translator->trans('zimbra.event_created_by_chill', locale: $organizerLang)));
$msg = new Msg();
$msg->setSubject($this->translator->trans('zimbra.event_created_trough_soap', locale: $organizerLang))
->setFolderId('10')
->setInvite($inv)
->setMimePart($mp);
$response = $api->createAppointment($msg, echo: true);
$echo = $response->getEcho();
$invite = $echo->getInvite();
$MPInviteInfo = $invite->getInvite();
/** @var InviteComponent $firstInvite */
$firstInvite = $MPInviteInfo->getInviteComponents()[0];
$id = $this->zimbraIdSerializer->serializeId(
$response->getCalItemId(),
$response->getCalInvId(),
$firstInvite->getUid(),
);
var_dump($response);
var_dump($id);
return $id;
}
}

View File

@@ -1,102 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle\Calendar\Connector\ZimbraConnector;
use Chill\CalendarBundle\Entity\Calendar;
use Chill\CalendarBundle\Entity\CalendarRange;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Templating\Entity\AddressRender;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use Zimbra\Common\Enum\FreeBusyStatus;
use Zimbra\Common\Enum\InviteClass;
use Zimbra\Common\Enum\InviteStatus;
use Zimbra\Common\Enum\Transparency;
use Zimbra\Mail\Struct\InviteComponent;
/**
* Class responsible for creating Zimbra invite components based on calendar data.
*/
final readonly class CreateZimbraComponent
{
public function __construct(
private PersonRenderInterface $personRender,
private AddressRender $addressRender,
private DateConverter $dateConverter,
private TranslatorInterface $translator,
) {}
/**
* Creates a Zimbra invite component from the provided calendar object.
*
* The method initializes a new InviteComponent object, sets its properties
* including name, free/busy status, status, classification, transparency,
* all-day and draft status, as well as start and end times. If the calendar
* contains a location, it also sets the location for the invite component.
*
* @param Calendar|CalendarRange $calendar a calendar object containing event data
*
* @return InviteComponent the configured Zimbra invite component
*/
public function createZimbraInviteComponentFromCalendar(Calendar|CalendarRange $calendar): InviteComponent
{
if ($calendar instanceof Calendar) {
$subject = '[Chill] '.
implode(
', ',
$calendar->getPersons()->map(fn (Person $p) => $this->personRender->renderString($p, []))->toArray()
);
} else {
$subject = $this->translator->trans('remote_calendar.calendar_range_title');
}
$comp = new InviteComponent();
$comp->setName($subject)
->setFreeBusy(FreeBusyStatus::BUSY)
->setStatus(InviteStatus::CONFIRMED)
->setCalClass(InviteClass::PUB)
->setTransparency(Transparency::OPAQUE)
->setIsAllDay(false)
->setIsDraft(false)
->setDtStart($this->dateConverter->phpToZimbraDateTime($calendar->getStartDate()))
->setDtEnd($this->dateConverter->phpToZimbraDateTime($calendar->getEndDate()));
if ($calendar->hasLocation()) {
$comp
->setLocation($this->createLocationString($calendar->getLocation()));
}
return $comp;
}
private function createLocationString(Location $location): string
{
$str = '';
if ('' !== ((string) $location->getName())) {
$str .= $location->getName();
$str .= ', ';
}
if ($location->hasAddress()) {
if ('' !== $str) {
$str .= ', ';
}
$str .= $this->addressRender->renderString($location->getAddress(), []);
}
return $str;
}
}

View File

@@ -1,37 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle\Calendar\Connector\ZimbraConnector;
use Zimbra\Mail\Struct\DtTimeInfo;
/**
* Class DateConverter.
*
* Provides methods for converting PHP DateTime objects
* into specific date-time formats or representations.
*/
final readonly class DateConverter
{
public const FORMAT_DATE_TIME = 'Ymd\THis';
/**
* Converts a PHP DateTimeInterface object into a Zimbra-specific DtTimeInfo object.
*
* @param \DateTimeInterface $date the date to be converted
*
* @return DtTimeInfo the converted DtTimeInfo object
*/
public function phpToZimbraDateTime(\DateTimeInterface $date): DtTimeInfo
{
return new DtTimeInfo($date->format(self::FORMAT_DATE_TIME), $date->getTimezone()->getName());
}
}

View File

@@ -1,78 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle\Calendar\Connector\ZimbraConnector;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\HttpClient\Psr18Client;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Zimbra\Common\Enum\AccountBy;
use Zimbra\Common\Soap\ClientFactory;
use Zimbra\Common\Struct\Header\AccountInfo;
use Zimbra\Mail\MailApi;
final readonly class SoapClientBuilder
{
private string $username;
private string $password;
private string $url;
public function __construct(private ParameterBagInterface $parameterBag, private HttpClientInterface $client)
{
$dsn = $this->parameterBag->get('chill_calendar.remote_calendar_dsn');
$url = parse_url($dsn);
$this->username = urldecode($url['user']);
$this->password = urldecode($url['pass']);
if ('zimbra+http' === $url['scheme']) {
$scheme = 'http://';
$port = $url['port'] ?? 80;
} elseif ('zimbra+https' === $url['scheme']) {
$scheme = 'https://';
$port = $url['port'] ?? 443;
} else {
throw new \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('Unsupported remote calendar scheme: '.$url['scheme']);
}
$this->url = $scheme.$url['host'].':'.$port;
}
private function buildApi(): MailApi
{
$baseClient = $this->client->withOptions([
'base_uri' => $location = $this->url.'/service/soap',
'verify_host' => false,
'verify_peer' => false,
]);
$psr18Client = new Psr18Client($baseClient);
$api = new MailApi();
$client = ClientFactory::create($location, $psr18Client);
$api->setClient($client);
return $api;
}
public function getApiForAccount(string $accountName): MailApi
{
$api = $this->buildApi();
$response = $api->authByAccountName($this->username, $this->password);
$token = $response->getAuthToken();
$apiBy = $this->buildApi();
$apiBy->setAuthToken($token);
$apiBy->setTargetAccount(new AccountInfo(AccountBy::NAME, $accountName));
return $apiBy;
}
}

View File

@@ -1,93 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle\Calendar\Connector\ZimbraConnector;
use Chill\CalendarBundle\Entity\Calendar;
use Chill\CalendarBundle\Entity\CalendarRange;
use Chill\ZimbraBundle\Exception\CalendarWithoutMainUserException;
use Symfony\Contracts\Translation\TranslatorInterface;
use Zimbra\Mail\Struct\InvitationInfo;
use Zimbra\Mail\Struct\MimePartInfo;
use Zimbra\Mail\Struct\Msg;
/**
* Updates an existing calendar event in Zimbra.
*
* This class handles the modification of existing calendar events in the Zimbra system.
* It uses the Zimbra SOAP API to update event details while maintaining the original
* event's metadata like IDs and sequences.
*/
final readonly class UpdateEvent
{
public function __construct(
private SoapClientBuilder $soapClientBuilder,
private CreateZimbraComponent $createZimbraComponent,
private TranslatorInterface $translator,
private ZimbraIdSerializer $zimbraIdSerializer,
) {}
/**
* Updates an existing calendar event in Zimbra.
*
* @param Calendar|CalendarRange $calendar The calendar event to update
*
* @throws CalendarWithoutMainUserException When the calendar has no associated user email
*/
public function __invoke(Calendar|CalendarRange $calendar): void
{
if ($calendar instanceof Calendar) {
$organizerEmail = $calendar->getMainUser()->getEmail();
$organizerLang = $calendar->getMainUser()->getLocale();
} else {
$organizerEmail = $calendar->getUser()->getEmail();
$organizerLang = $calendar->getUser()->getLocale();
}
if (null === $organizerEmail) {
throw new CalendarWithoutMainUserException();
}
$api = $this->soapClientBuilder->getApiForAccount($organizerEmail);
['calItemId' => $calItemId, 'calInvId' => $calInvId, 'inviteComponentCommonUid' => $inviteComponentCommonUid]
= $this->zimbraIdSerializer->deSerializeId($calendar->getRemoteId());
$existing = $api->getAppointment(sync: true, includeContent: true, includeInvites: true, id: $calItemId);
$appt = $existing->getApptItem();
$comp = $this->createZimbraComponent->createZimbraInviteComponentFromCalendar($calendar);
$comp->setUid($inviteComponentCommonUid);
$inv = new InvitationInfo();
$inv->setInviteComponent($comp)
->setUid($calInvId);
$mp = new MimePartInfo();
$mp->addMimePart(new MimePartInfo('text/plain', $this->translator->trans('zimbra.event_created_by_chill', locale: $organizerLang)));
$msg = new Msg();
$msg->setSubject($this->translator->trans('zimbra.event_created_trough_soap', locale: $organizerLang))
->setFolderId('10')
->setInvite($inv)
->setMimePart($mp)
;
$response = $api->modifyAppointment(
id: $calInvId,
componentNum: 0,
modifiedSequence: $appt->getModifiedSequence(),
revision: $appt->getRevision(),
msg: $msg,
echo: true
);
}
}

View File

@@ -1,67 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle\Calendar\Connector\ZimbraConnector;
use Chill\ZimbraBundle\Exception\ZimbraCalendarIdNotDeserializedException;
/**
* Serializes and deserializes Zimbra calendar event IDs.
*
* This class handles the conversion between Zimbra's individual ID components
* and a single serialized string format, allowing for consistent storage and retrieval
* of Zimbra calendar event identifiers.
*/
final readonly class ZimbraIdSerializer
{
/**
* Serializes individual Zimbra calendar ID components into a single string.
*
* @param string $calItemId The calendar item ID from Zimbra
* @param string $calInvId The calendar invitation ID from Zimbra
* @param string $inviteComponentCommonUid The common UID for the invite component
*
* @return string The serialized ID in format "calItemId|calInvId|inviteComponentCommonUid|v0"
*/
public function serializeId(string $calItemId, string $calInvId, string $inviteComponentCommonUid): string
{
return sprintf(
'%s|%s|%s|v0',
$calItemId,
$calInvId,
$inviteComponentCommonUid,
);
}
/**
* Deserializes a Zimbra calendar ID string into its component parts.
*
* @param string $remoteId The serialized ID, as stored in the remoteId's Calendar or CalendarRange
*
* @return array{calItemId: string, calInvId: string, inviteComponentCommonUid: string} Associative array containing the ID components
*
* @throws ZimbraCalendarIdNotDeserializedException If the remote ID format is invalid or incompatible
*/
public function deSerializeId(string $remoteId): array
{
if (!str_ends_with($remoteId, 'v0')) {
throw new ZimbraCalendarIdNotDeserializedException();
}
$exploded = explode('|', $remoteId);
return [
'calItemId' => $exploded[0],
'calInvId' => $exploded[1],
'inviteComponentCommonUid' => $exploded[2],
];
}
}

View File

@@ -1,16 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class ChillZimbraBundle extends Bundle {}

View File

@@ -1,178 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpClient\Psr18Client;
use Symfony\Contracts\HttpClient\HttpClientInterface;
use Zimbra\Common\Enum\AccountBy;
use Zimbra\Common\Enum\FreeBusyStatus;
use Zimbra\Common\Enum\InviteClass;
use Zimbra\Common\Enum\InviteStatus;
use Zimbra\Common\Enum\ItemType;
use Zimbra\Common\Enum\Transparency;
use Zimbra\Common\Soap\ClientFactory;
use Zimbra\Common\Struct\Header\AccountInfo;
use Zimbra\Mail\MailApi;
use Zimbra\Mail\Struct\DtTimeInfo;
use Zimbra\Mail\Struct\Folder;
use Zimbra\Mail\Struct\GetFolderSpec;
use Zimbra\Mail\Struct\InvitationInfo;
use Zimbra\Mail\Struct\InviteComponent;
use Zimbra\Mail\Struct\MimePartInfo;
use Zimbra\Mail\Struct\Msg;
class TestCommand extends Command
{
public function __construct(private HttpClientInterface $client)
{
parent::__construct();
}
public function getName()
{
return 'chill:zimbra:test';
}
public function execute(InputInterface $input, OutputInterface $output)
{
$this->getAppointments($this->createApiForJulien());
// $this->createAppointment($this->createApiForJulien());
// $api = $this->createApiForJulienDelegated();
// $this->createAppointment($api);
return Command::SUCCESS;
}
public function createApiForJulienDelegated(): MailApi
{
$baseClient = $this->client->withOptions([
'base_uri' => $location = 'https://zimbra.cldev.ours/service/soap',
'verify_host' => false,
'verify_peer' => false,
]);
$psr18Client = new Psr18Client($baseClient);
$api = new MailApi();
$client = ClientFactory::create($location, $psr18Client);
$api->setClient($client);
$response = $api->authByAccountName('chill@zimbra.cldev.ours', 'password');
$token = $response->getAuthToken();
var_dump($token);
$apiBy = new MailApi();
$apiBy->setClient($client);
$apiBy->setAuthToken($token);
$apiBy->setTargetAccount(new AccountInfo(AccountBy::NAME, 'julien@zimbra.cldev.ours'));
return $apiBy;
}
private function createApiForJulien(): MailApi
{
$baseClient = $this->client->withOptions([
'base_uri' => $location = 'https://zimbra.cldev.ours/service/soap',
'verify_host' => false,
'verify_peer' => false,
]);
$psr18Client = new Psr18Client($baseClient);
$api = new MailApi();
$client = ClientFactory::create($location, $psr18Client);
$api->setClient($client);
$api->authByAccountName('julien@zimbra.cldev.ours', 'Password;1234');
return $api;
}
private function updateAppointment(MailApi $api): void
{
$appointment = $api->getAppointment(id: '69ec3b5e-9f83-4467-a151-a99bc64cfb38:376');
}
private function createAppointment(MailApi $api): void
{
$date = new \DateTimeImmutable('2025-12-03T18:00:00Z');
$comp = new InviteComponent();
$comp->setName('Test Appointment by chill')
->setLocation('Test Location')
->setFreeBusy(FreeBusyStatus::BUSY)
->setStatus(InviteStatus::CONFIRMED)
->setCalClass(InviteClass::PUB)
->setTransparency(Transparency::OPAQUE)
->setIsAllDay(false)
->setIsDraft(false)
->setDtStart(new DtTimeInfo($date->format('Ymd\THis'), 'Europe/Brussels'))
->setDtEnd(new DtTimeInfo($date->add(new \DateInterval('PT1H'))->format('Ymd\THis'), 'Europe/Brussels'));
$inv = new InvitationInfo();
$inv->setInviteComponent($comp);
$mp = new MimePartInfo();
$mp->addMimePart(new MimePartInfo('text/plain', 'Appointment create via soap'));
$msg = new Msg();
$msg->setSubject('Réunion créée via soap')
->setFolderId('10')
->setInvite($inv)
->setMimePart($mp);
$response = $api->createAppointment($msg, echo: true);
var_dump($response->getEcho());
}
private function getAppointments(MailApi $api): void
{
// $folders = $api->getFolder(new GetFolderSpec(folderId: 10));
$foldersResponse = $api->getFolder(viewConstraint: ItemType::APPOINTMENT->value);
$calendarFolders = [];
foreach ($foldersResponse->getFolder()->getSubfolders() as $folder) {
if ($folder instanceof Folder) {
var_dump($folder->getView()?->value);
if ($folder->getView()?->value === ItemType::APPOINTMENT->value) {
var_dump('found a calendar');
$calendarFolders[] = $folder;
}
} else {
var_dump('not a calendar:'.$folder->getView());
}
}
$since = new \DateTimeImmutable('2025-11-28');
$until = new \DateTimeImmutable('2025-11-29');
$allAppointments = [];
foreach ($calendarFolders as $calendarFolder) {
$appointmentIdsInRange = $api
->getAppointmentIdsInRange($since->getTimestamp() * 1000, $until->getTimestamp() * 1000, $calendarFolder->getId())
->getAppointmentData()
;
$allAppointments = [...$allAppointments, ...$appointmentIdsInRange];
}
var_dump($allAppointments);
foreach ($allAppointments as $appointment) {
var_dump($appointment->getId());
$fetched = $api->getAppointment(id: $appointment->getId());
var_dump($fetched);
}
}
}

View File

@@ -1,26 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
class ChillZimbraExtension extends Extension
{
public function load(array $configs, ContainerBuilder $container)
{
$loader = new YamlFileLoader($container, new FileLocator(__DIR__.'/../config'));
$loader->load('services.yaml');
}
}

View File

@@ -1,14 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle\Exception;
class CalendarWithoutMainUserException extends \RuntimeException {}

View File

@@ -1,14 +0,0 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\ZimbraBundle\Exception;
class ZimbraCalendarIdNotDeserializedException extends \RuntimeException {}

View File

@@ -1,11 +0,0 @@
services:
_defaults:
autoconfigure: true
autowire: true
Chill\ZimbraBundle\Command\:
resource: '../Command'
tags: ['console.command']
Chill\ZimbraBundle\Calendar\:
resource: '../Calendar'

View File

@@ -1,3 +0,0 @@
zimbra:
event_created_by_chill: Événement créé par Chill
event_created_trough_soap: Événement créé via l'API SOAP

View File

@@ -3,7 +3,6 @@ parameters:
paths:
- src/
- utils/
- packages/
tmpDir: var/cache/phpstan
reportUnmatchedIgnoredErrors: false
excludePaths:

View File

@@ -382,6 +382,7 @@ final class ActivityController extends AbstractController
$entity = new Activity();
$entity->setUser($this->security->getUser());
$entity->addUser($this->security->getUser());
if ($person instanceof Person) {
$entity->setPerson($person);

View File

@@ -103,7 +103,7 @@ const store = createStore({
}
// console.log("suggested users", suggestedUsers);
return suggestedUsers;
return suggestedUsers.filter((u) => u.enabled === true);
},
suggestedResources(state) {
// const resources = state.activity.accompanyingPeriod.resources;

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Migration fixing the automatic association of users to activities (exchanges).
*
* Originally, the user who created an exchange was not automatically associated
* to it (the "TMS" column), which led to incomplete data and biased statistics.
*
* This migration:
* - retroactively associates the creator of each exchange to the corresponding
* activity;
* - flags these backfilled associations with a temporary column so it is clear
* they were added by this data correction and can be safely cleaned up later.
*/
final class Version20251118124241 extends AbstractMigration
{
public function getDescription(): string
{
return 'Insert the creator of activity into the activity_user table';
}
public function up(Schema $schema): void
{
$this->addSql('ALTER TABLE activity_user ADD COLUMN by_migration BOOL DEFAULT FALSE');
$this->addSql("COMMENT ON COLUMN activity_user.by_migration IS 'For backup purpose - can be safely deleted after a while. See migration \\Chill\\Migrations\\Activity\\Version20251118124241'");
$this->addSql('INSERT INTO activity_user (activity_id, user_id, by_migration)
SELECT id, user_id, true FROM activity
ON CONFLICT DO NOTHING');
}
public function down(Schema $schema): void
{
$this->addSql('ALTER TABLE activity_user DROP COLUMN by_migration');
}
}

View File

@@ -47,8 +47,6 @@ class ChillCalendarExtension extends Extension implements PrependExtensionInterf
} else {
$container->setParameter('chill_calendar.short_messages', null);
}
$container->setParameter('chill_calendar.remote_calendar_dsn', $config['remote_calendar_dsn']);
}
public function prepend(ContainerBuilder $container)

View File

@@ -32,10 +32,9 @@ class Configuration implements ConfigurationInterface
->canBeDisabled()
->children()->end()
->end() // end for short_messages
->scalarNode('remote_calendar_dsn')->defaultValue('null://null')->cannotBeEmpty()->end()
->arrayNode('remote_calendars_sync')->canBeEnabled()
->children()
->arrayNode('microsoft_graph')->canBeEnabled()->setDeprecated('chill-project/chill-bundles', '4.7.0', 'The child node %node% at path %path% is deprecated: use remote_calendar_dsn instead, with a "msgraph://default" value')
->arrayNode('microsoft_graph')->canBeEnabled()
->children()
->end() // end of machine_access_token
->end() // end of microsoft_graph children

View File

@@ -107,11 +107,6 @@ class CalendarRange implements TrackCreationInterface, TrackUpdateInterface
return $this;
}
public function hasLocation(): bool
{
return null !== $this->location;
}
public function setLocation(?Location $location): self
{
$this->location = $location;

View File

@@ -35,46 +35,25 @@ use TheNetworg\OAuth2\Client\Provider\Azure;
class RemoteCalendarCompilerPass implements CompilerPassInterface
{
private const ZIMBRA_CONNECTOR = 'Chill\ZimbraBundle\Calendar\Connector\ZimbraConnector';
private const MS_GRAPH_SERVICES_TO_REMOVE = [
MapAndSubscribeUserCalendarCommand::class,
AzureGrantAdminConsentAndAcquireToken::class,
RemoteCalendarConnectAzureController::class,
MachineTokenStorage::class,
MachineHttpClient::class,
MSGraphRemoteCalendarConnector::class,
MSUserAbsenceReaderInterface::class,
MSUserAbsenceSync::class,
];
public function process(ContainerBuilder $container)
{
$config = $container->getParameter('chill_calendar.remote_calendar_dsn');
if (true === $container->getParameter('chill_calendar')['remote_calendars_sync']['microsoft_graph']['enabled']) {
$dsn = 'msgraph://default';
} else {
$dsn = $config;
}
$config = $container->getParameter('chill_calendar');
$scheme = parse_url($dsn, PHP_URL_SCHEME);
if ('msgraph' === $scheme) {
if (true === $config['remote_calendars_sync']['microsoft_graph']['enabled']) {
$connector = MSGraphRemoteCalendarConnector::class;
$container->setAlias(HttpClientInterface::class.' $machineHttpClient', MachineHttpClient::class);
} elseif ('zimbra+http' === $scheme || 'zimbra+https' === $scheme) {
$connector = self::ZIMBRA_CONNECTOR;
foreach (self::MS_GRAPH_SERVICES_TO_REMOVE as $serviceId) {
$container->removeDefinition($serviceId);
}
} elseif ('null' === $scheme) {
$connector = NullRemoteCalendarConnector::class;
foreach (self::MS_GRAPH_SERVICES_TO_REMOVE as $serviceId) {
$container->removeDefinition($serviceId);
}
} else {
throw new \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('Unsupported remote calendar scheme: '.$scheme);
$connector = NullRemoteCalendarConnector::class;
// remove services which cannot be loaded
$container->removeDefinition(MapAndSubscribeUserCalendarCommand::class);
$container->removeDefinition(AzureGrantAdminConsentAndAcquireToken::class);
$container->removeDefinition(RemoteCalendarConnectAzureController::class);
$container->removeDefinition(MachineTokenStorage::class);
$container->removeDefinition(MachineHttpClient::class);
$container->removeDefinition(MSGraphRemoteCalendarConnector::class);
$container->removeDefinition(MSUserAbsenceReaderInterface::class);
$container->removeDefinition(MSUserAbsenceSync::class);
}
if (!$container->hasAlias(Azure::class) && $container->hasDefinition('knpu.oauth2.client.azure')) {
@@ -83,9 +62,7 @@ class RemoteCalendarCompilerPass implements CompilerPassInterface
foreach ([
NullRemoteCalendarConnector::class,
MSGraphRemoteCalendarConnector::class,
self::ZIMBRA_CONNECTOR,
] as $serviceId) {
MSGraphRemoteCalendarConnector::class, ] as $serviceId) {
if ($connector === $serviceId) {
$container->getDefinition($serviceId)
->setDecoratedService(RemoteCalendarConnectorInterface::class);

View File

@@ -486,7 +486,7 @@ final class ParticipationController extends AbstractController
return $this->redirectToRoute(
'chill_event__event_show',
['event_id' => $event->getId()]
['id' => $event->getId()]
);
}

View File

@@ -18,6 +18,7 @@ use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\ChillPhoneNumberType;
use Chill\MainBundle\Form\Type\PickCivilityType;
use Chill\MainBundle\Repository\UserJobRepository;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -36,7 +37,7 @@ use Symfony\Component\Validator\Constraints\Regex;
class UserType extends AbstractType
{
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag) {}
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper, protected ParameterBagInterface $parameterBag, private readonly UserJobRepository $userJobRepository) {}
public function buildForm(FormBuilderInterface $builder, array $options)
{
@@ -80,12 +81,7 @@ class UserType extends AbstractType
'placeholder' => 'choose a job',
'class' => UserJob::class,
'choice_label' => fn (UserJob $c) => $this->translatableStringHelper->localize($c->getLabel()),
'query_builder' => static function (EntityRepository $er) {
$qb = $er->createQueryBuilder('uj');
$qb->where('uj.active = TRUE');
return $qb;
},
'choices' => $this->loadAndSortUserJobs(),
])
->add('mainLocation', EntityType::class, [
'label' => 'Main location',
@@ -96,6 +92,7 @@ class UserType extends AbstractType
'query_builder' => static function (EntityRepository $er) {
$qb = $er->createQueryBuilder('l');
$qb->orderBy('l.locationType');
$qb->orderBy('l.name', 'ASC');
$qb->where('l.availableForUsers = TRUE');
return $qb;
@@ -155,6 +152,20 @@ class UserType extends AbstractType
}
}
private function loadAndSortUserJobs(): array
{
$items = $this->userJobRepository->findBy(['active' => true]);
usort(
$items,
fn ($a, $b) => mb_strtolower((string) $this->translatableStringHelper->localize($a->getLabel()))
<=>
mb_strtolower((string) $this->translatableStringHelper->localize($b->getLabel()))
);
return $items;
}
/**
* @param OptionsResolverInterface $resolver
*/

View File

@@ -41,6 +41,7 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
'isAbsent' => false,
'absenceStart' => null,
'absenceEnd' => null,
'enabled' => true,
];
public function __construct(private readonly UserRender $userRender, private readonly ClockInterface $clock) {}
@@ -108,6 +109,7 @@ class UserNormalizer implements ContextAwareNormalizerInterface, NormalizerAware
'isAbsent' => $object->isAbsent(),
'absenceStart' => $this->normalizer->normalize($object->getAbsenceStart(), $format, $absenceDatesContext),
'absenceEnd' => $this->normalizer->normalize($object->getAbsenceEnd(), $format, $absenceDatesContext),
'enabled' => $object->isEnabled(),
];
if ('docgen' === $format) {

View File

@@ -20,16 +20,16 @@
</ul>
</div>
<ul class="record_actions">
<li>
<button class="btn btn-save" disabled>
{{ $t("confirm.ok") }}
</button>
</li>
<li>
<a class="btn btn-delete" :href="deleteLink">
{{ $t("confirm.delete") }}
</a>
</li>
<li>
<button class="btn btn-save" disabled>
{{ $t("confirm.ok") }}
</button>
</li>
</ul>
</div>
@@ -40,6 +40,11 @@
"
/>
<ul class="record_actions">
<li>
<a class="btn btn-delete" :href="deleteLink">
{{ $t("confirm.delete") }}
</a>
</li>
<li>
<button
class="btn btn-save"
@@ -48,11 +53,6 @@
{{ $t("confirm.ok") }}
</button>
</li>
<li>
<a class="btn btn-delete" :href="deleteLink">
{{ $t("confirm.delete") }}
</a>
</li>
</ul>
</div>
</div>
@@ -112,7 +112,7 @@
</template>
<template #footer>
<button
class="btn btn-danger"
class="btn btn-save"
:disabled="disableConfirm"
@click="confirmCourse"
>

View File

@@ -2,9 +2,6 @@
"champs-libres/wopi-bundle": {
"version": "dev-master"
},
"chill-project/chill-zimbra-bundle": {
"version": "dev-472-zimbra-connector"
},
"doctrine/annotations": {
"version": "1.14",
"recipe": {