source: branches/2.4/prototype/modules/calendar/interceptors/Notifications.php @ 6826

Revision 6826, 22.2 KB checked in by eduardow, 12 years ago (diff)

Ticket #2965 - Problema com a hora ao importar evento em Outlook.

RevLine 
[5341]1<?php
[6027]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
[6754]8use prototype\api\Config as Config;
9
[6027]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;
[5514]20        }
[6027]21    }
[5514]22
[6027]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.
[5514]36
[6027]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            }
[6177]47            else if ($concept['concept'] === 'schedulable') { //Caso exista schedulable no commit antecipa o carregamento do owner             
[6027]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]);
[5947]63                }
[6027]64            }
65        }
[5947]66
[6027]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'));
[6177]73                if (!self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))
[6027]74                    continue; //Escapa eventos do passado
[5341]75
[6027]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;
[5514]81                }
82
[6027]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;
[5514]90                }
[6027]91            }
[5514]92        }
[6027]93
94        if (isset($updated)) {
95            $psUpdated = Controller::find(array('concept' => 'participant'), false, array('deepness' => '1', 'filter' => array('IN', 'id', $updated)));
[6331]96
[6027]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'));
[6177]101                if (!self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))
[6027]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            }
[5514]113        }
[6027]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
[6038]130        $referenceSuggestion = array('startTime' => strtotime($params['startTime'] . ' ' . $schedulable['timezone']) . '000',
131            'endTime' => strtotime($params['endTime'] . ' ' . $schedulable['timezone']) . '000',
[6027]132            'allDay' => $params['allDay']
133        );
[6038]134
[6027]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']));
[5514]147        }
[6027]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
[5947]206    /**
[6027]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) {
[5947]217
[6027]218        $delegatedParams = array();
[5947]219
[6027]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;
[5947]257            case STATUS_DELEGATED:
[6027]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);
[5947]263
[6027]264        $method = 'REQUEST';
265        $notificationType = 'Resposta Delegação';
266        $part = 'attendees';
267        self::mountStruture($partID['delegatedFrom'], $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType);
[5947]268
[6027]269        $data = array_merge($data, $delegatedParams);
270
271        self::sendMail($data, $ical, $part['user']['mail'], $subject, 'notify_response_delegated_status_body');
[5514]272    }
273
[6331]274    public static function mountStruture(&$partID, &$schedulable, $type = false, &$data, &$subject, &$ical, &$part = false, &$method, &$notificationType, $regSet = false) {
[5947]275
[6027]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';
[6826]278            $ical = Controller::format(array('service' => 'iCal'), array($schedulable), array('method' => $method , 'compatible' => true ));
[6027]279            if ($regSet)
280                Config::regSet('ical://' . $schedulable['id'] . '/' . $method, $ical);
281        }
282        else
283            $ical = Config::regGet('ical://' . $schedulable['id'] . '/' . $method);
[6038]284
[6034]285        if (!is_numeric($schedulable['endTime']))
[6038]286            $schedulable['startTime'] = self::parseTimeDate($schedulable['startTime'], $schedulable['timezone']);
[5514]287
[6038]288        if (!is_numeric($schedulable['endTime'])) {
289            $schedulable['endTime'] = self::parseTimeDate($schedulable['endTime'], $schedulable['timezone']);
290
291            if ($schedulable['allDay'])
292                $schedulable['endTime'] = $schedulable['endTime'] + 86400000;
[6034]293        }
[6038]294
[6027]295        $timezone = new DateTimeZone('UTC');
296        $sTime = new DateTime('@' . (int) ($schedulable['startTime'] / 1000), $timezone);
297        $eTime = new DateTime('@' . (int) ($schedulable['endTime'] / 1000), $timezone);
[6038]298
[6027]299        if (isset($schedulable['timezone'])) {
300            $sTime->setTimezone(new DateTimeZone($schedulable['timezone']));
301            $eTime->setTimezone(new DateTimeZone($schedulable['timezone']));
[5514]302        }
[6027]303
304        $data = array('startDate' => date_format($sTime, 'd/m/Y'),
305            'startTime' => ($schedulable['allDay']) ? '' : date_format($sTime, 'H:i'),
306            'endDate' => date_format($eTime, 'd/m/Y'),
307            'endTime' => ($schedulable['allDay']) ? '' : date_format($eTime, 'H:i'),
308            'eventTitle' => $schedulable['summary'],
309            'eventLocation' => $schedulable['location'],
310            'timezone' => ($schedulable['timezone']) ? $schedulable['timezone'] : 'UTC');
311        $temp = $part;
312        $part = false;
313
314        switch ($temp) {
315            case 'attendees':
316                $attList = '<UL> ';
317                foreach ($schedulable['participants'] as $i => $v) {
318                    if ($part === false && $v['id'] == $partID)
319                        $part = $v;
320
321                    $attList .= ' <LI> ' . (isset($v['user']['name']) ? $v['user']['name'] : $v['user']['mail']);
322                }
323                $attList .= '</UL>';
324                $data['participants'] = $attList;
325                break;
326            case 'me':
327                $part = self::_getAttendeeById($partID, $schedulable);
328                $data['participant'] = isset($part['user']['name']) ? $part['user']['name'] : $part['user']['mail'];
[6331]329                $partID = $part;
[6027]330                break;
331            case 'othersAttendees':
332                $data['participants'] = '<UL> ';
333                foreach ($schedulable['participants'] as $ii => $participant) {
334                    if (Config::me('mail') !== $participant['user']['mail'])
335                        $part[] = $participant['user']['mail'];
336
337                    $data['participants'] .= ' <LI> ' . (isset($participant['user']['name']) ? $participant['user']['name'] : $participant['user']['mail']);
338                }
339                break;
340        }
341        $subject['notificationType'] = $notificationType;
342        $subject['eventTitle'] = mb_convert_encoding($schedulable['summary'], 'ISO-8859-1', 'ISO-8859-1,UTF-8');
343        $subject['startDate'] = date_format($sTime, 'd/m/Y');
344        $subject['startTime'] = ($schedulable['allDay']) ? '' : date_format($sTime, 'H:i');
345        $subject['endDate'] = date_format($eTime, 'd/m/Y');
346        $subject['endTime'] = ($schedulable['allDay']) ? '' : date_format($eTime, 'H:i');
[6331]347        $subject['participant'] = (is_array($partID) && isset($partID['user']) )? $partID['user']['uid'] : Config::me('uid');
[6027]348    }
349
[5514]350    /**
[6027]351     * Monta o email de convite que sera enviado ao participant
352     *
353     * @license    http://www.gnu.org/copyleft/gpl.html GPL
354     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
355     * @sponsor    Caixa Econômica Federal
356     * @author     Cristiano Corrêa Schmidt
357     * @return     void
358     * @access     public
359     */
360    public static function participantCreated(&$partID, &$schedulable, $type = false, $delegatedParams = false, $organizer = false) {
[5947]361        $method = 'REQUEST';
[6027]362        $notificationType = 'Convite de Calendario';
[5947]363        $part = 'attendees';
[6027]364        self::mountStruture($partID, $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType, true);
[5947]365
[6027]366        if ($delegatedParams)
367            $data = array_merge($data, $delegatedParams);
[5947]368
[6027]369        self::sendMail($data, $ical, $part['user']['mail'], $subject, !$delegatedParams ? 'notify_create_body' : 'notify_create_delegated_body', $organizer);
[5341]370    }
[6027]371
[5341]372    /**
[6027]373     * Monta o email de aceito que sera enviado ao organizador
374     *
375     * @license    http://www.gnu.org/copyleft/gpl.html GPL
376     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
377     * @sponsor    Caixa Econômica Federal
378     * @author     Cristiano Corrêa Schmidt
379     * @return     void
380     * @access     public
381     */
[6331]382    public static function participantStatusChange(&$partID, &$schedulable, &$organizer, $type, $delegatedParams = false) {     
[6027]383        $method = 'REPLY';
[5947]384        $notificationType = 'Convite Aceito';
385        $part = 'me';
[5514]386
[6027]387        self::mountStruture($partID, $schedulable, $type, $data, $subject, $ical, $part, $method, $notificationType, true);
[5947]388
[6027]389        if ($delegatedParams) {
390            $data = array_merge($data, $delegatedParams);
391            $tplDelegated = 'notify_delegated_status_body';
[5947]392        }
393
[6027]394        switch ($type) {
395            case STATUS_ACCEPTED:
396                $tpl = !$delegatedParams ? 'notify_accept_body' : $tplDelegated;
397                $subject['notificationType'] = 'Convite Aceito';
398                break;
399            case STATUS_TENTATIVE:
400                $tpl = !$delegatedParams ? 'notify_attempt_body' : $tplDelegated;
401                $subject['notificationType'] = 'Convite  aceito provisoriamente';
402                break;
403            case STATUS_CANCELLED:
404                $tpl = !$delegatedParams ? 'notify_reject_body' : $tplDelegated;
405                $subject['notificationType'] = 'Convite rejeitado';
406                break;
407            case STATUS_DELEGATED:
408                if ($delegatedParams)
409                    $data = array_merge($data, $delegatedParams);
410                $tpl = 'notify_delegated_body';
411                $subject['notificationType'] = 'Convite delegado';
412                break;
413        }
[5341]414
[6331]415        self::sendMail($data, $ical, $organizer['user']['mail'], $subject, $tpl, $partID);
[5341]416    }
[6027]417
[5341]418    /**
[6027]419     * Monta o body e envia o email
420     *
421     * @license    http://www.gnu.org/copyleft/gpl.html GPL
422     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
423     * @sponsor    Caixa Econômica Federal
424     * @author     Cristiano Corrêa Schmidt
425     * @return     void
426     * @access     public
427     */
428    private static function sendMail(&$data, &$ical, $to, &$subject, $template, $from = false) {
[6826]429       
430
431        $ical1['type'] = 'text/plain';
432        $ical1['source'] = $ical['compatible'];
433        $ical1['name'] = 'outlook.ics';
434        $ical2['source'] = $ical['ical'];
[6027]435        $ical2['type'] = 'text/calendar';
436        $ical2['name'] = 'thunderbird.ics';
[6826]437
438        unset($ical);
[6027]439        $mail['attachments'][] = $ical2;
[6826]440        $mail['attachments'][] = $ical1;
441        unset($ical1);
442        unset($ical2);
[6027]443        $mail['isHtml'] = true;
444        $mail['body'] = parseTPL::load_tpl($data, ROOTPATH . '/modules/calendar/templates/' . $template . '.tpl');
445        $mail['subject'] = parseTPL::load_tpl($subject, ROOTPATH . '/modules/calendar/templates/notify_subject.tpl');
446        ;
447        $mail['from'] = $from ? ('"' . $from['user']['name'] . '" <' . $from['user']['mail'] . '>') : ('"' . Config::me('cn') . '" <' . Config::me('mail') . '>');
448        $mail['to'] = $to;
449        Controller::create(array('service' => 'SMTP'), $mail);
[5341]450    }
[6027]451
[5341]452    /**
[6027]453     * Monta o email de cancelado que sera enviado a todos os participantes
454     *
455     * @license    http://www.gnu.org/copyleft/gpl.html GPL
456     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
457     * @sponsor    Caixa Econômica Federal
458     * @author     Cristiano Corrêa Schmidt
459     * @return     void
460     * @access     public
461     */
462    public function deleteEvent(&$uri, &$result, &$params, $original) {
463        $schedulable = Controller::read(array('concept' => 'schedulable', 'id' => $uri['id']), null, array('deepness' => '2'));
[6177]464        if ((Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))) {
[5947]465            $method = 'CANCEL';
466            $notificationType = 'Cancelamento de Calendario';
467            $part = 'othersAttendees';
[6027]468            self::mountStruture($uri['id'], $schedulable, false, $data, $subject, $ical, $part, $method, $notificationType);
469
470            if (count($part) > 0)
471                self::sendMail($data, $ical, implode(',', $part), $subject, 'notify_cancel_body');
472        }
[5341]473    }
[6027]474
[5341]475    /**
[6027]476     * Monta o email de cancelado que sera enviado ao participant deleteado
477     *
478     * @license    http://www.gnu.org/copyleft/gpl.html GPL
479     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
480     * @sponsor    Caixa Econômica Federal
481     * @author     Cristiano Corrêa Schmidt
482     * @return     void
483     * @access     public
484     */
485    public function deleteParticipant(&$uri, &$result, &$params, $original) {
486
487        $participant = Controller::read(array('concept' => 'participant', 'id' => $uri['id']), null, array('deepness' => '1'));
488        $schedulable = Controller::read(array('concept' => 'schedulable', 'id' => $participant['schedulable']));
489
[6177]490        if ((Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))) {
[5947]491            $method = 'CANCEL';
492            $notificationType = 'Cancelamento de Calendario';
493            $part = 'others';
[6027]494            self::mountStruture(false, $schedulable, false, $data, $subject, $ical, $part, $method, $notificationType);
[5947]495
[6027]496            self::sendMail($data, $ical, $participant['user']['mail'], $subject, 'notify_cancel_body');
497        }
[5341]498    }
[6027]499
[5341]500    /**
[6027]501     * Faz um diff do update se ouve realmente uma alteração envia um email a todos os participants
502     *
503     * @license    http://www.gnu.org/copyleft/gpl.html GPL
504     * @author     Consórcio Expresso Livre - 4Linux (www.4linux.com.br) e Prognus Software Livre (www.prognus.com.br)
505     * @sponsor    Caixa Econômica Federal
506     * @author     Cristiano Corrêa Schmidt
507     * @return     void
508     * @access     public
509     */
[6190]510    public function updateEvent(&$uri, $params, &$criteria, $original) {
[6027]511        $schedulableOld = Controller::read(array('concept' => 'schedulable', 'id' => $uri['id']), null, array('deepness' => '2'));
512        $schedulable = $schedulableOld;
513        $alt = false;
[5514]514
[6027]515        foreach ($params as $i => $v) //Verifica se ouve alteração no evento
516            if (isset($schedulableOld[$i]) && $schedulableOld[$i] != $v && $i != 'participants') {
517                $schedulable[$i] = $v;
518                $alt = true;
519            }
[6190]520
[6177]521        if (($alt === true) && (Config::regGet('noAlarm') === false) && (self::futureEvent($schedulable['startTime'], $schedulable['rangeEnd'], $schedulable['id']))) {
[5947]522            $method = 'REQUEST';
[6027]523            $notificationType = 'Modificação de Calendario';
[6038]524            $part = 'othersAttendees';
[6027]525            self::mountStruture($uri['id'], $schedulable, false, $data, $subject, $ical, $part, $method, $notificationType);
[5341]526
[6027]527            if (isset($part) && $part && count($part) > 0)
528                self::sendMail($data, $ical, implode(',', $part), $subject, 'notify_modify_body');
529        }
[5341]530    }
[6038]531
532    static private function parseTimeDate($time, $timezone) {
533        return strtotime($time . ' ' . $timezone) . '000';
534    }
535
[6036]536}
[6038]537
[5341]538?>
Note: See TracBrowser for help on using the repository browser.