Index: trunk/prototype/services/iCal.php
===================================================================
--- trunk/prototype/services/iCal.php	(revision 6996)
+++ trunk/prototype/services/iCal.php	(revision 7006)
@@ -109,5 +109,76 @@
 			    
 			    break;
-
+            case TASK_ID:
+
+                $todo = $ical->newComponent('todo');
+
+                $todo->setProperty('summary', $v['summary']);
+                $todo->setProperty('description', isset($v['description']) ? $v['description'] : '');
+                $todo->setProperty('priority', $v['priority']);
+                $todo->setProperty('percent-complete', $v['percentage']);
+                $todo->setProperty('status', $this->_getStatusTodo($v['status']));
+
+                $timezone = new DateTimeZone('UTC');
+                $apTimezone = self::nomalizeTZID(( isset($v['timezone']) && $v['timezone'] != 'null' ) ? $v['timezone'] : $params['defaultTZI']);
+                $apTimezoneOBJ = new DateTimeZone($apTimezone);
+
+                $sTime = new DateTime('@' . (int) ($v['startTime'] / 1000), $timezone);
+                $sTime->setTimezone($apTimezoneOBJ);
+                $eTime = new DateTime('@' . (int) ($v['endTime'] / 1000), $timezone);
+                $eTime->setTimezone($apTimezoneOBJ);
+
+                if (isset($v['allDay']) && $v['allDay'] == 1) {
+                    $todo->setProperty('dtstart', $sTime->format(DATE_RFC822), array("VALUE" => "DATE"));
+                    $todo->setProperty('dtend', $eTime->format(DATE_RFC822), array("VALUE" => "DATE"));
+                    //$todo->setProperty('X-MICROSOFT-CDO-ALLDAYEVENT', 'TRUE');
+                } else {
+                    $todo->setProperty('dtstart', $sTime->format(DATE_RFC822), array('TZID' => $apTimezone));
+                    $todo->setProperty('dtend', $eTime->format(DATE_RFC822), array('TZID' => $apTimezone));
+                    //$todo->setProperty('X-MICROSOFT-CDO-ALLDAYEVENT', 'FALSE');
+                }
+
+                if(isset($v['due']) && $v['due'] != ''){
+                    $dueTime = new DateTime('@' . (int) ($v['due'] / 1000), $timezone);
+                    $dueTime->setTimezone($apTimezoneOBJ);
+
+                    $todo->setProperty('due', $dueTime->format(DATE_RFC822), array('TZID' => $apTimezone));
+                }
+                
+                $todo->setProperty('due', $dueTime->format(DATE_RFC822), array('TZID' => $apTimezone));
+                       
+                if (isset($v['participants']) && is_array($v['participants']) && count($v['participants']) > 0)
+                    $participants = $v['participants'];
+                else
+                    $participants = Controller::find(array('concept' => 'participant'), false, array('filter' => array('=', 'schedulable', $v['id'])));
+                
+                if (is_array($participants) && count($participants) > 0)
+                    foreach ($participants as $ii => $vv) {
+                    
+                        if(isset($participants[$ii]['user']) && !is_array($participants[$ii]['user']))
+                        {
+                            if ($vv['isExternal'] == 1)
+                                $participants[$ii]['user'] = Controller::read(array('concept' => 'user', 'id' => $vv['user'], 'service' => 'PostgreSQL'));
+                            else
+                                $participants[$ii]['user'] = Controller::read(array('concept' => 'user', 'id' => $vv['user']));
+                        }
+                    
+                        if ($participants[$ii]['user']['id'] == Config::me('uidNumber'))
+                        {
+                            $alarms = (isset($participants[$ii]['alarms'])) ? $participants[$ii]['alarms'] : Controller::find(array('concept' => 'alarm'), null, array('filter' => array('AND', array('=', 'participant', $vv['id']), array('=', 'schedulable', $v['id']))));
+                            if(is_array($alarms))
+                                self::createAlarms($alarms, $todo);
+                        }
+                    
+                    }
+
+                if (isset($v['participants']) && is_array($v['participants']) && count($v['participants']) > 0)
+                    $this->createAttendee($v['participants'], $todo);
+
+                if (isset($v['attachments']) && is_array($v['attachments']) && count($v['attachments']) > 0)
+                    $this->createAttachment($v['attachments'], $todo);
+
+                $todo->setProperty('uid', $v['uid']);  
+                
+                break;
 			default:
 			    break;
@@ -412,17 +483,17 @@
 			case 'PUBLISH':
 			    //Caso o evento não exista o mesmo cria um novo evento, se já existir o mesmo referencia o evento com agenda
-                            if (!$schedulable = self::_getSchedulable($uid))
-				$interation = self::_makeVEVENT($schedulable, $component, $params);
-                            else{
-                                $links = Controller::read(array('concept' => 'calendarToSchedulable'), array('id'), array('filter' =>
-				array('AND',
-				    array('=', 'calendar', $params['calendar']),
-				    array('=', 'schedulable', $schedulable['id'])
-				)));
-
-                                if(!$links &&  !isset($links[0]))
-                                    Controller::create(array('concept' => 'calendarToSchedulable'), array('calendar' => $params['calendar'], 'schedulable' => $schedulable['id']));
-
-                                }
+                if (!$schedulable = self::_getSchedulable($uid))
+				    $interation = self::_makeVEVENT($schedulable, $component, $params);
+                else{
+                    $links = Controller::read(array('concept' => 'calendarToSchedulable'), array('id'), array('filter' =>
+        				array('AND',
+        				    array('=', 'calendar', $params['calendar']),
+        				    array('=', 'schedulable', $schedulable['id'])
+        				)));
+
+                    if(!$links &&  !isset($links[0]))
+                        Controller::create(array('concept' => 'calendarToSchedulable'), array('calendar' => $params['calendar'], 'schedulable' => $schedulable['id']));
+
+                    }
 			    break;
 
@@ -441,7 +512,16 @@
 					    $user = Controller::Read(array('concept' => 'user'), false, array('filter' => array('=', 'id', $params['owner'])) );					    
 					    $pID = self::_getParticipantByMail($user[0]['mail'], $schedulable['participants']);
