|
|
|
@ -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,119 +3221,112 @@ class Agenda |
|
|
|
|
$isCollective = $personalEvent->isCollective(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($allowInvitees) { |
|
|
|
|
$form->addHtml( |
|
|
|
|
'<div id="invitations-block">' |
|
|
|
|
); |
|
|
|
|
$form->addHeader(get_lang('Invitations')); |
|
|
|
|
$form->addSelectAjax( |
|
|
|
|
'invitees', |
|
|
|
|
get_lang('Invitees'), |
|
|
|
|
$invitees, |
|
|
|
|
[ |
|
|
|
|
'multiple' => 'multiple', |
|
|
|
|
'url' => api_get_path(WEB_AJAX_PATH).'message.ajax.php?a=find_users', |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
$form->addCheckBox('collective', '', get_lang('IsItEditableByTheInvitees')); |
|
|
|
|
$form->addHtml('<hr>'); |
|
|
|
|
$form->addHtml('</div>'); |
|
|
|
|
$form->addHtml( |
|
|
|
|
'<div id="invitations-block" style="display: '.($withInvitation ? 'block;' : 'none;').'">' |
|
|
|
|
); |
|
|
|
|
$form->addHeader(get_lang('Invitations')); |
|
|
|
|
$form->addSelectAjax( |
|
|
|
|
'invitees', |
|
|
|
|
get_lang('Invitees'), |
|
|
|
|
$invitees, |
|
|
|
|
[ |
|
|
|
|
'multiple' => 'multiple', |
|
|
|
|
'url' => api_get_path(WEB_AJAX_PATH).'message.ajax.php?a=find_users', |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
$form->addCheckBox('collective', '', get_lang('IsItEditableByTheInvitees')); |
|
|
|
|
$form->addHtml('<hr>'); |
|
|
|
|
$form->addHtml('</div>'); |
|
|
|
|
|
|
|
|
|
$form->setDefaults([ |
|
|
|
|
'invitees' => array_keys($invitees), |
|
|
|
|
'collective' => $isCollective |
|
|
|
|
]); |
|
|
|
|
} |
|
|
|
|
$form->setDefaults([ |
|
|
|
|
'invitees' => array_keys($invitees), |
|
|
|
|
'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">' |
|
|
|
|
); |
|
|
|
|
$form->addHeader(get_lang('Subscriptions')); |
|
|
|
|
$form->addSelect( |
|
|
|
|
'subscription_visibility', |
|
|
|
|
get_lang('AllowSubscriptions'), |
|
|
|
|
[ |
|
|
|
|
AgendaEventSubscription::SUBSCRIPTION_NO => get_lang('No'), |
|
|
|
|
AgendaEventSubscription::SUBSCRIPTION_ALL => get_lang('AllUsersOfThePlatform'), |
|
|
|
|
AgendaEventSubscription::SUBSCRIPTION_CLASS => get_lang('UsersInsideClass'), |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
$slctItem = $form->addSelectAjax( |
|
|
|
|
'subscription_item', |
|
|
|
|
get_lang('SocialGroup').' / '.get_lang('Class'), |
|
|
|
|
[], |
|
|
|
|
[ |
|
|
|
|
'url' => api_get_path(WEB_AJAX_PATH).'usergroup.ajax.php?a=get_class_by_keyword', |
|
|
|
|
'disabled' => 'disabled', |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$form->addNumeric( |
|
|
|
|
'max_subscriptions', |
|
|
|
|
['', get_lang('MaxSubscriptionsLeaveEmptyToNotLimit')], |
|
|
|
|
[ |
|
|
|
|
'disabled' => 'disabled', |
|
|
|
|
'step' => 1, |
|
|
|
|
'min' => 0, |
|
|
|
|
'value' => 0, |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
$form->addHtml("<script> |
|
|
|
|
$(function () { |
|
|
|
|
$('#add_event_subscription_visibility') |
|
|
|
|
.on('change', function () { |
|
|
|
|
$('#max_subscriptions').prop('disabled', this.value == 0); |
|
|
|
|
$('#add_event_subscription_item').prop('disabled', this.value != 2); |
|
|
|
|
}) |
|
|
|
|
.trigger('change'); |
|
|
|
|
}) |
|
|
|
|
</script> |
|
|
|
|
"); |
|
|
|
|
|
|
|
|
|
$form->addSelect( |
|
|
|
|
'subscribers', |
|
|
|
|
get_lang('Subscribers'), |
|
|
|
|
$subscribers, |
|
|
|
|
['multiple' => 'multiple'] |
|
|
|
|
); |
|
|
|
|
$form->addHtml( |
|
|
|
|
'<div id="subscriptions-block" style="display: '.($withSubscription ? 'block;' : 'none;').'">' |
|
|
|
|
); |
|
|
|
|
$form->addHeader(get_lang('Subscriptions')); |
|
|
|
|
$form->addSelect( |
|
|
|
|
'subscription_visibility', |
|
|
|
|
get_lang('AllowSubscriptions'), |
|
|
|
|
[ |
|
|
|
|
AgendaEventSubscription::SUBSCRIPTION_NO => get_lang('No'), |
|
|
|
|
AgendaEventSubscription::SUBSCRIPTION_ALL => get_lang('AllUsersOfThePlatform'), |
|
|
|
|
AgendaEventSubscription::SUBSCRIPTION_CLASS => get_lang('UsersInsideClass'), |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
$slctItem = $form->addSelectAjax( |
|
|
|
|
'subscription_item', |
|
|
|
|
get_lang('SocialGroup').' / '.get_lang('Class'), |
|
|
|
|
[], |
|
|
|
|
[ |
|
|
|
|
'url' => api_get_path(WEB_AJAX_PATH).'usergroup.ajax.php?a=get_class_by_keyword', |
|
|
|
|
'disabled' => 'disabled', |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
/** @var AgendaEventSubscription $subscription */ |
|
|
|
|
$subscription = $personalEvent->getInvitation(); |
|
|
|
|
$form->setDefaults([ |
|
|
|
|
'max_subscriptions' => $subscription->getMaxAttendees(), |
|
|
|
|
]); |
|
|
|
|
$form->addNumeric( |
|
|
|
|
'max_subscriptions', |
|
|
|
|
['', get_lang('MaxSubscriptionsLeaveEmptyToNotLimit')], |
|
|
|
|
[ |
|
|
|
|
'disabled' => 'disabled', |
|
|
|
|
'step' => 1, |
|
|
|
|
'min' => 0, |
|
|
|
|
'value' => 0, |
|
|
|
|
] |
|
|
|
|
); |
|
|
|
|
$form->addHtml("<script> |
|
|
|
|
$(function () { |
|
|
|
|
$('#add_event_subscription_visibility') |
|
|
|
|
.on('change', function () { |
|
|
|
|
$('#max_subscriptions').prop('disabled', this.value == 0); |
|
|
|
|
$('#add_event_subscription_item').prop('disabled', this.value != 2); |
|
|
|
|
}) |
|
|
|
|
.trigger('change'); |
|
|
|
|
}) |
|
|
|
|
</script> |
|
|
|
|
"); |
|
|
|
|
|
|
|
|
|
$form->addSelect( |
|
|
|
|
'subscribers', |
|
|
|
|
get_lang('Subscribers'), |
|
|
|
|
$subscribers, |
|
|
|
|
['multiple' => 'multiple'] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$groupId = $personalEvent->getSubscriptionItemId(); |
|
|
|
|
$form->setDefaults([ |
|
|
|
|
'subscribers' => array_keys($subscribers), |
|
|
|
|
'max_subscriptions' => $maxSubscriptions, |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
if ($groupId) { |
|
|
|
|
$objUserGroup = new UserGroup(); |
|
|
|
|
if ($groupId) { |
|
|
|
|
$objUserGroup = new UserGroup(); |
|
|
|
|
|
|
|
|
|
$groupInfo = $objUserGroup->get($groupId); |
|
|
|
|
$groupInfo = $objUserGroup->get($groupId); |
|
|
|
|
|
|
|
|
|
$slctItem->addOption($groupInfo['name'], $groupId); |
|
|
|
|
} |
|
|
|
|
$slctItem->addOption($groupInfo['name'], $groupId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$form->addHtml('</div>'); |
|
|
|
|