Ignore:
Timestamp:
08/03/11 12:00:08 (13 years ago)
Author:
thiagoaos
Message:

Ticket #2180 - Adicionado código fonte completo do zpush

File:
1 edited

Legend:

Unmodified
Added
Removed
  • contrib/z-push/backend/BackendCalendarExpresso.php

    r4219 r4898  
    77 * Created   :   06.12.2010 - emerson-faria.nobre@serpro.gov.br 
    88 * 
    9  * ï¿œ Zarafa Deutschland GmbH, www.zarafaserver.de 
     9 * ᅵ Zarafa Deutschland GmbH, www.zarafaserver.de 
    1010 * This file is distributed under GPL v2. 
    1111 * Consult LICENSE file for details 
     
    6565                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    6666                        while ($row = pg_fetch_row($result)) { 
    67                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> Lê item do BD (cal_id: '.$row[0].', title: '.$row[4].', last_update: '.date("d/m/Y G:i:s",substr($row[1], 0, strlen($row[1])-3)).', last_update_timestamp: '.$row[1].', datetime: '.date("d/m/Y G:i:s",$row[2]).', datetime_timestamp: '.$row[2].', cal_type: '.$row[3].')'); 
     67                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> Lê item do BD (cal_id: '.$row[0].', title: '.$row[4].', last_update: '.date("d/m/Y G:i:s",substr($row[1], 0, strlen($row[1])-3)).', last_update_timestamp: '.$row[1].', datetime: '.date("d/m/Y G:i:s",$row[2]).', datetime_timestamp: '.$row[2].', cal_type: '.$row[3].')'); 
    6868                                $result_recur = pg_query($this->db,"select recur_enddate from phpgw_cal_repeats where cal_id = " . $row[0] . ";"); 
    6969                                if ($result_recur == FALSE) throw new Exception(pg_last_error($this->db)); 
    7070                                if ($row[3] == 'M') { 
    7171                                        if ($recur_enddate = pg_fetch_result($result_recur, 0, 0)) { 
    72                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> Evento '.$row[0].' é recorrente: recur_enddate : '.date("d/m/Y G:i:s",$recur_enddate).', recur_enddate_timestamp: '.$recur_enddate); 
     72                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> Evento '.$row[0].' é recorrente: recur_enddate : '.date("d/m/Y G:i:s",$recur_enddate).', recur_enddate_timestamp: '.$recur_enddate); 
    7373                                                if ($recur_enddate < $row[2]) { 
    74                                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> ERRO: Esse evento não será adicionado na lista porque o campo phpgw_cal_repeats.recur_enddate é menor que o campo phpgw_cal.datetime. Corrija o valor de um dos campos'); 
     74                                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> ERRO: Esse evento não será adicionado na lista porque o campo phpgw_cal_repeats.recur_enddate é menor que o campo phpgw_cal.datetime. Corrija o valor de um dos campos'); 
    7575                                                        continue; // Nao sincroniza este evento, porque a data final da recorrencia eh menor que a data inicial do evento. Eh o BD do Expresso que esta inconsistente. 
    7676                                                } 
     
    9191                        if ($result_invalid_ref == FALSE) throw new Exception(pg_last_error($this->db)); 
    9292                        while ($row_invalid_ref = pg_fetch_row($result_invalid_ref)) { 
    93                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> ERRO: Evento com campo reference inválido (cal_id: '.$row_invalid_ref[0].', title: '.$row_invalid_ref[4].', reference: '.$row_invalid_ref[5].', last_update: '.date("d/m/Y G:i:s",substr($row_invalid_ref[1], 0, strlen($row[1])-3)).', last_update_timestamp: '.$row_invalid_ref[1].', datetime: '.date("d/m/Y G:i:s",$row_invalid_ref[2]).', datetime_timestamp: '.$row_invalid_ref[2].', cal_type: '.$row_invalid_ref[3].')'); 
     93                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> ERRO: Evento com campo reference inválido (cal_id: '.$row_invalid_ref[0].', title: '.$row_invalid_ref[4].', reference: '.$row_invalid_ref[5].', last_update: '.date("d/m/Y G:i:s",substr($row_invalid_ref[1], 0, strlen($row[1])-3)).', last_update_timestamp: '.$row_invalid_ref[1].', datetime: '.date("d/m/Y G:i:s",$row_invalid_ref[2]).', datetime_timestamp: '.$row_invalid_ref[2].', cal_type: '.$row_invalid_ref[3].')'); 
    9494                        } 
    9595                        // Evento fora da faixa filtrada 
     
    107107                        debugLog("exception -> " . $e->getMessage() . " - ARQUIVO: " . $e->getFile() . " - LINHA: " . $e->getLine()); 
    108108                } 
    109                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> Fim normal da função'); 
     109                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> Fim normal da função'); 
    110110                return $messages; 
    111111        } 
     
    147147                if($folderid != "calendar") return false; 
    148148                try { 
    149                  $result = pg_query($this->db,"BEGIN;"); 
    150                  if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    151                  $result_calendar = pg_query($this->db, "select last_update from phpgw_cal where cal_id = " . $id . ";"); 
    152                  if ($result_calendar == FALSE) throw new Exception(pg_last_error($this->db)); 
    153                  while ($row_calendar = pg_fetch_row($result_calendar)) { 
    154                         if(isset($row_calendar[0])) { 
    155                                 $message = array(); 
    156                                 $message["mod"] = substr($row_calendar[0], 0, strlen($row_calendar[0])-3); 
    157                                 $message["id"] = $id; 
    158                                 $message["flags"] = 1; 
    159                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::StatMessage-> mod: '.$message["mod"].', id: '.$message["id"]); 
    160                                 return $message; 
    161                         } 
    162                  } 
    163                  $result = pg_query($this->db,"COMMIT;"); 
    164                  if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
     149                        $result = pg_query($this->db,"BEGIN;"); 
     150                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
     151                        $result_calendar = pg_query($this->db, "select last_update from phpgw_cal where cal_id = " . $id . ";"); 
     152                        if ($result_calendar == FALSE) throw new Exception(pg_last_error($this->db)); 
     153                while ($row_calendar = pg_fetch_row($result_calendar)) { 
     154                        if(isset($row_calendar[0])) { 
     155                                $message = array(); 
     156                                $message["mod"] = substr($row_calendar[0], 0, strlen($row_calendar[0])-3); 
     157                                $message["id"] = $id; 
     158                                $message["flags"] = 1; 
     159                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::StatMessage-> mod: '.$message["mod"].', id: '.$message["id"]); 
     160                                return $message; 
     161                        } 
     162                } 
     163                $result = pg_query($this->db,"COMMIT;"); 
     164                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    165165                } catch (Exception $e) { 
    166166                        pg_query($this->db,"ROLLBACK;"); 
    167167                        debugLog("exception -> " . $e->getMessage() . " - ARQUIVO: " . $e->getFile() . " - LINHA: " . $e->getLine()); 
    168168                } 
    169                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::StatMessage: ERRO: Não encontrou valor para o campo last_update para esse evento.'); 
     169                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::StatMessage: ERRO: Não encontrou valor para o campo last_update para esse evento.'); 
    170170                return false; 
    171171        } 
     
    186186                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    187187                        if ($row = pg_fetch_row($result)) { 
    188                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO-> Lê evento do DB para enviar para o celular (cal_id: '.$row[0].', title:'.$row[1].', location: '.$row[2].', mdatetime: '.$row[3].', datetime: '.$row[4].', edatetime: '.$row[5].', reference: '.$row[7].', isPublic: '.$row[8].')'); 
     188                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO-> Lê evento do DB para enviar para o celular (cal_id: '.$row[0].', title:'.$row[1].', location: '.$row[2].', mdatetime: '.$row[3].', datetime: '.$row[4].', edatetime: '.$row[5].', reference: '.$row[7].', isPublic: '.$row[8].')'); 
    189189                                if ($row[7] != 0) $has_parent_event = true; 
    190190                                else $has_parent_event = false; 
     
    236236                                        } 
    237237                                } 
    238                                 $message->alldayevent = 0; // (0 - Não(default), 1- Sim) 
     238                                $message->alldayevent = 0; // (0 - Não(default), 1- Sim) 
    239239                                $message->busystatus = 2; // 2 - Ocupado 
    240240                                //TODO: Tratar $message - timezone 
    241                                 //$tz = $this->_getGMTTZ(); 
     241                                // $tz = $this->_getGMTTZ(); 
    242242                                $tz = array("bias" => 180, "stdbias" => 0, "dstbias" => -60, "dstendyear" => 0, "dstendmonth" => 2, "dstendday" => 0, "dstendweek" => 2, "dstendhour" => 2, "dstendminute" => 0, "dstendsecond" => 0, "dstendmillis" => 0, 
    243                                                       "dststartyear" => 0, "dststartmonth" =>10, "dststartday" =>0, "dststartweek" => 3, "dststarthour" => 2, "dststartminute" => 0, "dststartsecond" => 0, "dststartmillis" => 0); 
     243                                                                                      "dststartyear" => 0, "dststartmonth" =>10, "dststartday" =>0, "dststartweek" => 3, "dststarthour" => 2, "dststartminute" => 0, "dststartsecond" => 0, "dststartmillis" => 0); 
    244244                                $message->timezone = base64_encode($this->_getSyncBlobFromTZ($tz)); 
    245245                                //TODO: Se necessario, tratar $message - meetingstatus 
     
    265265                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    266266                                if ($row = pg_fetch_row($result)){ 
    267                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO-> Lê recorrência do evento (recur_type: '.$row[0].', recur_use_end: '.$row[1].', recur_enddate: '.$row[2].', recur_interval: '.$row[3].', recur_data: '.$row[4].', recur_exception: '.$row[5].')'); 
     267                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO-> Lê recorrência do evento (recur_type: '.$row[0].', recur_use_end: '.$row[1].', recur_enddate: '.$row[2].', recur_interval: '.$row[3].', recur_data: '.$row[4].', recur_exception: '.$row[5].')'); 
    268268                                        $recur = new SyncRecurrence(); 
    269269                                        // Converte os tipos do Expresso para os tipos do Protocolo ActiveSync 
     
    311311                                        } 
    312312                                        $message->recurrence = $recur; 
    313                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO-> Fim do Bloco - Lê recorrência do evento.'); 
     313                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO-> Fim do Bloco - Lê recorrência do evento.'); 
    314314                                } 
    315315 
     
    318318                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    319319                                while ($row_recur_exception = pg_fetch_row($result)) { 
    320                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO: Lê evento único da recorrência com id: '.$row_recur_exception[0]); 
     320                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO: Lê evento único da recorrência com id: '.$row_recur_exception[0]); 
    321321                                        $recur_exception = $this->GetMessageDAO($row_recur_exception[0]); 
    322322                                        if ($recur_exception instanceof SyncAppointment) { 
     
    324324                                                array_push($message->exceptions, $recur_exception); 
    325325                                        } 
    326                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO-> Fim do Bloco - Lê evento único da recorrência com id: '.$row_recur_exception[0]); 
     326                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO-> Fim do Bloco - Lê evento único da recorrência com id: '.$row_recur_exception[0]); 
    327327                                } 
    328328 
     
    331331                                        $array_timestamps_recur_deleted = explode(",",$row[5]); 
    332332                                        foreach ($array_timestamps_recur_deleted as $timestamp_recur_deleted) { 
    333                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO: Timestamps dos eventos únicos da recorrência do tipo deletados: '.$timestamp_recur_deleted); 
     333                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO: Timestamps dos eventos únicos da recorrência do tipo deletados: '.$timestamp_recur_deleted); 
    334334                                                $recur_deleted = new SyncAppointment(); 
    335335                                                $recur_deleted->deleted = '1'; 
     
    340340                                } 
    341341                                //TODO: Tratar Participantes do Evento 
    342  
    343342                        } 
    344343                        $result = pg_query($this->db,"COMMIT;"); 
     
    349348                        return; 
    350349                } 
    351                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO-> Fim do Bloco - Lê evento do DB para enviar para o celular: '.$id); 
     350                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageDAO-> Fim do Bloco - Lê evento do DB para enviar para o celular: '.$id); 
    352351                return $message; 
    353352        } 
     
    389388                        return false; 
    390389                } 
    391                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog("CalendarExpresso::DeleteMessage-> Fim normal da Função."); 
     390                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog("CalendarExpresso::DeleteMessage-> Fim normal da Função."); 
    392391                return true; 
    393392        } 
     
    399398        function ChangeMessageDAO($id, $message) { 
    400399                debugLog('CalendarExpresso::ChangeMessageDAO('.$id.', ..)'); 
    401                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> O evento do celular será inserido/atualizado no BD com o ID: '.$id); 
     400                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> O evento do celular será inserido/atualizado no BD com o ID: '.$id); 
    402401                try { 
    403402                        $result = pg_query($this->db,"BEGIN;"); 
     
    543542                        //TODO: Implementar para os tipos 3 e 6. O Expresso ainda nao suporta esses tipos :-( 
    544543                        if (isset($message->recurrence) and ($message->recurrence->type == 0 or $message->recurrence->type == 1 or $message->recurrence->type == 2 or $message->recurrence->type == 5)) { 
    545                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> O Evento é Recorrente.'); 
     544                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> O Evento é Recorrente.'); 
    546545                                switch ($message->recurrence->type) { 
    547546                                        case 0: //repeticao diaria 
     
    562561                                                break; 
    563562                                } 
    564                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência-> recur_type: '.$arrayRecur["recur_type"]); 
     563                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência-> recur_type: '.$arrayRecur["recur_type"]); 
    565564                                if (isset($message->recurrence->interval)) { 
    566565                                        $arrayRecur["recur_interval"] = $message->recurrence->interval; 
    567                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência-> recur_interval: '.$arrayRecur["recur_interval"]); 
     566                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência-> recur_interval: '.$arrayRecur["recur_interval"]); 
    568567                                } 
    569568                                if ($message->recurrence->type == 1 or $message->recurrence->type == 3 or $message->recurrence->type == 6) { 
    570569                                        if (isset($message->recurrence->dayofweek)) { 
    571570                                                $arrayRecur["recur_data"] = $message->recurrence->dayofweek; 
    572                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência-> recur_data: '.$arrayRecur["recur_data"]); 
     571                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência-> recur_data: '.$arrayRecur["recur_data"]); 
    573572                                                /*$day = $message->recurrence->dayofweek; 
    574573                                                 $day_of_week_counter = 0; 
     
    615614                                        $arrayRecur["recur_enddate"] = 1893283200; // Se nao tem data de termino seta para 30/12/2029 
    616615                                } 
    617                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência-> recur_enddate: '.$arrayRecur["recur_enddate"]); 
     616                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência-> recur_enddate: '.$arrayRecur["recur_enddate"]); 
    618617 
    619618                                // Trata excecoes da recorrencia 
     
    621620                                        // Tem Excecoes de recorrencia do tipo Edicao 
    622621                                        // Verifica se ja existe o registro do evento de excecao de recorrencia na tabela phpgw_cal 
    623                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento tem exceção de recorrência'); 
     622                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento tem exceção de recorrência'); 
    624623                                        $recur_exception_changed_ids = ""; 
    625624                                        $recur_exception_deleted_starttimes = ""; 
     
    643642                                                                        $except_description_from_DB = $row[2]; 
    644643                                                                        $found_except_cal_id = true; 
    645                                                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Achou o evento na tabela phpgw_cal, vai ATUALIZAR a exceção da recorrência nessa tabela'); 
     644                                                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Achou o evento na tabela phpgw_cal, vai ATUALIZAR a exceção da recorrência nessa tabela'); 
    646645                                                                } 
    647646                                                        } 
     
    653652                                                                        if(isset($row[0])) { 
    654653                                                                                $found_except_cal_user = true; 
    655                                                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Achou o evento na tabela phpgw_cal_user, vai ATUALIZAR a exceção da recorrência nessa tabela'); 
     654                                                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Achou o evento na tabela phpgw_cal_user, vai ATUALIZAR a exceção da recorrência nessa tabela'); 
    656655                                                                        } 
    657656                                                                } 
     
    661660                                                        if(isset($message->uid)) { 
    662661                                                                $arrayExceptCal["uid"] = $this->truncateString(utf8_decode($message->uid),255); 
    663                                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> uid: '.$arrayExceptCal["uid"]); 
     662                                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> uid: '.$arrayExceptCal["uid"]); 
    664663                                                        } 
    665664                                                        if(isset($recur_exception->subject)) { 
     
    668667                                                                $arrayExceptCal["title"] = $this->truncateString(utf8_decode($message->subject),299); 
    669668                                                        } 
    670                                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> title: '.$arrayExceptCal["title"]); 
     669                                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> title: '.$arrayExceptCal["title"]); 
    671670                                                        if(isset($recur_exception->location)) { 
    672671                                                                $arrayExceptCal["location"] = $this->truncateString(utf8_decode($recur_exception->location),255); 
     
    674673                                                                $arrayExceptCal["location"] = $this->truncateString(utf8_decode($message->location),255); 
    675674                                                        } 
    676                                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> location: '.$arrayExceptCal["location"]); 
     675                                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> location: '.$arrayExceptCal["location"]); 
    677676                                                        if(isset($recur_exception->dtstamp)) { 
    678677                                                                $arrayExceptCal["mdatetime"] = $recur_exception->dtstamp; 
     
    680679                                                                $arrayExceptCal["mdatetime"] = $message->dtstamp; 
    681680                                                        } 
    682                                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> mdatetime: '.$arrayExceptCal["mdatetime"]); 
     681                                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> mdatetime: '.$arrayExceptCal["mdatetime"]); 
    683682                                                        if(isset($recur_exception->starttime)) { 
    684683                                                                $arrayExceptCal["datetime"] = $recur_exception->starttime; 
     
    686685                                                                $arrayExceptCal["datetime"] = $message->starttime; 
    687686                                                        } 
    688                                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> datetime: '.$arrayExceptCal["datetime"]); 
     687                                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> datetime: '.$arrayExceptCal["datetime"]); 
    689688                                                        if(isset($recur_exception->endtime)) { 
    690689                                                                $arrayExceptCal["edatetime"] = $recur_exception->endtime; 
     
    692691                                                                $arrayExceptCal["edatetime"] = $message->endtime; 
    693692                                                        } 
    694                                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> edatetime: '.$arrayExceptCal["edatetime"]); 
     693                                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> edatetime: '.$arrayExceptCal["edatetime"]); 
    695694                                                        if(isset($recur_exception->sensitivity) and $recur_exception->sensitivity == 0) { 
    696695                                                                $arrayExceptCal["is_public"] = 1; // 1 - Normal 
     
    700699                                                                $arrayExceptCal["is_public"] = 1; // 1 - Normal 
    701700                                                        }else $arrayExceptCal["is_public"] = 0; // 0 - Privado 
    702                                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> is_public: '.$arrayExceptCal["is_public"]); 
     701                                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> is_public: '.$arrayExceptCal["is_public"]); 
    703702                                                        if (isset($recur_exception->body)) { 
    704703                                                                $arrayExceptCal["description"] = utf8_decode($recur_exception->body); 
     
    738737                                                                } 
    739738                                                        } 
    740                                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> category: '.$arrayExceptCal["category"]); 
     739                                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> category: '.$arrayExceptCal["category"]); 
    741740                                                        //TODO: Converter eventos que sao alldayevent para iniciar as 0:00hs e terminar as 23:59hs. Isso porque o Expresso nao suporta alldayevents 
    742741                                                        //               if(isset($message->alldayevent)) { 
     
    752751                                                                $result = pg_insert($this->db, 'phpgw_cal', $arrayExceptCal); 
    753752                                                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    754                                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento de Exceção da Recorrência INSERIDO na tabela phpgw_cal com cal_id: '.$arrayExceptCal["cal_id"]); 
     753                                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento de Exceção da Recorrência INSERIDO na tabela phpgw_cal com cal_id: '.$arrayExceptCal["cal_id"]); 
    755754                                                        } else { 
    756755                                                                $result = pg_update($this->db, 'phpgw_cal', $arrayExceptCal, array('cal_id' => $except_cal_id)); 
    757756                                                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    758                                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento de Exceção da Recorrência ATUALIZADO na tabela phpgw_cal'); 
     757                                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento de Exceção da Recorrência ATUALIZADO na tabela phpgw_cal'); 
    759758                                                        } 
    760759 
     
    768767                                                                $result = pg_insert($this->db, 'phpgw_cal_user', $arrayExceptCalUser); 
    769768                                                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    770                                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento de Exceção da Recorrência INSERIDO na tabela phpgw_cal_user com cal_id: '.$arrayExceptCalUser["cal_id"]); 
     769                                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento de Exceção da Recorrência INSERIDO na tabela phpgw_cal_user com cal_id: '.$arrayExceptCalUser["cal_id"]); 
    771770                                                        } else { 
    772771                                                                $result = pg_update($this->db, 'phpgw_cal_user', $arrayExceptCalUser, array('cal_id' => $except_cal_id, 'cal_login' => $this->_uidnumber)); 
    773772                                                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    774                                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento de Exceção da Recorrência ATUALIZADO na tabela phpgw_cal_user'); 
     773                                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento de Exceção da Recorrência ATUALIZADO na tabela phpgw_cal_user'); 
    775774                                                        } 
    776775                                                        if ($recur_exception_changed_ids == "") { 
     
    790789                                                //Tem Excecoes de recorrencia do tipo Exclusao 
    791790                                                $arrayRecur["recur_exception"] = $recur_exception_deleted_starttimes; 
    792                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento tem exceção de recorrência do tipo exclusão com os seguintes starttimes: '.$recur_exception_deleted_starttimes); 
     791                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento tem exceção de recorrência do tipo exclusão com os seguintes starttimes: '.$recur_exception_deleted_starttimes); 
    793792                                        } else { 
    794793                                                $arrayRecur["recur_exception"] = ""; 
    795                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Não tem exceção de recorrência do tipo exclusão para esse evento'); 
     794                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Não tem exceção de recorrência do tipo exclusão para esse evento'); 
    796795                                        } 
    797796                                        if ($recur_exception_changed_ids == "") { 
     
    801800                                                $result = pg_query($this->db, "delete from phpgw_cal where reference = " . $cal_id . ";"); 
    802801                                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    803                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Não tem exceção de recorrência, então deleta possíveis eventos de exceção de recorrência criados anteriormente para esse evento.'); 
     802                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Não tem exceção de recorrência, então deleta possíveis eventos de exceção de recorrência criados anteriormente para esse evento.'); 
    804803                                        } else { 
    805804                                                //Deleta as excecoes da recorrencia, exceto as inseridas/atualizadas acima 
     
    808807                                                $result = pg_query($this->db, "delete from phpgw_cal where reference = " . $cal_id . " and cal_id not in (" . $recur_exception_changed_ids . ");"); 
    809808                                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    810                                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Deleta as exçeções da recorrência, exceto as inseridas/atualizadas pelo celular com os seguintes cal_id:'.$recur_exception_changed_ids); 
     809                                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Deleta as exçeções da recorrência, exceto as inseridas/atualizadas pelo celular com os seguintes cal_id:'.$recur_exception_changed_ids); 
    811810                                        } 
    812811                                } else { 
     
    817816                                        $result = pg_query($this->db, "delete from phpgw_cal where reference = " . $cal_id . ";"); 
    818817                                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    819                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Não tem exceção de recorrência, então deleta possíveis eventos de exceção de recorrência criados anteriormente para esse evento..'); 
     818                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Não tem exceção de recorrência, então deleta possíveis eventos de exceção de recorrência criados anteriormente para esse evento..'); 
    820819                                } 
    821820                                if (!$found_cal_repeats){ 
     
    823822                                        $result = pg_insert($this->db, 'phpgw_cal_repeats', $arrayRecur); 
    824823                                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    825                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência INSERIDA na tabela phpgw_cal_repeats com cal_id: '.$arrayRecur["cal_id"]); 
     824                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência INSERIDA na tabela phpgw_cal_repeats com cal_id: '.$arrayRecur["cal_id"]); 
    826825                                } else { 
    827826                                        $result = pg_update($this->db, 'phpgw_cal_repeats', $arrayRecur, array('cal_id' => $cal_id)); 
    828827                                        if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    829                                         if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência ATUALIZADA na tabela phpgw_cal_repeats'); 
     828                                        if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência ATUALIZADA na tabela phpgw_cal_repeats'); 
    830829                                } 
    831830                        } elseif ($found_cal_id) { 
     
    837836                                $result = pg_query($this->db, "delete from phpgw_cal_repeats where cal_id = " . $cal_id . ";"); 
    838837                                if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 
    839                                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Não tem recorrência, então deleta possíveis eventos de recorrência criados anteriormente para esse evento'); 
     838                                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Não tem recorrência, então deleta possíveis eventos de recorrência criados anteriormente para esse evento'); 
    840839                        } 
    841840                        $result = pg_query($this->db,"COMMIT;"); 
     
    847846                        return false; 
    848847                } 
    849                 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Fim normal da Função'); 
     848                if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Fim normal da Função'); 
    850849                return $id; 
    851850        } 
     
    917916 
    918917        function  removeAccents($data){ 
    919                 $data = strtr($data,"ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÜÚÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùüúþÿ","aaaaaaaceeeeiiii noooooxouuutbaaaaaaaceeeeiiii nooooo/ouuuty"); 
     918                $data = strtr($data,"ÀÁÂÃÄà
     919ÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÜÚÞßàáâãÀåÊçÚéêëìíîïðñòóÎõö÷ÞùÌúßÿ","aaaaaaaceeeeiiii noooooxouuutbaaaaaaaceeeeiiii nooooo/ouuuty"); 
    920920                return $data; 
    921921        } 
     
    944944        function _getGMTTZ() { 
    945945                //$tz = array("bias" => 0, "stdbias" => 0, "dstbias" => 0, "dstendyear" => 0, "dstendmonth" => 2, "dstendday" => 0, "dstendweek" => 2, "dstendhour" => 2, "dstendminute" => 0, "dstendsecond" => 0, "dstendmillis" => 0, 
    946                 //                              "dststartyear" => 0, "dststartmonth" =>10, "dststartday" =>0, "dststartweek" => 3, "dststarthour" => 2, "dststartminute" => 0, "dststartsecond" => 0, "dststartmillis" => 0); 
    947                 $tz = array("bias" => 120, "stdbias" => 0, "dstbias" => -60, "dstendyear" => 0, "dstendmonth" => 2, "dstendday" => 0, "dstendweek" => 2, "dstendhour" => 2, "dstendminute" => 0, "dstendsecond" => 0, "dstendmillis" => 0, 
    948                                                       "dststartyear" => 0, "dststartmonth" =>10, "dststartday" =>0, "dststartweek" => 3, "dststarthour" => 2, "dststartminute" => 0, "dststartsecond" => 0, "dststartmillis" => 0); 
     946                //"dststartyear" => 0, "dststartmonth" =>10, "dststartday" =>0, "dststartweek" => 3, "dststarthour" => 2, "dststartminute" => 0, "dststartsecond" => 0, "dststartmillis" => 0); 
     947                $tz = array("bias" => 120, "stdbias" => 0, "dstbias" => -60, "dstendyear" => 0, "dstendmonth" => 2, "dstendday" => 0, "dstendweek" => 2, "dstendhour" => 2, "dstendminute" => 0, "dstendsecond" => 0, "dstendmillis" => 0, "dststartyear" => 0, "dststartmonth" =>10, "dststartday" =>0, "dststartweek" => 3, "dststarthour" => 2, "dststartminute" => 0, "dststartsecond" => 0, "dststartmillis" => 0); 
     948                 
    949949                return $tz; 
    950950        } 
Note: See TracChangeset for help on using the changeset viewer.