-					}else
-					    $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']);
-					$interation['participant://' . $pID]['status'] = $params['status'];
+					}else{
+    					    $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']);
+                            //caso nõa seja participante adiciona a lista de participantes
+                            if(!$pID){
+                                $pID =  mt_rand() . '2(Formatter)';
+                                $interation['participant://' . $pID]['status'] = $params['status'];
+                                $interation['participant://' . $pID]['user'] = $params['owner'];
+                                $interation['participant://' . $pID]['isOrganizer'] = '0';
+                                $interation['participant://' . $pID]['schedulable'] = $schedulable['id'];
+                            }else
+    				            $interation['participant://' . $pID]['status'] = $params['status'];
+                        }
 				    }
 
@@ -1049,18 +1129,18 @@
 				foreach ($schedulable['participants'] as $value)
 				    if ($value['user']['id'] == $params['owner']) {
-					$isParticipant = true;
-					if ($value['isOrganizer'])
-					    $isOrganizer = true;
-
-					if (!self::_existInMyCalendars($schedulable['id'], $params['owner'])) {
-					    $interation = ICAL_ACTION_UPDATE;
-					    $interation = ( strrpos($value['acl'], ATTENDEE_ACL_PARTICIPATION_REQUIRED) ) ? ICAL_ACTION_IMPORT_REQUIRED : array('action' => ICAL_ACTION_IMPORT, 'type' => 'calendarIds');
-					    break;
-					}
+    					$isParticipant = true;
+    					if ($value['isOrganizer'])
+    					    $isOrganizer = true;
+
+    					if (!self::_existInMyCalendars($schedulable['id'], $params['owner'])) {
+    					    $interation = ICAL_ACTION_UPDATE;
+    					    $interation = ( strrpos($value['acl'], ATTENDEE_ACL_PARTICIPATION_REQUIRED) ) ? ICAL_ACTION_IMPORT_REQUIRED : array('action' => ICAL_ACTION_IMPORT, 'type' => 'calendarIds');
+    					    break;
+    					}
 				    } else {
-					if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) //Organizador esta requisitando que você atualize o evento
-					    $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_UPDATE : ICAL_ACTION_UPDATE;
-					else
-					    $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_NONE : ICAL_ACTION_NONE;
+    					if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) //Organizador esta requisitando que você atualize o evento
+    					    $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_UPDATE : ICAL_ACTION_UPDATE;
+    					else
+    					    $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_NONE : ICAL_ACTION_NONE;
 				    }
 				if (!$isParticipant){
@@ -1068,5 +1148,5 @@
 				    }
 			    }else
