Index: /trunk/prototype/modules/calendar/alarms.php
===================================================================
--- /trunk/prototype/modules/calendar/alarms.php	(revision 6528)
+++ /trunk/prototype/modules/calendar/alarms.php	(revision 7388)
@@ -12,5 +12,5 @@
 $target = (gmdate('U') - 300 ).'000';
 
-$parts = Controller::service('PostgreSQL')->execSql('SELECT DISTINCT calendar_participant.user_info_id as "user", co.id as "schedulable", co.allDay as "allDay" ,co.dtend as "endTime", co.dtstart as "startTime", co.summary as "summary", co.tzid as "timezone", co.location as "location", al.id as "id" '.
+$parts = Controller::service('PostgreSQL')->execSql('SELECT DISTINCT calendar_participant.user_info_id as "user", co.id as "schedulable", co.type_id as "type", co.allDay as "allDay" ,co.dtend as "endTime", co.dtstart as "startTime", co.summary as "summary", co.tzid as "timezone", co.location as "location", al.id as "id" '.
                             'FROM calendar_participant, calendar_alarm as "al", calendar_object as "co", calendar_repeat as "rep" WHERE ('.
                             "al.participant_id = calendar_participant.id AND ".
@@ -60,5 +60,5 @@
 		      'participants' =>  '<UL> <LI> '.implode( '<LI></LI> ', $attList ).'</LI> </UL>');
 
-	Controller::create( array( 'service' => 'SMTP' ), array( 'body' => parseTPL::load_tpl( $data, ROOTPATH.'/modules/calendar/templates/notify_alarm_body.tpl' ),
+	Controller::create( array( 'service' => 'SMTP' ), array( 'body' => parseTPL::load_tpl( $data, ROOTPATH.'/modules/calendar/templates/'. ($parts['type'] == '1' ? 'notify_alarm_body.tpl' : 'notify_alarm_body_task.tpl')),
 								  'isHtml' => true,
 								  'subject' => 'Alarme de Calendario',
Index: /trunk/prototype/modules/calendar/js/calendar.codecs.js
===================================================================
--- /trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 7356)
+++ /trunk/prototype/modules/calendar/js/calendar.codecs.js	(revision 7388)
@@ -128,4 +128,5 @@
 	var constantAcl = function(acl){
 	    var returns = {};
+
 	    for (var i in constantsCalendarShared){
 		returns[constantsCalendarShared[i]] = acl.indexOf(i) >= 0 ? true : false
@@ -133,5 +134,5 @@
 	    return returns;
 	};
-    console.log(evtObj);
+
 	var res = $.map(evtObj, function( objEvent ){			
 	    return {
@@ -676,5 +677,5 @@
 		alarms: !!participantInfo.user ? participantInfo.user.alarms : [],
 		status: !!participantInfo.user ? participantInfo.user.status : 1,
-		acl: constantAcl(me.acl || 'roiw'),
+		acl: constantAcl((me.acl && me.acl != '') ? me.acl : ((!objEvent.id || objEvent.id == '') ? 'row' : 'r')),
 		isShared: isShared,
 		isAttendee: (isAttendee ? true : (objEvent.id && isShared ? false : true)),
@@ -764,5 +765,6 @@
                     id: attendee,
                     isOrganizer: (form.attendee_organizer == attendee ? 1 : 0 ),
-                    isExternal: !!parseInt(form.attendeeType[i]) ? 1 : 0
+                    isExternal: !!parseInt(form.attendeeType[i]) ? 1 : 0,
+                    delegatedFrom: (form.delegatedFrom[i] != '0' && form.delegatedFrom[i] != '') ? form.delegatedFrom[i] : '0'
                     };
             };
@@ -868,15 +870,21 @@
                 isExternal: attend.isExternal,
                 acl: attend.acl,
-                delegatedFrom: attend.delegatedFrom
+                delegatedFrom: attend.delegatedFrom,
+                isOrganizer: attend.isOrganizer
             };
 
             if(!!parseInt(attend.delegatedFrom)){
                 delegatedFrom[attend.delegatedFrom] = DataLayer.copy(person);
-                return(null);
+
+                if( !!parseInt(attend.isOrganizer)){
+                    participantInfo.organizer = DataLayer.copy(person);
+                }
+
+                return null;
             }
 
             if( !!parseInt(attend.isOrganizer)){
                 participantInfo.organizer = DataLayer.copy(person);
-                return(null);
+                return null;
             };                  
 
Index: /trunk/prototype/modules/calendar/js/task.helpers.js
===================================================================
--- /trunk/prototype/modules/calendar/js/task.helpers.js	(revision 7356)
+++ /trunk/prototype/modules/calendar/js/task.helpers.js	(revision 7388)
@@ -845,11 +845,11 @@
     });
 
-    blkAddAtendee.find('.add-attendee-search .ui-icon-search').click(function (task) {
+    blkAddAtendee.find('.add-attendee-search .ui-icon-search').click(function (evt) {
         blkAddAtendee.find('.add-attendee-search input').keydown();
     });
 
-    blkAddAtendee.find('.add-attendee-search input').keydown(function (task) {
-
-        if (task.keyCode == '13' || typeof (task.keyCode) == 'undefined') {
+    blkAddAtendee.find('.add-attendee-search input').keydown(function (evt) {
+
+        if (evt.keyCode == '13' || typeof (evt.keyCode) == 'undefined') {
             var result = DataLayer.get('user', ["*", "name", $(this).val()], true);
 
@@ -867,7 +867,7 @@
             blkAddAtendee.find('ul.search-result-list').append(DataLayer.render(path + 'templates/participants_search_itemlist.ejs', result));
 
-            blkAddAtendee.find('ul.search-result-list li').click(function (task, ui) {
-                if ($(task.target).is('input')) {
-                    old_item = $(task.target).parents('li');
+            blkAddAtendee.find('ul.search-result-list li').click(function (event, ui) {
+                if ($(event.target).is('input')) {
+                    old_item = $(event.target).parents('li');
                     newAttendeeId = DataLayer.put('participant', {
                         user: old_item.find('.id').html(),
@@ -925,5 +925,5 @@
             });
 
-            event.preventDefault();
+            evt.preventDefault();
         }
     });
Index: /trunk/prototype/modules/calendar/templates/attendee_add.ejs
===================================================================
--- /trunk/prototype/modules/calendar/templates/attendee_add.ejs	(revision 7377)
+++ /trunk/prototype/modules/calendar/templates/attendee_add.ejs	(revision 7388)
@@ -43,5 +43,5 @@
 			    <%}%>
 			    
-				<li class="organizer <%= (data.event.acl.organization) ? "hidden" : "" %>"> 
+				<li class="organizer <%= (data.event.acl.organization || (data.event.delegatedFrom[data.event.me.id] && data.event.delegatedFrom[data.event.me.id].isOrganizer == '1')) ? "hidden" : "" %>">
 					<div style="overflow:hidden; width:100%; display:table;">
 						<span class="space-status ui-icon <%=iconStatus[data.event.organizer.status]%>" title="<%=legendStatus[data.event.organizer.status]%>"></span>
Index: /trunk/prototype/modules/calendar/templates/attendees_task.ejs
===================================================================
--- /trunk/prototype/modules/calendar/templates/attendees_task.ejs	(revision 7356)
+++ /trunk/prototype/modules/calendar/templates/attendees_task.ejs	(revision 7388)
@@ -15,5 +15,5 @@
                 <%}%>
             </select>
-	    <% if (data.task.id && !data.task.delegatedFrom[data.task.me.id]) { %>
+	    <% if (data.task.id && !data.task.delegatedFrom[data.task.me.id] && !data.task.isOrganizer) { %>
 		    <fieldset class="add-attendee-options-read">
 			    <a href="#" class="button participant-delegate add-attendee-options-button">Delegar participação a um novo participante</a>
@@ -35,5 +35,5 @@
                 <label for="attendee" title="<%=  data.task.me.user ? data.task.me.user.mail : data.task.me.mail %>" class="mail hidden"></label>
                 
-                <li class="organizer <%= data.task.isOrganizer ? "hidden" : "" %>"> 
+                <li class="organizer <%= (data.task.isOrganizer || (data.task.delegatedFrom[data.task.me.id] && data.task.delegatedFrom[data.task.me.id].isOrganizer == '1')) ? "hidden" : "" %>">
                     <div style="overflow:hidden; width:100%; display:table;">
                         <span class="space-status ui-icon <%=iconStatus[data.task.organizer.status]%>" title="<%=legendStatus[data.task.organizer.status]%>"></span>
Index: /trunk/prototype/modules/calendar/templates/notify_alarm_body_task.tpl
===================================================================
--- /trunk/prototype/modules/calendar/templates/notify_alarm_body_task.tpl	(revision 7388)
+++ /trunk/prototype/modules/calendar/templates/notify_alarm_body_task.tpl	(revision 7388)
@@ -0,0 +1,6 @@
+<br />Este é um lembrete informando que você possui uma tarefa agendada para [startDate].<br /><br />
+<strong>[eventTitle]</strong><br />
+<strong>Início:</strong> [startDate] [startTime]<br />
+<strong>Término:</strong> [endDate] [endTime]<br />
+<strong>Fuso Horario:</strong> [timezone]<br />
+<strong>Participantes:</strong> [participants]
Index: /trunk/prototype/modules/calendar/templates/notify_create_delegated_body_task.tpl
===================================================================
--- /trunk/prototype/modules/calendar/templates/notify_create_delegated_body_task.tpl	(revision 7350)
+++ /trunk/prototype/modules/calendar/templates/notify_create_delegated_body_task.tpl	(revision 7388)
@@ -1,3 +1,3 @@
-<br />Você foi convidado por [delegatedFrom] para participar em seu lugar ns tarefa agendada para [startDate].<br /><br />
+<br />Você foi convidado por [delegatedFrom] para participar em seu lugar na tarefa agendada para [startDate].<br /><br />
 <strong>[eventTitle]</strong><br />
 <strong>Início:</strong> [startDate] [startTime]<br />
