From dbe0e52c548a5d38dee86a47df38801bdd2499c2 Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 1 Jun 2023 01:22:36 +0200 Subject: [PATCH] Calendar: Fix missing group context in event edition Author: @TheTomcat14 --- main/calendar/agenda.php | 9 +++++++-- main/calendar/agenda_js.php | 2 ++ main/inc/lib/agenda.lib.php | 5 +++-- main/template/default/agenda/month.tpl | 3 +++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/main/calendar/agenda.php b/main/calendar/agenda.php index 1353206619..628ebc5677 100755 --- a/main/calendar/agenda.php +++ b/main/calendar/agenda.php @@ -14,10 +14,16 @@ if (!empty($course_info)) { $action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : null; +$group_id = api_get_group_id(); + $url = null; if (empty($action)) { if (!empty($course_info)) { - $url = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=course&'.api_get_cidreq(); + if (!empty($group_id)) { + $url = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=course&'.api_get_cidreq().'&user_id=GROUP:'.$group_id; + } else { + $url = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=course&'.api_get_cidreq(); + } } else { $url = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?'; } @@ -31,7 +37,6 @@ $logInfo = [ ]; Event::registerLog($logInfo); -$group_id = api_get_group_id(); $groupInfo = GroupManager::get_group_properties($group_id); $eventId = $_REQUEST['id'] ?? null; $type = $event_type = $_GET['type'] ?? null; diff --git a/main/calendar/agenda_js.php b/main/calendar/agenda_js.php index 8733136035..1d69e32d65 100755 --- a/main/calendar/agenda_js.php +++ b/main/calendar/agenda_js.php @@ -369,6 +369,8 @@ $extraSettings = Agenda::returnFullCalendarExtraSettings(); $tpl->assign('fullcalendar_settings', $extraSettings); +$tpl->assign('group_id', (!empty($group_id) ? $group_id : 0)); + $templateName = $tpl->get_template('agenda/month.tpl'); $content = $tpl->fetch($templateName); $tpl->assign('content', $content); diff --git a/main/inc/lib/agenda.lib.php b/main/inc/lib/agenda.lib.php index e70197eb65..e34d4b0ff1 100644 --- a/main/inc/lib/agenda.lib.php +++ b/main/inc/lib/agenda.lib.php @@ -1923,7 +1923,7 @@ class Agenda OR ( pa.subscriptionVisibility = ".AgendaEventSubscription::SUBSCRIPTION_CLASS." AND pa.subscriptionItemId IN (".implode(', ', array_column($groupList, 'id')).") - ) + ) "; } @@ -2487,6 +2487,7 @@ class Agenda ); $event['sent_to'] = '
'.$sent_to.'
'; $event['type'] = 'group'; + $event['group_id'] = $row['to_group_id']; } // Event sent to a user? @@ -3180,7 +3181,7 @@ class Agenda $('#add_event_subscription_visibility') .on('change', function () { $('#max_subscriptions').prop('disabled', this.value == 0); - $('#add_event_subscription_item').prop('disabled', this.value != 2); + $('#add_event_subscription_item').prop('disabled', this.value != 2); }) .trigger('change'); }) diff --git a/main/template/default/agenda/month.tpl b/main/template/default/agenda/month.tpl index 6546076b1a..3f6580e237 100755 --- a/main/template/default/agenda/month.tpl +++ b/main/template/default/agenda/month.tpl @@ -744,6 +744,9 @@ $(function() { {% endif %} '{{ "Edit"|get_lang }}' : function() { url = "{{ _p.web_main }}calendar/agenda.php?action=edit&type=fromjs&id="+calEvent.id+'&course_id='+calEvent.course_id+""; + if (typeof calEvent.group_id != "undefined" && {{ group_id }} != 0) { + url = url + '&gidReq=' + calEvent.group_id; + } window.location.href = url; $("#dialog-form").dialog( "close" ); },