Revision: 2257
          http://mrbs.svn.sourceforge.net/mrbs/?rev=2257&view=rev
Author:   cimorrison
Date:     2012-01-27 10:34:05 +0000 (Fri, 27 Jan 2012)
Log Message:
-----------
- supplied a name if SUMMARY is missing (a SUMMARY is optional in RFC 5545 but 
mandatory in MRBS)
- supplied a UID if missing (it's mandatory in RFC 5545 but we'll be tolerant)

Modified Paths:
--------------
    mrbs/branches/ics_import/web/import.php

Modified: mrbs/branches/ics_import/web/import.php
===================================================================
--- mrbs/branches/ics_import/web/import.php     2012-01-27 10:00:08 UTC (rev 
2256)
+++ mrbs/branches/ics_import/web/import.php     2012-01-27 10:34:05 UTC (rev 
2257)
@@ -170,7 +170,7 @@
     $properties[$property['name']] = array('params' => $property['params'],
                                            'value' => $property['value']);
   }
-  // Get the start time and UID, because we'll need them later
+  // Get the start time because we'll need it later
   if (!isset($properties['DTSTART']))
   {
     trigger_error("No DTSTART", E_USER_WARNING);
@@ -180,7 +180,6 @@
     $booking['start_time'] = get_time($properties['DTSTART']['value'],
                                       $properties['DTSTART']['params']);
   }
-  $booking['ical_uid'] = (isset($properties['UID'])) ? 
$properties['UID']['value'] : "unknown UID";
   // Now go through the rest of the properties
   foreach($properties as $name => $details)
   {
@@ -232,12 +231,30 @@
           $booking['status'] |= STATUS_TENTATIVE;
         }
         break;
+      case 'UID':
+        $booking['ical_uid'] = $details['value'];
+        break;
       case 'SEQUENCE':
         $booking['ical_sequence'] = $details['value'];
         break;
     }
   }
 
+  // A SUMMARY is optional in RFC 5545, however a brief description is 
mandatory
+  // in MRBS.   So if the VEVENT didn't include a name, we'll give it one
+  if (!isset($booking['name']))
+  {
+    $booking['name'] = "Imported event - no SUMMARY name";
+  }
+  
+  // On the other hand a UID is mandatory in RFC 5545.   We'll be lenient and
+  // provide one if it is missing
+  if (!isset($booking['ical_uid']))
+  {
+    $booking['ical_uid'] = generate_global_uid($booking['name']);
+    $booking['sequence'] = 0;  // and we'll start the sequence from 0
+  }
+  
   if (empty($problems))
   {
     // Get the area settings for this room, if we haven't got them already
@@ -365,6 +382,8 @@
       if (isset($first_line))
       {
         // Get rid of empty lines at the end of the file
+        // (Strictly speaking there must be a CRLF at the end of the file, but
+        // we will be tolerant and accept files without one)
         do
         {
           $last_line = array_pop($lines);

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


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to