/**
  * A function to generate event block in month calendar
  * @param object $event event to format
  * @param string $color event color
  * @return icalendar list of user events
  */
 public static function icalendar()
 {
     $ical = "BEGIN:VCALENDAR" . PHP_EOL;
     $ical .= "VERSION:2.0" . PHP_EOL;
     $show_personal_bak = Calendar_Events::$calsettings->show_personal;
     $show_course_bak = Calendar_Events::$calsettings->show_course;
     $show_deadline_bak = Calendar_Events::$calsettings->show_deadline;
     $show_admin_bak = Calendar_Events::$calsettings->show_admin;
     Calendar_Events::set_calendar_settings(1, 1, 1, 1);
     Calendar_Events::get_calendar_settings();
     $eventlist = Calendar_Events::get_calendar_events();
     Calendar_Events::set_calendar_settings($show_personal_bak, $show_course_bak, $show_deadline_bak, $show_admin_bak);
     Calendar_Events::get_calendar_settings();
     $events = array();
     foreach ($eventlist as $event) {
         $ical .= "BEGIN:VEVENT" . PHP_EOL;
         $startdatetime = new DateTime($event->start);
         $ical .= "DTSTART:" . $startdatetime->format("Ymd\\THis") . PHP_EOL;
         $duration = new DateTime($event->duration);
         $ical .= "DURATION:" . $duration->format("\\P\\TH\\Hi\\Ms\\S") . PHP_EOL;
         $ical .= "SUMMARY:[" . strtoupper($event->event_group) . "] " . $event->title . PHP_EOL;
         $ical .= "DESCRIPTION:" . canonicalize_whitespace(strip_tags($event->content)) . PHP_EOL;
         if ($event->event_group == 'deadline') {
             $ical .= "BEGIN:VALARM" . PHP_EOL;
             $ical .= "TRIGGER:-PT24H" . PHP_EOL;
             $ical .= "DURATION:PT10H" . PHP_EOL;
             $ical .= "ACTION:DISPLAY" . PHP_EOL;
             $ical .= "DESCRIPTION:DEADLINE REMINDER for " . canonicalize_whitespace(strip_tags($event->title)) . PHP_EOL;
             $ical .= "END:VALARM" . PHP_EOL;
         }
         $ical .= "END:VEVENT" . PHP_EOL;
     }
     $ical .= "END:VCALENDAR" . PHP_EOL;
     return $ical;
 }
Exemple #2
0
$_user['persoLastLogin'] = last_login($uid);
$_user['lastLogin'] = str_replace('-', ' ', $_user['persoLastLogin']);

$user_announcements = '';

//  Get user's course info
$user_lesson_info = getUserLessonInfo($uid);
//if user is registered to at least one lesson
if (count($lesson_ids) > 0) {    
    // get user announcements    
    $user_announcements = getUserAnnouncements($lesson_ids);        
}

// get user latest personal messages
$user_messages = getUserMessages();

// create array with content
$today = getdate();
$day = $today['mday'];
$month = $today['mon'];
$year = $today['year'];
Calendar_Events::get_calendar_settings();
$user_personal_calendar = Calendar_Events::small_month_calendar($day, $month, $year);

// create array with personalised content
$perso_tool_content = array(
    'lessons_content' => $user_lesson_info,    
    'personal_calendar_content' => $user_personal_calendar
);