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

Revision 5523, 23.1 KB checked in by cristiano, 12 years ago (diff)

Ticket #2434 - Compatibilidade de ics com outlook2000 e tamnho de textarea incorreto

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 );
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('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'] = 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                        switch($temp){
308                                case 'attendees':
309                                        $attList = '<UL> ';
310                                        foreach ($schedulable['participants'] as $i => $v) 
311                                        {               
312                                                if($part === false && $v['id'] == $partID)
313                                                   $part = $v;
314
315                                                $attList .= ' <LI> '. (isset($v['user']['name']) ? $v['user']['name'] : $v['user']['mail']) ;
316                                        }
317                                        $attList .= '</UL>';
318                                        $data['participants'] = $attList;
319                                break;
320                                case 'me':
321                                        $part = self::_getAttendeeById($partID, $schedulable);
322                                        $data['participant'] = isset($part['user']['name']) ? $part['user']['name'] : $part['user']['mail'];
323                                break;
324                                case 'othersAttendees':
325                                        $data['participants'] = '<UL> ';
326                                        foreach ($schedulable['participants'] as $ii => $participant){
327                                                if(Config::me('mail') !== $participant['user']['mail'])
328                                                        $part[] = $participant['user']['mail'];
329                                       
330                                        $data['participants'] .= ' <LI> '. (isset($participant['user']['name']) ? $participant['user']['name'] : $participant['user']['mail']) ;
331                                        }
332                                break;
333                        }         
334                        $subject['notificationType'] = $notificationType;
335                        $subject['eventTitle'] = mb_convert_encoding($schedulable['summary'],'ISO-8859-1','ISO-8859-1,UTF-8');
336                        $subject['startDate'] = date_format( $sTime , 'd/m/Y');
337                        $subject['startTime'] = ($schedulable['allDay']) ? '' : date_format( $sTime , 'H:i');
338                        $subject['endDate'] = date_format( $eTime , 'd/m/Y');
339                        $subject['endTime'] = ($schedulable['allDay']) ? '' : date_format( $eTime , 'H:i');
340                        $subject['participant'] = Config::me('uid');
341        }
342       
343       
344    /**
345    * Monta o email de convite que sera enviado ao participant
346    *
347    * @license    http://www.gnu.org/copyleft/gpl.html GPL
348    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
349    * @sponsor    Caixa Econômica Federal
350    * @author     Cristiano Corrêa Schmidt
351    * @return     void
352    * @access     public
353    */
354    public static function participantCreated( &$partID , &$schedulable, $type = false, $delegatedParams = false)
355    {   
356                $method = 'REQUEST';
357                $notificationType = 'Convite de Calendario';
358                $part = 'attendees';
359                self::mountStruture($partID, $schedulable, $type , $data,  $subject, $ical, $part, $method, $notificationType, true);
360       
361                if($delegatedParams)
362                        $data = array_merge($data, $delegatedParams);
363                                         
364                 self::sendMail($data, $ical , $part['user']['mail'] , $subject , !$delegatedParams  ? 'notify_create_body' : 'notify_create_delegated_body' );
365       
366    }
367   
368    /**
369    * Monta o email de aceito que sera enviado ao organizador
370    *
371    * @license    http://www.gnu.org/copyleft/gpl.html GPL
372    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
373    * @sponsor    Caixa Econômica Federal
374    * @author     Cristiano Corrêa Schmidt
375    * @return     void
376    * @access     public
377    */
378    public static function participantStatusChange( &$partID , &$schedulable , &$organizer , $type, $delegatedParams = false )
379    {   
380        $method = 'REPLY';
381                $notificationType = 'Convite Aceito';
382                $part = 'me';
383               
384                self::mountStruture($partID, $schedulable, $type , $data,  $subject, $ical, $part, $method, $notificationType, true );
385                       
386                if($delegatedParams){
387                        $data = array_merge($data, $delegatedParams);
388                        $tplDelegated = 'notify_delegated_status_body';
389                }
390
391       switch($type)
392       {
393            case STATUS_ACCEPTED:
394                $tpl =   !$delegatedParams ? 'notify_accept_body' : $tplDelegated;
395                $subject['notificationType'] = 'Convite Aceito';
396            break;
397            case STATUS_TENTATIVE:
398                $tpl =   !$delegatedParams ? 'notify_attempt_body' : $tplDelegated;
399                $subject['notificationType'] = 'Convite  aceito provisoriamente';
400            break;
401            case STATUS_CANCELLED:
402                $tpl =   !$delegatedParams ? 'notify_reject_body' : $tplDelegated;
403                $subject['notificationType'] = 'Convite rejeitado';
404            break;
405                        case STATUS_DELEGATED:
406                                if($delegatedParams)
407                                        $data = array_merge($data, $delegatedParams);
408                $tpl =   'notify_delegated_body';
409                $subject['notificationType'] = 'Convite delegado';
410            break;
411
412       }
413       
414        self::sendMail($data, $ical , $organizer['user']['mail'] , $subject , $tpl);
415    }
416   
417    /**
418    * Monta o body e envia o email
419    *
420    * @license    http://www.gnu.org/copyleft/gpl.html GPL
421    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
422    * @sponsor    Caixa Econômica Federal
423    * @author     Cristiano Corrêa Schmidt
424    * @return     void
425    * @access     public
426    */
427    private static function sendMail(&$data , &$ical , $to ,  &$subject , $template )
428    {
429       $ical2 = $ical;
430       $ical2['type'] = 'text/calendar';
431       $ical2['name'] = 'thunderbird.ics';
432       $mail['attachments'][] = $ical2;
433       $mail['attachments'][] = $ical;
434       $mail['isHtml'] = true;                         
435       $mail['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/'.$template.'.tpl');
436       $mail['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');;
437       $mail['from'] = Config::me('mail');   
438       $mail['to'] = $to;
439       Controller::create( array( 'service' => 'SMTP' ), $mail );
440    }
441   
442 
443    /**
444    * Monta o email de cancelado que sera enviado a todos os participantes
445    *
446    * @license    http://www.gnu.org/copyleft/gpl.html GPL
447    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
448    * @sponsor    Caixa Econômica Federal
449    * @author     Cristiano Corrêa Schmidt
450    * @return     void
451    * @access     public
452    */
453    public function deleteEvent( &$uri , &$result , &$params , $original  )
454    {           
455       $schedulable =  Controller::read(  array( 'concept' => 'schedulable' , 'id' => $uri['id'] ) , null , array('deepness' => '2') ) ;
456       if((Config::regGet('noAlarm') === false) && (self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd'])))
457       {
458                        $method = 'CANCEL';
459                        $notificationType = 'Cancelamento de Calendario';
460                        $part = 'othersAttendees';
461                        self::mountStruture($uri['id'], $schedulable, false , $data,  $subject, $ical, $part, $method, $notificationType );
462               
463           if(count($part) > 0)
464            self::sendMail($data, $ical , implode(',' , $part) ,$subject, 'notify_cancel_body');
465       }
466    }
467   
468    /**
469    * Monta o email de cancelado que sera enviado ao participant deleteado
470    *
471    * @license    http://www.gnu.org/copyleft/gpl.html GPL
472    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
473    * @sponsor    Caixa Econômica Federal
474    * @author     Cristiano Corrêa Schmidt
475    * @return     void
476    * @access     public
477    */
478    public function deleteParticipant( &$uri , &$result , &$params , $original  )
479    {
480       
481       $participant =  Controller::read(  array( 'concept' => 'participant' , 'id' => $uri['id'] ) , null , array('deepness' => '1') ) ;
482       $schedulable =  Controller::read(  array( 'concept' => 'schedulable' , 'id' => $participant['schedulable'] ) ) ;
483             
484       if((Config::regGet('noAlarm') === false) && (self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd'])))
485       { 
486                        $method = 'CANCEL';
487                        $notificationType = 'Cancelamento de Calendario';
488                        $part = 'others';
489                        self::mountStruture(false, $schedulable, false , $data,  $subject, $ical, $part, $method, $notificationType );
490                                           
491                        self::sendMail($data, $ical , $participant['user']['mail'] , $subject , 'notify_cancel_body'); 
492        }
493    }
494   
495    /**
496    * Faz um diff do update se ouve realmente uma alteração envia um email a todos os participants
497    *
498    * @license    http://www.gnu.org/copyleft/gpl.html GPL
499    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
500    * @sponsor    Caixa Econômica Federal
501    * @author     Cristiano Corrêa Schmidt
502    * @return     void
503    * @access     public
504    */
505    public function updateEvent( &$uri , &$params , &$criteria , $original  )
506    {       
507       $schedulableOld =  Controller::find( array( 'concept' => 'schedulable' , 'id' => $uri['id'] ) , null , array('deepness' => '2') ) ;     
508       $schedulable = $schedulableOld;
509       $alt = false;
510
511       foreach ($params as $i => $v) //Verifica se ouve alteração no evento
512           if( isset( $schedulableOld[$i] ) && $schedulableOld[$i] != $v && $i != 'participants')
513           {
514               $schedulable[$i] = $v;
515               $alt = true;   
516           }
517           
518       if ( ($alt === true) && (Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'])) )
519       {                       
520                        $method = 'REQUEST';
521                        $notificationType = 'Modificação de Calendario';
522                        $part = 'othersAttendees';
523                        self::mountStruture($partID, $schedulable, $type , $data,  $subject, $ical, $part, $method, $notificationType);
524
525            if ( isset($part) && count($part) > 0)
526                self::sendMail($data, $ical, implode(',', $part), $subject, 'notify_modify_body');
527        }
528    }
529}
530
531?>
Note: See TracBrowser for help on using the repository browser.