Skip to content

Commit

Permalink
Add course setting agenda_share_events_in_sessions - refs BT#19051
Browse files Browse the repository at this point in the history
  • Loading branch information
AngelFQC committed Nov 22, 2021
1 parent 45d4f58 commit dad370c
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 12 deletions.
28 changes: 28 additions & 0 deletions main/course_info/infocours.php
Expand Up @@ -950,6 +950,34 @@ function is_settings_editable()
$globalGroup
);

// Agenda settings -->
$group = [];
$group[] = $form->createElement(
'radio',
'agenda_share_events_in_sessions',
null,
get_lang('AgendaEventsInBaseCourseWillBeVisibleInCourseSessions'),
1
);
$group[] = $form->createElement(
'radio',
'agenda_share_events_in_sessions',
null,
get_lang('AgendaEventsOnlyVisibleInCurrentCourse'), 0
);

$globalGroup = [
get_lang('ShareEventsInSessions') => $group,
'' => $form->addButtonSave(get_lang('SaveSettings'), 'submit_save', true),
];

$form->addPanelOption(
'agenda',
Display::return_icon('agenda.png', get_lang('Agenda')).' '.get_lang('Agenda'),
$globalGroup
);
// <-- end of agenda settings

if ($allowPortfolioTool) {
$globalGroup = [
get_lang('QualifyPortfolioItems') => [
Expand Down
1 change: 1 addition & 0 deletions main/inc/lib/add_course.lib.inc.php
Expand Up @@ -663,6 +663,7 @@ public static function fill_db_course(
'show_course_in_user_language' => ['default' => 2, 'category' => null],
'email_to_teachers_on_new_work_feedback' => ['default' => 1, 'category' => null],
'email_alert_teachers_new_post' => ['default' => 2, 'category' => 'portfolio'],
'agenda_share_events_in_sessions' => ['default' => 0, 'category' => 'agenda'],
];

$counter = 1;
Expand Down
25 changes: 13 additions & 12 deletions main/inc/lib/agenda.lib.php
Expand Up @@ -1794,18 +1794,16 @@ public function getCourseEvents(
$tlb_course_agenda = Database::get_course_table(TABLE_AGENDA);
$tbl_property = Database::get_course_table(TABLE_ITEM_PROPERTY);

if (empty($sessionId)) {
$sessionCondition = "
(
agenda.session_id = 0 AND (ip.session_id IS NULL OR ip.session_id = 0)
) ";
} else {
$sessionCondition = "
(
agenda.session_id = $sessionId AND
ip.session_id = $sessionId
) ";
}
$shareEventsInSessions = 1 == api_get_course_setting('agenda_share_events_in_sessions', $courseInfo);

$agendaSessionCondition = str_replace(
' AND ',
'',
api_get_session_condition($sessionId, true, $shareEventsInSessions, 'agenda.session_id')
);
$ipSessionCondition = api_get_session_condition($sessionId, true, $shareEventsInSessions, 'ip.session_id');

$sessionCondition = "($agendaSessionCondition $ipSessionCondition)";

if ($isAllowToEdit) {
// No group filter was asked
Expand Down Expand Up @@ -1993,6 +1991,9 @@ public function getCourseEvents(
if ($isAllowToEditByHrm) {
$event['editable'] = true;
}
if ($sessionId != $row['session_id']) {
$event['editable'] = false;
}
}
// if user is author then he can edit the item
if (api_get_user_id() == $row['insert_user_id']) {
Expand Down
1 change: 1 addition & 0 deletions main/inc/lib/course.lib.php
Expand Up @@ -5802,6 +5802,7 @@ public static function getCourseSettingVariables(AppPlugin $appPlugin)
'quiz_question_limit_per_day',
'subscribe_users_to_forum_notifications',
'share_forums_in_sessions',
'agenda_share_events_in_sessions',
];

$courseModels = ExerciseLib::getScoreModels();
Expand Down

0 comments on commit dad370c

Please sign in to comment.