Ical import fix, checking the duration if enddate value is not provided see CT#1238

skala
Julio Montoya 15 years ago
parent 01545a2ea0
commit 7ab05c41ef
  1. 29
      main/calendar/agenda.inc.php

@ -4599,17 +4599,36 @@ function agenda_import_ical($course_info,$file) {
$ve = $ical->getComponent(VEVENT);
$ttitle = $ve->getProperty('summary');
$title = api_convert_encoding($ttitle,$charset,'UTF-8');
$tdesc = $ve->getProperty('description');
$desc = api_convert_encoding($tdesc,$charset,'UTF-8');
$ts = $ve->getProperty('dtstart');
$start_date = $ts['year'].'-'.$ts['month'].'-'.$ts['day'].' '.$ts['hour'].':'.$ts['min'].':'.$ts['sec'];
$start_date = $ve->getProperty('dtstart');
$start_date_string = $start_date['year'].'-'.$start_date['month'].'-'.$start_date['day'].' '.$start_date['hour'].':'.$start_date['min'].':'.$start_date['sec'];
$ts = $ve->getProperty('dtend');
if ($ts != false) {
$end_date_string = $ts['year'].'-'.$ts['month'].'-'.$ts['day'].' '.$ts['hour'].':'.$ts['min'].':'.$ts['sec'];
} else {
//Check duration if dtend does not exist
$duration = $ve->getProperty('duration');
if ($duration != false) {
$duration = $ve->getProperty('duration');
$duration_string = $duration['year'].'-'.$duration['month'].'-'.$duration['day'].' '.$duration['hour'].':'.$duration['min'].':'.$duration['sec'];
$start_date_tms = mktime(intval($start_date['hour']), intval($start_date['min']), intval($start_date['sec']), intval($start_date['month']), intval($start_date['day']), intval($start_date['year']));
//$start_date_tms = mktime(($start_date['hour']), ($start_date['min']), ($start_date['sec']), ($start_date['month']), ($start_date['day']), ($start_date['year']));
//echo date('d-m-Y - h:i:s', $start_date_tms);
$end_date_string = mktime(intval($start_date['hour']) +$duration['hour'], intval($start_date['min']) + $duration['min'], intval($start_date['sec']) + $duration['sec'], intval($start_date['month']) + $duration['month'], intval($start_date['day'])+$duration['day'], intval($start_date['year']) + $duration['year']);
$end_date_string = date('Y-m-d H:i:s', $end_date_string);
//echo date('d-m-Y - h:i:s', $end_date_string);
}
}
$ts = $ve->getProperty('dtend');
$end_date = $ts['year'].'-'.$ts['month'].'-'.$ts['day'].' '.$ts['hour'].':'.$ts['min'].':'.$ts['sec'];
//echo $start_date.' - '.$end_date;
$organizer = $ve->getProperty('organizer');
@ -4617,7 +4636,7 @@ function agenda_import_ical($course_info,$file) {
$course_name = $ve->getProperty('location');
//insert the event in our database
//var_dump($title,$desc,$start_date,$end_date);
$id = agenda_add_item($course_info,$title,$desc,$start_date,$end_date,$_POST['selectedform']);
$id = agenda_add_item($course_info,$title,$desc,$start_date_string,$end_date_string,$_POST['selectedform']);
$repeat = $ve->getProperty('rrule');
if(is_array($repeat) && !empty($repeat['FREQ'])) {

Loading…
Cancel
Save