Index: trunk/calendar/inc/class.bocalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.bocalendar.inc.php	(revision 29)
+++ trunk/calendar/inc/class.bocalendar.inc.php	(revision 36)
@@ -2687,8 +2687,8 @@
 			}
 
-			if(!is_object($GLOBALS['phpgw']->send))
+			/*if(!is_object($GLOBALS['phpgw']->send))
 			{
 				$GLOBALS['phpgw']->send = CreateObject('phpgwapi.send');
-			}
+			}*/
 		//	$send = &$GLOBALS['phpgw']->send;
 			
@@ -2708,5 +2708,7 @@
 			foreach($to_notify as $userid => $statusid) 
 			{
-			
+			 	$mail->ClearAllRecipients();
+			 	$mail->ClearAttachments();
+			 	
 				$userid = (int)$userid;
 
@@ -2731,4 +2733,5 @@
 
 					$to = $preferences->email_address($userid);
+					
 					if (empty($to) || $to[0] == '@' || $to[0] == '$')	// we have no valid email-address
 					{
@@ -2945,5 +2948,5 @@
 							break;
 					}
-					$mail->AddAddress(implode(",",$to));	
+					$mail->AddAddress($to);
 					$mail->Body = $tmpbody;
 					$mail->From = $sender;
@@ -2957,4 +2960,5 @@
 					if(!$mail->Send())
 					{
+						
    						$returncode=false;
 					}
@@ -2991,6 +2995,7 @@
 						if($ex_participant)
 							$to[] = $ex_participant;
-				}
-				$mail->AddAddress(implode(",",$to));
+				}		
+				foreach($to as $i => $to_array)
+					$mail->AddAddress($to_array);
 				$_body = explode("<hr size='1' width='100%'>",$tmpbody);
 				$tmpbody = $_body[0];
@@ -2998,6 +3003,23 @@
 				$tmpbody.= "<br>".lang("Summary").": ".$this->so->cal->event[title]."<br>";
 				$tmpbody.= "<br>".lang("Start date").": ".$GLOBALS['phpgw']->common->show_date($starttime)."<br>".lang("End date").": ".$GLOBALS['phpgw']->common->show_date($endtime)."<br>";
-				$tmpbody.= "<br><br><hr size='1' width='100%'><font color='red'>".lang("This message was sent by server. You must send a message to sender to confirm this event")."</font>";
-			
+				$tmpbody.= "<br><br><hr size='1' width='100%'><font color='red'>"
+				.lang("This message was sent by server. You must send a message to sender to confirm this event")."<br>"
+				.lang("This is an external event. Even if it added to your expresso its can be changed any time at all")."</font><br>";
+				
+				if ($GLOBALS['bocalendar']->so->cal->event[start][month] > 10)
+					$event_month=$GLOBALS['bocalendar']->so->cal->event[start][month];
+				else
+					$event_month="0".$GLOBALS['bocalendar']->so->cal->event[start][month];
+				$tmpbody .="<a href='../index.php?menuaction=calendar.uicalendar.add&date="
+				.$GLOBALS['bocalendar']->so->cal->event[start][year]
+				.$event_month
+				.$GLOBALS['bocalendar']->so->cal->event[start][mday]
+				."&hour=".$GLOBALS['bocalendar']->so->cal->event[start][hour]
+				."&minute=".$GLOBALS['bocalendar']->so->cal->event[start][min]
+				."&title=".$GLOBALS['bocalendar']->so->cal->event['title']
+				."&description=".$GLOBALS['bocalendar']->so->cal->event['description']
+				."&location=".$GLOBALS['bocalendar']->so->cal->event['location']."'>"
+				."<h2>".lang("Add to my expresso")."</h2>";
+				
 				//attach extern vcard			
 				// define('context','$GLOBALS.bocalendar.so.cal.event');
@@ -3013,5 +3035,5 @@
 				fclose($attach_fd);
 				$mail->From = $sender;
-				$mail->FromName = lang("Expresso external user").": ".$GLOBALS['phpgw_info']['user']['fullname'];
+				$mail->FromName = $GLOBALS['phpgw_info']['user']['fullname'];
 				$mail->Sender = $mail->From;
 				$mail->SenderName = $mail->FromName;
Index: trunk/calendar/inc/class.uicalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.uicalendar.inc.php	(revision 29)
+++ trunk/calendar/inc/class.uicalendar.inc.php	(revision 36)
@@ -1181,11 +1181,20 @@
 				$endmin    = $startmin + (int)$this->bo->prefs['calendar']['defaultlength'];
 				$endhour   = $starthour + $this->bo->normalizeminutes($endmin);
-				;
+				
+				$subject	= (string)(get_var('title',array('GET'),0));
+				if ($subject != '0')
+				{
+					$description	= (string)(get_var('description',array('GET'),0));
+					$location	= (string)(get_var('location',array('GET'),0));
+				}
+				else
+					unset($subject);
+				
 				$this->bo->set_start($this->bo->year,$this->bo->month,$this->bo->day,$starthour,$startmin,0);
 				$this->bo->set_end($this->bo->year,$this->bo->month,$this->bo->day,$endhour,$endmin,0);
-				$this->bo->set_title('');
-				$this->bo->set_description('');
+				$this->bo->set_title($subject);
+				$this->bo->set_description($description);
+				$this->bo->add_attribute('location',$location);
 				$this->bo->set_ex_participants('');
-				$this->bo->add_attribute('location','');
 				$this->bo->add_attribute('uid','');
 				$this->bo->add_attribute('priority',2);
@@ -4005,6 +4014,9 @@
 										$user_context[] = $dn_part;
 								}
-								$user_context = implode(",",$user_context);
-								$combo_org = $this->get_organizations($context, trim(strtolower($user_context)));
+								// Prepara o contexto do usuario com sua OU raiz, pois ele pode pertencer a uma OU de nivel N.
+								$user_ou = explode(",",str_replace($context,"",implode(",",$user_context)));								
+								$user_context = trim(strtolower($user_ou[count($user_ou) - 2].",".$context));
+								// Fim
+								$combo_org = $this->get_sectors(trim(strtolower($user_context)));
 								$footer_ext_participantes = lang("Tip: To search in the <b>Global Catalog</b>, type the <b>F9</b> key, like the ExpressoMail.");
 								
@@ -4045,5 +4057,5 @@
 											"<script type='text/javascript'>var DEFAULT_URL = '".$module_name."/controller.php?action=';</script> ".											
 											"<script type='text/javascript'>" .
-											"setTimeout('get_available_users(\"".$module_name."\",\'".$user_context."\')',1000);" .
+											"setTimeout('get_available_users(\"".$module_name."\",\'".$user_context."\')',1000);". 
 											"</script> "
 												
@@ -4630,10 +4642,11 @@
 		}
 
-		function get_organizations($context, $selected='')
+		function get_sectors($selected='')
 		{
 			$s = CreateObject('phpgwapi.sector_search_ldap');
-			$sectors_info = $s->get_organizations($context, $selected, false, false);
+			$sectors_info = $s->get_sectors($selected, false, false);
 			return $sectors_info;
 		}
+		
 		/*
 		function get_organizations($context, $selected='')
