Index: branches/2.4/prototype/modules/calendar/interceptors/Notifications.php
===================================================================
--- branches/2.4/prototype/modules/calendar/interceptors/Notifications.php	(revision 7360)
+++ branches/2.4/prototype/modules/calendar/interceptors/Notifications.php	(revision 7364)
@@ -68,6 +68,7 @@
 	    $psCreated = Controller::find(array('concept' => 'participant'), false, array('deepness' => '1', 'filter' => array('IN', 'id', $created)));
 	    foreach ($psCreated as $i => $pCreated) {
-		if ($pCreated['isOrganizer'] == '1')
+		if ($pCreated['isOrganizer'] == '1' && $pCreated['delegatedFrom'] == '0')
 		    continue; //escapa organizador
+
 		$schedulable = isset($schedulables[$pCreated['schedulable']]) ? $schedulables[$pCreated['schedulable']] : Controller::read(array('concept' => 'schedulable', 'id' => $pCreated['schedulable']), false, array('deepness' => '2'));
 		if (!self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))
@@ -93,9 +94,12 @@
 
 	if (isset($updated)) {
+
 	    $psUpdated = Controller::find(array('concept' => 'participant'), false, array('deepness' => '1', 'filter' => array('IN', 'id', $updated)));
 
 	    foreach ($psUpdated as $i => $pUpdated) {
-		if ($pUpdated['isOrganizer'] == '1')
+		if ($pUpdated['isOrganizer'] == '1' && $pUpdated['delegateFrom'] == '0'){
 		    continue; //escapa organizador
+		}
+
 		$schedulable = isset($schedulables[$pUpdated['schedulable']]) ? $schedulables[$pUpdated['schedulable']] : Controller::read(array('concept' => 'schedulable', 'id' => $pUpdated['schedulable']), false, array('deepness' => '2'));
 		if (!self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))
@@ -106,5 +110,5 @@
 			break;
 
-		if ($pUpdated['delegatedFrom'] != 0) {
+		if ($pUpdated['delegatedFrom'] != '0') {
 		    self::participantDelegatedStatusChange($pUpdated, $schedulable, $organizer, $pUpdated['status']);
 		} else if ($pUpdated['status'] != STATUS_UNANSWERED && $pUpdated['status'] != STATUS_DELEGATED)
@@ -221,16 +225,17 @@
      */
     public static function participantDelegated(&$partID, &$schedulable, &$organizer) {
-
-	$delegatedParams = array();
-
-	$delegatedFrom = self::_getAttendeeById($partID['delegatedFrom'], $schedulable);
-	$delegatedParams['delegatedFrom'] = $delegatedFrom['user']['uid'];
-
-	self::participantCreated($partID['id'], $schedulable, STATUS_DELEGATED, $delegatedParams);
-
-	$delegatedTo = self::_getAttendeeById($partID['id'], $schedulable);
-	$delegatedParams['delegated'] = $delegatedTo['user']['uid'];
-
-	self::participantStatusChange($partID['delegatedFrom'], $schedulable, $organizer, STATUS_DELEGATED, $delegatedParams);
+	$delegatedParams = array(); 
+ 		 
+    $delegatedFrom = self::_getAttendeeById($partID['delegatedFrom'], $schedulable); 
+    $delegatedParams['delegatedFrom'] = $delegatedFrom['user']['uid']; 
+
+    self::participantCreated($partID['id'], $schedulable, STATUS_DELEGATED, $delegatedParams); 
+
+    $delegatedTo = self::_getAttendeeById($partID['id'], $schedulable); 
+    $delegatedParams['delegated'] = $delegatedTo['user']['uid']; 
+
+    if($partID['isOrganizer'] == '0'){ 
+        self::participantStatusChange($partID['delegatedFrom'], $schedulable, $organizer, STATUS_DELEGATED, $delegatedParams); 
+    }
     }
 
@@ -246,34 +251,35 @@
      */
     public static function participantDelegatedStatusChange(&$partID, &$schedulable, $organizer, &$type = false) {
-	$delegatedParams = array();
-
-	$delegated = self::_getAttendeeById($partID['id'], $schedulable);
-	$delegatedParams['delegated'] = $delegated['user']['uid'];
-
-	switch ($partID['status']) {
-	    case STATUS_ACCEPTED:
-		$delegatedParams['status'] = 'aceitou';
-		break;
-	    case STATUS_TENTATIVE:
-		$delegatedParams['status'] = 'marcou como tentativa';
-		break;
-	    case STATUS_CANCELLED:
-		$delegatedParams['status'] = 'rejeitou';
-		break;
-	    case STATUS_DELEGATED:
-		$delegatedParams['status'] = 'delegou para um novo participante';
-		break;
-	}
-	//notifica o organizador a resposta do delegado
-	self::participantStatusChange($partID['delegatedFrom'], $schedulable, $organizer, $type, $delegatedParams);
-
-	$method = 'REQUEST';
-	$notificationType = 'Resposta Delegação';
-	$part = 'attendees';
-	self::mountStruture($partID['delegatedFrom'], $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType);
-
-	$data = array_merge($data, $delegatedParams);
-
-	self::sendMail($data, $ical, $part['user']['mail'], $subject, $schedulable['type'] == '1' ? 'notify_response_delegated_status_body' : 'notify_response_delegated_status_body_task');
+	$delegatedParams = array(); 
+ 		 
+    $delegated = self::_getAttendeeById($partID['id'], $schedulable); 
+    $delegatedParams['delegated'] = $delegated['user']['uid']; 
+
+    switch ($partID['status']) { 
+        case STATUS_ACCEPTED: 
+        $delegatedParams['status'] = 'aceitou'; 
+        break; 
+        case STATUS_TENTATIVE: 
+        $delegatedParams['status'] = 'marcou como tentativa'; 
+        break; 
+        case STATUS_CANCELLED: 
+        $delegatedParams['status'] = 'rejeitou'; 
+        break; 
+        case STATUS_DELEGATED: 
+        $delegatedParams['status'] = 'delegou para um novo participante'; 
+        break; 
+        } 
+        //notifica o organizador a resposta do delegado 
+        if($partID['isOraganizer'] == '0') 
+        self::participantStatusChange($partID['delegatedFrom'], $schedulable, $organizer, $type, $delegatedParams); 
+
+    $method = 'REQUEST'; 
+    $notificationType = 'Resposta Delegação'; 
+    $part = 'attendees'; 
+    self::mountStruture($partID['delegatedFrom'], $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType); 
+
+    $data = array_merge($data, $delegatedParams); 
+
+    self::sendMail($data, $ical, $part['user']['mail'], $subject, $schedulable['type'] == '1' ? 'notify_response_delegated_status_body' : 'notify_response_delegated_status_body_task'); 
     }
 
@@ -457,5 +463,4 @@
 	$mail['body'] = parseTPL::load_tpl($data, ROOTPATH . '/modules/calendar/templates/' . $template . '.tpl');
 	$mail['subject'] = parseTPL::load_tpl($subject, ROOTPATH . '/modules/calendar/templates/notify_subject.tpl');
-	;
 	$mail['from'] = $from ? ('"' . $from['user']['name'] . '" <' . $from['user']['mail'] . '>') : ('"' . Config::me('cn') . '" <' . Config::me('mail') . '>');
 	$mail['to'] = $to;
