api_get_path(WEB_CODE_PATH)."group/group.php?".api_get_cidreq(), "name" => get_lang('Groups'), ]; $interbreadcrumb[] = [ "url" => api_get_path(WEB_CODE_PATH)."group/group_space.php?".api_get_cidreq(), "name" => get_lang('GroupSpace').' '.$group_properties['name'], ]; } $tpl = new Template(get_lang('Agenda')); $tpl->assign('use_google_calendar', 0); $can_add_events = 0; switch ($type) { case 'admin': api_protect_admin_script(); $this_section = SECTION_PLATFORM_ADMIN; if (api_is_platform_admin()) { $can_add_events = 1; } break; case 'course': api_protect_course_script(true); $allowToEdit = $agenda->getIsAllowedToEdit(); $this_section = SECTION_COURSES; if ($allowToEdit) { $can_add_events = 1; } break; case 'personal': if (api_is_anonymous()) { api_not_allowed(true); } $googleCalendarUrl = Agenda::returnGoogleCalendarUrl(api_get_user_id()); if (!empty($googleCalendarUrl)) { $tpl->assign('use_google_calendar', 1); $tpl->assign('google_calendar_url', $googleCalendarUrl); } $this_section = SECTION_MYAGENDA; if (!api_is_anonymous() && ('true' === api_get_setting('allow_personal_agenda'))) { $can_add_events = 1; } break; } $tpl->assign('js_format_date', 'll'); $region_value = api_get_language_isocode(); if ('en' == $region_value) { $region_value = 'en-GB'; } $tpl->assign('region_value', $region_value); $export_icon = Display::return_icon( 'export.png', null, null, null, null, true, false ); $export_icon_low = Display::return_icon( 'export_low_fade.png', null, null, null, null, true, false ); $export_icon_high = Display::return_icon( 'export_high_fade.png', null, null, null, null, true, false ); $tpl->assign( 'export_ical_confidential_icon', Display::return_icon($export_icon_high, get_lang('ExportiCalConfidential')) ); $actions = $agenda->displayActions('calendar', $userId); $tpl->assign('toolbar', $actions); // Calendar Type : course, admin, personal $tpl->assign('type', $type); $type_event_class = $type.'_event'; $type_label = get_lang(ucfirst($type).'Calendar'); if ($type == 'course' && !empty($group_id)) { $type_event_class = 'group_event'; $type_label = get_lang('GroupCalendar'); } $defaultView = api_get_setting('default_calendar_view'); if (empty($defaultView)) { $defaultView = 'month'; } /* month, basicWeek, agendaWeek, agendaDay */ $tpl->assign('default_view', $defaultView); if ($type == 'course' && !empty($session_id)) { $type_event_class = 'session_event'; $type_label = get_lang('SessionCalendar'); } $agendaColors = array_merge( [ 'platform' => 'red', //red 'course' => '#458B00', //green 'group' => '#A0522D', //siena 'session' => '#00496D', // kind of green 'other_session' => '#999', // kind of green 'personal' => 'steel blue', //steel blue 'student_publication' => '#FF8C00', //DarkOrange ], api_get_configuration_value('agenda_colors') ?: [] ); switch ($type_event_class) { case 'admin_event': $tpl->assign('type_event_color', $agendaColors['platform']); break; case 'course_event': $tpl->assign('type_event_color', $agendaColors['course']); break; case 'group_event': $tpl->assign('type_event_color', $agendaColors['group']); break; case 'session_event': $tpl->assign('type_event_color', $agendaColors['session']); break; case 'personal_event': $tpl->assign('type_event_color', $agendaColors['personal']); break; } $tpl->assign('type_label', $type_label); $tpl->assign('type_event_class', $type_event_class); // Current user can add event? $tpl->assign('can_add_events', $can_add_events); // Setting AJAX caller if (!empty($userId)) { $agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?user_id='.$userId.'&type='.$type; } else { $agenda_ajax_url = api_get_path(WEB_AJAX_PATH).'agenda.ajax.php?type='.$type; } if ('course' === $type && !empty($courseId)) { $agenda_ajax_url .= '&'.api_get_cidreq(); } if (isset($_GET['session_id'])) { $agenda_ajax_url .= '&session_id='.intval($_GET['session_id']); } $agenda_ajax_url .= '&sec_token='.Security::get_token(); $tpl->assign('web_agenda_ajax_url', $agenda_ajax_url); $form = new FormValidator( 'form', 'get', api_get_self().'?'.api_get_cidreq(), null, ['id' => 'add_event_form'] ); $form->addHeader(get_lang('Events')); $form->addHtml('
'); $sendTo = $agenda->parseAgendaFilter($userId); $addOnlyItemsInSendTo = true; if ($sendTo['everyone']) { $addOnlyItemsInSendTo = false; } $agenda->showToForm($form, $sendTo, [], $addOnlyItemsInSendTo); $form->addHtml('
'); $form->addHtml(''); $form->addElement('label', get_lang('Agenda'), '

