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

Revision 5514, 22.6 KB checked in by acoutinho, 12 years ago (diff)

Ticket #2434 - Implementacao anexos, acls e delegacao de participantes

RevLine 
[5341]1<?php
2require_once ROOTPATH.'/modules/calendar/constants.php';
3require_once ROOTPATH.'/modules/calendar/interceptors/Helpers.php';
[5399]4require_once ROOTPATH.'/plugins/icalcreator/iCalcreator.class.php';
5require_once ROOTPATH.'/api/parseTPL.php';
[5341]6 
7class Notifications extends Helpers
8{
9   
[5514]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        /**
[5341]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)
[5514]33    {                           
[5341]34        if(Config::regGet('noAlarm') !== false) return; //Escapa notificações caso a flag de noAlarm esteja ativa.
[5514]35               
[5341]36        $organizers = array(); //Cache Organizadores
37        $schedulables = array(); //Cache Schedulables
[5514]38
[5341]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;
[5514]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                        }
[5341]67        }
68       
69        if( isset( $created ) )
70        {
[5514]71           $psCreated =  Controller::find(array('concept' => 'participant'), false , array('deepness' => '1' , 'filter' => array('IN', 'id' , $created )));               
72                   foreach ($psCreated as $i => $pCreated)   
[5341]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'] );
[5514]79                           
80                                if($pCreated['delegatedFrom'] != 0){
81                                        self::participantDelegated( $pCreated , $schedulable , $organizer);   
82                                        continue;
83                                }
84                           
[5341]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 )));
[5514]100                        foreach ($psUpdated as $i => $pUpdated)   
101            {                   
[5341]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                   
[5514]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'] );   
[5341]113            }
114        }
115    }
[5514]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                       
[5341]138
[5514]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                $params['attachments'][] = $ical;
156                $params['isHtml'] = true;                         
157                $params['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/notify_suggestion_body.tpl');
158                $params['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');;
159                $params['from'] = Config::me('mail');   
160                $params['to'] = $organizer['user']['mail'];
161               
162        } 
163       
164        public function formatSuggestionResponse(&$params){     
165                $schedulable = $params['schedulable'];
166                foreach ($schedulable['participants'] as $i => $v) {//salva em $organizer as informações do organizador     
167            if($v['isOrganizer'] === '1') $organizer = $v;
168                        if($v['user']['mail'] == Config::me('mail')) $me = $v;
169                }
170                $method = 'DECLINECOUNTER';
171                $notificationType = 'Sugestão de horário';
172                $part = 'other';
173               
174                $schedulable['participants'] = array();
175                array_push($schedulable['participants'], $me, $organizer);
176               
177                self::mountStruture(false, $schedulable, false , $data,  $subject, $ical, $part, $method, $notificationType);
178               
179                if($params['status'] == 'DECLINECOUNTER')
180                        $data['status'] = 'não pode ser aceito';
181                       
182                $params['attachments'][] = $ical;
183                $params['isHtml'] = true;                         
184                $params['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/notify_suggestion_response_body.tpl');
185                $params['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');;
186                $params['to'] = $params['from'];
187                $params['from'] = Config::me('mail');   
188        }
189       
190       
191        public static function _getAttendeeById($attendeId, $schedulable){
192                foreach ($schedulable['participants'] as $id => $dv)
193                        if($dv['id'] == $attendeId )
194                                return $dv;
195        }
196       
197        /**
198    * Prepara para criação de email de delegação
[5341]199    *
200    * @license    http://www.gnu.org/copyleft/gpl.html GPL
201    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
202    * @sponsor    Caixa Econômica Federal
[5514]203    * @author     Adriano Coutinho da Silva
204    * @return     void
205    * @access     public
206    */
207        public static function participantDelegated( &$partID , &$schedulable , &$organizer){
208       
209                $delegatedParams = array();
210               
211                $delegatedFrom = self::_getAttendeeById($partID['delegatedFrom'], $schedulable);
212                $delegatedParams['delegatedFrom'] = $delegatedFrom['user']['uid'];
213               
214                self::participantCreated( $partID['id'] , $schedulable , STATUS_DELEGATED, $delegatedParams );         
215               
216                $delegatedTo = self::_getAttendeeById($partID['id'], $schedulable);
217                $delegatedParams['delegated'] = $delegatedTo['user']['uid'];
218               
219                self::participantStatusChange( $partID['delegatedFrom'] , $schedulable , $organizer , STATUS_DELEGATED, $delegatedParams );
220        }
221       
222        /**
223    * Monta o email de resposta que sera enviado ao delegatedFrom
224    *
225    * @license    http://www.gnu.org/copyleft/gpl.html GPL
226    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
227    * @sponsor    Caixa Econômica Federal
[5341]228    * @author     Cristiano Corrêa Schmidt
229    * @return     void
230    * @access     public
231    */
[5514]232    public static function participantDelegatedStatusChange( &$partID , &$schedulable, $organizer, &$type = false){
233       
234                $delegatedParams = array();
235                                       
236                $delegated = self::_getAttendeeById($partID['id'], $schedulable);
237                $delegatedParams['delegated'] = $delegated['user']['uid'];             
238               
239                switch($partID['status']){
240            case STATUS_ACCEPTED:
241                $delegatedParams['status'] = 'aceitou';
242            break;
243            case STATUS_TENTATIVE:
244                $delegatedParams['status'] = 'marcou como tentativa';
245            break;
246            case STATUS_CANCELLED:
247                $delegatedParams['status'] = 'rejeitou';
248            break;
249                        case STATUS_DELEGATED:
250                                $delegatedParams['status'] = 'delegou para um novo participante';
251            break;
252                }
253                        //notifica o organizador a resposta do delegado
254                        self::participantStatusChange( $partID['delegatedFrom'] , $schedulable , $organizer , $type, $delegatedParams );
255       
256                        $method = 'REQUEST';
257                        $notificationType = 'Resposta Delegação';
258                        $part = 'attendees';
259                        self::mountStruture($partID['delegatedFrom'], $schedulable, $type , $data,  $subject, $ical, $part, $method, $notificationType );
260                       
261                        $data = array_merge($data, $delegatedParams);
262                       
263            self::sendMail($data, $ical , $part['user']['mail'] , $subject , 'notify_response_delegated_status_body');
264       
265    }
266
267        public static function mountStruture( $partID , &$schedulable, $type = false, &$data, &$subject, &$ical, &$part = false, &$method, &$notificationType, $regSet = false) {
268               
269                if( (Config::regGet('ical://'.$schedulable['id'].'/'.$method) === false) || ($method == 'CANCEL') ) //Verifica se o ical ja não esta no reg
270                {
271                        $schedulable['URI']['concept'] = 'schedulable';
272                        $ical['source'] = Controller::format( array( 'service' => 'iCal' ) , array($schedulable) , array('method' => $method) ); 
273                        $ical['type'] = 'text/calendar';
274                        $ical['name'] = 'calendar.ics';
275                        if($regSet)
276                                Config::regSet('ical://'.$schedulable['id'].'/'.$method, $ical);
277                }
278                else
279                        $ical = Config::regGet('ical://'.$schedulable['id'].'/'.$method);
[5341]280       
[5514]281                        $timezone = new DateTimeZone('UTC');
282                        $sTime = new DateTime( '@'.(int)($schedulable['startTime'] / 1000) , $timezone );
283                        $eTime =  new DateTime( '@'.(int)($schedulable['endTime'] / 1000) , $timezone );
[5341]284           
[5514]285                        if(isset($schedulable['timezone']))
286                        {
287                                $sTime->setTimezone(new DateTimeZone($schedulable['timezone']));
288                                $eTime->setTimezone(new DateTimeZone($schedulable['timezone']));
289                        }
[5341]290           
[5514]291                        $data = array(     'startDate' =>  date_format( $sTime , 'd/m/Y') ,
[5341]292                              'startTime' =>  ($schedulable['allDay']) ? '' : date_format( $sTime , 'H:i') ,
293                              'endDate' =>  date_format( $eTime , 'd/m/Y') ,
294                              'endTime' =>  ($schedulable['allDay']) ? '' :  date_format( $eTime , 'H:i') ,
295                              'eventTitle' =>  $schedulable['summary'],
296                              'eventLocation' =>  $schedulable['location'],
[5514]297                              'timezone' =>  ($schedulable['timezone']) ? $schedulable['timezone'] : 'UTC');
298                        $temp = $part;
299                        $part = false;
300                        switch($temp){
301                                case 'attendees':
302                                        $attList = '<UL> ';
303                                        foreach ($schedulable['participants'] as $i => $v) 
304                                        {               
305                                                if($part === false && $v['id'] == $partID)
306                                                   $part = $v;
307
308                                                $attList .= ' <LI> '. (isset($v['user']['name']) ? $v['user']['name'] : $v['user']['mail']) ;
309                                        }
310                                        $attList .= '</UL>';
311                                        $data['participants'] = $attList;
312                                break;
313                                case 'me':
314                                        $part = self::_getAttendeeById($partID, $schedulable);
315                                        $data['participant'] = isset($part['user']['name']) ? $part['user']['name'] : $part['user']['mail'];
316                                break;
317                                case 'othersAttendees':
318                                        $data['participants'] = '<UL> ';
319                                        foreach ($schedulable['participants'] as $ii => $participant){
320                                                if(Config::me('mail') !== $participant['user']['mail'])
321                                                        $part[] = $participant['user']['mail'];
322                                       
323                                        $data['participants'] .= ' <LI> '. (isset($participant['user']['name']) ? $participant['user']['name'] : $participant['user']['mail']) ;
324                                        }
325                                break;
326                        }         
327                        $subject['notificationType'] = $notificationType;
328                        $subject['eventTitle'] = mb_convert_encoding($schedulable['summary'],'ISO-8859-1','ISO-8859-1,UTF-8');
329                        $subject['startDate'] = date_format( $sTime , 'd/m/Y');
330                        $subject['startTime'] = ($schedulable['allDay']) ? '' : date_format( $sTime , 'H:i');
331                        $subject['endDate'] = date_format( $eTime , 'd/m/Y');
332                        $subject['endTime'] = ($schedulable['allDay']) ? '' : date_format( $eTime , 'H:i');
333                        $subject['participant'] = Config::me('uid');
334        }
335       
336       
337    /**
338    * Monta o email de convite que sera enviado ao participant
339    *
340    * @license    http://www.gnu.org/copyleft/gpl.html GPL
341    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
342    * @sponsor    Caixa Econômica Federal
343    * @author     Cristiano Corrêa Schmidt
344    * @return     void
345    * @access     public
346    */
347    public static function participantCreated( &$partID , &$schedulable, $type = false, $delegatedParams = false)
348    {   
349                $method = 'REQUEST';
350                $notificationType = 'Convite de Calendario';
351                $part = 'attendees';
352                self::mountStruture($partID, $schedulable, $type , $data,  $subject, $ical, $part, $method, $notificationType, true);
353       
354                if($delegatedParams)
355                        $data = array_merge($data, $delegatedParams);
356                                         
357                 self::sendMail($data, $ical , $part['user']['mail'] , $subject , !$delegatedParams  ? 'notify_create_body' : 'notify_create_delegated_body' );
[5341]358       
359    }
360   
361    /**
362    * Monta o email de aceito que sera enviado ao organizador
363    *
364    * @license    http://www.gnu.org/copyleft/gpl.html GPL
365    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
366    * @sponsor    Caixa Econômica Federal
367    * @author     Cristiano Corrêa Schmidt
368    * @return     void
369    * @access     public
370    */
[5514]371    public static function participantStatusChange( &$partID , &$schedulable , &$organizer , $type, $delegatedParams = false )
372    {   
373        $method = 'REPLY';
374                $notificationType = 'Convite Aceito';
375                $part = 'me';
376               
377                self::mountStruture($partID, $schedulable, $type , $data,  $subject, $ical, $part, $method, $notificationType, true );
378                       
379                if($delegatedParams){
380                        $data = array_merge($data, $delegatedParams);
381                        $tplDelegated = 'notify_delegated_status_body';
382                }
383
[5341]384       switch($type)
385       {
386            case STATUS_ACCEPTED:
[5514]387                $tpl =   !$delegatedParams ? 'notify_accept_body' : $tplDelegated;
[5341]388                $subject['notificationType'] = 'Convite Aceito';
389            break;
[5514]390            case STATUS_TENTATIVE:
391                $tpl =   !$delegatedParams ? 'notify_attempt_body' : $tplDelegated;
[5341]392                $subject['notificationType'] = 'Convite  aceito provisoriamente';
393            break;
394            case STATUS_CANCELLED:
[5514]395                $tpl =   !$delegatedParams ? 'notify_reject_body' : $tplDelegated;
[5341]396                $subject['notificationType'] = 'Convite rejeitado';
397            break;
[5514]398                        case STATUS_DELEGATED:
399                                if($delegatedParams)
400                                        $data = array_merge($data, $delegatedParams);
401                $tpl =   'notify_delegated_body';
402                $subject['notificationType'] = 'Convite delegado';
403            break;
[5341]404
405       }
406       
407        self::sendMail($data, $ical , $organizer['user']['mail'] , $subject , $tpl);
408    }
409   
410    /**
411    * Monta o body e envia o email
412    *
413    * @license    http://www.gnu.org/copyleft/gpl.html GPL
414    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
415    * @sponsor    Caixa Econômica Federal
416    * @author     Cristiano Corrêa Schmidt
417    * @return     void
418    * @access     public
419    */
420    private static function sendMail(&$data , &$ical , $to ,  &$subject , $template )
421    {
422       $mail['attachments'][] = $ical;
423       $mail['isHtml'] = true;                         
[5399]424       $mail['body'] = parseTPL::load_tpl( $data ,ROOTPATH.'/modules/calendar/templates/'.$template.'.tpl');
425       $mail['subject'] = parseTPL::load_tpl( $subject ,ROOTPATH.'/modules/calendar/templates/notify_subject.tpl');;
[5341]426       $mail['from'] = Config::me('mail');   
427       $mail['to'] = $to;
428       Controller::create( array( 'service' => 'SMTP' ), $mail );
429    }
430   
431 
432    /**
433    * Monta o email de cancelado que sera enviado a todos os participantes
434    *
435    * @license    http://www.gnu.org/copyleft/gpl.html GPL
436    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
437    * @sponsor    Caixa Econômica Federal
438    * @author     Cristiano Corrêa Schmidt
439    * @return     void
440    * @access     public
441    */
442    public function deleteEvent( &$uri , &$result , &$params , $original  )
443    {           
444       $schedulable =  Controller::read(  array( 'concept' => 'schedulable' , 'id' => $uri['id'] ) , null , array('deepness' => '2') ) ;
445       if((Config::regGet('noAlarm') === false) && (self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd'])))
446       {
[5514]447                        $method = 'CANCEL';
448                        $notificationType = 'Cancelamento de Calendario';
449                        $part = 'othersAttendees';
450                        self::mountStruture($uri['id'], $schedulable, false , $data,  $subject, $ical, $part, $method, $notificationType );
[5341]451               
[5514]452           if(count($part) > 0)
453            self::sendMail($data, $ical , implode(',' , $part) ,$subject, 'notify_cancel_body');
[5341]454       }
455    }
456   
457    /**
458    * Monta o email de cancelado que sera enviado ao participant deleteado
459    *
460    * @license    http://www.gnu.org/copyleft/gpl.html GPL
461    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
462    * @sponsor    Caixa Econômica Federal
463    * @author     Cristiano Corrêa Schmidt
464    * @return     void
465    * @access     public
466    */
467    public function deleteParticipant( &$uri , &$result , &$params , $original  )
468    {
469       
470       $participant =  Controller::read(  array( 'concept' => 'participant' , 'id' => $uri['id'] ) , null , array('deepness' => '1') ) ;
471       $schedulable =  Controller::read(  array( 'concept' => 'schedulable' , 'id' => $participant['schedulable'] ) ) ;
472             
473       if((Config::regGet('noAlarm') === false) && (self::futureEvent( $schedulable['startTime'] , $schedulable['rangeEnd'])))
474       { 
[5514]475                        $method = 'CANCEL';
476                        $notificationType = 'Cancelamento de Calendario';
477                        $part = 'others';
478                        self::mountStruture(false, $schedulable, false , $data,  $subject, $ical, $part, $method, $notificationType );
479                                           
480                        self::sendMail($data, $ical , $participant['user']['mail'] , $subject , 'notify_cancel_body'); 
[5341]481        }
482    }
483   
484    /**
485    * Faz um diff do update se ouve realmente uma alteração envia um email a todos os participants
486    *
487    * @license    http://www.gnu.org/copyleft/gpl.html GPL
488    * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
489    * @sponsor    Caixa Econômica Federal
490    * @author     Cristiano Corrêa Schmidt
491    * @return     void
492    * @access     public
493    */
494    public function updateEvent( &$uri , &$params , &$criteria , $original  )
[5514]495    {       
496       $schedulableOld =  Controller::find( array( 'concept' => 'schedulable' , 'id' => $uri['id'] ) , null , array('deepness' => '2') ) ;     
[5341]497       $schedulable = $schedulableOld;
498       $alt = false;
[5514]499
[5341]500       foreach ($params as $i => $v) //Verifica se ouve alteração no evento
501           if( isset( $schedulableOld[$i] ) && $schedulableOld[$i] != $v && $i != 'participants')
502           {
503               $schedulable[$i] = $v;
504               $alt = true;   
505           }
506           
507       if ( ($alt === true) && (Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'])) )
[5514]508       {                       
509                        $method = 'REQUEST';
510                        $notificationType = 'Modificação de Calendario';
511                        $part = 'othersAttendees';
512                        self::mountStruture($partID, $schedulable, $type , $data,  $subject, $ical, $part, $method, $notificationType);
[5341]513
[5514]514            if ( isset($part) && count($part) > 0)
515                self::sendMail($data, $ical, implode(',', $part), $subject, 'notify_modify_body');
[5341]516        }
517    }
518}
519
520?>
Note: See TracBrowser for help on using the repository browser.