source: trunk/prototype/modules/calendar/interceptors/Notifications.php @ 5947

Revision 5947, 23.4 KB checked in by acoutinho, 12 years ago (diff)

Ticket #2626 - Inconsistencia no organizador de um evento quando criado a partir de uma agenda compartilhada

Line 
1<?php
2require_once ROOTPATH.'/modules/calendar/constants.php';
3require_once ROOTPATH.'/modules/calendar/interceptors/Helpers.php';
4require_once ROOTPATH.'/plugins/icalcreator/iCalcreator.class.php';
5require_once ROOTPATH.'/api/parseTPL.php';
6 
7class Notifications extends Helpers
8{
9   
10        public function formatNotification(&$uri , &$params , &$data , $original){     
11            switch ($params['type']) {
12                case 'suggestion':
13                        self::formatSuggestion($params);   
14                        break;
15                case 'suggestionResponse':
16                        self::formatSuggestionResponse($params);   
17                        break;
18                }
19        }
20       
21       
22        /**
23    * Analisa o commit do conceito participant e encaminha cada participant para seu devido metodo de notrificação
24    *
25    * @license    http://www.gnu.org/copyleft/gpl.html GPL
26    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
27    * @sponsor    Caixa Econômica Federal
28    * @author     Cristiano Corrêa Schmidt
29    * @return     void
30    * @access     public
31    */
32    public function commitParticipant(&$uri , &$result , &$data , $original)
33    {                           
34        if(Config::regGet('noAlarm') !== false) return; //Escapa notificações caso a flag de noAlarm esteja ativa.
35               
36        $organizers = array(); //Cache Organizadores
37        $schedulables = array(); //Cache Schedulables
38
39        foreach ($data as $i => $concept)
40        {
41            if($concept['concept'] === 'participant')
42            {
43               if( $concept['method'] == 'create' )
44                   $created[] = $concept['id'];
45               else if( $concept['method'] == 'update' )
46                   $updated[] = $concept['id'];
47            }
48            else if($concept['concept'] === 'schedulable') //Caso exista schedulable no commit antecipa o carregamento do owner
49            {
50                $schedulables[ $concept['id'] ] = Controller::read( array('concept' => 'schedulable', 'id' => $concept['id']) , false , array('deepness' => '2'));
51                foreach ($schedulables[ $concept['id'] ]['participants'] as $i => $v) //salva em $organizers as informações do organizador     
52                    if(($v['isOrganizer'] === '1') && ($organizers[$concept['id']] = $v) ) break;
53                        }else if($concept['concept'] === 'schedulableToAttachment')
54                        {
55                                $relationAttachment = Controller::find( array( 'concept' => 'schedulableToAttachment' ) , false ,array( 'filter' => array('=', 'id' , $concept['id'])));                       
56                                                       
57                               
58                                       
59                                foreach($relationAttachment as $key => $value){
60                                        if(!array_key_exists('attachments',$schedulables[$value['schedulable']]))
61                                                $schedulables[$value['schedulable']]['attachments'] = array();
62
63                                        $temp = Controller::find( array( 'concept' => 'attachment' ) , false ,array( 'filter' => array('=', 'id' , $value['attachment'])));
64                                        array_push($schedulables[$value['schedulable']]['attachments'] , $temp[0]);                             
65                                }
66                        }
67        }
68       
69        if( isset( $created ) )
70        {
71           $psCreated =  Controller::find(array('concept' => 'participant'), false , array('deepness' => '1' , 'filter' => array('IN', 'id' , $created )));               
72                   foreach ($psCreated as $i => $pCreated)   
73           {   
74               if($pCreated['isOrganizer'] == '1') continue; //escapa organizador
75               $schedulable = isset( $schedulables[$pCreated['schedulable']] ) ? $schedulables[$pCreated['schedulable']] : Controller::read( array('concept' => 'schedulable', 'id' => $pCreated['schedulable']) , false , array('deepness' => '2'));
76               if(!self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd'])) continue; //Escapa eventos do passado
77               
78               $organizer = isset( $organizers[$pCreated['schedulable']] ) ? $organizers[ $pCreated['schedulable'] ] : self::getOrganizer( $pCreated['schedulable'] );
79                           
80                if($pCreated['delegatedFrom'] != 0){
81                        self::participantDelegated( $pCreated , $schedulable , $organizer);   
82                        continue;
83                }
84                           
85               switch ($pCreated['status'])
86               {
87                   case STATUS_CONFIRMED:
88                        self::participantStatusChange( $pCreated['id'] , $schedulable , $organizer  , STATUS_ACCEPTED);
89                       break;
90                   case STATUS_UNANSWERED:
91                        self::participantCreated( $pCreated['id'] , $schedulable, false, false, $organizer );
92                       break;
93               }
94           }
95        }
96       
97        if( isset( $updated ) )
98        {
99            $psUpdated  = Controller::find(array('concept' => 'participant'), false , array('deepness' => '1' , 'filter' => array('IN', 'id' , $updated )));
100                        foreach ($psUpdated as $i => $pUpdated)   
101            {                   
102                if($pUpdated['isOrganizer'] == '1') continue; //escapa organizador
103                $schedulable = isset( $schedulables[$pUpdated['schedulable']] ) ? $schedulables[ $pUpdated['schedulable'] ] : Controller::read( array('concept' => 'schedulable', 'id' => $pUpdated['schedulable']) , false , array('deepness' => '2'));
104                if(!self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd'])) continue; //Escapa eventos do passado
105                 
106                foreach ($schedulable['participants'] as $i => $v) //salva em $organizer as informações do organizador     
107                    if(($v['isOrganizer'] === '1') && ($organizer = $v) ) break;
108                   
109                if($pUpdated['delegatedFrom'] != 0){
110                    self::participantDelegatedStatusChange( $pUpdated , $schedulable , $organizer , $pUpdated['status'] );   
111                }else if( $pUpdated['status'] != STATUS_UNANSWERED && $pUpdated['status'] != STATUS_DELEGATED)
112                    self::participantStatusChange( $pUpdated['id'] , $schedulable , $organizer , $pUpdated['status'] );   
113            }
114        }
115    }
116       
117        public function formatSuggestion(&$params){
118           
119            $schedulable =  Controller::read(  array( 'concept' => 'schedulable' , 'id' => $params['schedulable'] ) , null , array('deepness' => '2') ) ;
120
121            foreach ($schedulable['participants'] as $i => $v) //salva em $organizer as informações do organizador     
122            if(($v['isOrganizer'] === '1') && ($organizer = $v) ) break;
123               
124                $method = 'COUNTER';
125                $notificationType = 'Sugestão de horário';
126                $part = 'other';
127               
128                $schedulableReference = $schedulable;
129               
130                $referenceSuggestion = array( 'startTime' => $params['startTime'],
131                                                                        'endTime' => $params['endTime'],
132                                                                        'allDay' => $params['allDay']
133                                                                );
134                $schedulable = array_merge($schedulable, $referenceSuggestion);
135               
136                self::mountStruture(false, $schedulable, false , $data,  $subject, $ical, $part, $method, $notificationType);
137                       
138
139                $timezone = new DateTimeZone('UTC');
140                $sTime = new DateTime( '@'.(int)($schedulableReference['startTime'] / 1000) , $timezone );
141                $eTime =  new DateTime( '@'.(int)($schedulableReference['endTime'] / 1000) , $timezone );
142           
143                if(isset($schedulableReference['timezone']))
144                {
145                        $sTime->setTimezone(new DateTimeZone($schedulableReference['timezone']));
146                        $eTime->setTimezone(new DateTimeZone($schedulableReference['timezone']));
147                }
148
149                $data['nowStartDate'] = date_format( $sTime , 'd/m/Y');
150                $data['nowStartTime'] = ($schedulableReference['allDay']) ? '' : date_format( $sTime , 'H:i');
151                $data['nowEndDate'] = date_format( $eTime , 'd/m/Y');
152                $data['nowEndTime'] = ($schedulableReference['allDay']) ? '' :  date_format( $eTime , 'H:i');
153                $data['userRequest'] = Config::me('uid');
154               
155                $ical2 = $ical;
156                $ical2['type'] = 'text/calendar';
157                $ical2['name'] = 'thunderbird.ics';
158                $params['attachments'][] = $ical2;
159                $params['attachments'][] = $ical;
160                $params['isHtml'] = true;                         
161                $params['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/notify_suggestion_body.tpl');
162                $params['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');;
163                $params['from'] ='"'.Config::me('cn').'" <'.Config::me('mail').'>';   
164                $params['to'] = $organizer['user']['mail'];
165               
166        } 
167       
168        public function formatSuggestionResponse(&$params){     
169                $schedulable = $params['schedulable'];
170                foreach ($schedulable['participants'] as $i => $v) {//salva em $organizer as informações do organizador     
171            if($v['isOrganizer'] === '1') $organizer = $v;
172                        if($v['user']['mail'] == Config::me('mail')) $me = $v;
173                }
174                $method = 'DECLINECOUNTER';
175                $notificationType = 'Sugestão de horário';
176                $part = 'other';
177               
178                $schedulable['participants'] = array();
179                array_push($schedulable['participants'], $me, $organizer);
180               
181                self::mountStruture(false, $schedulable, false , $data,  $subject, $ical, $part, $method, $notificationType);
182               
183                if($params['status'] == 'DECLINECOUNTER')
184                        $data['status'] = 'não pode ser aceito';
185                                $ical2 = $ical;
186                $ical2['type'] = 'text/calendar';
187                $ical2['name'] = 'thunderbird.ics';
188                $params['attachments'][] = $ical2;     
189                $params['attachments'][] = $ical;
190                $params['isHtml'] = true;                         
191                $params['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/notify_suggestion_response_body.tpl');
192                $params['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');;
193                $params['to'] = $params['from'];
194                $params['from'] = $params['from'] ='"'.Config::me('cn').'" <'.Config::me('mail').'>';
195        }
196       
197       
198        public static function _getAttendeeById($attendeId, $schedulable){
199                foreach ($schedulable['participants'] as $id => $dv)
200                        if($dv['id'] == $attendeId )
201                                return $dv;
202        }
203       
204        /**
205    * Prepara para criação de email de delegação
206    *
207    * @license    http://www.gnu.org/copyleft/gpl.html GPL
208    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
209    * @sponsor    Caixa Econômica Federal
210    * @author     Adriano Coutinho da Silva
211    * @return     void
212    * @access     public
213    */
214        public static function participantDelegated( &$partID , &$schedulable , &$organizer){
215       
216                $delegatedParams = array();
217               
218                $delegatedFrom = self::_getAttendeeById($partID['delegatedFrom'], $schedulable);
219                $delegatedParams['delegatedFrom'] = $delegatedFrom['user']['uid'];
220               
221                self::participantCreated( $partID['id'] , $schedulable , STATUS_DELEGATED, $delegatedParams );         
222               
223                $delegatedTo = self::_getAttendeeById($partID['id'], $schedulable);
224                $delegatedParams['delegated'] = $delegatedTo['user']['uid'];
225               
226                self::participantStatusChange( $partID['delegatedFrom'] , $schedulable , $organizer , STATUS_DELEGATED, $delegatedParams );
227        }
228       
229    /**
230    * Monta o email de resposta que sera enviado ao delegatedFrom
231    *
232    * @license    http://www.gnu.org/copyleft/gpl.html GPL
233    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
234    * @sponsor    Caixa Econômica Federal
235    * @author     Cristiano Corrêa Schmidt
236    * @return     void
237    * @access     public
238    */
239    public static function participantDelegatedStatusChange( &$partID , &$schedulable, $organizer, &$type = false){
240       
241            $delegatedParams = array();
242
243            $delegated = self::_getAttendeeById($partID['id'], $schedulable);
244            $delegatedParams['delegated'] = $delegated['user']['uid'];         
245
246            switch($partID['status']){
247            case STATUS_ACCEPTED:
248                $delegatedParams['status'] = 'aceitou';
249            break;
250            case STATUS_TENTATIVE:
251                $delegatedParams['status'] = 'marcou como tentativa';
252            break;
253            case STATUS_CANCELLED:
254                $delegatedParams['status'] = 'rejeitou';
255            break;
256            case STATUS_DELEGATED:
257                    $delegatedParams['status'] = 'delegou para um novo participante';
258            break;
259                }
260            //notifica o organizador a resposta do delegado
261            self::participantStatusChange( $partID['delegatedFrom'] , $schedulable , $organizer , $type, $delegatedParams );
262
263            $method = 'REQUEST';
264            $notificationType = 'Resposta Delegação';
265            $part = 'attendees';
266            self::mountStruture($partID['delegatedFrom'], $schedulable, $type , $data,  $subject, $ical, $part, $method, $notificationType );
267
268            $data = array_merge($data, $delegatedParams);
269                       
270            self::sendMail($data, $ical , $part['user']['mail'] , $subject , 'notify_response_delegated_status_body');
271       
272    }
273
274        public static function mountStruture( $partID , &$schedulable, $type = false, &$data, &$subject, &$ical, &$part = false, &$method, &$notificationType, $regSet = false) {
275               
276                if( (Config::regGet('ical://'.$schedulable['id'].'/'.$method) === false) || ($method == 'CANCEL') ) //Verifica se o ical ja não esta no reg
277                {
278                        $schedulable['URI']['concept'] = 'schedulable';
279                        $ical['source'] = Controller::format( array( 'service' => 'iCal' ) , array($schedulable) , array('method' => $method) ); 
280                        $ical['type'] = 'text/plain';
281                        $ical['name'] = 'outlook.ics';
282                        if($regSet)
283                                Config::regSet('ical://'.$schedulable['id'].'/'.$method, $ical);
284                }
285                else
286                        $ical = Config::regGet('ical://'.$schedulable['id'].'/'.$method);
287       
288                        $timezone = new DateTimeZone('UTC');
289                        $sTime = new DateTime( '@'.(int)($schedulable['startTime'] / 1000) , $timezone );
290                        $eTime =  new DateTime( '@'.(int)($schedulable['endTime'] / 1000) , $timezone );
291           
292                        if(isset($schedulable['timezone']))
293                        {
294                                $sTime->setTimezone(new DateTimeZone($schedulable['timezone']));
295                                $eTime->setTimezone(new DateTimeZone($schedulable['timezone']));
296                        }
297           
298                        $data = array(     'startDate' =>  date_format( $sTime , 'd/m/Y') ,
299                              'startTime' =>  ($schedulable['allDay']) ? '' : date_format( $sTime , 'H:i') ,
300                              'endDate' =>  date_format( $eTime , 'd/m/Y') ,
301                              'endTime' =>  ($schedulable['allDay']) ? '' :  date_format( $eTime , 'H:i') ,
302                              'eventTitle' =>  $schedulable['summary'],
303                              'eventLocation' =>  $schedulable['location'],
304                              'timezone' =>  ($schedulable['timezone']) ? $schedulable['timezone'] : 'UTC');
305                        $temp = $part;
306                        $part = false;
307
308                        switch($temp){
309                                case 'attendees':
310                                        $attList = '<UL> ';
311                                        foreach ($schedulable['participants'] as $i => $v) 
312                                        {               
313                                                if($part === false && $v['id'] == $partID)
314                                                   $part = $v;
315
316                                                $attList .= ' <LI> '. (isset($v['user']['name']) ? $v['user']['name'] : $v['user']['mail']) ;
317                                        }
318                                        $attList .= '</UL>';
319                                        $data['participants'] = $attList;
320                                break;
321                                case 'me':
322                                        $part = self::_getAttendeeById($partID, $schedulable);
323                                        $data['participant'] = isset($part['user']['name']) ? $part['user']['name'] : $part['user']['mail'];
324                                break;
325                                case 'othersAttendees':
326                                        $data['participants'] = '<UL> ';
327                                        foreach ($schedulable['participants'] as $ii => $participant){
328                                                if(Config::me('mail') !== $participant['user']['mail'])
329                                                        $part[] = $participant['user']['mail'];
330                                       
331                                        $data['participants'] .= ' <LI> '. (isset($participant['user']['name']) ? $participant['user']['name'] : $participant['user']['mail']) ;
332                                        }
333                                break;
334                        }         
335                        $subject['notificationType'] = $notificationType;
336                        $subject['eventTitle'] = mb_convert_encoding($schedulable['summary'],'ISO-8859-1','ISO-8859-1,UTF-8');
337                        $subject['startDate'] = date_format( $sTime , 'd/m/Y');
338                        $subject['startTime'] = ($schedulable['allDay']) ? '' : date_format( $sTime , 'H:i');
339                        $subject['endDate'] = date_format( $eTime , 'd/m/Y');
340                        $subject['endTime'] = ($schedulable['allDay']) ? '' : date_format( $eTime , 'H:i');
341                        $subject['participant'] = Config::me('uid');
342        }
343       
344       
345    /**
346    * Monta o email de convite que sera enviado ao participant
347    *
348    * @license    http://www.gnu.org/copyleft/gpl.html GPL
349    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
350    * @sponsor    Caixa Econômica Federal
351    * @author     Cristiano Corrêa Schmidt
352    * @return     void
353    * @access     public
354    */
355    public static function participantCreated( &$partID , &$schedulable, $type = false, $delegatedParams = false, $organizer = false)
356    {   
357        $method = 'REQUEST';
358        $notificationType = 'Convite de Calendario';
359        $part = 'attendees';
360        self::mountStruture($partID, $schedulable, $type , $data,  $subject, $ical, $part, $method, $notificationType, true);
361
362        if($delegatedParams)
363                $data = array_merge($data, $delegatedParams);
364
365            self::sendMail($data, $ical , $part['user']['mail'] , $subject , !$delegatedParams  ? 'notify_create_body' : 'notify_create_delegated_body', $organizer );
366       
367    }
368   
369    /**
370    * Monta o email de aceito que sera enviado ao organizador
371    *
372    * @license    http://www.gnu.org/copyleft/gpl.html GPL
373    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
374    * @sponsor    Caixa Econômica Federal
375    * @author     Cristiano Corrêa Schmidt
376    * @return     void
377    * @access     public
378    */
379    public static function participantStatusChange( &$partID , &$schedulable , &$organizer , $type, $delegatedParams = false )
380    {   
381        $method = 'REPLY';
382        $notificationType = 'Convite Aceito';
383        $part = 'me';
384
385        self::mountStruture($partID, $schedulable, $type , $data,  $subject, $ical, $part, $method, $notificationType, true );
386
387        if($delegatedParams){
388                $data = array_merge($data, $delegatedParams);
389                $tplDelegated = 'notify_delegated_status_body';
390        }
391
392       switch($type)
393       {
394            case STATUS_ACCEPTED:
395                $tpl =   !$delegatedParams ? 'notify_accept_body' : $tplDelegated;
396                $subject['notificationType'] = 'Convite Aceito';
397            break;
398            case STATUS_TENTATIVE:
399                $tpl =   !$delegatedParams ? 'notify_attempt_body' : $tplDelegated;
400                $subject['notificationType'] = 'Convite  aceito provisoriamente';
401            break;
402            case STATUS_CANCELLED:
403                $tpl =   !$delegatedParams ? 'notify_reject_body' : $tplDelegated;
404                $subject['notificationType'] = 'Convite rejeitado';
405            break;
406                case STATUS_DELEGATED:
407                    if($delegatedParams)
408                        $data = array_merge($data, $delegatedParams);
409                $tpl =   'notify_delegated_body';
410                $subject['notificationType'] = 'Convite delegado';
411            break;
412
413       }
414       
415        self::sendMail($data, $ical , $organizer['user']['mail'] , $subject , $tpl, false);
416    }
417   
418    /**
419    * Monta o body e envia o email
420    *
421    * @license    http://www.gnu.org/copyleft/gpl.html GPL
422    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
423    * @sponsor    Caixa Econômica Federal
424    * @author     Cristiano Corrêa Schmidt
425    * @return     void
426    * @access     public
427    */
428    private static function sendMail(&$data , &$ical , $to ,  &$subject , $template, $from = false )
429    {
430       $ical2 = $ical;
431       $ical2['type'] = 'text/calendar';
432       $ical2['name'] = 'thunderbird.ics';
433       $mail['attachments'][] = $ical2;
434       $mail['attachments'][] = $ical;
435       $mail['isHtml'] = true;                         
436       $mail['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/'.$template.'.tpl');
437       $mail['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');;
438       $mail['from'] = $from ? ('"'.$from['user']['name'].'" <'.$from['user']['mail'].'>') : ('"'.Config::me('cn').'" <'.Config::me('mail').'>');
439       $mail['to'] = $to;
440       Controller::create( array( 'service' => 'SMTP' ), $mail );
441    }
442   
443 
444    /**
445    * Monta o email de cancelado que sera enviado a todos os participantes
446    *
447    * @license    http://www.gnu.org/copyleft/gpl.html GPL
448    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
449    * @sponsor    Caixa Econômica Federal
450    * @author     Cristiano Corrêa Schmidt
451    * @return     void
452    * @access     public
453    */
454    public function deleteEvent( &$uri , &$result , &$params , $original  )
455    {           
456       $schedulable =  Controller::read(  array( 'concept' => 'schedulable' , 'id' => $uri['id'] ) , null , array('deepness' => '2') ) ;
457       if((Config::regGet('noAlarm') === false) && (self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd'])))
458       {
459            $method = 'CANCEL';
460            $notificationType = 'Cancelamento de Calendario';
461            $part = 'othersAttendees';
462            self::mountStruture($uri['id'], $schedulable, false , $data,  $subject, $ical, $part, $method, $notificationType );
463               
464            if(count($part) > 0)
465                self::sendMail($data, $ical , implode(',' , $part) ,$subject, 'notify_cancel_body');
466       }
467    }
468   
469    /**
470    * Monta o email de cancelado que sera enviado ao participant deleteado
471    *
472    * @license    http://www.gnu.org/copyleft/gpl.html GPL
473    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
474    * @sponsor    Caixa Econômica Federal
475    * @author     Cristiano Corrêa Schmidt
476    * @return     void
477    * @access     public
478    */
479    public function deleteParticipant( &$uri , &$result , &$params , $original  )
480    {
481       
482       $participant =  Controller::read(  array( 'concept' => 'participant' , 'id' => $uri['id'] ) , null , array('deepness' => '1') ) ;
483       $schedulable =  Controller::read(  array( 'concept' => 'schedulable' , 'id' => $participant['schedulable'] ) ) ;
484             
485       if((Config::regGet('noAlarm') === false) && (self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd'])))
486       { 
487            $method = 'CANCEL';
488            $notificationType = 'Cancelamento de Calendario';
489            $part = 'others';
490            self::mountStruture(false, $schedulable, false , $data,  $subject, $ical, $part, $method, $notificationType );
491
492            self::sendMail($data, $ical , $participant['user']['mail'] , $subject , 'notify_cancel_body'); 
493        }
494    }
495   
496    /**
497    * Faz um diff do update se ouve realmente uma alteração envia um email a todos os participants
498    *
499    * @license    http://www.gnu.org/copyleft/gpl.html GPL
500    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
501    * @sponsor    Caixa Econômica Federal
502    * @author     Cristiano Corrêa Schmidt
503    * @return     void
504    * @access     public
505    */
506    public function updateEvent( &$uri , &$params , &$criteria , $original  )
507    {       
508       $schedulableOld =  Controller::find( array( 'concept' => 'schedulable' , 'id' => $uri['id'] ) , null , array('deepness' => '2') ) ;     
509       $schedulable = $schedulableOld;
510       $alt = false;
511
512       foreach ($params as $i => $v) //Verifica se ouve alteração no evento
513           if( isset( $schedulableOld[$i] ) && $schedulableOld[$i] != $v && $i != 'participants')
514           {
515               $schedulable[$i] = $v;
516               $alt = true;   
517           }
518           
519       if ( ($alt === true) && (Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'])) )
520       {                       
521            $method = 'REQUEST';
522            $notificationType = 'Modificação de Calendario';
523            $part = 'othersAttendees';
524            self::mountStruture($partID, $schedulable, $type , $data,  $subject, $ical, $part, $method, $notificationType);
525
526            if ( isset($part) && count($part) > 0)
527                self::sendMail($data, $ical, implode(',', $part), $subject, 'notify_modify_body');
528        }
529    }
530}
531
532?>
Note: See TracBrowser for help on using the repository browser.