'); $form->addElement( 'label', get_lang('Date'), '

' ); $form->addElement('text', 'title', get_lang('Title'), ['id' => 'title']); $form->addHtmlEditor( 'content', get_lang('Description'), false, false, [ 'ToolbarSet' => 'TestProposedAnswer', 'Height' => '120', 'id' => 'content', ] ); if ('course' === $agenda->type) { $form->addHtml(''); $form->addElement('textarea', 'comment', get_lang('Comment'), ['id' => 'comment']); } $allowCollectiveInvitations = api_get_configuration_value('agenda_collective_invitations') && 'personal' === $agenda->type; $allowEventSubscriptions = api_is_platform_admin() && api_get_configuration_value('agenda_event_subscriptions') && 'personal' === $agenda->type; if ($allowCollectiveInvitations && $allowEventSubscriptions) { $form->addRadio( 'invitation_type', get_lang('Allowed'), [ 'invitations' => get_lang('Invitations'), 'subscriptions' => get_lang('Subscriptions'), ], [ 'onchange' => "$('#invitations-block, #subscriptions-block').hide(); $('#' + this.value + '-block').show();", ] ); } if ($allowCollectiveInvitations) { $form->addHtml( '
' ); $form->addHeader(get_lang('Invitations')); $form->addSelectAjax( 'invitees', get_lang('Invitees'), [], [ 'multiple' => 'multiple', 'url' => api_get_path(WEB_AJAX_PATH).'message.ajax.php?a=find_users', ] ); $form->addCheckBox('collective', '', get_lang('IsItEditableByTheInvitees')); $form->addHtml('
'); } if ($allowEventSubscriptions) { $form->addHtml( '
' ); $form->addHeader(get_lang('Subscriptions')); $form->addHtml('
'); $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'), ], [ 'onchange' => 'document.getElementById(\'max_subscriptions\').disabled = this.value == 0; document.getElementById(\'form_subscription_item\').disabled = this.value != 2', ] ); $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', 'dropdownParent' => '#form_subscriptions_container', ] ); $form->addNumeric( 'max_subscriptions', ['', get_lang('MaxSubscriptionsLeaveEmptyToNotLimit')], [ 'disabled' => 'disabled', 'step' => 1, 'min' => 0, 'value' => 0, ] ); $form->addHtml('
'); $form->addHtml(''); $form->addHtml('
'); } if (api_get_configuration_value('agenda_reminders')) { $tpl->assign( 'agenda_reminders_js', Agenda::getJsForReminders('#form_add_notification') ); $form->addHtml('
'); $form->addButton('add_notification', get_lang('AddNotification'), 'bell-o')->setType('button'); $form->addHtml('
'); } if (api_get_configuration_value('allow_careers_in_global_agenda') && 'admin' === $agenda->type) { Career::addCareerFieldsToForm($form); $form->addHtml('
'); } $form->addHtml(''); $tpl->assign('form_add', $form->returnForm()); $tpl->assign('legend_list', api_get_configuration_value('agenda_legend')); $onHoverInfo = Agenda::returnOnHoverInfo(); $tpl->assign('on_hover_info', $onHoverInfo); $extraSettings = Agenda::returnFullCalendarExtraSettings(); $tpl->assign('fullcalendar_settings', $extraSettings); $tpl->assign('group_id', (!empty($group_id) ? $group_id : 0)); if (api_is_https()) { $tpl->assign('is_https', 1); } else { $tpl->assign('is_https', 0); } $templateName = $tpl->get_template('agenda/month.tpl'); $content = $tpl->fetch($templateName); $tpl->assign('content', $content); $tpl->display_one_col_template();