Get moodle face-to-face iCal invites to work with MS Exchange / Outlook
The Problem
Moodle's Face-to-Face module sends you an iCal invite that is not properly interpreted by MS Outlook client. The iCal invite comes through as a blank attachment. Apparently the iCal worked just fine on OWA and on Evolution running on Linux.
Our Environment
- Moodle v.1.94+
- MS Exchange server 2003 (don't know which patch level).
Disclaimer
The changes below are what got my problem fixed at work. I don't guarantee that it will work for you. Use this information at your own risk. I also won't pretend this is the best solution out there. I am positive it can be improve in many ways. If you have problems with this solution and if I have the time to revisit this in the future I may look into it.
A Tentative Solution
Change the /moodle/moodlelib.php and the /moodle/mod/facetoface/lib.php files on the following fashion:
moodle/mod/facetoface/lib.php
Around line 1374, change this code:
if (!email_to_user($user, $fromaddress, $attachment['subject'], $attachment['body'], $attachment['htmlbody'], $attachment['filename'], $attachmentfilename)) {
if (!email_to_user($user, $fromaddress, $attachment['subject'], file_get_contents($CFG->dataroot . '/' . $attachment['filename']),'ical')) {
The change above will use the file attachment as the body if the user opted to send out an iCal invite and add a special marker ("ical") as the parameter for the changes we will make on the moodlelib.php
moodle/moodlelib.php
Around line 4117, after the global and static declarations, add the following code:
if ($messagehtml == 'ical') { $messagehtml = ''; $is_this_an_ical_request = TRUE; }
This will set a control variable if the user chose to send an iCal. Then, around the new line 4283, right before the if ($mail->Send()) {, add the following code:
if ($is_this_an_ical_request) { $mail->ContentType = 'text/calendar; method=REQUEST; charset="UTF-8"'; $mail->Encoding = 'quoted-printable'; }
Optional Item: setting a smart default
In the interest of completeness, another change we did at work is to set the default option for the user to send just an iCal invite. This is done in the moodle/mod/facetoface/signup.html file, around lines 124 and 126. On line 124, remove the selected="selected" statement and make line 126 look like this:
<option value="<?php echo MDL_F2F_ICAL ?>" selected="selected"><?php print_string('notificationical', 'facetoface') ?> </option>
Easy Peasy!
-PCP
Update!
As pointed out by a colleague, this fix apparently will not work with gmail.com. If there is sufficient interest I can work out a solution that works for both.
- peter's blog
- Login or register to post comments

Comments
Smile - First impressions last, and first impressions created with a smile is definitely an advantage. Try smiling at every person you come across the street and you'll see what I mean.
Buy tractors
Respect - We all know that respect is earned and not given. However, you should always give respect, initially, to any person you meet. It's always easy to do a favor for someone who shows you respect.
customremodelers-siding.com
Build instant rapport - People who can create rapport instantly with anyone has more friends and can establish good relationships than those who can't.
minneapolis seo
Use body language - Understanding body language is part of the plan. Our everyday communication is 55% body language. Although you get the signals unconsciously from the people you talk to, knowing how to consciously recognize these signals is a plus in the art of persuasion.
get facebook likes