source: sandbox/2.4.1-3/prototype/modules/calendar/interceptors/Notifications.php @ 6357

Revision 6357, 22.0 KB checked in by gustavo, 12 years ago (diff)

Ticket #2768 - Melhorias na inserção de destinatários na criacao de mensagem

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            foreach ($psUpdated as $i => $pUpdated) {
97                if ($pUpdated['isOrganizer'] == '1')
98                    continue; //escapa organizador
99                $schedulable = isset($schedulables[$pUpdated['schedulable']]) ? $schedulables[$pUpdated['schedulable']] : Controller::read(array('concept' => 'schedulable', 'id' => $pUpdated['schedulable']), false, array('deepness' => '2'));
100                if (!self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))
101                    continue; //Escapa eventos do passado
102
103                foreach ($schedulable['participants'] as $i => $v) //salva em $organizer as informações do organizador     
104                    if (($v['isOrganizer'] === '1') && ($organizer = $v))
105                        break;
106
107                if ($pUpdated['delegatedFrom'] != 0) {
108                    self::participantDelegatedStatusChange($pUpdated, $schedulable, $organizer, $pUpdated['status']);
109                } else if ($pUpdated['status'] != STATUS_UNANSWERED && $pUpdated['status'] != STATUS_DELEGATED)
110                    self::participantStatusChange($pUpdated['id'], $schedulable, $organizer, $pUpdated['status']);
111            }
112        }
113    }
114
115    public function formatSuggestion(&$params) {
116
117        $schedulable = Controller::read(array('concept' => 'schedulable', 'id' => $params['schedulable']), null, array('deepness' => '2'));
118
119        foreach ($schedulable['participants'] as $i => $v) //salva em $organizer as informações do organizador     
120            if (($v['isOrganizer'] === '1') && ($organizer = $v))
121                break;
122
123        $method = 'COUNTER';
124        $notificationType = 'Sugestão de horário';
125        $part = 'other';
126
127        $schedulableReference = $schedulable;
128
129        $referenceSuggestion = array('startTime' => strtotime($params['startTime'] . ' ' . $schedulable['timezone']) . '000',
130            'endTime' => strtotime($params['endTime'] . ' ' . $schedulable['timezone']) . '000',
131            'allDay' => $params['allDay']
132        );
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            $sTime->setTimezone(new DateTimeZone($schedulableReference['timezone']));
145            $eTime->setTimezone(new DateTimeZone($schedulableReference['timezone']));
146        }
147
148        $data['nowStartDate'] = date_format($sTime, 'd/m/Y');
149        $data['nowStartTime'] = ($schedulableReference['allDay']) ? '' : date_format($sTime, 'H:i');
150        $data['nowEndDate'] = date_format($eTime, 'd/m/Y');
151        $data['nowEndTime'] = ($schedulableReference['allDay']) ? '' : date_format($eTime, 'H:i');
152        $data['userRequest'] = Config::me('uid');
153
154        $ical2 = $ical;
155        $ical2['type'] = 'text/calendar';
156        $ical2['name'] = 'thunderbird.ics';
157        $params['attachments'][] = $ical2;
158        $params['attachments'][] = $ical;
159        $params['isHtml'] = true;
160        $params['body'] = parseTPL::load_tpl($data, ROOTPATH . '/modules/calendar/templates/notify_suggestion_body.tpl');
161        $params['subject'] = parseTPL::load_tpl($subject, ROOTPATH . '/modules/calendar/templates/notify_subject.tpl');
162        ;
163        $params['from'] = '"' . Config::me('cn') . '" <' . Config::me('mail') . '>';
164        $params['to'] = $organizer['user']['mail'];
165    }
166
167    public function formatSuggestionResponse(&$params) {
168        $schedulable = $params['schedulable'];
169        foreach ($schedulable['participants'] as $i => $v) {//salva em $organizer as informações do organizador     
170            if ($v['isOrganizer'] === '1')
171                $organizer = $v;
172            if ($v['user']['mail'] == Config::me('mail'))
173                $me = $v;
174        }
175        $method = 'DECLINECOUNTER';
176        $notificationType = 'Sugestão de horário';
177        $part = 'other';
178
179        $schedulable['participants'] = array();
180        array_push($schedulable['participants'], $me, $organizer);
181
182        self::mountStruture(false, $schedulable, false, $data, $subject, $ical, $part, $method, $notificationType);
183
184        if ($params['status'] == 'DECLINECOUNTER')
185            $data['status'] = 'não pode ser aceito';
186        $ical2 = $ical;
187        $ical2['type'] = 'text/calendar';
188        $ical2['name'] = 'thunderbird.ics';
189        $params['attachments'][] = $ical2;
190        $params['attachments'][] = $ical;
191        $params['isHtml'] = true;
192        $params['body'] = parseTPL::load_tpl($data, ROOTPATH . '/modules/calendar/templates/notify_suggestion_response_body.tpl');
193        $params['subject'] = parseTPL::load_tpl($subject, ROOTPATH . '/modules/calendar/templates/notify_subject.tpl');
194        ;
195        $params['to'] = $params['from'];
196        $params['from'] = $params['from'] = '"' . Config::me('cn') . '" <' . Config::me('mail') . '>';
197    }
198
199    public static function _getAttendeeById($attendeId, $schedulable) {
200        foreach ($schedulable['participants'] as $id => $dv)
201            if ($dv['id'] == $attendeId)
202                return $dv;
203    }
204
205    /**
206     * Prepara para criação de email de delegação
207     *
208     * @license    http://www.gnu.org/copyleft/gpl.html GPL
209     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
210     * @sponsor    Caixa Econômica Federal
211     * @author     Adriano Coutinho da Silva
212     * @return     void
213     * @access     public
214     */
215    public static function participantDelegated(&$partID, &$schedulable, &$organizer) {
216
217        $delegatedParams = array();
218
219        $delegatedFrom = self::_getAttendeeById($partID['delegatedFrom'], $schedulable);
220        $delegatedParams['delegatedFrom'] = $delegatedFrom['user']['uid'];
221
222        self::participantCreated($partID['id'], $schedulable, STATUS_DELEGATED, $delegatedParams);
223
224        $delegatedTo = self::_getAttendeeById($partID['id'], $schedulable);
225        $delegatedParams['delegated'] = $delegatedTo['user']['uid'];
226
227        self::participantStatusChange($partID['delegatedFrom'], $schedulable, $organizer, STATUS_DELEGATED, $delegatedParams);
228    }
229
230    /**
231     * Monta o email de resposta que sera enviado ao delegatedFrom
232     *
233     * @license    http://www.gnu.org/copyleft/gpl.html GPL
234     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
235     * @sponsor    Caixa Econômica Federal
236     * @author     Cristiano Corrêa Schmidt
237     * @return     void
238     * @access     public
239     */
240    public static function participantDelegatedStatusChange(&$partID, &$schedulable, $organizer, &$type = false) {
241
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                break;
332            case 'othersAttendees':
333                $data['participants'] = '<UL> ';
334                foreach ($schedulable['participants'] as $ii => $participant) {
335                    if (Config::me('mail') !== $participant['user']['mail'])
336                        $part[] = $participant['user']['mail'];
337
338                    $data['participants'] .= ' <LI> ' . (isset($participant['user']['name']) ? $participant['user']['name'] : $participant['user']['mail']);
339                }
340                break;
341        }
342        $subject['notificationType'] = $notificationType;
343        $subject['eventTitle'] = mb_convert_encoding($schedulable['summary'], 'ISO-8859-1', 'ISO-8859-1,UTF-8');
344        $subject['startDate'] = date_format($sTime, 'd/m/Y');
345        $subject['startTime'] = ($schedulable['allDay']) ? '' : date_format($sTime, 'H:i');
346        $subject['endDate'] = date_format($eTime, 'd/m/Y');
347        $subject['endTime'] = ($schedulable['allDay']) ? '' : date_format($eTime, 'H:i');
348        $subject['participant'] = Config::me('uid');
349    }
350
351    /**
352     * Monta o email de convite que sera enviado ao participant
353     *
354     * @license    http://www.gnu.org/copyleft/gpl.html GPL
355     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
356     * @sponsor    Caixa Econômica Federal
357     * @author     Cristiano Corrêa Schmidt
358     * @return     void
359     * @access     public
360     */
361    public static function participantCreated(&$partID, &$schedulable, $type = false, $delegatedParams = false, $organizer = false) {
362        $method = 'REQUEST';
363        $notificationType = 'Convite de Calendario';
364        $part = 'attendees';
365        self::mountStruture($partID, $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType, true);
366
367        if ($delegatedParams)
368            $data = array_merge($data, $delegatedParams);
369
370        self::sendMail($data, $ical, $part['user']['mail'], $subject, !$delegatedParams ? 'notify_create_body' : 'notify_create_delegated_body', $organizer);
371    }
372
373    /**
374     * Monta o email de aceito que sera enviado ao organizador
375     *
376     * @license    http://www.gnu.org/copyleft/gpl.html GPL
377     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
378     * @sponsor    Caixa Econômica Federal
379     * @author     Cristiano Corrêa Schmidt
380     * @return     void
381     * @access     public
382     */
383    public static function participantStatusChange(&$partID, &$schedulable, &$organizer, $type, $delegatedParams = false) {
384        $method = 'REPLY';
385        $notificationType = 'Convite Aceito';
386        $part = 'me';
387
388        self::mountStruture($partID, $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType, true);
389
390        if ($delegatedParams) {
391            $data = array_merge($data, $delegatedParams);
392            $tplDelegated = 'notify_delegated_status_body';
393        }
394
395        switch ($type) {
396            case STATUS_ACCEPTED:
397                $tpl = !$delegatedParams ? 'notify_accept_body' : $tplDelegated;
398                $subject['notificationType'] = 'Convite Aceito';
399                break;
400            case STATUS_TENTATIVE:
401                $tpl = !$delegatedParams ? 'notify_attempt_body' : $tplDelegated;
402                $subject['notificationType'] = 'Convite  aceito provisoriamente';
403                break;
404            case STATUS_CANCELLED:
405                $tpl = !$delegatedParams ? 'notify_reject_body' : $tplDelegated;
406                $subject['notificationType'] = 'Convite rejeitado';
407                break;
408            case STATUS_DELEGATED:
409                if ($delegatedParams)
410                    $data = array_merge($data, $delegatedParams);
411                $tpl = 'notify_delegated_body';
412                $subject['notificationType'] = 'Convite delegado';
413                break;
414        }
415
416        self::sendMail($data, $ical, $organizer['user']['mail'], $subject, $tpl, false);
417    }
418
419    /**
420     * Monta o body e envia o email
421     *
422     * @license    http://www.gnu.org/copyleft/gpl.html GPL
423     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
424     * @sponsor    Caixa Econômica Federal
425     * @author     Cristiano Corrêa Schmidt
426     * @return     void
427     * @access     public
428     */
429    private static function sendMail(&$data, &$ical, $to, &$subject, $template, $from = false) {
430        $ical2 = $ical;
431        $ical2['type'] = 'text/calendar';
432        $ical2['name'] = 'thunderbird.ics';
433        $mail['attachments'][] = $ical2;
434        $mail['attachments'][] = $ical;
435        $mail['isHtml'] = true;
436        $mail['body'] = parseTPL::load_tpl($data, ROOTPATH . '/modules/calendar/templates/' . $template . '.tpl');
437        $mail['subject'] = parseTPL::load_tpl($subject, ROOTPATH . '/modules/calendar/templates/notify_subject.tpl');
438        ;
439        $mail['from'] = $from ? ('"' . $from['user']['name'] . '" <' . $from['user']['mail'] . '>') : ('"' . Config::me('cn') . '" <' . Config::me('mail') . '>');
440        $mail['to'] = $to;
441        Controller::create(array('service' => 'SMTP'), $mail);
442    }
443
444    /**
445     * Monta o email de cancelado que sera enviado a todos os participantes
446     *
447     * @license    http://www.gnu.org/copyleft/gpl.html GPL
448     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
449     * @sponsor    Caixa Econômica Federal
450     * @author     Cristiano Corrêa Schmidt
451     * @return     void
452     * @access     public
453     */
454    public function deleteEvent(&$uri, &$result, &$params, $original) {
455        $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'], $schedulable['id']))) {
457            $method = 'CANCEL';
458            $notificationType = 'Cancelamento de Calendario';
459            $part = 'othersAttendees';
460            self::mountStruture($uri['id'], $schedulable, false, $data, $subject, $ical, $part, $method, $notificationType);
461
462            if (count($part) > 0)
463                self::sendMail($data, $ical, implode(',', $part), $subject, 'notify_cancel_body');
464        }
465    }
466
467    /**
468     * Monta o email de cancelado que sera enviado ao participant deleteado
469     *
470     * @license    http://www.gnu.org/copyleft/gpl.html GPL
471     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
472     * @sponsor    Caixa Econômica Federal
473     * @author     Cristiano Corrêa Schmidt
474     * @return     void
475     * @access     public
476     */
477    public function deleteParticipant(&$uri, &$result, &$params, $original) {
478
479        $participant = Controller::read(array('concept' => 'participant', 'id' => $uri['id']), null, array('deepness' => '1'));
480        $schedulable = Controller::read(array('concept' => 'schedulable', 'id' => $participant['schedulable']));
481
482        if ((Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))) {
483            $method = 'CANCEL';
484            $notificationType = 'Cancelamento de Calendario';
485            $part = 'others';
486            self::mountStruture(false, $schedulable, false, $data, $subject, $ical, $part, $method, $notificationType);
487
488            self::sendMail($data, $ical, $participant['user']['mail'], $subject, 'notify_cancel_body');
489        }
490    }
491
492    /**
493     * Faz um diff do update se ouve realmente uma alteração envia um email a todos os participants
494     *
495     * @license    http://www.gnu.org/copyleft/gpl.html GPL
496     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
497     * @sponsor    Caixa Econômica Federal
498     * @author     Cristiano Corrêa Schmidt
499     * @return     void
500     * @access     public
501     */
502    public function updateEvent(&$uri, $params, &$criteria, $original) {
503        $schedulableOld = Controller::read(array('concept' => 'schedulable', 'id' => $uri['id']), null, array('deepness' => '2'));
504        $schedulable = $schedulableOld;
505        $alt = false;
506
507        foreach ($params as $i => $v) //Verifica se ouve alteração no evento
508            if (isset($schedulableOld[$i]) && $schedulableOld[$i] != $v && $i != 'participants') {
509                $schedulable[$i] = $v;
510                $alt = true;
511            }
512
513        if (($alt === true) && (Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))) {
514            $method = 'REQUEST';
515            $notificationType = 'Modificação de Calendario';
516            $part = 'othersAttendees';
517            self::mountStruture($uri['id'], $schedulable, false, $data, $subject, $ical, $part, $method, $notificationType);
518
519            if (isset($part) && $part && count($part) > 0)
520                self::sendMail($data, $ical, implode(',', $part), $subject, 'notify_modify_body');
521        }
522    }
523
524    static private function parseTimeDate($time, $timezone) {
525        return strtotime($time . ' ' . $timezone) . '000';
526    }
527
528}
529
530?>
Note: See TracBrowser for help on using the repository browser.