Revision: 1680
          http://mrbs.svn.sourceforge.net/mrbs/?rev=1680&view=rev
Author:   cimorrison
Date:     2010-12-08 19:46:51 +0000 (Wed, 08 Dec 2010)

Log Message:
-----------
Added ATTENDEE and ROLE information to the iCalendar object.

Modified Paths:
--------------
    mrbs/branches/ics_attachments/web/functions_ical.inc
    mrbs/branches/ics_attachments/web/functions_mail.inc

Modified: mrbs/branches/ics_attachments/web/functions_ical.inc
===================================================================
--- mrbs/branches/ics_attachments/web/functions_ical.inc        2010-12-08 
17:37:52 UTC (rev 1679)
+++ mrbs/branches/ics_attachments/web/functions_ical.inc        2010-12-08 
19:46:51 UTC (rev 1680)
@@ -134,7 +134,7 @@
 
 
 // Creates an iCalendar object in RFC 5545 format
-function create_icalendar($method, $data, $text_description, 
$html_description, $series=FALSE)
+function create_icalendar($method, $data, $text_description, 
$html_description, $addresses, $series=FALSE)
 {
   require_once "version.inc";
   
@@ -181,6 +181,34 @@
   {
     $results[] = "STATUS:". (($data['status'] & STATUS_TENTATIVE) ? 
"TENTATIVE" : "CONFIRMED");
   }
+  
+  // Put the people on the "to" list as required participants and those on the 
cc
+  // list as non particpants.   In theory the email client can then decide 
whether
+  // to enter the booking automaticaly on the user's calendar - although at the
+  // time of writing (Dec 2010) there don't seem to be any that do so!
+  $keys = array('to', 'cc');  // We won't do 'bcc' as they need to stay blind
+  foreach ($keys as $key)
+  {
+    if (!empty($addresses[$key]))
+    {
+      $address_list = $addresses[$key];
+      $address_array = explode(',', $address_list);
+      foreach ($address_array as $address)
+      {
+        switch ($key)
+        {
+          case 'to':
+            $role = "REQ-PARTICIPANT";
+            break;
+          default:
+            $role = "NON-PARTICIPANT";
+            break;
+        }
+        $results[] = "ATTENDEE;ROLE=$role:mailto:"; . trim($address);
+      }
+    }
+  }
+
   $results[] = "END:VEVENT";
   
   $results[] = "END:VCALENDAR";

Modified: mrbs/branches/ics_attachments/web/functions_mail.inc
===================================================================
--- mrbs/branches/ics_attachments/web/functions_mail.inc        2010-12-08 
17:37:52 UTC (rev 1679)
+++ mrbs/branches/ics_attachments/web/functions_mail.inc        2010-12-08 
19:46:51 UTC (rev 1680)
@@ -807,7 +807,7 @@
   if ($mail_settings['icalendar'])
   {
     $attachment['method']   = "REQUEST";
-    $attachment['content']  = create_icalendar($attachment['method'], $data, 
$text_body, $html_body, $series);
+    $attachment['content']  = create_icalendar($attachment['method'], $data, 
$text_body, $html_body, $addresses, $series);
     $attachment['name']     = $mail_settings['ics_filename'] . ".ics";
   }
 
@@ -876,7 +876,7 @@
   if ($mail_settings['icalendar'])
   {
     $attachment['method']   = "CANCEL";
-    $attachment['content']  = create_icalendar($attachment['method'], 
$mail_previous, $text_body, $html_body, $series);
+    $attachment['content']  = create_icalendar($attachment['method'], 
$mail_previous, $text_body, $html_body, $addresses, $series);
     $attachment['name']     = "meeting.ics";
   }
   


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
This SF Dev2Dev email is sponsored by:

WikiLeaks The End of the Free Internet
http://p.sf.net/sfu/therealnews-com
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to