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

Revision 7174, 22.5 KB checked in by cristiano, 12 years ago (diff)

Ticket #3094 - Horário incorreto ao importar evento no Outlook 2010

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