Changeset 7695


Ignore:
Timestamp:
12/28/12 15:42:26 (11 years ago)
Author:
acoutinho
Message:

Ticket #3258 - Inconsistencia na atualizacao de evento na agenda

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/expressoMail1_2/js/main.js

    r7690 r7695  
    50775077    function decodeOwner(){ 
    50785078        owner = User.me.id; 
    5079         var imapBox = openTab.imapBox[currentTab].split(cyrus_delimiter); 
     5079        var imapBox = (openTab.imapBox[currentTab].indexOf( 'user' ) >= 0 ? openTab.imapBox[currentTab].split(cyrus_delimiter) : [] ); 
    50805080        if(imapBox.length > 1){ 
    50815081            var user = DataLayer.get('user', {filter: ['=','uid',imapBox[1]]});              
     
    52065206                                        return; 
    52075207                                        break; 
     5208                                        case 4: 
    52085209                                        case 9: 
    52095210                                            alert('Seu evento/tarefa não possui alterações!'); 
  • trunk/prototype/services/iCal.php

    r7680 r7695  
    563563                        case 'REQUEST': 
    564564                            $schedulable = self::_getSchedulable($uid); 
     565                $calendar = false; 
    565566 
    566567                            if ($schedulable) { //Caso o evento exista 
    567                                 if (!self::_existInMyCalendars($schedulable['id'], $params['owner'])) { 
    568                                     $calendarToSchedulable = array(); 
    569                                     $calendarToSchedulable['calendar'] = $params['calendar']; 
    570                                     $calendarToSchedulable['schedulable'] = $schedulable['id']; 
    571                                     $interation['calendarToSchedulable://' . mt_rand() . '(Formatter)'] = $calendarToSchedulable; 
    572      
    573                                     if (isset($params['status'])) { 
    574                                         if($params['owner'] != Config::me("uidNumber")){                                             
    575                                             $user = Controller::Read(array('concept' => 'user'), false, array('filter' => array('=', 'id', $params['owner'])) );                                             
    576                                             $pID = self::_getParticipantByMail($user[0]['mail'], $schedulable['participants']); 
    577                                         }else{ 
    578                                             $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']); 
    579                             //caso nõa seja participante adiciona a lista de participantes 
    580                             if(!$pID){ 
    581                                 $pID =  mt_rand() . '2(Formatter)'; 
     568                    if (!($calendar = self::_existInMyCalendars($schedulable['id'], $params['owner']) )) { 
     569                        $calendarToSchedulable = array(); 
     570                        $calendarToSchedulable['calendar'] = $params['calendar']; 
     571                        $calendarToSchedulable['schedulable'] = $schedulable['id']; 
     572                        $interation['calendarToSchedulable://' . mt_rand() . '(Formatter)'] = $calendarToSchedulable; 
     573 
     574                        if (isset($params['status'])) { 
     575                            if($params['owner'] != Config::me("uidNumber")){ 
     576                                $user = Controller::Read(array('concept' => 'user'), false, array('filter' => array('=', 'id', $params['owner'])) ); 
     577                                $pID = self::_getParticipantByMail($user[0]['mail'], $schedulable['participants']); 
     578                            }else{ 
     579                                $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']); 
     580                                //caso nõa seja participante adiciona a lista de participantes 
     581                                if(!$pID){ 
     582                                    $pID =  mt_rand() . '2(Formatter)'; 
     583                                    $interation['participant://' . $pID]['status'] = $params['status']; 
     584                                    $interation['participant://' . $pID]['user'] = $params['owner']; 
     585                                    $interation['participant://' . $pID]['isOrganizer'] = '0'; 
     586                                    $interation['participant://' . $pID]['schedulable'] = $schedulable['id']; 
     587                                }else 
     588                                    $interation['participant://' . $pID]['status'] = $params['status']; 
     589                            } 
     590                        } 
     591 
     592                        Config::regSet('noAlarm', FALSE); //reativa notificação 
     593                    } else { 
     594 
     595                        if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']){ //Organizador esta requisitando que você atualize o evento 
     596 
     597                            $params['calendar'] = $params['calendar'] == 'true' ? $calendar : $params['calendar']; 
     598                            $interation = self::_makeVEVENT($schedulable, $component, $params); 
     599                        }else if ($component->getProperty('sequence', false, false) === $schedulable['sequence']) { 
     600                            //Ler melhor rfc sobre isto 3.2.2.2 
     601                            //Aparentemente é para retornar um ical com o evento atualizado para o attende 
     602                        } 
     603 
     604                        if (isset($params['status'])) { 
     605                            if($params['owner'] != Config::me("uidNumber")){ 
     606                               $user = Controller::Read(array('concept' => 'user'), false, array('filter' => array('=', 'id', $params['owner'])) ); 
     607                                $pID = self::_getParticipantByMail($user[0]['mail'], $schedulable['participants']); 
     608                            }else 
     609                                $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']); 
     610                            //Verifica a importação de eventos em que não participo 
     611                            if ($pID) { 
    582612                                $interation['participant://' . $pID]['status'] = $params['status']; 
    583                                 $interation['participant://' . $pID]['user'] = $params['owner']; 
    584                                 $interation['participant://' . $pID]['isOrganizer'] = '0'; 
    585                                 $interation['participant://' . $pID]['schedulable'] = $schedulable['id']; 
    586                             }else 
    587                                             $interation['participant://' . $pID]['status'] = $params['status']; 
     613                            } 
    588614                        } 
    589                                     } 
    590  
    591                                     Config::regSet('noAlarm', FALSE); //reativa notificação 
    592                                 } else { 
    593  
    594                                     if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) //Organizador esta requisitando que você atualize o evento 
    595                                         $interation = self::_makeVEVENT($schedulable, $component, $params); 
    596                                     else if ($component->getProperty('sequence', false, false) === $schedulable['sequence']) { 
    597                                         //Ler melhor rfc sobre isto 3.2.2.2 
    598                                         //Aparentemente é para retornar um ical com o evento atualizado para o attende 
    599                                     } 
    600  
    601                                     if (isset($params['status'])) { 
    602                                         if($params['owner'] != Config::me("uidNumber")){                                             
    603                                            $user = Controller::Read(array('concept' => 'user'), false, array('filter' => array('=', 'id', $params['owner'])) );                                      
    604                                             $pID = self::_getParticipantByMail($user[0]['mail'], $schedulable['participants']); 
    605                                         }else 
    606                                             $pID = self::_getParticipantByMail(Config::me('mail'), $schedulable['participants']); 
    607                                         //Verifica a importação de eventos em que não participo 
    608                                         if ($pID) { 
    609                                             $interation['participant://' . $pID]['status'] = $params['status']; 
    610                                         } 
    611                                     } 
    612                                 } 
    613                             } else { // Importar evento 
    614                                 $interation = self::_makeVEVENT(array(), $component, $params); 
    615  
    616                                 if (strpos($params['prodid'], 'kigkonsult.se') !== false) { //envia notificação para fora 
    617  
    618                                     /* Data de Inicio */ 
    619                                     $startTime = $component->getProperty('dtstart', false, true); 
    620  
    621                                     $tzid = isset($startTime['params']['TZID']) ? $startTime['params']['TZID'] : $params['X-WR-TIMEZONE']; 
    622  
    623                                     /* Tiem zone do evento */    
    624                                     if ($tzid) 
    625                                         $sc['timezone'] = self::nomalizeTZID($tzid); 
    626                                     else 
    627                                         $sc['timezone'] = isset($params['calendar_timezone']) ? $params['calendar_timezone'] : 'America/Sao_Paulo'; 
    628  
    629                                     $objTimezone = new DateTimeZone($sc['timezone']); 
    630  
    631                                     if (isset($startTime['params']['VALUE']) && $startTime['params']['VALUE'] === 'DATE' && isset($params['calendar_timezone'])) { 
    632                                         $sc['allDay'] = 1; 
    633                                         $sc['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $sc['timezone']) . '000'; 
    634                                     } elseif (isset($startTime['params']['TZID']) && !isset($startTime['value']['tz']))/* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 
    635                                         $sc['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $startTime['params']['TZID']) . '000'; 
    636                                     else { 
    637                                         $sc['startTime'] = self::date2timestamp($startTime['value']) . '000'; 
    638                                         if (strpos($params['prodid'], 'Outlook') !== false) { 
    639                                             //Se o ics veio em utc não aplicar horario de verão 
    640                                             $sTime = new DateTime('@' . (int) ($sc['startTime'] / 1000), new DateTimeZone('UTC')); 
    641                                             $sTime->setTimezone($objTimezone); 
    642                                             if ($sTime->format('I')) //Se o ics veio em utc não aplicar horario de verão 
    643                                                 $sc['startTime'] = $sc['startTime'] - 3600000; 
    644                                         } 
    645                                     } 
    646  
    647  
    648                                     /* Data de Termino */ 
    649                                     $endTime = $component->getProperty('dtend', false, true); 
    650  
    651                                     if (isset($endTime['params']['VALUE']) && $endTime['params']['VALUE'] === 'DATE') 
    652                                         $sc['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $sc['timezone']) . '000'; 
    653                                     else if (isset($endTime['params']['TZID']) && !isset($endTime['value']['tz'])) /* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 
    654                                         $sc['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $endTime['params']['TZID']) . '000'; 
    655                                     else { 
    656                                         $sc['endTime'] = self::date2timestamp($endTime['value']) . '000'; 
    657                                         if (strpos($params['prodid'], 'Outlook') !== false) { 
    658                                             //Se o ics veio em utc não aplicar horario de verão 
    659                                             $eTime = new DateTime('@' . (int) ($sc['endTime'] / 1000), new DateTimeZone('UTC')); 
    660                                             $eTime->setTimezone($objTimezone); 
    661                                             if ($eTime->format('I')) 
    662                                                 $sc['endTime'] = $sc['endTime'] - 3600000; 
    663                                         } 
    664                                     } 
    665  
    666  
    667                                     if ($uid = $component->getProperty('uid', false, false)) 
    668                                         ; 
    669                                     $sc['uid'] = $uid; 
    670  
    671  
    672                                     $sc['summary'] = mb_convert_encoding($component->getProperty('summary', false, false), 'UTF-8', 'UTF-8,ISO-8859-1'); 
    673  
    674                                     /* Definindo Description */ 
    675                                     if ($desc = $component->getProperty('description', false, false)) 
    676                                         $sc['description'] = mb_convert_encoding(str_ireplace(array('\n', '\t'), array("\n", "\t"), $desc), 'UTF-8', 'UTF-8,ISO-8859-1'); 
    677  
    678                                     /* Definindo location */ 
    679                                     if ($location = $component->getProperty('location', false, false)) 
    680                                         $sc['location'] = mb_convert_encoding($location, 'UTF-8', 'UTF-8,ISO-8859-1'); 
    681  
    682  
    683  
    684                                     if ($property = $component->getProperty('organizer', FALSE, TRUE)) { 
    685                                         $participant = array(); 
    686                                         $mailUser = trim(str_replace('MAILTO:', '', $property['value'])); 
    687  
    688                                         $participantID = mt_rand() . '2(Formatter)'; 
    689  
    690                                         $participant['isOrganizer'] = '1'; 
    691  
    692                                         $user = null; 
    693  
    694                                         $participant['isExternal'] = 1; 
    695                                         /* Gera um randon id para o contexto formater */ 
    696                                         $userID = mt_rand() . '4(Formatter)'; 
    697  
    698                                         $user['mail'] = $mailUser; 
    699                                         $organizerMail = $mailUser; 
    700  
    701                                         $user['name'] = ( isset($property['params']['CN']) ) ? $property['params']['CN'] : ''; 
    702                                         $user['isExternal'] = '1'; 
    703                                         $participant['user'] = $user; 
    704  
    705                                         $sc['participants'][] = $participant; 
    706                                     } 
    707  
    708  
    709                                     $participant['status'] = isset($params['status']) ? $params['status'] : STATUS_ACCEPTED; 
    710                                     $participant['isOrganizer'] = '0'; 
    711                                     $participant['isExternal'] = 0; 
    712                                     $participant['user'] = array('mail' => Config::me('mail'), 'name' => Config::me('cn')); 
    713                                     $sc['participants'][] = $participant; 
    714                                     $sc['type'] = EVENT_ID; 
    715  
    716  
    717                                     $ical['source'] = Controller::format(array('service' => 'iCal'), array($sc), array('method' => 'REPLY')); 
    718                                     $ical['type'] = 'application/ics'; 
    719                                     $ical['name'] = 'outlook.ics'; 
    720  
    721                                     $ical2['source'] = $ical['source']; 
    722                                     $ical2['type'] = 'text/calendar; method=REPLY'; 
    723                                     $ical2['name'] = 'thunderbird.ics'; 
    724  
    725                                     $timezone = new DateTimeZone('UTC'); 
    726                                     $sTime = new DateTime('@' . (int) ($sc['startTime'] / 1000), $timezone); 
    727                                     $eTime = new DateTime('@' . (int) ($sc['endTime'] / 1000), $timezone); 
    728  
    729                                     if (isset($sc['timezone'])) { 
    730                                         $sTime->setTimezone(new DateTimeZone($sc['timezone'])); 
    731                                         $eTime->setTimezone(new DateTimeZone($sc['timezone'])); 
    732                                     } 
    733  
    734                                     $data = array('startDate' => date_format($sTime, 'd/m/Y'), 
    735                                         'startTime' => (isset($sc['allDay']) && $sc['allDay'] ) ? '' : date_format($sTime, 'H:i'), 
    736                                         'endDate' => date_format($eTime, 'd/m/Y'), 
    737                                         'endTime' => isset($sc['allDay']) ? '' : date_format($eTime, 'H:i'), 
    738                                         'eventTitle' => $sc['summary'], 
    739                                         'eventLocation' => isset($sc['location']) ? $sc['location'] : '', 
    740                                         'timezone' => ($sc['timezone']) ? $sc['timezone'] : 'UTC', 
    741                                         'participant' => (isset($part['user']['name']) ? $part['user']['name'] : $part['user']['mail'])); 
    742  
    743                                     $subject['notificationType'] = 'Convite Aceito'; 
    744                                     $subject['eventTitle'] = mb_convert_encoding($sc['summary'], 'ISO-8859-1', 'ISO-8859-1,UTF-8'); 
    745                                     $subject['startDate'] = date_format($sTime, 'd/m/Y'); 
    746                                     $subject['startTime'] = ($sc['allDay']) ? '' : date_format($sTime, 'H:i'); 
    747                                     $subject['endDate'] = date_format($eTime, 'd/m/Y'); 
    748                                     $subject['endTime'] = ($sc['allDay']) ? '' : date_format($eTime, 'H:i'); 
    749                                     $subject['participant'] = Config::me('uid'); 
    750  
    751                                     $params['status'] = isset($params['status']) ? $params['status'] : STATUS_ACCEPTED; 
    752  
    753                                     switch ($params['status']) { 
    754                                         case STATUS_ACCEPTED: 
    755                                             $tpl = 'notify_accept_body'; 
    756                                             $subject['notificationType'] = 'Convite Aceito'; 
    757                                             break; 
    758                                         case STATUS_TENTATIVE: 
    759                                             $tpl = 'notify_attempt_body'; 
    760                                             $subject['notificationType'] = 'Convite  aceito provisoriamente'; 
    761                                             break; 
    762                                         case STATUS_CANCELLED: 
    763                                             $tpl = 'notify_reject_body'; 
    764                                             $subject['notificationType'] = 'Convite rejeitado'; 
    765                                             break; 
    766                                     } 
    767                                     require_once ROOTPATH . '/api/parseTPL.php'; 
    768  
    769                                     $mail = array(); 
    770                                     $mail['attachments'][] = $ical; 
    771                                     $mail['attachments'][] = $ical2; 
    772  
    773                                     $mail['isHtml'] = true; 
    774                                     $mail['body'] = parseTPL::load_tpl($data, ROOTPATH . '/modules/calendar/templates/' . $tpl . '.tpl'); 
    775                                     $mail['subject'] = parseTPL::load_tpl($subject, ROOTPATH . '/modules/calendar/templates/notify_subject.tpl'); 
    776                                     ; 
    777                                     $mail['from'] = '"' . Config::me('cn') . '" <' . Config::me('mail') . '>'; 
    778                                     $mail['to'] = $organizerMail; 
    779  
    780  
    781                                     Controller::create(array('service' => 'SMTP'), $mail); 
    782                                 } 
     615                    } 
     616                } else { // Importar evento 
     617                    $interation = self::_makeVEVENT(array(), $component, $params); 
     618 
     619                    if (strpos($params['prodid'], 'kigkonsult.se') !== false) { //envia notificação para fora 
     620 
     621                        /* Data de Inicio */ 
     622                        $startTime = $component->getProperty('dtstart', false, true); 
     623 
     624                        $tzid = isset($startTime['params']['TZID']) ? $startTime['params']['TZID'] : $params['X-WR-TIMEZONE']; 
     625 
     626                        /* Tiem zone do evento */ 
     627                        if ($tzid) 
     628                        $sc['timezone'] = self::nomalizeTZID($tzid); 
     629                        else 
     630                        $sc['timezone'] = isset($params['calendar_timezone']) ? $params['calendar_timezone'] : 'America/Sao_Paulo'; 
     631 
     632                        $objTimezone = new DateTimeZone($sc['timezone']); 
     633 
     634                        if (isset($startTime['params']['VALUE']) && $startTime['params']['VALUE'] === 'DATE' && isset($params['calendar_timezone'])) { 
     635                        $sc['allDay'] = 1; 
     636                        $sc['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $sc['timezone']) . '000'; 
     637                        } elseif (isset($startTime['params']['TZID']) && !isset($startTime['value']['tz']))/* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 
     638                        $sc['startTime'] = self::date2timestamp($startTime['value']) - self::_getTzOffset('UTC', $startTime['params']['TZID']) . '000'; 
     639                        else { 
     640                        $sc['startTime'] = self::date2timestamp($startTime['value']) . '000'; 
     641                        if (strpos($params['prodid'], 'Outlook') !== false) { 
     642                            //Se o ics veio em utc não aplicar horario de verão 
     643                            $sTime = new DateTime('@' . (int) ($sc['startTime'] / 1000), new DateTimeZone('UTC')); 
     644                            $sTime->setTimezone($objTimezone); 
     645                            if ($sTime->format('I')) //Se o ics veio em utc não aplicar horario de verão 
     646                            $sc['startTime'] = $sc['startTime'] - 3600000; 
     647                        } 
     648                        } 
     649 
     650 
     651                        /* Data de Termino */ 
     652                        $endTime = $component->getProperty('dtend', false, true); 
     653 
     654                        if (isset($endTime['params']['VALUE']) && $endTime['params']['VALUE'] === 'DATE') 
     655                        $sc['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $sc['timezone']) . '000'; 
     656                        else if (isset($endTime['params']['TZID']) && !isset($endTime['value']['tz'])) /* Caso não tenha um tz na data mais exista um parametro TZID deve ser aplicado o timezone do TZID a data */ 
     657                        $sc['endTime'] = self::date2timestamp($endTime['value']) - self::_getTzOffset('UTC', $endTime['params']['TZID']) . '000'; 
     658                        else { 
     659                        $sc['endTime'] = self::date2timestamp($endTime['value']) . '000'; 
     660                        if (strpos($params['prodid'], 'Outlook') !== false) { 
     661                            //Se o ics veio em utc não aplicar horario de verão 
     662                            $eTime = new DateTime('@' . (int) ($sc['endTime'] / 1000), new DateTimeZone('UTC')); 
     663                            $eTime->setTimezone($objTimezone); 
     664                            if ($eTime->format('I')) 
     665                            $sc['endTime'] = $sc['endTime'] - 3600000; 
     666                        } 
     667                        } 
     668 
     669 
     670                        if ($uid = $component->getProperty('uid', false, false)) 
     671                        ; 
     672                        $sc['uid'] = $uid; 
     673 
     674 
     675                        $sc['summary'] = mb_convert_encoding($component->getProperty('summary', false, false), 'UTF-8', 'UTF-8,ISO-8859-1'); 
     676 
     677                        /* Definindo Description */ 
     678                        if ($desc = $component->getProperty('description', false, false)) 
     679                        $sc['description'] = mb_convert_encoding(str_ireplace(array('\n', '\t'), array("\n", "\t"), $desc), 'UTF-8', 'UTF-8,ISO-8859-1'); 
     680 
     681                        /* Definindo location */ 
     682                        if ($location = $component->getProperty('location', false, false)) 
     683                        $sc['location'] = mb_convert_encoding($location, 'UTF-8', 'UTF-8,ISO-8859-1'); 
     684 
     685 
     686 
     687                        if ($property = $component->getProperty('organizer', FALSE, TRUE)) { 
     688                        $participant = array(); 
     689                        $mailUser = trim(str_replace('MAILTO:', '', $property['value'])); 
     690 
     691                        $participantID = mt_rand() . '2(Formatter)'; 
     692 
     693                        $participant['isOrganizer'] = '1'; 
     694 
     695                        $user = null; 
     696 
     697                        $participant['isExternal'] = 1; 
     698                        /* Gera um randon id para o contexto formater */ 
     699                        $userID = mt_rand() . '4(Formatter)'; 
     700 
     701                        $user['mail'] = $mailUser; 
     702                        $organizerMail = $mailUser; 
     703 
     704                        $user['name'] = ( isset($property['params']['CN']) ) ? $property['params']['CN'] : ''; 
     705                        $user['isExternal'] = '1'; 
     706                        $participant['user'] = $user; 
     707 
     708                        $sc['participants'][] = $participant; 
     709                        } 
     710 
     711 
     712                        $participant['status'] = isset($params['status']) ? $params['status'] : STATUS_ACCEPTED; 
     713                        $participant['isOrganizer'] = '0'; 
     714                        $participant['isExternal'] = 0; 
     715                        $participant['user'] = array('mail' => Config::me('mail'), 'name' => Config::me('cn')); 
     716                        $sc['participants'][] = $participant; 
     717                        $sc['type'] = EVENT_ID; 
     718 
     719 
     720                        $ical['source'] = Controller::format(array('service' => 'iCal'), array($sc), array('method' => 'REPLY')); 
     721                        $ical['type'] = 'application/ics'; 
     722                        $ical['name'] = 'outlook.ics'; 
     723 
     724                        $ical2['source'] = $ical['source']; 
     725                        $ical2['type'] = 'text/calendar; method=REPLY'; 
     726                        $ical2['name'] = 'thunderbird.ics'; 
     727 
     728                        $timezone = new DateTimeZone('UTC'); 
     729                        $sTime = new DateTime('@' . (int) ($sc['startTime'] / 1000), $timezone); 
     730                        $eTime = new DateTime('@' . (int) ($sc['endTime'] / 1000), $timezone); 
     731 
     732                        if (isset($sc['timezone'])) { 
     733                        $sTime->setTimezone(new DateTimeZone($sc['timezone'])); 
     734                        $eTime->setTimezone(new DateTimeZone($sc['timezone'])); 
     735                        } 
     736 
     737                        $data = array('startDate' => date_format($sTime, 'd/m/Y'), 
     738                        'startTime' => (isset($sc['allDay']) && $sc['allDay'] ) ? '' : date_format($sTime, 'H:i'), 
     739                        'endDate' => date_format($eTime, 'd/m/Y'), 
     740                        'endTime' => isset($sc['allDay']) ? '' : date_format($eTime, 'H:i'), 
     741                        'eventTitle' => $sc['summary'], 
     742                        'eventLocation' => isset($sc['location']) ? $sc['location'] : '', 
     743                        'timezone' => ($sc['timezone']) ? $sc['timezone'] : 'UTC', 
     744                        'participant' => (isset($part['user']['name']) ? $part['user']['name'] : $part['user']['mail'])); 
     745 
     746                        $subject['notificationType'] = 'Convite Aceito'; 
     747                        $subject['eventTitle'] = mb_convert_encoding($sc['summary'], 'ISO-8859-1', 'ISO-8859-1,UTF-8'); 
     748                        $subject['startDate'] = date_format($sTime, 'd/m/Y'); 
     749                        $subject['startTime'] = ($sc['allDay']) ? '' : date_format($sTime, 'H:i'); 
     750                        $subject['endDate'] = date_format($eTime, 'd/m/Y'); 
     751                        $subject['endTime'] = ($sc['allDay']) ? '' : date_format($eTime, 'H:i'); 
     752                        $subject['participant'] = Config::me('uid'); 
     753 
     754                        $params['status'] = isset($params['status']) ? $params['status'] : STATUS_ACCEPTED; 
     755 
     756                        switch ($params['status']) { 
     757                        case STATUS_ACCEPTED: 
     758                            $tpl = 'notify_accept_body'; 
     759                            $subject['notificationType'] = 'Convite Aceito'; 
     760                            break; 
     761                        case STATUS_TENTATIVE: 
     762                            $tpl = 'notify_attempt_body'; 
     763                            $subject['notificationType'] = 'Convite  aceito provisoriamente'; 
     764                            break; 
     765                        case STATUS_CANCELLED: 
     766                            $tpl = 'notify_reject_body'; 
     767                            $subject['notificationType'] = 'Convite rejeitado'; 
     768                            break; 
     769                        } 
     770                        require_once ROOTPATH . '/api/parseTPL.php'; 
     771 
     772                        $mail = array(); 
     773                        $mail['attachments'][] = $ical; 
     774                        $mail['attachments'][] = $ical2; 
     775 
     776                        $mail['isHtml'] = true; 
     777                        $mail['body'] = parseTPL::load_tpl($data, ROOTPATH . '/modules/calendar/templates/' . $tpl . '.tpl'); 
     778                        $mail['subject'] = parseTPL::load_tpl($subject, ROOTPATH . '/modules/calendar/templates/notify_subject.tpl'); 
     779                        ; 
     780                        $mail['from'] = '"' . Config::me('cn') . '" <' . Config::me('mail') . '>'; 
     781                        $mail['to'] = $organizerMail; 
     782 
     783 
     784                        Controller::create(array('service' => 'SMTP'), $mail); 
     785                    } 
    783786                            } 
    784787                            break; 
     
    11891192                            $schedulable = self::_getSchedulable($uid); 
    11901193                            if ($schedulable) { //Caso o evento exista 
    1191                                 $isOrganizer = false; 
    1192                                 $isParticipant = false; 
    1193  
    1194                                 foreach ($schedulable['participants'] as $value) 
    1195                                     if ($value['user']['id'] == $params['owner']) { 
    1196                                         $isParticipant = true; 
    1197                                         if ($value['isOrganizer']) 
    1198                                             $isOrganizer = true; 
    1199  
    1200                                         if (!self::_existInMyCalendars($schedulable['id'], $params['owner'])) { 
    1201                                             $interation = ICAL_ACTION_UPDATE; 
    1202                                             $interation = ( strrpos($value['acl'], ATTENDEE_ACL_PARTICIPATION_REQUIRED) ) ? ICAL_ACTION_IMPORT_REQUIRED : array('action' => ICAL_ACTION_IMPORT, 'type' => 'calendarIds'); 
    1203                                             break; 
    1204                                         } 
    1205                                     } else { 
    1206                                         if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) //Organizador esta requisitando que você atualize o evento 
    1207                                             $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_UPDATE : ICAL_ACTION_UPDATE; 
    1208                                         else 
    1209                                             $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_NONE : ICAL_ACTION_NONE; 
    1210                                     } 
    1211                                 if (!$isParticipant){ 
    1212                                       $interation = self::_checkParticipantByPermissions($schedulable); 
    1213                                     } 
    1214                             }else 
    1215                                     $interation = array('action' => ICAL_ACTION_IMPORT, 'type' => 'calendarIds'); 
    1216                              
    1217                             if(($interation != ICAL_ACTION_NONE) && ($interation != ICAL_ACTION_ORGANIZER_NONE) && ($interation != ICAL_ACTION_ORGANIZER_UPDATE) && ($interation != ICAL_ACTION_NONE)) { 
    1218                                 if($params['owner'] != Config::me("uidNumber")){ 
    1219                                     $sig = Controller::find(array('concept' => 'calendarSignature'), array('calendar'), array('filter' => array('AND', array('=', 'user', $params['owner']), array('=', 'isOwner', '1')))); 
    1220                                     $calendars = array(); 
    1221                                     foreach ($sig as $val) 
    1222                                         $calendars[] = $val['calendar']; 
    1223                                  
    1224                                     $calendarsPermission = Controller::find(array('concept' => 'calendarToPermission'), array('calendar'), array('filter' => array('AND', array('=', 'user', Config::me("uidNumber")), array('IN', 'calendar', $calendars))));    
    1225                                      
    1226                                     foreach ($calendarsPermission as $val) 
    1227                                         $ids[] = $val['calendar']; 
    1228  
    1229                                     $interation = array('action' => ICAL_ACTION_IMPORT_FROM_PERMISSION ,'calendar' => $ids); 
    1230                                 } 
    1231                             } 
     1194                    $isOrganizer = false; 
     1195                    $isParticipant = false; 
     1196 
     1197                    foreach ($schedulable['participants'] as $value){ 
     1198 
     1199                        if ($value['user']['id'] == $params['owner']) { 
     1200                            $isParticipant = true; 
     1201                            if ($value['isOrganizer']) 
     1202                                $isOrganizer = true; 
     1203 
     1204                            if (!self::_existInMyCalendars($schedulable['id'], $params['owner'])) { 
     1205                                $interation = ICAL_ACTION_UPDATE; 
     1206                                $interation = ( strrpos($value['acl'], ATTENDEE_ACL_PARTICIPATION_REQUIRED) ) ? ICAL_ACTION_IMPORT_REQUIRED : array('action' => ICAL_ACTION_IMPORT, 'type' => 'calendarIds'); 
     1207                                break; 
     1208                            } 
     1209                        } else { 
     1210                            if (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] || $component->getProperty('sequence', false, false) > $schedulable['sequence']) //Organizador esta requisitando que você atualize o evento 
     1211                                $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_UPDATE : ICAL_ACTION_UPDATE; 
     1212                            else 
     1213                                $interation = ($isOrganizer) ? ICAL_ACTION_ORGANIZER_NONE : ICAL_ACTION_NONE; 
     1214                        } 
     1215 
     1216                    } 
     1217 
     1218                    if (!$isParticipant){ 
     1219                        if( self::_existInMyCalendars($schedulable['id'], $params['owner']) ){ 
     1220 
     1221                            $interation = (self::_getTime($component, 'dtstamp') > $schedulable['dtstamp'] ? ICAL_ACTION_UPDATE  :  ICAL_ACTION_NONE); 
     1222 
     1223                        }else{ 
     1224 
     1225                            $interation =  self::_checkParticipantByPermissions($schedulable); 
     1226 
     1227                        } 
     1228 
     1229 
     1230                    } 
     1231                }else 
     1232                    $interation = array('action' => ICAL_ACTION_IMPORT_REQUIRED, 'type' => 'calendarIds'); 
     1233 
     1234                    if(($interation != ICAL_ACTION_NONE) && ($interation != ICAL_ACTION_ORGANIZER_NONE) && ($interation != ICAL_ACTION_ORGANIZER_UPDATE) && ($interation != ICAL_ACTION_NONE) && ($interation != ICAL_ACTION_UPDATE) && (!is_array($interation ) )) { 
     1235                        if($params['owner'] != Config::me("uidNumber")){ 
     1236                            $sig = Controller::find(array('concept' => 'calendarSignature'), array('calendar'), array('filter' => array('AND', array('=', 'user', $params['owner']), array('=', 'isOwner', '1')))); 
     1237                            $calendars = array(); 
     1238                            foreach ($sig as $val) 
     1239                            $calendars[] = $val['calendar']; 
     1240 
     1241                            $calendarsPermission = Controller::find(array('concept' => 'calendarToPermission'), array('calendar'), array('filter' => array('AND', array('=', 'user', Config::me("uidNumber")), array('IN', 'calendar', $calendars)))); 
     1242 
     1243                            foreach ($calendarsPermission as $val) 
     1244                            $ids[] = $val['calendar']; 
     1245 
     1246                            $interation = array('action' => ICAL_ACTION_IMPORT_FROM_PERMISSION ,'calendar' => $ids); 
     1247                        } 
     1248                    } 
    12321249 
    12331250                            break; 
Note: See TracChangeset for help on using the changeset viewer.