source: sandbox/2.4.2-expresso1/prototype/modules/calendar/interceptors/Notifications.php @ 6528

Revision 6528, 22.1 KB checked in by gustavo, 12 years ago (diff)

Ticket #2766 - Merge do branch das novas funcionalidaes para o trunk

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    /**
207     * Prepara para criação de email de delegação
208     *
209     * @license    http://www.gnu.org/copyleft/gpl.html GPL
210     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
211     * @sponsor    Caixa Econômica Federal
212     * @author     Adriano Coutinho da Silva
213     * @return     void
214     * @access     public
215     */
216    public static function participantDelegated(&$partID, &$schedulable, &$organizer) {
217
218        $delegatedParams = array();
219
220        $delegatedFrom = self::_getAttendeeById($partID['delegatedFrom'], $schedulable);
221        $delegatedParams['delegatedFrom'] = $delegatedFrom['user']['uid'];
222
223        self::participantCreated($partID['id'], $schedulable, STATUS_DELEGATED, $delegatedParams);
224
225        $delegatedTo = self::_getAttendeeById($partID['id'], $schedulable);
226        $delegatedParams['delegated'] = $delegatedTo['user']['uid'];
227
228        self::participantStatusChange($partID['delegatedFrom'], $schedulable, $organizer, STATUS_DELEGATED, $delegatedParams);
229    }
230
231    /**
232     * Monta o email de resposta que sera enviado ao delegatedFrom
233     *
234     * @license    http://www.gnu.org/copyleft/gpl.html GPL
235     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
236     * @sponsor    Caixa Econômica Federal
237     * @author     Cristiano Corrêa Schmidt
238     * @return     void
239     * @access     public
240     */
241    public static function participantDelegatedStatusChange(&$partID, &$schedulable, $organizer, &$type = false) {
242        $delegatedParams = array();
243
244        $delegated = self::_getAttendeeById($partID['id'], $schedulable);
245        $delegatedParams['delegated'] = $delegated['user']['uid'];
246
247        switch ($partID['status']) {
248            case STATUS_ACCEPTED:
249                $delegatedParams['status'] = 'aceitou';
250                break;
251            case STATUS_TENTATIVE:
252                $delegatedParams['status'] = 'marcou como tentativa';
253                break;
254            case STATUS_CANCELLED:
255                $delegatedParams['status'] = 'rejeitou';
256                break;
257            case STATUS_DELEGATED:
258                $delegatedParams['status'] = 'delegou para um novo participante';
259                break;
260        }
261        //notifica o organizador a resposta do delegado
262        self::participantStatusChange($partID['delegatedFrom'], $schedulable, $organizer, $type, $delegatedParams);
263
264        $method = 'REQUEST';
265        $notificationType = 'Resposta Delegação';
266        $part = 'attendees';
267        self::mountStruture($partID['delegatedFrom'], $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType);
268
269        $data = array_merge($data, $delegatedParams);
270
271        self::sendMail($data, $ical, $part['user']['mail'], $subject, 'notify_response_delegated_status_body');
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            $schedulable['URI']['concept'] = 'schedulable';
278            $ical['source'] = Controller::format(array('service' => 'iCal'), array($schedulable), array('method' => $method));
279            $ical['type'] = 'text/plain';
280            $ical['name'] = 'outlook.ics';
281            if ($regSet)
282                Config::regSet('ical://' . $schedulable['id'] . '/' . $method, $ical);
283        }
284        else
285            $ical = Config::regGet('ical://' . $schedulable['id'] . '/' . $method);
286
287        if (!is_numeric($schedulable['endTime']))
288            $schedulable['startTime'] = self::parseTimeDate($schedulable['startTime'], $schedulable['timezone']);
289
290        if (!is_numeric($schedulable['endTime'])) {
291            $schedulable['endTime'] = self::parseTimeDate($schedulable['endTime'], $schedulable['timezone']);
292
293            if ($schedulable['allDay'])
294                $schedulable['endTime'] = $schedulable['endTime'] + 86400000;
295        }
296
297        $timezone = new DateTimeZone('UTC');
298        $sTime = new DateTime('@' . (int) ($schedulable['startTime'] / 1000), $timezone);
299        $eTime = new DateTime('@' . (int) ($schedulable['endTime'] / 1000), $timezone);
300
301        if (isset($schedulable['timezone'])) {
302            $sTime->setTimezone(new DateTimeZone($schedulable['timezone']));
303            $eTime->setTimezone(new DateTimeZone($schedulable['timezone']));
304        }
305
306        $data = array('startDate' => date_format($sTime, 'd/m/Y'),
307            'startTime' => ($schedulable['allDay']) ? '' : date_format($sTime, 'H:i'),
308            'endDate' => date_format($eTime, 'd/m/Y'),
309            'endTime' => ($schedulable['allDay']) ? '' : date_format($eTime, 'H:i'),
310            'eventTitle' => $schedulable['summary'],
311            'eventLocation' => $schedulable['location'],
312            'timezone' => ($schedulable['timezone']) ? $schedulable['timezone'] : 'UTC');
313        $temp = $part;
314        $part = false;
315
316        switch ($temp) {
317            case 'attendees':
318                $attList = '<UL> ';
319                foreach ($schedulable['participants'] as $i => $v) {
320                    if ($part === false && $v['id'] == $partID)
321                        $part = $v;
322
323                    $attList .= ' <LI> ' . (isset($v['user']['name']) ? $v['user']['name'] : $v['user']['mail']);
324                }
325                $attList .= '</UL>';
326                $data['participants'] = $attList;
327                break;
328            case 'me':
329                $part = self::_getAttendeeById($partID, $schedulable);
330                $data['participant'] = isset($part['user']['name']) ? $part['user']['name'] : $part['user']['mail'];
331                $partID = $part;
332                break;
333            case 'othersAttendees':
334                $data['participants'] = '<UL> ';
335                foreach ($schedulable['participants'] as $ii => $participant) {
336                    if (Config::me('mail') !== $participant['user']['mail'])
337                        $part[] = $participant['user']['mail'];
338
339                    $data['participants'] .= ' <LI> ' . (isset($participant['user']['name']) ? $participant['user']['name'] : $participant['user']['mail']);
340                }
341                break;
342        }
343        $subject['notificationType'] = $notificationType;
344        $subject['eventTitle'] = mb_convert_encoding($schedulable['summary'], 'ISO-8859-1', 'ISO-8859-1,UTF-8');
345        $subject['startDate'] = date_format($sTime, 'd/m/Y');
346        $subject['startTime'] = ($schedulable['allDay']) ? '' : date_format($sTime, 'H:i');
347        $subject['endDate'] = date_format($eTime, 'd/m/Y');
348        $subject['endTime'] = ($schedulable['allDay']) ? '' : date_format($eTime, 'H:i');
349        $subject['participant'] = (is_array($partID) && isset($partID['user']) )? $partID['user']['uid'] : Config::me('uid');
350    }
351
352    /**
353     * Monta o email de convite que sera enviado ao participant
354     *
355     * @license    http://www.gnu.org/copyleft/gpl.html GPL
356     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
357     * @sponsor    Caixa Econômica Federal
358     * @author     Cristiano Corrêa Schmidt
359     * @return     void
360     * @access     public
361     */
362    public static function participantCreated(&$partID, &$schedulable, $type = false, $delegatedParams = false, $organizer = false) {
363        $method = 'REQUEST';
364        $notificationType = 'Convite de Calendario';
365        $part = 'attendees';
366        self::mountStruture($partID, $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType, true);
367
368        if ($delegatedParams)
369            $data = array_merge($data, $delegatedParams);
370
371        self::sendMail($data, $ical, $part['user']['mail'], $subject, !$delegatedParams ? 'notify_create_body' : 'notify_create_delegated_body', $organizer);
372    }
373
374    /**
375     * Monta o email de aceito que sera enviado ao organizador
376     *
377     * @license    http://www.gnu.org/copyleft/gpl.html GPL
378     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
379     * @sponsor    Caixa Econômica Federal
380     * @author     Cristiano Corrêa Schmidt
381     * @return     void
382     * @access     public
383     */
384    public static function participantStatusChange(&$partID, &$schedulable, &$organizer, $type, $delegatedParams = false) {     
385        $method = 'REPLY';
386        $notificationType = 'Convite Aceito';
387        $part = 'me';
388
389        self::mountStruture($partID, $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType, true);
390
391        if ($delegatedParams) {
392            $data = array_merge($data, $delegatedParams);
393            $tplDelegated = 'notify_delegated_status_body';
394        }
395
396        switch ($type) {
397            case STATUS_ACCEPTED:
398                $tpl = !$delegatedParams ? 'notify_accept_body' : $tplDelegated;
399                $subject['notificationType'] = 'Convite Aceito';
400                break;
401            case STATUS_TENTATIVE:
402                $tpl = !$delegatedParams ? 'notify_attempt_body' : $tplDelegated;
403                $subject['notificationType'] = 'Convite  aceito provisoriamente';
404                break;
405            case STATUS_CANCELLED:
406                $tpl = !$delegatedParams ? 'notify_reject_body' : $tplDelegated;
407                $subject['notificationType'] = 'Convite rejeitado';
408                break;
409            case STATUS_DELEGATED:
410                if ($delegatedParams)
411                    $data = array_merge($data, $delegatedParams);
412                $tpl = 'notify_delegated_body';
413                $subject['notificationType'] = 'Convite delegado';
414                break;
415        }
416
417        self::sendMail($data, $ical, $organizer['user']['mail'], $subject, $tpl, $partID);
418    }
419
420    /**
421     * Monta o body e envia o email
422     *
423     * @license    http://www.gnu.org/copyleft/gpl.html GPL
424     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
425     * @sponsor    Caixa Econômica Federal
426     * @author     Cristiano Corrêa Schmidt
427     * @return     void
428     * @access     public
429     */
430    private static function sendMail(&$data, &$ical, $to, &$subject, $template, $from = false) {
431        $ical2 = $ical;
432        $ical2['type'] = 'text/calendar';
433        $ical2['name'] = 'thunderbird.ics';
434        $mail['attachments'][] = $ical2;
435        $mail['attachments'][] = $ical;
436        $mail['isHtml'] = true;
437        $mail['body'] = parseTPL::load_tpl($data, ROOTPATH . '/modules/calendar/templates/' . $template . '.tpl');
438        $mail['subject'] = parseTPL::load_tpl($subject, ROOTPATH . '/modules/calendar/templates/notify_subject.tpl');
439        ;
440        $mail['from'] = $from ? ('"' . $from['user']['name'] . '" <' . $from['user']['mail'] . '>') : ('"' . Config::me('cn') . '" <' . Config::me('mail') . '>');
441        $mail['to'] = $to;
442        Controller::create(array('service' => 'SMTP'), $mail);
443    }
444
445    /**
446     * Monta o email de cancelado que sera enviado a todos os participantes
447     *
448     * @license    http://www.gnu.org/copyleft/gpl.html GPL
449     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
450     * @sponsor    Caixa Econômica Federal
451     * @author     Cristiano Corrêa Schmidt
452     * @return     void
453     * @access     public
454     */
455    public function deleteEvent(&$uri, &$result, &$params, $original) {
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'], $schedulable['id']))) {
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        $participant = Controller::read(array('concept' => 'participant', 'id' => $uri['id']), null, array('deepness' => '1'));
481        $schedulable = Controller::read(array('concept' => 'schedulable', 'id' => $participant['schedulable']));
482
483        if ((Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))) {
484            $method = 'CANCEL';
485            $notificationType = 'Cancelamento de Calendario';
486            $part = 'others';
487            self::mountStruture(false, $schedulable, false, $data, $subject, $ical, $part, $method, $notificationType);
488
489            self::sendMail($data, $ical, $participant['user']['mail'], $subject, 'notify_cancel_body');
490        }
491    }
492
493    /**
494     * Faz um diff do update se ouve realmente uma alteração envia um email a todos os participants
495     *
496     * @license    http://www.gnu.org/copyleft/gpl.html GPL
497     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
498     * @sponsor    Caixa Econômica Federal
499     * @author     Cristiano Corrêa Schmidt
500     * @return     void
501     * @access     public
502     */
503    public function updateEvent(&$uri, $params, &$criteria, $original) {
504        $schedulableOld = Controller::read(array('concept' => 'schedulable', 'id' => $uri['id']), null, array('deepness' => '2'));
505        $schedulable = $schedulableOld;
506        $alt = false;
507
508        foreach ($params as $i => $v) //Verifica se ouve alteração no evento
509            if (isset($schedulableOld[$i]) && $schedulableOld[$i] != $v && $i != 'participants') {
510                $schedulable[$i] = $v;
511                $alt = true;
512            }
513
514        if (($alt === true) && (Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))) {
515            $method = 'REQUEST';
516            $notificationType = 'Modificação de Calendario';
517            $part = 'othersAttendees';
518            self::mountStruture($uri['id'], $schedulable, false, $data, $subject, $ical, $part, $method, $notificationType);
519
520            if (isset($part) && $part && count($part) > 0)
521                self::sendMail($data, $ical, implode(',', $part), $subject, 'notify_modify_body');
522        }
523    }
524
525    static private function parseTimeDate($time, $timezone) {
526        return strtotime($time . ' ' . $timezone) . '000';
527    }
528
529}
530
531?>
Note: See TracBrowser for help on using the repository browser.