Index: event/ical.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/event/ical.inc,v
retrieving revision 1.6
diff -u -r1.6 ical.inc
--- event/ical.inc	18 Sep 2006 21:54:09 -0000	1.6
+++ event/ical.inc	24 Feb 2007 02:43:18 -0000
@@ -5,7 +5,7 @@
  * @file
  * API for event import/export in iCalendar format as outlined in Internet Calendaring and Scheduling Core Object Specification
  * http://www.ietf.org/rfc/rfc2445.txt
- * 
+ *
  * This module is IN DEVELOPMENT and not a finished product
  */
 
@@ -32,7 +32,7 @@
  */
 function ical_export($events, $calname = NULL) {
   $output .= "BEGIN:VCALENDAR\nVERSION:2.0\n";
-  $output .= 'X-WR-CALNAME:'. variable_get('site_name', '') .' | '. $calname ."\n";
+  $output .= 'X-WR-CALNAME:'. variable_get('site_name', '') .' | '. ical_escape_text($calname) ."\n";
   $output .= "PRODID:-//strange bird labs//Drupal iCal API//EN\n";
   foreach ($events as $uid => $event) {
     $output .= "BEGIN:VEVENT\n";
@@ -51,11 +51,11 @@
     else if ($event['start']) {
       $output .= "DTSTART;VALUE=DATE-TIME:" . gmdate("Ymd\THis\Z", $event['start']) . "\n";
     }
-    $output .= "SUMMARY;ENCODING=QUOTED-PRINTABLE:" . ical_quoted_printable_escaped($event['summary']) . "\n";
-    if ($event['description']) $output .= "DESCRIPTION;ENCODING=QUOTED-PRINTABLE:" . ical_quoted_printable_escaped($event['description']) . "\n";
-    if ($event['url']) $output .= "URL;VALUE=URI:" . $event['url'] . "\n";
-    if ($event['location']) $output .= "LOCATION;ENCODING=QUOTED-PRINTABLE:" . ical_quoted_printable_escaped($event['location']) . "\n";
     $output .= "UID:" . ($event['uid'] ? $event['uid'] : $uid) . "\n";
+    if ($event['url']) $output .= "URL;VALUE=URI:" . $event['url'] . "\n";
+    if ($event['location']) $output .= "LOCATION:" . ical_escape_text($event['location']) . "\n";
+    $output .= "SUMMARY:" . ical_escape_text($event['summary']) . "\n";
+    if ($event['description']) $output .= "DESCRIPTION:" . ical_escape_text($event['description']) . "\n";
     $output .= "END:VEVENT\n";
   }
   $output .= "END:VCALENDAR\n";
@@ -73,33 +73,33 @@
  *
  */
 function ical_escape_text($text) {
-  $text = strip_tags($text);
-  $text = str_replace("\"", "DQUOTE", $text);
+  //$text = strip_tags($text);
+  $text = str_replace('"', '\"', $text);
   $text = str_replace("\\", "\\\\", $text);
   $text = str_replace(",", "\,", $text);
-  $text = str_replace(":", "\":\"", $text);
+  $text = str_replace(":", "\:", $text);
   $text = str_replace(";", "\;", $text);
   $text = str_replace("\n", "\n ", $text);
   return $text;
 }
 
-/**                                                                                                                                                                   
+/**
  * Given the location of a valide iCalendar file, will return an array of event information
  *
  * @param $filename
  *   Location (local or remote) of a valid iCalendar file
- *                                                                                                                                                                   
- * @return                                                                                                                                                     
- *   An array of associative arrays where                                                                                                                             
+ *
+ * @return
+ *   An array of associative arrays where
  *      'start'         => Unix timestamp (GMT) of start time
  *      'end'           => Unix timestamp (GMT) of end time
  *      'allday_start'  => Start date of all-day event in YYYYMMDD format
- *      'allday_end'    => End date of all-day event in YYYYMMDD format                                                                              
- *      'summary'       => Title of event                                                                                                                      
- *      'description'   => Description of event                                                                                                                
- *      'location'      => Location of event                                                                                                                   
+ *      'allday_end'    => End date of all-day event in YYYYMMDD format
+ *      'summary'       => Title of event
+ *      'description'   => Description of event
+ *      'location'      => Location of event
  *      'uid'           => ID of the event in calendaring program
- *      'url'           => URL of event information                                                                                                                    * 
+ *      'url'           => URL of event information                                                                                                                    *
  */
 function ical_import($filename) {
   $items = array();
@@ -180,7 +180,7 @@
 	    $tz_tmp = explode('=', $field);
 	    $tz_dtstart = $tz_tmp[1];
 	    unset($tz_tmp);
-	  } 
+	  }
 	  elseif ($zulu_time) {
 	    $tz_dtstart = 'GMT';
 	  }
