Skip to content

Commit 7805cd6

Browse files
committed
Calendar : add options for course agenda to define default participants - refs BT#22464
1 parent 1ee2d8b commit 7805cd6

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

main/inc/lib/agenda.lib.php

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3032,7 +3032,34 @@ public function getForm($params = [])
30323032
);
30333033
$form->addElement('hidden', 'to', 'true');
30343034
} else {
3035-
$sendTo = isset($params['send_to']) ? $params['send_to'] : ['everyone' => true];
3035+
$defaultSendTo = ['everyone' => true];
3036+
if (api_get_configuration_value('course_agenda_set_default_send_to_with_none')) {
3037+
$defaultSendTo = ['everyone' => false];
3038+
}
3039+
$defaultSendToCurrentUser = '';
3040+
if (api_get_configuration_value('course_agenda_set_default_send_to_with_current_user')) {
3041+
$defaultSendToCurrentUser = api_get_user_id();
3042+
}
3043+
if (api_get_configuration_value('course_agenda_set_default_send_to_with_teachers')) {
3044+
$currentCourseInfo = api_get_course_info();
3045+
$sessionId = api_get_session_id();
3046+
if ($sessionId) {
3047+
$usersSendTo = SessionManager::getCoachesByCourseSession($sessionId, $currentCourseInfo['real_id']);
3048+
} else {
3049+
$courseTeachers = CourseManager::get_teacher_list_from_course_code($currentCourseInfo['code']);
3050+
$courseTeachersUid = [];
3051+
foreach ($courseTeachers as $courseTeacher) {
3052+
$courseTeachersUid[] = $courseTeacher['user_id'];
3053+
}
3054+
$usersSendTo = $courseTeachersUid;
3055+
}
3056+
$usersSendTo[] = $defaultSendToCurrentUser;
3057+
$defaultSendTo = ['users' => $usersSendTo];
3058+
} elseif ($defaultSendToCurrentUser) {
3059+
$defaultSendTo = ['users' => [$defaultSendToCurrentUser]];
3060+
}
3061+
$sendTo = isset($params['send_to']) ? $params['send_to'] : $defaultSendTo;
3062+
30363063
if ($this->type == 'course') {
30373064
$this->showToForm($form, $sendTo, [], false, true);
30383065
}

main/install/configuration.dist.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,14 @@
493493
//$_configuration['agenda_reminders'] = false;
494494
// Sets the sender ID when using the cron main/cron/agenda_reminders.php to send reminders in course events.
495495
//$_configuration['agenda_reminders_sender_id'] = 0;
496+
//
497+
//In course agenda do not select any participant by default
498+
//$_configuration['course_agenda_set_default_send_to_with_none'] = false;
499+
//In course agenda add the current user has default participant
500+
//$_configuration['course_agenda_set_default_send_to_with_current_user'] = false;
501+
//In course agenda add the course teachers or the course session coach in session context has default participants
502+
//$_configuration['course_agenda_set_default_send_to_with_teachers'] = false;
503+
496504
// ------
497505
//
498506
// Save some tool titles with HTML editor. Require DB changes:

0 commit comments

Comments
 (0)