Changeset 7364 for branches


Ignore:
Timestamp:
10/08/12 10:24:31 (7 years ago)
Author:
eduardow
Message:

Ticket #3144 - Não é enviado email para o usuario ao qual é delegado um evento.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.4/prototype/modules/calendar/interceptors/Notifications.php

    r7360 r7364  
    6868            $psCreated = Controller::find(array('concept' => 'participant'), false, array('deepness' => '1', 'filter' => array('IN', 'id', $created))); 
    6969            foreach ($psCreated as $i => $pCreated) { 
    70                 if ($pCreated['isOrganizer'] == '1') 
     70                if ($pCreated['isOrganizer'] == '1' && $pCreated['delegatedFrom'] == '0') 
    7171                    continue; //escapa organizador 
     72 
    7273                $schedulable = isset($schedulables[$pCreated['schedulable']]) ? $schedulables[$pCreated['schedulable']] : Controller::read(array('concept' => 'schedulable', 'id' => $pCreated['schedulable']), false, array('deepness' => '2')); 
    7374                if (!self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id'])) 
     
    9394 
    9495        if (isset($updated)) { 
     96 
    9597            $psUpdated = Controller::find(array('concept' => 'participant'), false, array('deepness' => '1', 'filter' => array('IN', 'id', $updated))); 
    9698 
    9799            foreach ($psUpdated as $i => $pUpdated) { 
    98                 if ($pUpdated['isOrganizer'] == '1') 
     100                if ($pUpdated['isOrganizer'] == '1' && $pUpdated['delegateFrom'] == '0'){ 
    99101                    continue; //escapa organizador 
     102                } 
     103 
    100104                $schedulable = isset($schedulables[$pUpdated['schedulable']]) ? $schedulables[$pUpdated['schedulable']] : Controller::read(array('concept' => 'schedulable', 'id' => $pUpdated['schedulable']), false, array('deepness' => '2')); 
    101105                if (!self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id'])) 
     
    106110                        break; 
    107111 
    108                 if ($pUpdated['delegatedFrom'] != 0) { 
     112                if ($pUpdated['delegatedFrom'] != '0') { 
    109113                    self::participantDelegatedStatusChange($pUpdated, $schedulable, $organizer, $pUpdated['status']); 
    110114                } else if ($pUpdated['status'] != STATUS_UNANSWERED && $pUpdated['status'] != STATUS_DELEGATED) 
     
    221225     */ 
    222226    public static function participantDelegated(&$partID, &$schedulable, &$organizer) { 
    223  
    224         $delegatedParams = array(); 
    225  
    226         $delegatedFrom = self::_getAttendeeById($partID['delegatedFrom'], $schedulable); 
    227         $delegatedParams['delegatedFrom'] = $delegatedFrom['user']['uid']; 
    228  
    229         self::participantCreated($partID['id'], $schedulable, STATUS_DELEGATED, $delegatedParams); 
    230  
    231         $delegatedTo = self::_getAttendeeById($partID['id'], $schedulable); 
    232         $delegatedParams['delegated'] = $delegatedTo['user']['uid']; 
    233  
    234         self::participantStatusChange($partID['delegatedFrom'], $schedulable, $organizer, STATUS_DELEGATED, $delegatedParams); 
     227        $delegatedParams = array();  
     228                  
     229    $delegatedFrom = self::_getAttendeeById($partID['delegatedFrom'], $schedulable);  
     230    $delegatedParams['delegatedFrom'] = $delegatedFrom['user']['uid'];  
     231 
     232    self::participantCreated($partID['id'], $schedulable, STATUS_DELEGATED, $delegatedParams);  
     233 
     234    $delegatedTo = self::_getAttendeeById($partID['id'], $schedulable);  
     235    $delegatedParams['delegated'] = $delegatedTo['user']['uid'];  
     236 
     237    if($partID['isOrganizer'] == '0'){  
     238        self::participantStatusChange($partID['delegatedFrom'], $schedulable, $organizer, STATUS_DELEGATED, $delegatedParams);  
     239    } 
    235240    } 
    236241 
     
    246251     */ 
    247252    public static function participantDelegatedStatusChange(&$partID, &$schedulable, $organizer, &$type = false) { 
    248         $delegatedParams = array(); 
    249  
    250         $delegated = self::_getAttendeeById($partID['id'], $schedulable); 
    251         $delegatedParams['delegated'] = $delegated['user']['uid']; 
    252  
    253         switch ($partID['status']) { 
    254             case STATUS_ACCEPTED: 
    255                 $delegatedParams['status'] = 'aceitou'; 
    256                 break; 
    257             case STATUS_TENTATIVE: 
    258                 $delegatedParams['status'] = 'marcou como tentativa'; 
    259                 break; 
    260             case STATUS_CANCELLED: 
    261                 $delegatedParams['status'] = 'rejeitou'; 
    262                 break; 
    263             case STATUS_DELEGATED: 
    264                 $delegatedParams['status'] = 'delegou para um novo participante'; 
    265                 break; 
    266         } 
    267         //notifica o organizador a resposta do delegado 
    268         self::participantStatusChange($partID['delegatedFrom'], $schedulable, $organizer, $type, $delegatedParams); 
    269  
    270         $method = 'REQUEST'; 
    271         $notificationType = 'Resposta Delegação'; 
    272         $part = 'attendees'; 
    273         self::mountStruture($partID['delegatedFrom'], $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType); 
    274  
    275         $data = array_merge($data, $delegatedParams); 
    276  
    277         self::sendMail($data, $ical, $part['user']['mail'], $subject, $schedulable['type'] == '1' ? 'notify_response_delegated_status_body' : 'notify_response_delegated_status_body_task'); 
     253        $delegatedParams = array();  
     254                  
     255    $delegated = self::_getAttendeeById($partID['id'], $schedulable);  
     256    $delegatedParams['delegated'] = $delegated['user']['uid'];  
     257 
     258    switch ($partID['status']) {  
     259        case STATUS_ACCEPTED:  
     260        $delegatedParams['status'] = 'aceitou';  
     261        break;  
     262        case STATUS_TENTATIVE:  
     263        $delegatedParams['status'] = 'marcou como tentativa';  
     264        break;  
     265        case STATUS_CANCELLED:  
     266        $delegatedParams['status'] = 'rejeitou';  
     267        break;  
     268        case STATUS_DELEGATED:  
     269        $delegatedParams['status'] = 'delegou para um novo participante';  
     270        break;  
     271        }  
     272        //notifica o organizador a resposta do delegado  
     273        if($partID['isOraganizer'] == '0')  
     274        self::participantStatusChange($partID['delegatedFrom'], $schedulable, $organizer, $type, $delegatedParams);  
     275 
     276    $method = 'REQUEST';  
     277    $notificationType = 'Resposta Delegação';  
     278    $part = 'attendees';  
     279    self::mountStruture($partID['delegatedFrom'], $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType);  
     280 
     281    $data = array_merge($data, $delegatedParams);  
     282 
     283    self::sendMail($data, $ical, $part['user']['mail'], $subject, $schedulable['type'] == '1' ? 'notify_response_delegated_status_body' : 'notify_response_delegated_status_body_task');  
    278284    } 
    279285 
     
    457463        $mail['body'] = parseTPL::load_tpl($data, ROOTPATH . '/modules/calendar/templates/' . $template . '.tpl'); 
    458464        $mail['subject'] = parseTPL::load_tpl($subject, ROOTPATH . '/modules/calendar/templates/notify_subject.tpl'); 
    459         ; 
    460465        $mail['from'] = $from ? ('"' . $from['user']['name'] . '" <' . $from['user']['mail'] . '>') : ('"' . Config::me('cn') . '" <' . Config::me('mail') . '>'); 
    461466        $mail['to'] = $to; 
Note: See TracChangeset for help on using the changeset viewer.