@@ -194,7 +194,7 @@
 	  if (isset($tz_dtstart)) {
 	    if ($tz = _ical_tz($tz_dtstart)) {
 	      $offset_tmp = date('I', $start_unixtime) ? $tz->offset_dst : $tz->offset;
-	    } 
+	    }
 	    else {
 	      $offset_tmp = '+0000';
 	    }
@@ -229,7 +229,7 @@
 	    $tz_tmp = explode('=', $field);
 	    $tz_dtend = $tz_tmp[1];
 	    unset($tz_tmp);
-	  } 
+	  }
 	  elseif ($zulu_time) {
 	    $tz_dtend = 'GMT';
 	  }
@@ -242,7 +242,7 @@
 	  if (isset($tz_dtend)) {
 	    if ($tz = _ical_tz($tz_dtend)) {
 	      $offset_tmp = date('I', $end_unixtime) ? $tz->offset_dst : $tz->offset;
-	    } 
+	    }
 	    else {
 	      $offset_tmp = '+0000';
 	    }
@@ -263,12 +263,12 @@
 	break;
       case 'DURATION':
 	if (!stristr($field, '=DURATION')) {
-	  ereg ('^P([0-9]{1,2}[W])?([0-9]{1,2}[D])?([T]{0,1})?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,2}[S])?', $data, $duration); 
-	  $weeks = str_replace('W', '', $duration[1]); 
-	  $days = str_replace('D', '', $duration[2]); 
-	  $hours = str_replace('H', '', $duration[4]); 
-	  $minutes = str_replace('M', '', $duration[5]); 
-	  $seconds = str_replace('S', '', $duration[6]); 
+	  ereg ('^P([0-9]{1,2}[W])?([0-9]{1,2}[D])?([T]{0,1})?([0-9]{1,2}[H])?([0-9]{1,2}[M])?([0-9]{1,2}[S])?', $data, $duration);
+	  $weeks = str_replace('W', '', $duration[1]);
+	  $days = str_replace('D', '', $duration[2]);
+	  $hours = str_replace('H', '', $duration[4]);
+	  $minutes = str_replace('M', '', $duration[5]);
+	  $seconds = str_replace('S', '', $duration[6]);
 	  $the_duration = ($weeks * 60 * 60 * 24 * 7) + ($days * 60 * 60 * 24) + ($hours * 60 * 60) + ($minutes * 60) + ($seconds);
 	}
 	break;
@@ -305,10 +305,14 @@
     return t('iCalendar API for Events Modules');
     break;
   }
-} 
+}
 
 function _ical_tz($tz) {
-  return db_fetch_object(db_query("SELECT * FROM {ical_timezones} WHERE timezone = '%s'", $tz));
+  include_once(drupal_get_path('module', 'event') .'/date_timezones.inc');
+  foreach (event_get_timezones() as $delta => $zone) {
+    if ($tz == $zone['timezone']);
+    return (object) $zone;
+  }
 }
 
 function _ical_chooseOffset($time, $timezone) {