-				$interation = array('action' => ICAL_ACTION_IMPORT, 'type' => 'calendarIds');
+				    $interation = array('action' => ICAL_ACTION_IMPORT, 'type' => 'calendarIds');
 			    
 			    if(($interation != ICAL_ACTION_NONE) && ($interation != ICAL_ACTION_ORGANIZER_NONE) && ($interation != ICAL_ACTION_ORGANIZER_UPDATE) && ($interation != ICAL_ACTION_NONE)) {
@@ -1269,26 +1349,26 @@
     private static function _checkParticipantByPermissions($schedulable) {
 
-	$calendarIds = Controller::find(array('concept' => 'calendarSignature'), array('calendar'), array('filter' => array('AND', array('=','isOwner','0'), array('=', 'user', Config::me("uidNumber")))));
-
-	if($calendarIds && isset($calendarIds[0])){
-	    $ids = array();
-	    foreach($calendarIds as $value)
-		    array_push($ids, $value['calendar']);
-
-	    $signaturesOfOwners = Controller::find(array('concept' => 'calendarSignature'), false, array('filter' => array('AND', array('IN', 'calendar', $ids) , array('=','isOwner','1')), 'deepness' => 2 ));
-	    
-	    foreach($signaturesOfOwners as $value){
-		if(self::_getParticipantByMail($value['user']['mail'], $schedulable['participants'])){
-		    $eventoFromCalendar = Controller::read( array( 'concept' => 'calendarToSchedulable') , false, array('filter' => array('AND', array('=','schedulable',$schedulable['id']), array('=','calendar', $value['calendar']['id']))));
-
-		    return  ($eventoFromCalendar && isset($eventoFromCalendar[0])) ? ICAL_ACTION_NONE_FROM_PERMISSION : array('action' => ICAL_ACTION_IMPORT_FROM_PERMISSION, 'calendar' => array($value['calendar']['id']) );
-		}
-	    }    
-	}
-	return ICAL_ACTION_ORGANIZER_NONE;
+    	$calendarIds = Controller::find(array('concept' => 'calendarSignature'), array('calendar'), array('filter' => array('AND', array('=','isOwner','0'), array('=', 'user', Config::me("uidNumber")))));
+
+    	if($calendarIds && isset($calendarIds[0])){
+    	    $ids = array();
+    	    foreach($calendarIds as $value)
+    		    array_push($ids, $value['calendar']);
+
+    	    $signaturesOfOwners = Controller::find(array('concept' => 'calendarSignature'), false, array('filter' => array('AND', array('IN', 'calendar', $ids) , array('=','isOwner','1')), 'deepness' => 2 ));
+    	    
+    	    foreach($signaturesOfOwners as $value){
+        		if(self::_getParticipantByMail($value['user']['mail'], $schedulable['participants'])){
+        		    $eventoFromCalendar = Controller::read( array( 'concept' => 'calendarToSchedulable') , false, array('filter' => array('AND', array('=','schedulable',$schedulable['id']), array('=','calendar', $value['calendar']['id']))));
+
+        		    return  ($eventoFromCalendar && isset($eventoFromCalendar[0])) ? ICAL_ACTION_NONE_FROM_PERMISSION : array('action' => ICAL_ACTION_IMPORT_FROM_PERMISSION, 'calendar' => array($value['calendar']['id']) );
+        		}
+    	    }    
+    	}
+    	return array('action' => ICAL_ACTION_IMPORT, 'type' => 'calendarIds');
     }
     
     
-    private static function _getParticipantByMail($mail, &$participants, $isFull) {
+    private static function _getParticipantByMail($mail, &$participants, $isFull = false) {
 	if ($participants && $participants != '')
 	    foreach ($participants as $i => $v)
@@ -1382,285 +1462,291 @@
     }
 
-        static private function _makeVEVENT($schedulable, $component, $params) {
-	$interation = array();
-	$eventID = isset($schedulable['id']) ? $schedulable['id'] : mt_rand() . '(Formatter)';
-
-	/* Data de Inicio */
-	$startTime = $component->getProperty('dtstart', false, true);
-
-	$tzid = (isset($startTime['params']['TZID']) ? $startTime['params']['TZID'] : $params['X-WR-TIMEZONE']);
-
-	/* Tiem zone do evento */
-	if ($tzid){
-	    $tzid = self::nomalizeTZID($tzid);
-	    $schedulable['timezone'] = $tzid;
-	}else
-	    $schedulable['timezone'] = isset($params['calendar_timezone']) ? $params['calendar_timezone'] : 'America/Sao_Paulo';
-
-	$objTimezone = new DateTimeZone($schedulable['timezone']);
-
-	if (isset($startTime['params']['VALUE']) && $startTime['params']['VALUE'] === 'DATE' && isset($params['calendar_timezone'])) {
-	    $schedulable['allDay'] = 1;
-	    $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $schedulable['timezone'], '@' . self::date2timestamp($startTime['value'])) . '000';
-	} elseif ($tzid && !isset($startTime['value']['tz'])) {/* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */
-	    $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $tzid, '@' . self::date2timestamp($startTime['value'])) . '000';
-	    $schedulable['allDay'] = 0;
-	} else {
-	    $schedulable['startTime'] = self::date2timestamp($startTime['value']) . '000';
-	    if (strpos($params['prodid'], 'Outlook') !== false) {
-		//Se o ics veio em utc não aplicar horario de verão
-		$sTime = new DateTime('@' . (int) ($schedulable['startTime'] / 1000), new DateTimeZone('UTC'));
-		$sTime->setTimezone($objTimezone);
-		if ($sTime->format('I')) //Se o ics veio em utc não aplicar horario de verão
-		    $schedulable['startTime'] = $schedulable['startTime'] - 3600000;
-	    }
-	}
-
-	/* Data de Termino */
-	$endTime = $component->getProperty('dtend', false, true);
-
-	$tzid = isset($endTime['params']['TZID']) ? $endTime['params']['TZID'] : $params['X-WR-TIMEZONE'];
-	
-	if($tzid)
-	    $tzid = self::nomalizeTZID($tzid);
-
-	if (isset($endTime['params']['VALUE']) && $endTime['params']['VALUE'] === 'DATE')
-	    $schedulable['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $schedulable['timezone'], '@' . self::date2timestamp($endTime['value'])) . '000';
-	else if ($tzid && !isset($endTime['value']['tz'])) /* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */
-	    $schedulable['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $tzid, '@' . self::date2timestamp($endTime['value'])) . '000';
-	else {
-	    $schedulable['endTime'] = self::date2timestamp($endTime['value']) . '000';
-	    if (strpos($params['prodid'], 'Outlook') !== false) {
-		//Se o ics veio em utc não aplicar horario de verão
-		$eTime = new DateTime('@' . (int) ($schedulable['endTime'] / 1000), new DateTimeZone('UTC'));
-		$eTime->setTimezone($objTimezone);
-		if ($eTime->format('I'))
-		    $schedulable['endTime'] = $schedulable['endTime'] - 3600000;
-	    }
-	}
-
-
-	$schedulable['summary'] = mb_convert_encoding($component->getProperty('summary', false, false), 'ISO-8859-1', 'UTF-8,ISO-8859-1');
-
-	/* Definindo Description */
-	if ($desc = $component->getProperty('description', false, false))
-	    $schedulable['description'] = mb_convert_encoding(str_ireplace(array('\n', '\t'), array("\n", "\t"), $desc), 'ISO-8859-1', 'UTF-8,ISO-8859-1');
-
-	/* Definindo location */
-	if ($location = $component->getProperty('location', false, false))
-	    $schedulable['location'] = mb_convert_encoding($location, 'ISO-8859-1', 'UTF-8,ISO-8859-1');
-
-
-	/* Definindo Class */
-	$class = $component->getProperty('class', false, false);
-	if ($class && defined(constant(strtoupper('CLASS_' . $class))))
-	    $schedulable['class'] = constant(strtoupper('CLASS_' . $class));
-	else if (!isset($schedulable['class']))
-	    $schedulable['class'] = CLASS_PRIVATE; // padrão classe private
-
-	/* Definindo RRULE */
-	if ($rrule = $component->getProperty('rrule', false, false)) {
-	    /* Gera um randon id para o contexto formater */
-	    $repeatID = mt_rand() . '3(Formatter)';
-
-	    $repeat = array();
-	    $repeat['schedulable'] = $eventID;
-	    foreach ($rrule as $i => $v) {
-		if (strtolower($i) == 'freq')
-		    $repeat['frequency'] = $v;
-		else if (strtolower($i) == 'until')
-		    $repeat['endTime'] = $v;
-		else
-		    $repeat[strtolower($i)] = $v;
-	    }
-
-	    $interation['repeat://' . $repeatID] = $repeat;
-	}
-
-
-	$schedulable['calendar'] = $params['calendar'];
-
-	$participantsInEvent = array();
-
-	//TODO: Participants com delegated nao estao sendo levados em conta
-	while ($property = $component->getProperty('attendee', FALSE, TRUE)) {
-	    $participant = array();
-
-	    $mailUser = trim(str_replace('MAILTO:', '', $property['value']));
-
-	    $participantID = ($tpID = self::_getParticipantByMail($mailUser, $schedulable['participants'])) ? $tpID : mt_rand() . '2(Formatter)';
-	    $participant['schedulable'] = $eventID;
-
-	    if (isset($params['status']) && $mailUser == Config::me('mail'))
-		$participant['status'] = $params['status'];
-	    else
-		$participant['status'] = (isset($property['params']['PARTSTAT']) && constant('STATUS_' . $property['params']['PARTSTAT']) !== null ) ? constant('STATUS_' . $property['params']['PARTSTAT']) : STATUS_UNANSWERED;
-
-
-	    $participant['isOrganizer'] = '0';
-
-	    /* Verifica se este usuario é um usuario interno do ldap */
-	    $intUser = Controller::find(array('concept' => 'user'), array('id', 'isExternal'), array('filter' => array('OR', array('=', 'mail', $mailUser), array('=', 'mailAlternateAddress', $mailUser))));
-
-	    $user = null;
-	    if ($intUser && count($intUser) > 0) {
-		$participant['isExternal'] = isset($intUser[0]['isExternal']) ? $intUser[0]['isExternal'] : 0;
-		$participant['user'] = $intUser[0]['id'];
-	    } else {
-		$participant['isExternal'] = 1;
-		/* Gera um randon id para o contexto formater */
-		$userID = mt_rand() . '4(Formatter)';
-
-		$user['mail'] = $mailUser;
-		$user['isExternal'] = '1';
-		$user['name'] = ( isset($property['params']['CN']) ) ? $property['params']['CN'] : '';
-		$user['participants'] = array($participantID);
-		$participant['user'] = $userID;
-		$interation['user://' . $userID] = $user;
-	    }
-
-	    $interation['participant://' . $participantID] = $participant;
-	    $schedulable['participants'][] = $participantID;
-	};
-
-	if ($property = $component->getProperty('organizer', FALSE, TRUE)) {
-	    $participant = array();
-	    $mailUser = trim(str_replace('MAILTO:', '', $property['value']));
-
-	    $participantID = mt_rand() . '2(Formatter)';
-
-	    $participant['schedulable'] = $eventID;
-	    $participant['status'] = (isset($property['params']['PARTSTAT']) && constant('STATUS_' . $property['params']['PARTSTAT']) !== null ) ? constant('STATUS_' . $property['params']['PARTSTAT']) : STATUS_UNANSWERED;
-	    $participant['isOrganizer'] = '1';
-	    $participant['acl'] = 'rowi';
-
-	    /* Verifica se este usuario é um usuario interno do ldap */
-	    $intUser = Controller::find(array('concept' => 'user'), array('id', 'isExternal'), array('filter' => array('OR', array('=', 'mail', $mailUser), array('=', 'mailAlternateAddress', $mailUser))));
-
-	    $user = null;
-	    if ($intUser && count($intUser) > 0) {
-		$participant['isExternal'] = isset($intUser[0]['isExternal']) ? $intUser[0]['isExternal'] : 0;
-		$participant['user'] = $intUser[0]['id'];
-	    } else {
-		$participant['isExternal'] = 1;
-		/* Gera um randon id para o contexto formater */
-		$userID = mt_rand() . '4(Formatter)';
-
-		$user['mail'] = $mailUser;
-		$user['name'] = ( isset($property['params']['CN']) ) ? $property['params']['CN'] : '';
-		$user['participants'] = array($participantID);
-		$user['isExternal'] = '1';
-		$participant['user'] = $userID;
-		$interation['user://' . $userID] = $user;
-	    }
-
-	    $interation['participant://' . $participantID] = $participant;
-	    $schedulable['participants'][] = $participantID;
-	} else if (!is_array($schedulable['participants']) || count($schedulable['participants']) < 1) {//caso não tenha organizador o usuario se torna organizador
-	    $user = Controller::read(array('concept' => 'user', 'id' => $params['owner']), array('mail'));
-
-	    if (!self::_getParticipantByMail($user['mail'], $schedulable['participants'])) {
-		$participantID = mt_rand() . '2(Formatter)';
-
-		$participant['schedulable'] = $eventID;
-		$participant['status'] = STATUS_CONFIRMED;
-		$participant['isOrganizer'] = '1';
-		$participant['acl'] = 'rowi';
-		$participant['isExternal'] = 0;
-		$participant['user'] = $params['owner'];
-		$interation['participant://' . $participantID] = $participant;
-		$schedulable['participants'][] = $participantID;
-	    }
-	}
-	
-	$alarms = array();
-	
-	/* Definindo ALARMES */
-	while ($alarmComp = $component->getComponent('valarm'))
-	{
-		$alarm = array();
-		$alarmID = mt_rand() . '6(Formatter)';
-		$action =  $alarmComp->getProperty('action', false, true);
-		$trygger = $alarmComp->getProperty('trigger', false, true);
-		$alarm['type'] = self::decodeAlarmAction($action['value']);
-
-		 if(isset($trygger['value']['day']))
-		{
-			$alarm['time'] = $trygger['value']['day'];
-			$alarm['unit'] = 'd';
-		}
-		else if(isset($trygger['value']['hour']))
-		{
-			$alarm['time'] = $trygger['value']['hour'];
-			$alarm['unit'] = 'h';
- 		}
-		else if(isset($trygger['value']['min']))
-		{
-			$alarm['time'] = $trygger['value']['min'];
-			$alarm['unit'] = 'm';
-		}
-		
-		foreach ($interation as $iint => &$vint)
-		{
-			if(isset($vint['user']) && $vint['user'] == Config::me('uidNumber'))
-			{
-				$alarm['participant'] = str_replace('participant://', '', $iint);	
-				$vint['alarms'][] = $alarmID;
-			}
-		}
-		$alarm['schedulable'] = $eventID;
-				
-		$interation['alarm://' . $alarmID ] = $alarm;
-		
-	}
-	
-	
-	/* Definindo DTSTAMP */
-	if ($dtstamp = self::_getTime($component, 'dtstamp'))
-	    $schedulable['dtstamp'] = $dtstamp;
-
-	/* Definindo TRANSP */
-	if (($tranp = $component->getProperty('transp', false, true)) && $tranp && is_string($tranp) && strtoupper($tranp) == 'OPAQUE')
-	    $schedulable['transparent'] = 1;
-
-	/* Definindo last_update */
-	if ($lastUpdate = self::_getTime($component, 'LAST-MODIFIED'))
-	    $schedulable['lastUpdate'] = $lastUpdate;
-
-
-	if ($sequence = $component->getProperty('SEQUENCE', false, false))
-	    $schedulable['sequence'] = $sequence;
-
-	if ($uid = $component->getProperty('uid', false, false))
-	    ;
-	$schedulable['uid'] = $uid;
-
-	while ($attach = $component->getProperty('ATTACH', FALSE, TRUE)) {
-
-	    $attachCurrent = array('name' => $attach['params']['X-FILENAME'],
-		'size' => strlen($attach['value']),
-		'type' => self::_getContentType($attach['params']['X-FILENAME'])
-	    );
-
-	    $ids = Controller::find(array('concept' => 'attachment'), array('id'), array('filter' => array('AND', array('=', 'name', $attachCurrent['name']), array('=', 'size', $attachCurrent['size']), array('=', 'type', $attachCurrent['type']))));
-
-	    if (!is_array($ids)) {
-		$attachCurrent['source'] = $attach['value'];
-		//insere o anexo no banco e pega id para colcar no relacionamento				
-		$idAttachment = Controller::create(array('concept' => 'attachment'), $attachCurrent);
-	    }else
-		$idAttachment = array('id' => $ids[0]['id']);
-
-	    $calendarToAttachmentId = mt_rand() . '2(Formatter)';
-	    $calendarToAttachment['attachment'] = $idAttachment['id'];
-	    $calendarToAttachment['schedulable'] = $eventID;
-	    $interation['schedulableToAttachment://' . $calendarToAttachmentId] = $calendarToAttachment;
-
-	    $schedulable['attachments'][] = $calendarToAttachmentId;
-	}
-
-	$interation['schedulable://' . $eventID] = $schedulable;
-
-	return $interation;
+    static private function _makeVEVENT($schedulable, $component, $params) {
+    	$interation = array();
+    	$eventID = isset($schedulable['id']) ? $schedulable['id'] : mt_rand() . '(Formatter)';
+
+    	/* Data de Inicio */
+    	$startTime = $component->getProperty('dtstart', false, true);
+
+    	$tzid = (isset($startTime['params']['TZID']) ? $startTime['params']['TZID'] : $params['X-WR-TIMEZONE']);
+
+    	/* Tiem zone do evento */
+    	if ($tzid){
+    	    $tzid = self::nomalizeTZID($tzid);
+    	    $schedulable['timezone'] = $tzid;
+    	}else
+    	    $schedulable['timezone'] = isset($params['calendar_timezone']) ? $params['calendar_timezone'] : 'America/Sao_Paulo';
+
+    	$objTimezone = new DateTimeZone($schedulable['timezone']);
+
+    	if (isset($startTime['params']['VALUE']) && $startTime['params']['VALUE'] === 'DATE' && isset($params['calendar_timezone'])) {
+    	    $schedulable['allDay'] = 1;
+    	    $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $schedulable['timezone'], '@' . self::date2timestamp($startTime['value'])) . '000';
+    	} elseif ($tzid && !isset($startTime['value']['tz'])) {/* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */
+    	    $schedulable['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $tzid, '@' . self::date2timestamp($startTime['value'])) . '000';
+    	    $schedulable['allDay'] = 0;
+    	} else {
+    	    $schedulable['startTime'] = self::date2timestamp($startTime['value']) . '000';
+    	    if (strpos($params['prodid'], 'Outlook') !== false) {
+    		//Se o ics veio em utc não aplicar horario de verão
+    		$sTime = new DateTime('@' . (int) ($schedulable['startTime'] / 1000), new DateTimeZone('UTC'));
+    		$sTime->setTimezone($objTimezone);
+    		if ($sTime->format('I')) //Se o ics veio em utc não aplicar horario de verão
+    		    $schedulable['startTime'] = $schedulable['startTime'] - 3600000;
+    	    }
+    	}
+
+    	/* Data de Termino */
+    	$endTime = $component->getProperty('dtend', false, true);
+
+    	$tzid = isset($endTime['params']['TZID']) ? $endTime['params']['TZID'] : $params['X-WR-TIMEZONE'];
+    	
+    	if($tzid)
+    	    $tzid = self::nomalizeTZID($tzid);
+
+    	if (isset($endTime['params']['VALUE']) && $endTime['params']['VALUE'] === 'DATE')
+    	    $schedulable['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $schedulable['timezone'], '@' . self::date2timestamp($endTime['value'])) . '000';
+    	else if ($tzid && !isset($endTime['value']['tz'])) /* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */
+    	    $schedulable['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $tzid, '@' . self::date2timestamp($endTime['value'])) . '000';
+    	else {
+    	    $schedulable['endTime'] = self::date2timestamp($endTime['value']) . '000';
+    	    if (strpos($params['prodid'], 'Outlook') !== false) {
+    		//Se o ics veio em utc não aplicar horario de verão
+    		$eTime = new DateTime('@' . (int) ($schedulable['endTime'] / 1000), new DateTimeZone('UTC'));
+    		$eTime->setTimezone($objTimezone);
+    		if ($eTime->format('I'))
+    		    $schedulable['endTime'] = $schedulable['endTime'] - 3600000;
+    	    }
+    	}
+
+
+    	$schedulable['summary'] = mb_convert_encoding($component->getProperty('summary', false, false), 'ISO-8859-1', 'UTF-8,ISO-8859-1');
+
+    	/* Definindo Description */
+    	if ($desc = $component->getProperty('description', false, false))
+    	    $schedulable['description'] = mb_convert_encoding(str_ireplace(array('\n', '\t'), array("\n", "\t"), $desc), 'ISO-8859-1', 'UTF-8,ISO-8859-1');
+
+    	/* Definindo location */
+    	if ($location = $component->getProperty('location', false, false))
+    	    $schedulable['location'] = mb_convert_encoding($location, 'ISO-8859-1', 'UTF-8,ISO-8859-1');
+
+
+    	/* Definindo Class */
+    	$class = $component->getProperty('class', false, false);
+    	if ($class && defined(constant(strtoupper('CLASS_' . $class))))
+    	    $schedulable['class'] = constant(strtoupper('CLASS_' . $class));
+    	else if (!isset($schedulable['class']))
+    	    $schedulable['class'] = CLASS_PRIVATE; // padrão classe private
+
+    	/* Definindo RRULE */
+    	if ($rrule = $component->getProperty('rrule', false, false)) {
+    	    /* Gera um randon id para o contexto formater */
+    	    $repeatID = mt_rand() . '3(Formatter)';
+
+    	    $repeat = array();
+    	    $repeat['schedulable'] = $eventID;
+    	    foreach ($rrule as $i => $v) {
+    		if (strtolower($i) == 'freq')
+    		    $repeat['frequency'] = $v;
+    		else if (strtolower($i) == 'until')
+    		    $repeat['endTime'] = $v;
+    		else
+    		    $repeat[strtolower($i)] = $v;
+    	    }
+
+    	    $interation['repeat://' . $repeatID] = $repeat;
+    	}
+
+
+    	$schedulable['calendar'] = $params['calendar'];
+
+    	$participantsInEvent = array();
+
+    	//TODO: Participants com delegated nao estao sendo levados em conta
+    	while ($property = $component->getProperty('attendee', FALSE, TRUE)) {
+    	    $participant = array();
+
+    	    $mailUser = trim(str_replace('MAILTO:', '', $property['value']));
+
+    	    $participantID = ($tpID = self::_getParticipantByMail($mailUser, $schedulable['participants'])) ? $tpID : mt_rand() . '2(Formatter)';
+    	    $participant['schedulable'] = $eventID;
+
+    	    if (isset($params['status']) && $mailUser == Config::me('mail'))
+    		$participant['status'] = $params['status'];
+    	    else
+    		$participant['status'] = (isset($property['params']['PARTSTAT']) && constant('STATUS_' . $property['params']['PARTSTAT']) !== null ) ? constant('STATUS_' . $property['params']['PARTSTAT']) : STATUS_UNANSWERED;
+
+
+    	    $participant['isOrganizer'] = '0';
+
+    	    /* Verifica se este usuario é um usuario interno do ldap */
+    	    $intUser = Controller::find(array('concept' => 'user'), array('id', 'isExternal'), array('filter' => array('OR', array('=', 'mail', $mailUser), array('=', 'mailAlternateAddress', $mailUser))));
+
+    	    $user = null;
+    	    if ($intUser && count($intUser) > 0) {
+    		$participant['isExternal'] = isset($intUser[0]['isExternal']) ? $intUser[0]['isExternal'] : 0;
+    		$participant['user'] = $intUser[0]['id'];
+    	    } else {
+    		$participant['isExternal'] = 1;
+    		/* Gera um randon id para o contexto formater */
+    		$userID = mt_rand() . '4(Formatter)';
+
+    		$user['mail'] = $mailUser;
+    		$user['isExternal'] = '1';
+    		$user['name'] = ( isset($property['params']['CN']) ) ? $property['params']['CN'] : '';
+    		$user['participants'] = array($participantID);
+    		$participant['user'] = $userID;
+    		$interation['user://' . $userID] = $user;
+    	    }
+
+    	    $interation['participant://' . $participantID] = $participant;
+    	    $schedulable['participants'][] = $participantID;
+    	};
+
+    	if ($property = $component->getProperty('organizer', FALSE, TRUE)) {
+    	    $participant = array();
+    	    $mailUser = trim(str_replace('MAILTO:', '', $property['value']));
+
+    	    $participantID = mt_rand() . '2(Formatter)';
+
+    	    $participant['schedulable'] = $eventID;
+    	    $participant['status'] = (isset($property['params']['PARTSTAT']) && constant('STATUS_' . $property['params']['PARTSTAT']) !== null ) ? constant('STATUS_' . $property['params']['PARTSTAT']) : STATUS_UNANSWERED;
+    	    $participant['isOrganizer'] = '1';
+    	    $participant['acl'] = 'rowi';
+
+    	    /* Verifica se este usuario é um usuario interno do ldap */
+    	    $intUser = Controller::find(array('concept' => 'user'), array('id', 'isExternal'), array('filter' => array('OR', array('=', 'mail', $mailUser), array('=', 'mailAlternateAddress', $mailUser))));
+
+    	    $user = null;
+    	    if ($intUser && count($intUser) > 0) {
+    		$participant['isExternal'] = isset($intUser[0]['isExternal']) ? $intUser[0]['isExternal'] : 0;
+    		$participant['user'] = $intUser[0]['id'];
+    	    } else {
+    		$participant['isExternal'] = 1;
+    		/* Gera um randon id para o contexto formater */
+    		$userID = mt_rand() . '4(Formatter)';
+
+    		$user['mail'] = $mailUser;
+    		$user['name'] = ( isset($property['params']['CN']) ) ? $property['params']['CN'] : '';
+    		$user['participants'] = array($participantID);
+    		$user['isExternal'] = '1';
+    		$participant['user'] = $userID;
+    		$interation['user://' . $userID] = $user;
+    	    }
+
+    	    $interation['participant://' . $participantID] = $participant;
+    	    $schedulable['participants'][] = $participantID;
+    	} else if (!isset($schedulable['participants']) || !is_array($schedulable['participants']) || count($schedulable['participants']) < 1) {//caso não tenha organizador o usuario se torna organizador
+    	    $user = Controller::read(array('concept' => 'user', 'id' => $params['owner']), array('mail'));
+
+    	    if (!self::_getParticipantByMail($user['mail'], $schedulable['participants'])) {
+        		$participantID = mt_rand() . '2(Formatter)';
+
+        		$participant['schedulable'] = $eventID;
+        		$participant['status'] = STATUS_CONFIRMED;
+        		$participant['isOrganizer'] = '1';
+        		$participant['acl'] = 'rowi';
+        		$participant['isExternal'] = 0;
+        		$participant['user'] = $params['owner'];
+        		$interation['participant://' . $participantID] = $participant;
+        		$schedulable['participants'][] = $participantID;
+    	    }
+    	}
+    	
+    	$alarms = array();
+    	
+    	/* Definindo ALARMES */
+    	while ($alarmComp = $component->getComponent('valarm'))
+    	{
+    		$alarm = array();
+    		$alarmID = mt_rand() . '6(Formatter)';
+    		$action =  $alarmComp->getProperty('action', false, true);
+    		$trygger = $alarmComp->getProperty('trigger', false, true);
+    		$alarm['type'] = self::decodeAlarmAction($action['value']);
+
+    		 if(isset($trygger['value']['day']))
+    		{
+    			$alarm['time'] = $trygger['value']['day'];
+    			$alarm['unit'] = 'd';
+    		}
+    		else if(isset($trygger['value']['hour']))
+    		{
+    			$alarm['time'] = $trygger['value']['hour'];
+    			$alarm['unit'] = 'h';
+     		}
+    		else if(isset($trygger['value']['min']))
+    		{
+    			$alarm['time'] = $trygger['value']['min'];
+    			$alarm['unit'] = 'm';
+    		}
+    		
+    		foreach ($interation as $iint => &$vint)
+    		{
+    			if(isset($vint['user']) && $vint['user'] == Config::me('uidNumber'))
+    			{
+    				$alarm['participant'] = str_replace('participant://', '', $iint);	
+    				$vint['alarms'][] = $alarmID;
+    			}
+    		}
+    		$alarm['schedulable'] = $eventID;
+    				
+    		$interation['alarm://' . $alarmID ] = $alarm;
+    		
+    	}
+    	
+    	
+    	/* Definindo DTSTAMP */
+    	if ($dtstamp = self::_getTime($component, 'dtstamp'))
+    	    $schedulable['dtstamp'] = $dtstamp;
+
+    	/* Definindo TRANSP */
+    	if (($tranp = $component->getProperty('transp', false, true)) && $tranp && is_string($tranp) && strtoupper($tranp) == 'OPAQUE')
+    	    $schedulable['transparent'] = 1;
+
+    	/* Definindo last_update */
+    	if ($lastUpdate = self::_getTime($component, 'LAST-MODIFIED'))
+    	    $schedulable['lastUpdate'] = $lastUpdate;
+
+
+    	if ($sequence = $component->getProperty('SEQUENCE', false, false))
+    	    $schedulable['sequence'] = $sequence;
+
+    	if ($uid = $component->getProperty('uid', false, false))
+    	    ;
+    	$schedulable['uid'] = $uid;
+
+    	while ($attach = $component->getProperty('ATTACH', FALSE, TRUE)) {
+
+    	    $attachCurrent = array('name' => $attach['params']['X-FILENAME'],
+    		'size' => strlen($attach['value']),
+    		'type' => self::_getContentType($attach['params']['X-FILENAME'])
+    	    );
+
+    	    $ids = Controller::find(array('concept' => 'attachment'), array('id'), array('filter' => array('AND', array('=', 'name', $attachCurrent['name']), array('=', 'size', $attachCurrent['size']), array('=', 'type', $attachCurrent['type']))));
+
+    	    if (!is_array($ids)) {
+    		$attachCurrent['source'] = $attach['value'];
+    		//insere o anexo no banco e pega id para colcar no relacionamento				
+    		$idAttachment = Controller::create(array('concept' => 'attachment'), $attachCurrent);
+    	    }else
+    		$idAttachment = array('id' => $ids[0]['id']);
+
+    	    $calendarToAttachmentId = mt_rand() . '2(Formatter)';
+    	    $calendarToAttachment['attachment'] = $idAttachment['id'];
+    	    $calendarToAttachment['schedulable'] = $eventID;
+    	    $interation['schedulableToAttachment://' . $calendarToAttachmentId] = $calendarToAttachment;
+
+    	    $schedulable['attachments'][] = $calendarToAttachmentId;
+    	}
+
+        $schedulable['type'] = '1';
+
+    	$interation['schedulable://' . $eventID] = $schedulable;
+
+
+
+
+
+    	return $interation;
     }
     
Index: trunk/prototype/modules/calendar/interceptors/DBMapping.php
===================================================================
--- trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 6996)
+++ trunk/prototype/modules/calendar/interceptors/DBMapping.php	(revision 7006)
@@ -13,16 +13,18 @@
     {
 
-    	if (isset($params['startTime']) && !is_numeric($params['startTime'])){
+    	if (isset($params['startTime']) && !is_numeric($params['startTime']))
     	    $params['startTime'] = self::parseTimeDate($params['startTime'], $params['timezone']);
-	    $params['rangeStart'] = $params['startTime'];
-	}
+	
+        $params['rangeStart'] = $params['startTime'];
+	
     	if (isset($params['endTime']) && !is_numeric($params['endTime'])) {
     	    $params['endTime'] = self::parseTimeDate($params['endTime'], $params['timezone']);
 
     	    if ($params['allDay'])
-    		$params['endTime'] = $params['endTime'] + 86400000;
+    	       	$params['endTime'] = $params['endTime'] + 86400000;
+	    }
 	    
-	    $params['rangeEnd'] = $params['endTime'];
-    	}
+        $params['rangeEnd'] = $params['endTime'];
+    	
 
         if (isset($params['due']) && $params['due'] != '' && !is_numeric($params['due']))
Index: trunk/prototype/modules/calendar/css/style.css
===================================================================
--- trunk/prototype/modules/calendar/css/style.css	(revision 6996)
+++ trunk/prototype/modules/calendar/css/style.css	(revision 7006)
@@ -543,7 +543,7 @@
 .calendar-addevent-details-txt-timezone, .calendar-addtask-details-txt-timezone{width: 217px;} 
 
-.div-addtask #calendar_addtask_details1 .time-previsao { width: 40px; }
-
-.div-addtask #calendar_addtask_details1 .date-previsao{ width: 80px; }
+.div-addtask #calendar_addtask_details1 .time-prevision { width: 40px; }
+
+.div-addtask #calendar_addtask_details1 .date-prevision{ width: 80px; }
 
 .div-addtask #calendar_addtask_details1 .start-time{ width: 40px; }
@@ -551,5 +551,5 @@
 .div-addtask #calendar_addtask_details1 .end-time{ width: 40px; }
 .div-addtask #calendar_addtask_details1 .end-date{ width: 80px; }
-.div-addtask #calendar_addtask_details1 .previsao-termino { margin: 0 0 0 30px; }
+.div-addtask #calendar_addtask_details1 .prevision-termino { margin: 0 0 0 30px; }
 .div-addtask #calendar_addtask_details1 .subitem { margin: 5px; display: block;}
 .div-addtask #calendar_addtask_details1 .subitem .span_done{ margin: 0 30px;}
@@ -614,5 +614,5 @@
 .div-addactivity #group_addactivity_details1 .end-time{ width: 40px; }
 .div-addactivity #group_addactivity_details1 .end-date{ width: 80px; }
-.div-addactivity #group_addactivity_details1 .previsao-termino { margin: 0 0 0 30px; }
+.div-addactivity #group_addactivity_details1 .prevision-termino { margin: 0 0 0 30px; }
 .div-addactivity #group_addactivity_details1 .subitem { margin: 5px; display: block;}
 .div-addactivity #group_addactivity_details1 .subitem .span_done{ margin: 0 30px;}
Index: trunk/prototype/modules/calendar/js/calendar.codecs.js
===================================================================
--- trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 6996)
+++ trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 7006)
@@ -901,5 +901,5 @@
         'status': 'Status',
         'percentage': 'Porcentagem',
-        'priority': 'Priorudade',
+        'priority': 'Prioridade',
         'due' : 'Previsão de término'
     }
Index: trunk/prototype/modules/calendar/js/init.js
===================================================================
--- trunk/prototype/modules/calendar/js/init.js	(revision 6996)
+++ trunk/prototype/modules/calendar/js/init.js	(revision 7006)
@@ -249,4 +249,5 @@
     		    			endTime: new Date().toString('yyyy-MM-dd 00:00:00'),
     		    			allDay: '1',
+                            priority: '1',
 					participants: 
 					[{  
Index: trunk/prototype/modules/calendar/js/task.helpers.js
===================================================================
--- trunk/prototype/modules/calendar/js/task.helpers.js	(revision 6996)
+++ trunk/prototype/modules/calendar/js/task.helpers.js	(revision 7006)
@@ -25,6 +25,6 @@
     var start_time = $(".new-task-win.active .start-time").val();
     var end_time   = $(".new-task-win.active .end-time").val();
-	var due_date   = $(".new-task-win.active .date-previsao").val();
-	var due_time   =  $.trim($(".new-task-win.active .time-previsao").val());
+	var due_date   = $(".new-task-win.active .date-prevision").val();
+	var due_time   =  $.trim($(".new-task-win.active .time-prevision").val());
     var isAllDay   = $('.new-task-win.active input[name="allDay"]').is(':checked');
     var customDate = $(".endRepeat").val() == "customDate";
@@ -431,5 +431,5 @@
     UI.dialogs.addTask.find(".input-group .h1").Watermark("Tarefa sem título");
     if (User.preferences.hourFormat.length == 5) {
-        UI.dialogs.addTask.find(".end-time, .start-time, .time-previsao").mask("99:99", {
+        UI.dialogs.addTask.find(".end-time, .start-time, .time-prevision").mask("99:99", {
             completed: function () {
                 updateMap();
@@ -439,5 +439,5 @@
         $.mask.definitions['{'] = '[ap]';
         $.mask.definitions['}'] = '[m]';
-        UI.dialogs.addTask.find(".end-time, .start-time").mask("99:99 {}", {
+        UI.dialogs.addTask.find(".end-time, .start-time, .time-prevision").mask("99:99 {}", {
             completed: function () {
                 $(this).val(date.Calendar.defaultToAmPm($(this).val()));
Index: trunk/prototype/modules/calendar/templates/task_add.ejs
===================================================================
--- trunk/prototype/modules/calendar/templates/task_add.ejs	(revision 6996)
+++ trunk/prototype/modules/calendar/templates/task_add.ejs	(revision 7006)
@@ -20,7 +20,7 @@
 			<input type="text" class="time end-time<%= (data.task.allDay) ? ' hidden' : '' %>" <%= data.task.isOrganizer ? '' : 'disabled="disabled"'%> value="<%= (data.task.endHour) ? data.task.endHour : '' %>" name="endHour" />
 
-				<span class="previsao-termino">Previsão término:</span>
-				<input type="text" name="dueDate" class="date date-previsao" <%= data.task.isOrganizer ? '' : 'disabled="disabled"'%> value="<%= data.task.dueDate %>">
-				<input type="text" name="dueTime" class="time time-previsao" <%= data.task.isOrganizer ? '' : 'disabled="disabled"'%> value="<%= data.task.dueTime %>">
+				<span class="prevision-termino">Previsão término:</span>
+				<input type="text" name="dueDate" class="date date-prevision" <%= data.task.isOrganizer ? '' : 'disabled="disabled"'%> value="<%= data.task.dueDate %>">
+				<input type="text" name="dueTime" class="time time-prevision" <%= data.task.isOrganizer ? '' : 'disabled="disabled"'%> value="<%= data.task.dueTime %>">
 
 				<a href="#" class="calendar_addtask_details_lnk_timezone" <%= data.task.isOrganizer ? '' : 'disabled="disabled"'%>>Fuso horário</a>
Index: trunk/prototype/modules/calendar/templates/attendees_task.ejs
===================================================================
--- trunk/prototype/modules/calendar/templates/attendees_task.ejs	(revision 6996)
+++ trunk/prototype/modules/calendar/templates/attendees_task.ejs	(revision 7006)
@@ -118,5 +118,5 @@
             </ul>
         </dd>
-        <dd class="attendee-list-add" <%= data.task.isOrganizer ? '' : 'disabled="disabled"'%>>
+        <dd class="attendee-list-add <%= data.task.isOrganizer ? '' : 'hidden'%>">
             <fieldset class="add-attendee-input input-field-rounded ui-corner-all">
                 <span class="ui-icon ui-icon-plus" <%= data.task.isOrganizer ? '' : 'disabled="disabled"'%>></span>
@@ -154,5 +154,5 @@
     <dl class="block-add-attendee search <%= data.task.isOrganizer ? '' : 'hidden'%>">
     <dt class="add-attendee search">Adicionar outros convidados</dt>
-    <dd class="add-attendee">
+    <dd class="add-attendee  <%= data.task.isOrganizer ? '' : 'hidden'%>">
         <fieldset class="block-add-attendee" title="Participantes">
             <fieldset class="add-attendee-search search-field ui-corner-all">
