Index: branches/2.2/calendar/inc/class.bocalendar.inc.php
===================================================================
--- branches/2.2/calendar/inc/class.bocalendar.inc.php	(revision 1949)
+++ branches/2.2/calendar/inc/class.bocalendar.inc.php	(revision 3196)
@@ -2731,64 +2731,43 @@
 		}
 
-	function create_vcard($event_array)
-	{
-	if(!is_array($event_array))
-		return null;
-	$tmpattach="BEGIN:VCALENDAR\n"
-	."PRODID:-//Expresso Livre//Calendar//EN\n"
-	."VERSION:1.0\n";
-		foreach ($event_array as $event)
-		{
-			// It translates int to string
-			if (!is_object($event) && !is_array($event) || !array_key_exists  ('end', $event))
-				$event = $event_array;
-			if ( $event['end']['month'] < 10 )
-				$end_event_month="0".$event['end']['month'];
-			else
-				$end_event_month=$event['end']['month'];
-			if ( $event['start']['month'] < 10 )
-				$start_event_month="0".$event['start']['month'];
-			else
-				$start_event_month=$event['start']['month'];
-			if ( $event['end']['mday'] < 10 )
-				$end_event_day="0".$event['end']['mday'];
-			else
-				$end_event_day=$event['end']['mday'];
-			if ( $event['start']['mday'] < 10 )
-				$start_event_day="0".$event['start']['mday'];
-			else
-				$start_event_day=$event['start']['mday'];
-			if ( $event['start']['hour'] < 10)
-				$start_event_hour="0".$event['start']['hour'];
-			else
-				$start_event_hour=$event['start']['hour'];
-			if ( $event['end']['hour'] < 10)
-				$end_event_hour="0".$event['end']['hour'];
-			else
-				$end_event_hour=$event['end']['hour'];
-				
-			if ( $event['start']['min'] < 10)
-				$start_event_min="0".$event['start']['min'];
-			else
-				$start_event_min=$event['start']['min'];
-			if ( $event['end']['min'] < 10)
-				$end_event_min="0".$event['end']['min'];
-			else
-				$end_event_min=$event['end']['min'];	
-		
-
-			$tmpattach.="BEGIN:VEVENT\n"
-			."DTSTART:".$event['start'][year].$start_event_month.$start_event_day."T".$start_event_hour.$start_event_min."00Z\n"
-			."DTEND:".$event[end][year].$end_event_month.$end_event_day."T".$end_event_hour.$end_event_min."00Z\n"
-			."UID:Expresso-".$event[id].$event[uid]."\n"
-			."LAST-MODIFIED:".time()."\n"
-			."DESCRIPTION:".$event[description]."\n"
-			."SUMMARY:".$event[title]."\n"
-			."LOCATION:".$event[location]."\n"
-			."END:VEVENT"."\n";
-		}
-			$tmpattach.="END:VCALENDAR\n";
+		function create_vcard($event_array)
+		{
+			if(!is_array($event_array))
+				return null;
+			
+			$sy = $event_array['start']['year'];
+			$sm = $event_array['start']['month'];
+			$sd = $event_array['start']['mday'];
+			$sh = $event_array['start']['hour'];
+			$sn = $event_array['start']['min'];
+			$dtstart = sprintf("%04d%02d%02dT%02d%02d00Z", $sy, $sm, $sd, $sh, $sn);
+			
+			$ey = $event_array['end']['year'];
+			$em = $event_array['end']['month'];
+			$ed = $event_array['end']['mday'];
+			$eh = $event_array['end']['hour'];
+			$en = $event_array['end']['min'];
+			$dtend = sprintf("%04d%02d%02dT%02d%02d00Z", $ey, $em, $ed, $eh, $en);
+
+			// NecessÃ¡rio espaÃ§os apÃ³s quebra-de-linha, na descriÃ§Ã£o, caso contrÃ¡rio 
+			// ocorrerÃ¡ erro ao importar o agendamento no Outlook (erro lunar).
+			$description = str_replace("\n","\n ", $event_array['description']);
+			
+			$tmpattach="BEGIN:VCALENDAR\r\n"
+			."PRODID:-//Expresso Livre//Calendar//EN\r\n"
+			."VERSION:1.0\r\n"
+			."BEGIN:VEVENT\r\n"
+			."DTSTART:".$dtstart."\r\n"
+			."DTEND:".$dtend."\r\n"
+			."LAST-MODIFIED:".gmdate("Ymd\THis\Z")."\r\n" //Hora no formato UTC
+			."UID:Expresso-".$event_array['id'].$event_array['uid']."\r\n"
+			."DESCRIPTION:".$description."\r\n"
+			."SUMMARY:".$event_array['title']."\r\n"
+			."LOCATION:".$event_array['location']."\r\n"
+			."END:VEVENT\r\n"
+			."END:VCALENDAR\r\n";
+			
 			return $tmpattach;
-}
+		}
 
 		/*!
@@ -2802,7 +2781,5 @@
 		*/
 		function send_update($msg_type,$to_notify,$old_event,$new_event=False,$user=False)
-		{
-			
-			//echo "<p>bocalendar::send_update(type=$msg_type,to_notify="; print_r($to_notify); echo ", old_event="; print_r($old_event); echo ", new_event="; print_r($new_event); echo ", user=$user)</p>\n";
+		{			
 			if (!is_array($to_notify))
 			{
@@ -2947,5 +2924,5 @@
 			$mail->IsHTML(true);
 
-			// Aqui ï¿œ enviado o email
+			// Aqui e enviado o email
 			foreach($to_notify as $userid => $statusid) 
 			{
@@ -3253,5 +3230,5 @@
 				else
 					$event_month="0".$GLOBALS['bocalendar']->so->cal->event[start][month];
-				//attach extern vcard			
+				//attach extern vcalendar/icalendar (ics)			
 				// define('context','$GLOBALS.bocalendar.so.cal.event');
 				$tmpattach = $this->create_vcard($GLOBALS['bocalendar']->so->cal->event);
@@ -3274,5 +3251,5 @@
 					$attach_fd = fopen($filename,"w+");
 					fwrite($attach_fd,$tmpattach);
-					$mail->AddAttachment($filename, "extern.vcard", "base64", "text/plain"); // "application/octet-stream"
+					$mail->AddAttachment($filename, "extern.ics", "base64", "text/plain"); // "application/octet-stream"
 					fclose($attach_fd);
 				}
