Changeset 4219 for contrib/z-push/backend/BackendCalendarExpresso.php
- Timestamp:
- 05/05/11 09:37:13 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
contrib/z-push/backend/BackendCalendarExpresso.php
r4000 r4219 52 52 53 53 function GetMessageList($folderid, $cutoffdate) { 54 debugLog('CalendarExpresso::GetMessageList('.$this->_uidnumber.')'); 54 debugLog('CalendarExpresso::GetMessageList('.$this->_uidnumber.', '.$cutoffdate.')'); 55 if (TRACE_UID !== false and $cutoffdate !== 0 and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> Filtra eventos com data maior que cutoffdate: '.date("d/m/Y G:i:s",$cutoffdate).', cutoffdate_timestamp: '.$cutoffdate); 55 56 if ($folderid != "calendar") return false; 56 57 58 $cal_ids = null; 57 59 $messages = array(); 58 60 try { 59 61 $result = pg_query($this->db,"BEGIN;"); 60 62 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 61 if ($cutoffdate == 0) $result = pg_query($this->db, "select c.cal_id, c.last_update, c.datetime, c.cal_type from phpgw_cal c join phpgw_cal_user u on (c.cal_id = u.cal_id) where u.cal_login ='" . $this->_uidnumber . "'and c.reference = 0;");62 else $result = pg_query($this->db, "select c.cal_id, c.last_update, c.datetime, c.cal_type from phpgw_cal c join phpgw_cal_user u on (c.cal_id = u.cal_id) where u.cal_login ='" . $this->_uidnumber . "'and c.reference = 0 and c.edatetime > " . $cutoffdate . ";");63 if ($cutoffdate == 0) $result = pg_query($this->db, "select c.cal_id, c.last_update, c.datetime, c.cal_type, c.title from phpgw_cal c join phpgw_cal_user u on (c.cal_id = u.cal_id) where u.cal_login ='" . $this->_uidnumber . "'and c.reference = 0;"); 64 else $result = pg_query($this->db, "select c.cal_id, c.last_update, c.datetime, c.cal_type, c.title from phpgw_cal c join phpgw_cal_user u on (c.cal_id = u.cal_id) where u.cal_login ='" . $this->_uidnumber . "'and c.reference = 0 and c.edatetime > " . $cutoffdate . ";"); 63 65 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 64 66 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].')'); 65 68 $result_recur = pg_query($this->db,"select recur_enddate from phpgw_cal_repeats where cal_id = " . $row[0] . ";"); 66 69 if ($result_recur == FALSE) throw new Exception(pg_last_error($this->db)); 67 70 if ($row[3] == 'M') { 68 71 if ($recur_enddate = pg_fetch_result($result_recur, 0, 0)) { 69 if ($recur_enddate < $row[2]) 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. 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); 73 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'); 75 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. 76 } 70 77 } 71 78 } … … 76 83 $message["flags"] = 1; // always 'read' 77 84 $messages[] = $message; 85 if ($cal_ids === null) $cal_ids = $row[0]; 86 else $cal_ids = $cal_ids . ',' . $row[0]; 87 } 88 // Eventos com reference invalidos 89 if ($cutoffdate == 0) $result_invalid_ref = pg_query($this->db, "select c.cal_id, c.last_update, c.datetime, c.cal_type, c.title, c.reference from phpgw_cal c join phpgw_cal_user u on (c.cal_id = u.cal_id) where u.cal_login ='" . $this->_uidnumber . "'and c.reference <> 0 and c.reference not in(".$cal_ids.");"); 90 else $result_invalid_ref = pg_query($this->db, "select c.cal_id, c.last_update, c.datetime, c.cal_type, c.title, c.reference from phpgw_cal c join phpgw_cal_user u on (c.cal_id = u.cal_id) where u.cal_login ='" . $this->_uidnumber . "'and c.reference <> 0 and c.reference not in(".$cal_ids.") and c.datetime > ". $cutoffdate .";"); 91 if ($result_invalid_ref == FALSE) throw new Exception(pg_last_error($this->db)); 92 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].')'); 94 } 95 // Evento fora da faixa filtrada 96 if ($cutoffdate !== 0) { 97 $result_out_cutoffdate = pg_query($this->db, "select c.cal_id, c.datetime, c.cal_type, c.title, c.reference from phpgw_cal c join phpgw_cal_user u on (c.cal_id = u.cal_id) where u.cal_login ='" . $this->_uidnumber . "'and c.datetime <= ". $cutoffdate .";"); 98 if ($result_out_cutoffdate == FALSE) throw new Exception(pg_last_error($this->db)); 99 while ($row_out_cutoffdate = pg_fetch_row($result_out_cutoffdate)) { 100 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> INFORMACAO: Evento com campo datetime fora da faixa filtrada (cal_id: '.$row_out_cutoffdate[0].', title: '.$row_out_cutoffdate[3].', reference: '.$row_out_cutoffdate[4].', datetime: '.date("d/m/Y G:i:s",$row_out_cutoffdate[1]).', datetime_timestamp: '.$row_out_cutoffdate[1].', cal_type: '.$row_out_cutoffdate[2].')'); 101 } 78 102 } 79 103 $result = pg_query($this->db,"COMMIT;"); … … 83 107 debugLog("exception -> " . $e->getMessage() . " - ARQUIVO: " . $e->getFile() . " - LINHA: " . $e->getLine()); 84 108 } 109 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::GetMessageList-> Fim normal da função'); 85 110 return $messages; 86 111 } … … 132 157 $message["id"] = $id; 133 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"]); 134 160 return $message; 135 161 } … … 141 167 debugLog("exception -> " . $e->getMessage() . " - ARQUIVO: " . $e->getFile() . " - LINHA: " . $e->getLine()); 142 168 } 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.'); 143 170 return false; 144 171 } … … 159 186 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 160 187 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].')'); 161 189 if ($row[7] != 0) $has_parent_event = true; 162 190 else $has_parent_event = false; … … 237 265 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 238 266 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].')'); 239 268 $recur = new SyncRecurrence(); 240 269 // Converte os tipos do Expresso para os tipos do Protocolo ActiveSync … … 282 311 } 283 312 $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.'); 284 314 } 285 315 … … 288 318 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 289 319 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]); 290 321 $recur_exception = $this->GetMessageDAO($row_recur_exception[0]); 291 322 if ($recur_exception instanceof SyncAppointment) { … … 293 324 array_push($message->exceptions, $recur_exception); 294 325 } 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]); 295 327 } 296 328 … … 299 331 $array_timestamps_recur_deleted = explode(",",$row[5]); 300 332 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); 301 334 $recur_deleted = new SyncAppointment(); 302 335 $recur_deleted->deleted = '1'; … … 307 340 } 308 341 //TODO: Tratar Participantes do Evento 342 309 343 } 310 344 $result = pg_query($this->db,"COMMIT;"); … … 315 349 return; 316 350 } 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); 317 352 return $message; 318 353 } … … 354 389 return false; 355 390 } 391 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog("CalendarExpresso::DeleteMessage-> Fim normal da Função."); 356 392 return true; 357 393 } … … 363 399 function ChangeMessageDAO($id, $message) { 364 400 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); 365 402 try { 366 403 $result = pg_query($this->db,"BEGIN;"); … … 380 417 $description_from_DB = $row[3]; 381 418 $found_cal_id = true; 419 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Achou o evento na tabela phpgw_cal, vai ATUALIZAR essa tabela'); 382 420 } 383 421 } … … 388 426 if(isset($row[0])) { 389 427 $found_cal_user = true; 428 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 essa tabela'); 390 429 } 391 430 } … … 396 435 if(isset($row[0])) { 397 436 $found_cal_repeats = true; 437 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Achou o evento na tabela phpgw_cal_repeats, vai ATUALIZAR essa tabela'); 398 438 } 399 439 } … … 403 443 if(isset($message->uid)) { 404 444 $arrayCal["uid"] = $this->truncateString(utf8_decode($message->uid),255); 445 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> uid: '.$arrayCal["uid"]); 405 446 } 406 447 if(isset($message->subject)) { 407 448 $arrayCal["title"] = $this->truncateString(utf8_decode($message->subject),299); 449 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> title: '.$arrayCal["title"]); 408 450 } 409 451 if(isset($message->location)) { 410 452 $arrayCal["location"] = $this->truncateString(utf8_decode($message->location),255); 453 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> location: '.$arrayCal["location"]); 411 454 } 412 455 if(isset($message->dtstamp)) { 413 456 $arrayCal["mdatetime"] = $message->dtstamp; 457 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> mdatetime: '.$arrayCal["mdatetime"]); 414 458 } 415 459 if(isset($message->starttime)) { 416 460 $arrayCal["datetime"] = $message->starttime; 461 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> datetime: '.$arrayCal["datetime"]); 417 462 } 418 463 if(isset($message->endtime)) { 419 464 $arrayCal["edatetime"] = $message->endtime; 465 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> edatetime: '.$arrayCal["edatetime"]); 420 466 } 421 467 if(isset($message->sensitivity) and $message->sensitivity == 0) { 422 468 $arrayCal["is_public"] = 1; // 1 - Normal 423 469 } else $arrayCal["is_public"] = 0; // 0 - Privado 470 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> is_public: '.$arrayCal["is_public"]); 424 471 425 472 if(isset($message->rtf)) { … … 429 476 if ($result_loadrtf == true) $rtf_to_ascii->parse(); 430 477 $arrayCal["description"] = $rtf_to_ascii->out; 478 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> description: '.$arrayCal["description"]); 431 479 // } else { 432 480 // $arrayCal["description"] = ''; … … 444 492 } 445 493 } 494 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> category: '.$arrayCal["category"]); 446 495 } 447 496 $tz_CEL = $this->_getTZFromSyncBlob(base64_decode($message->timezone)); … … 462 511 $result = pg_insert($this->db, 'phpgw_cal', $arrayCal); 463 512 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 513 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento INSERIDO na tabela phpgw_cal com cal_id: '.$arrayCal["cal_id"]); 464 514 } else { 465 515 if (isset($cal_type_from_DB)) { … … 469 519 $result = pg_update($this->db, 'phpgw_cal', $arrayCal, array('cal_id' => $cal_id)); 470 520 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 521 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento ATUALIZADO na tabela phpgw_cal'); 471 522 } 472 523 … … 480 531 $result = pg_insert($this->db, 'phpgw_cal_user', $arrayCalUser); 481 532 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 533 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento INSERIDO na tabela phpgw_cal_user com cal_id: '.$arrayCalUser["cal_id"]); 482 534 } else { 483 535 $result = pg_update($this->db, 'phpgw_cal_user', $arrayCalUser, array('cal_id' => $cal_id, 'cal_login' => $this->_uidnumber)); 484 536 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 537 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Evento ATUALIZADO na tabela phpgw_cal_user'); 485 538 } 486 539 if (!$id) { … … 490 543 //TODO: Implementar para os tipos 3 e 6. O Expresso ainda nao suporta esses tipos :-( 491 544 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.'); 492 546 switch ($message->recurrence->type) { 493 547 case 0: //repeticao diaria … … 508 562 break; 509 563 } 564 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência-> recur_type: '.$arrayRecur["recur_type"]); 510 565 if (isset($message->recurrence->interval)) { 511 566 $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"]); 512 568 } 513 569 if ($message->recurrence->type == 1 or $message->recurrence->type == 3 or $message->recurrence->type == 6) { 514 570 if (isset($message->recurrence->dayofweek)) { 515 571 $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"]); 516 573 /*$day = $message->recurrence->dayofweek; 517 574 $day_of_week_counter = 0; … … 558 615 $arrayRecur["recur_enddate"] = 1893283200; // Se nao tem data de termino seta para 30/12/2029 559 616 } 617 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Recorrência-> recur_enddate: '.$arrayRecur["recur_enddate"]); 560 618 561 619 // Trata excecoes da recorrencia … … 563 621 // Tem Excecoes de recorrencia do tipo Edicao 564 622 // 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'); 565 624 $recur_exception_changed_ids = ""; 566 625 $recur_exception_deleted_starttimes = ""; … … 584 643 $except_description_from_DB = $row[2]; 585 644 $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'); 586 646 } 587 647 } … … 593 653 if(isset($row[0])) { 594 654 $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'); 595 656 } 596 657 } … … 600 661 if(isset($message->uid)) { 601 662 $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"]); 602 664 } 603 665 if(isset($recur_exception->subject)) { … … 606 668 $arrayExceptCal["title"] = $this->truncateString(utf8_decode($message->subject),299); 607 669 } 670 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> title: '.$arrayExceptCal["title"]); 608 671 if(isset($recur_exception->location)) { 609 672 $arrayExceptCal["location"] = $this->truncateString(utf8_decode($recur_exception->location),255); … … 611 674 $arrayExceptCal["location"] = $this->truncateString(utf8_decode($message->location),255); 612 675 } 676 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> location: '.$arrayExceptCal["location"]); 613 677 if(isset($recur_exception->dtstamp)) { 614 678 $arrayExceptCal["mdatetime"] = $recur_exception->dtstamp; … … 616 680 $arrayExceptCal["mdatetime"] = $message->dtstamp; 617 681 } 682 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> mdatetime: '.$arrayExceptCal["mdatetime"]); 618 683 if(isset($recur_exception->starttime)) { 619 684 $arrayExceptCal["datetime"] = $recur_exception->starttime; … … 621 686 $arrayExceptCal["datetime"] = $message->starttime; 622 687 } 688 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> datetime: '.$arrayExceptCal["datetime"]); 623 689 if(isset($recur_exception->endtime)) { 624 690 $arrayExceptCal["edatetime"] = $recur_exception->endtime; … … 626 692 $arrayExceptCal["edatetime"] = $message->endtime; 627 693 } 694 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> edatetime: '.$arrayExceptCal["edatetime"]); 628 695 if(isset($recur_exception->sensitivity) and $recur_exception->sensitivity == 0) { 629 696 $arrayExceptCal["is_public"] = 1; // 1 - Normal … … 633 700 $arrayExceptCal["is_public"] = 1; // 1 - Normal 634 701 }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"]); 635 703 if (isset($recur_exception->body)) { 636 704 $arrayExceptCal["description"] = utf8_decode($recur_exception->body); … … 670 738 } 671 739 } 740 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Exceção De Recorrência-> category: '.$arrayExceptCal["category"]); 672 741 //TODO: Converter eventos que sao alldayevent para iniciar as 0:00hs e terminar as 23:59hs. Isso porque o Expresso nao suporta alldayevents 673 742 // if(isset($message->alldayevent)) { … … 683 752 $result = pg_insert($this->db, 'phpgw_cal', $arrayExceptCal); 684 753 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"]); 685 755 } else { 686 756 $result = pg_update($this->db, 'phpgw_cal', $arrayExceptCal, array('cal_id' => $except_cal_id)); 687 757 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'); 688 759 } 689 760 … … 697 768 $result = pg_insert($this->db, 'phpgw_cal_user', $arrayExceptCalUser); 698 769 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"]); 699 771 } else { 700 772 $result = pg_update($this->db, 'phpgw_cal_user', $arrayExceptCalUser, array('cal_id' => $except_cal_id, 'cal_login' => $this->_uidnumber)); 701 773 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'); 702 775 } 703 776 if ($recur_exception_changed_ids == "") { … … 717 790 //Tem Excecoes de recorrencia do tipo Exclusao 718 791 $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); 719 793 } else { 720 794 $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'); 721 796 } 722 797 if ($recur_exception_changed_ids == "") { … … 726 801 $result = pg_query($this->db, "delete from phpgw_cal where reference = " . $cal_id . ";"); 727 802 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.'); 728 804 } else { 729 805 //Deleta as excecoes da recorrencia, exceto as inseridas/atualizadas acima … … 732 808 $result = pg_query($this->db, "delete from phpgw_cal where reference = " . $cal_id . " and cal_id not in (" . $recur_exception_changed_ids . ");"); 733 809 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); 734 811 } 735 812 } else { … … 740 817 $result = pg_query($this->db, "delete from phpgw_cal where reference = " . $cal_id . ";"); 741 818 if ($result == FALSE) throw new Exception(pg_last_error($this->db)); 742 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..'); 743 820 } 744 821 if (!$found_cal_repeats){ … … 746 823 $result = pg_insert($this->db, 'phpgw_cal_repeats', $arrayRecur); 747 824 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"]); 748 826 } else { 749 827 $result = pg_update($this->db, 'phpgw_cal_repeats', $arrayRecur, array('cal_id' => $cal_id)); 750 828 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'); 751 830 } 752 831 } elseif ($found_cal_id) { … … 758 837 $result = pg_query($this->db, "delete from phpgw_cal_repeats where cal_id = " . $cal_id . ";"); 759 838 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'); 760 840 } 761 841 $result = pg_query($this->db,"COMMIT;"); … … 767 847 return false; 768 848 } 849 if (TRACE_UID !== false and (TRACE_TYPE == 'CALENDAR' or TRACE_TYPE == 'ALL')) traceLog('CalendarExpresso::ChangeMessageDAO-> Fim normal da Função'); 769 850 return $id; 770 851 }
Note: See TracChangeset
for help on using the changeset viewer.