Add personal_calendar_show_sessions_occupation conf setting - refs BT#19393

Display sessions ocuppations in personal agenda
pull/4093/head
Angel Fernando Quiroz Campos 4 years ago
parent 3af197e7db
commit fec6129173
  1. 97
      main/inc/lib/agenda.lib.php
  2. 2
      main/install/configuration.dist.php
  3. 36
      main/template/default/agenda/month.tpl

@ -1221,6 +1221,7 @@ class Agenda
$ignoreVisibility = api_get_configuration_value('personal_agenda_show_all_session_events');
$session_list = [];
// Getting course events
$my_course_list = [];
if (!api_is_anonymous()) {
@ -1316,6 +1317,9 @@ class Agenda
}
}
}
$this->loadSessionsAsEvents($start, $end);
break;
}
@ -1339,6 +1343,99 @@ class Agenda
}
}
private function loadSessionsAsEvents(int $start, int $end)
{
if (false === api_get_configuration_value('personal_calendar_show_sessions_occupation')) {
return;
}
$userInfo = api_get_user_info();
$sessionList = SessionManager::getSessionsFollowedByUser($userInfo['id'], $userInfo['status']);
foreach ($sessionList as $sessionInfo) {
if (!empty($sessionInfo['duration'])) {
$courseAccess = CourseManager::getFirstCourseAccessPerSessionAndUser(
$sessionInfo['session_id'],
$userInfo['id']
);
if (empty($courseAccess)) {
continue;
}
$firstAccessDate = new DateTime($courseAccess['login_course_date'], new DateTimeZone('UTC'));
$lastAccessDate = clone $firstAccessDate;
$lastAccessDate->modify('+'.$sessionInfo['duration'].' days');
if ($firstAccessDate->format('Y-m-d H:i:s') > $start
&& $lastAccessDate->format('Y-m-d H:i:s') < $end
) {
continue;
}
$courseList = SessionManager::get_course_list_by_session_id($sessionInfo['id']);
$firstCourse = current($courseList);
$this->events[] = [
'id' => 'session_' . $sessionInfo['id'],
'session_id' => $sessionInfo['id'],
'title' => $sessionInfo['name'],
'description' => $sessionInfo['show_description'] ? $sessionInfo['description'] : '',
'className' => 'personal',
'borderColor' => $this->event_personal_color,
'backgroundColor' => $this->event_personal_color,
'editable' => false,
'sent_to' => get_lang('Me'),
'type' => 'session',
'start' => $firstAccessDate->format(DateTime::ISO8601),
'start_date_localtime' => api_get_local_time($firstAccessDate),
'end' => $lastAccessDate->format(DateTime::ISO8601),
'end_date_localtime' => api_get_local_time($lastAccessDate),
'allDay' => 0,
'parent_event_id' => 0,
'has_children' => 0,
'course_url' => api_get_course_url($firstCourse['code'], $sessionInfo['id']),
];
continue;
}
if ($sessionInfo['display_start_date'] < $start
&& $sessionInfo['display_end_date'] > $end
) {
continue;
}
$courseList = SessionManager::get_course_list_by_session_id($sessionInfo['id']);
$firstCourse = current($courseList);
$this->events[] = [
'id' => 'session_' . $sessionInfo['id'],
'session_id' => $sessionInfo['id'],
'title' => $sessionInfo['name'],
'description' => $sessionInfo['show_description'] ? $sessionInfo['description'] : '',
'className' => 'personal',
'borderColor' => $this->event_personal_color,
'backgroundColor' => $this->event_personal_color,
'editable' => false,
'sent_to' => get_lang('Me'),
'type' => 'session',
'start' => $sessionInfo['display_start_date'],
'start_date_localtime' => $sessionInfo['display_start_date']
? $this->formatEventDate($sessionInfo['display_start_date'])
: '',
'end' => $sessionInfo['display_end_date'],
'end_date_localtime' => $sessionInfo['display_end_date']
? $this->formatEventDate($sessionInfo['display_end_date'])
: '',
'allDay' => 0,
'parent_event_id' => 0,
'has_children' => 0,
'course_url' => api_get_course_url($firstCourse['code'], $sessionInfo['id']),
];
}
}
/**
* Clean events.
*

@ -436,6 +436,8 @@ $_configuration['agenda_colors'] = [
'student_publication' => '#FF8C00'
];
*/
// Display sessions ocuppations in personal agenda
//$_configuration['personal_calendar_show_sessions_occupation'] = false;
// ------
//
// Save some tool titles with HTML editor. Require DB changes:

@ -722,22 +722,30 @@ $(function() {
$("#simple_comment").html(calEvent.comment);
$("#simple_attachment").html(calEvent.attachment);
var buttons = {
'{{"ExportiCalConfidential"|get_lang}}' : function() {
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";
window.location.href = url;
},
'{{"ExportiCalPrivate"|get_lang}}': function() {
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";
window.location.href = url;
},
'{{"ExportiCalPublic"|get_lang}}': function() {
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";
window.location.href = url;
}
};
if ('session' === calEvent.type) {
buttons['{{ "GoToCourse"|get_lang }}'] = function() {
window.location.href = calEvent.course_url;
};
}
$("#simple-dialog-form").dialog("open");
$("#simple-dialog-form").dialog({
buttons: {
'{{"ExportiCalConfidential"|get_lang}}' : function() {
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=confidential";
window.location.href = url;
},
'{{"ExportiCalPrivate"|get_lang}}': function() {
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=private";
window.location.href = url;
},
'{{"ExportiCalPublic"|get_lang}}': function() {
url = "ical_export.php?id=" + calEvent.id+'&course_id='+calEvent.course_id+"&class=public";
window.location.href = url;
}
}
buttons: buttons
});
}
},

Loading…
Cancel
Save