|
|
|
@ -3147,7 +3147,7 @@ class Agenda |
|
|
|
|
if ($allowCollectiveInvitations && $allowEventSubscriptions && !$personalEvent) { |
|
|
|
|
$form->addRadio( |
|
|
|
|
'invitation_type', |
|
|
|
|
get_lang('Allow'), |
|
|
|
|
get_lang('Allowed'), |
|
|
|
|
[ |
|
|
|
|
'invitations' => get_lang('Invitations'), |
|
|
|
|
'subscriptions' => get_lang('Subscriptions'), |
|
|
|
@ -3204,13 +3204,13 @@ class Agenda |
|
|
|
|
{ |
|
|
|
|
$invitees = []; |
|
|
|
|
$isCollective = false; |
|
|
|
|
$allowInvitees = true; |
|
|
|
|
$withInvitation = false; |
|
|
|
|
|
|
|
|
|
if ($personalEvent) { |
|
|
|
|
$eventInvitation = $personalEvent->getInvitation(); |
|
|
|
|
$allowInvitees = !$eventInvitation instanceof AgendaEventSubscription; |
|
|
|
|
$withInvitation = !($eventInvitation instanceof AgendaEventSubscription); |
|
|
|
|
|
|
|
|
|
if ($eventInvitation && $allowInvitees) { |
|
|
|
|
if ($withInvitation) { |
|
|
|
|
foreach ($eventInvitation->getInvitees() as $invitee) { |
|
|
|
|
$inviteeUser = $invitee->getUser(); |
|
|
|
|
|
|
|
|
@ -3221,9 +3221,8 @@ class Agenda |
|
|
|
|
$isCollective = $personalEvent->isCollective(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($allowInvitees) { |
|
|
|
|
$form->addHtml( |
|
|
|
|
'<div id="invitations-block">' |
|
|
|
|
'<div id="invitations-block" style="display: '.($withInvitation ? 'block;' : 'none;').'">' |
|
|
|
|
); |
|
|
|
|
$form->addHeader(get_lang('Invitations')); |
|
|
|
|
$form->addSelectAjax( |
|
|
|
@ -3244,31 +3243,29 @@ class Agenda |
|
|
|
|
'collective' => $isCollective |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private function addSubscriptionFields(FormValidator $form, ?PersonalAgenda $personalEvent) |
|
|
|
|
{ |
|
|
|
|
$subscribers = []; |
|
|
|
|
$allowSubscribers = true; |
|
|
|
|
$withSubscription = false; |
|
|
|
|
$maxSubscriptions = 0; |
|
|
|
|
$groupId = null; |
|
|
|
|
|
|
|
|
|
if ($personalEvent) { |
|
|
|
|
$eventInvitation = $personalEvent->getInvitation(); |
|
|
|
|
$allowSubscribers = $eventInvitation instanceof AgendaEventSubscription; |
|
|
|
|
$withSubscription = $eventInvitation instanceof AgendaEventSubscription; |
|
|
|
|
$maxSubscriptions = $withSubscription ? $eventInvitation->getMaxAttendees() : 0; |
|
|
|
|
$groupId = $personalEvent->getSubscriptionItemId(); |
|
|
|
|
|
|
|
|
|
$subscribers = self::getInviteesForPersonalEvent($personalEvent->getId(), AgendaEventSubscriber::class); |
|
|
|
|
$subscribers = array_combine( |
|
|
|
|
array_column($subscribers, 'id'), |
|
|
|
|
array_column($subscribers, 'name') |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$form->setDefaults([ |
|
|
|
|
'subscribers' => array_keys($subscribers), |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($allowSubscribers) { |
|
|
|
|
$form->addHtml( |
|
|
|
|
'<div id="subscriptions-block">' |
|
|
|
|
'<div id="subscriptions-block" style="display: '.($withSubscription ? 'block;' : 'none;').'">' |
|
|
|
|
); |
|
|
|
|
$form->addHeader(get_lang('Subscriptions')); |
|
|
|
|
$form->addSelect( |
|
|
|
@ -3319,14 +3316,11 @@ class Agenda |
|
|
|
|
['multiple' => 'multiple'] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
/** @var AgendaEventSubscription $subscription */ |
|
|
|
|
$subscription = $personalEvent->getInvitation(); |
|
|
|
|
$form->setDefaults([ |
|
|
|
|
'max_subscriptions' => $subscription->getMaxAttendees(), |
|
|
|
|
'subscribers' => array_keys($subscribers), |
|
|
|
|
'max_subscriptions' => $maxSubscriptions, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
$groupId = $personalEvent->getSubscriptionItemId(); |
|
|
|
|
|
|
|
|
|
if ($groupId) { |
|
|
|
|
$objUserGroup = new UserGroup(); |
|
|
|
|
|
|
|
|
@ -3334,7 +3328,6 @@ class Agenda |
|
|
|
|
|
|
|
|
|
$slctItem->addOption($groupInfo['name'], $groupId); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$form->addHtml('</div>'); |
|
|
|
|
} |
|
|
|
|