Fix calendar errors.

1.10.x
Julio Montoya 10 years ago
parent 3c26a21852
commit 22eed0ae2d
  1. 4
      app/Resources/public/css/base.css
  2. 47
      main/inc/lib/agenda.lib.php
  3. 42
      main/template/default/agenda/month.tpl

@ -801,6 +801,10 @@ a.tag {
background-color: #FFCA8D;
}
#calendar_course_info h4, #calendar_session_info h4 {
font-weight: bold;
}
/* ---------------------------------------------------
styles for the personal agenda
-----------------------------------------------------*/

@ -977,7 +977,6 @@ class Agenda
}
}
if (!empty($session_list)) {
foreach ($session_list as $session_item) {
if ($sessionFilterActive) {
@ -988,10 +987,17 @@ class Agenda
$my_courses = $session_item['courses'];
$my_session_id = $session_item['session_id'];
if (!empty($my_courses)) {
foreach ($my_courses as $course_item) {
$courseInfo = api_get_course_info_by_id($course_item['real_id']);
$this->getCourseEvents($start, $end, $courseInfo, 0, $my_session_id);
$this->getCourseEvents(
$start,
$end,
$courseInfo,
0,
$my_session_id
);
}
}
}
@ -1004,7 +1010,11 @@ class Agenda
$this->getCourseEvents($start, $end, $course_info_item);
}
} else {
$this->getCourseEvents($start, $end, $course_info_item);
$this->getCourseEvents(
$start,
$end,
$course_info_item
);
}
}
}
@ -1318,6 +1328,8 @@ class Agenda
return array();
}
$session_id = intval($session_id);
$user_id = intval($user_id);
$groupList = GroupManager::get_group_list(null, $courseInfo['code']);
@ -1352,8 +1364,6 @@ class Agenda
$group_memberships = array($groupId);
}
$session_id = intval($session_id);
if (is_array($group_memberships) && count($group_memberships) > 0) {
if (api_is_allowed_to_edit()) {
if (!empty($groupId)) {
@ -1393,19 +1403,22 @@ class Agenda
if ($user_id == 0) {
$where_condition = "";
} else {
$where_condition = " ( ip.to_user_id = ".$user_id. ") AND ";
$where_condition = " (ip.to_user_id = ".$user_id.") OR ";
}
$visibilityCondition = " (ip.visibility IN ('1', '0')) AND ";
} else {
$where_condition = " ( ip.to_user_id = ".api_get_user_id()." AND (ip.to_group_id='0' OR ip.to_group_id IS NULL)) AND ";
$where_condition = " ( ip.to_user_id = ".api_get_user_id()." AND (ip.to_group_id='0' OR ip.to_group_id IS NULL)) OR ";
}
$sessionCondition = " agenda.session_id = $session_id AND
ip.session_id = $session_id ";
if (empty($session_id)) {
$sessionCondition = "
(agenda.session_id = 0 OR agenda.session_id IS NULL) AND
(ip.session_id = 0 OR ip.session_id IS NULL) ";
(
(agenda.session_id = 0 OR agenda.session_id IS NULL) AND
(ip.session_id = 0 OR ip.session_id IS NULL)
) ";
}
$sql = "SELECT DISTINCT
@ -1445,8 +1458,11 @@ class Agenda
$sql .= $dateCondition;
$result = Database::query($sql);
if (Database::num_rows($result)) {
$events_added = array();
$events_added = array_column($this->events, 'id');
while ($row = Database::fetch_array($result, 'ASSOC')) {
$eventId = $row['ref'];
$items = $this->getUsersAndGroupSubscribedToEvent($eventId, $course_id, $this->sessionId);
@ -1456,7 +1472,7 @@ class Agenda
$event['id'] = 'course_'.$row['id'];
// To avoid doubles
if (in_array($row['id'], $events_added)) {
if (in_array($event['id'], $events_added)) {
continue;
}
@ -1477,8 +1493,13 @@ class Agenda
$event['allDay'] = 'false';
$event['course_id'] = $course_id;
$event['course_name'] = isset($courseInfo['name']) ? $courseInfo['name'] : '';
$event['session_name'] = isset($sessionInfo['name']) ? $sessionInfo['name'] : '';
$event['borderColor'] = $event['backgroundColor'] = $this->event_course_color;
$sessionInfo = [];
if (isset($row['session_id']) && !empty($row['session_id'])) {
$sessionInfo = api_get_session_info($session_id);
$event['borderColor'] = $event['backgroundColor'] = $this->event_session_color;
}
@ -1486,7 +1507,6 @@ class Agenda
$event['borderColor'] = $event['backgroundColor'] = $this->event_group_color;
}
if (isset($row['color']) && !empty($row['color'])) {
$event['borderColor'] = $event['backgroundColor'] = $row['color'];
}
@ -1763,6 +1783,9 @@ class Agenda
if (is_array($userList)) {
$options = array();
foreach ($userList as $user) {
if ($user['status'] == ANONYMOUS) {
continue;
}
$option = array(
'text' => api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')',
'value' => "USER:".$user['user_id']

@ -22,9 +22,6 @@ var region_value = '{{ region_value }}';
$(document).ready(function() {
var date = new Date();
var d = date.getDate();
var m = date.getMonth()+1;
var y = date.getFullYear();
// Reset button.
$("button[type=reset]").click(function() {
@ -102,9 +99,6 @@ $(document).ready(function() {
},
// Add event
select: function(start, end, jsEvent, view) {
//Removing UTC stuff
//var start_date = $.datepicker.formatDate("yy-mm-dd", start) + " " + start.toTimeString().substr(0, 8);
//var end_date = $.datepicker.formatDate("yy-mm-dd", end) + " " + end.toTimeString().substr(0, 8);
var start_date = start.format("YY-MM-DD");
var end_date = end.format("YY-MM-DD");
@ -245,7 +239,6 @@ $(document).ready(function() {
} else {
var end_date = '';
if (calEvent.end && calEvent.end != '') {
//var end_date = Math.round(calEvent.end.getTime() / 1000);
var end_date = calEvent.end.format("YY-MM-DD");
}
}
@ -268,12 +261,8 @@ $(document).ready(function() {
$('#color_calendar').removeClass('group_event');
$('#color_calendar').addClass(calEvent.type+'_event');
//my_start_month = calEvent.start.getMonth() +1;
//$('#start_date').html(calEvent.start.getDate() +"/"+ my_start_month +"/"+calEvent.start.getFullYear());
$('#start_date').html(calEvent.start.format("YY-MM-DD"));
if (calEvent.end) {
//my_end_month = calEvent.end.getMonth() +1;
//$('#end_date').html(' '+calEvent.end.getDate() +"/"+ my_end_month +"/"+calEvent.end.getFullYear());
$('#end_date').html(' - '+calEvent.end.format("YY-MM-DD"));
}
@ -440,16 +429,36 @@ $(document).ready(function() {
});
} else {
// Simple form
// my_start_month = calEvent.start.getMonth() +1;
$('#simple_start_date').html(calEvent.start.format("YY-MM-DD"));
if (end_date != '') {
my_end_month = calEvent.end.getMonth() +1;
//$('#simple_start_date').html(calEvent.start.getDate() +"/"+ my_start_month +"/"+calEvent.start.getFullYear() +" - "+calEvent.start.toLocaleTimeString());
$('#simple_start_date').html(calEvent.start.format("YY-MM-DD"));
//$('#simple_end_date').html(' '+calEvent.end.getDate() +"/"+ my_end_month +"/"+calEvent.end.getFullYear() +" - "+calEvent.end.toLocaleTimeString());
$('#simple_end_date').html(' ' + calEvent.end.format("YY-MM-DD"));
}
console.log(calEvent);
var courseInfoText = '';
$.ajax({
url: '{{ _p.web_ajax }}' + 'course.ajax.php?a=get_course_info&id=' + calEvent.course_id,
dataType: 'json',
async: false,
success: function (data) {
courseInfoText = data.title;
}
});
if (calEvent.course_name) {
$("#calendar_course_info").html('<h4>{{ 'Course' | get_lang }}</h4>' + calEvent.course_name);
} else {
$("#calendar_course_info").html('');
}
if (calEvent.session_name) {
$("#calendar_session_info").html('<h4>{{ 'Session' | get_lang }}</h4>' + calEvent.session_name);
} else {
$("#calendar_session_info").html('');
}
$("#simple_title").html(calEvent.title);
$("#simple_content").html(calEvent.description);
@ -512,6 +521,8 @@ $(document).ready(function() {
<div id="simple-dialog-form" style="display:none;">
<div style="width:500px">
<form name="form-simple" class="form-vertical">
<span id="calendar_course_info"></span>
<span id="calendar_session_info"></span>
<div class="control-group">
<label class="control-label">
<b>{{ "Date" |get_lang}}</b>
@ -546,7 +557,6 @@ $(document).ready(function() {
<div id="simple_comment"></div>
</div>
</div>
</form>
</div>
</div>

Loading…
Cancel
Save