function w2ui($string) { return windows1252_to_utf8($string, "//TRANSLIT"); }
function GetMessage($folderid, $id, $truncsize) { debugLog("IMAP-GetMessage: (fid: '{$folderid}' id: '{$id}' truncsize: {$truncsize})"); // Get flags, etc $stat = $this->StatMessage($folderid, $id); if ($stat) { $this->imap_reopenFolder($folderid); $mail = @imap_fetchheader($this->_mbox, $id, FT_PREFETCHTEXT | FT_UID) . @imap_body($this->_mbox, $id, FT_PEEK | FT_UID); $mobj = new Mail_mimeDecode($mail); $message = $mobj->decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $mail, 'crlf' => "\n", 'charset' => 'utf-8')); $output = new SyncMail(); // decode body to truncate it $body = utf8_to_windows1252($this->getBody($message)); if (strlen($body) > $truncsize) { $body = substr($body, 0, $truncsize); $output->bodytruncated = 1; } else { $body = $body; $output->bodytruncated = 0; } $body = str_replace("\n", "\r\n", windows1252_to_utf8(str_replace("\r", "", $body))); $output->bodysize = strlen($body); $output->body = $body; $output->datereceived = isset($message->headers["date"]) ? strtotime($message->headers["date"]) : null; $output->displayto = isset($message->headers["to"]) ? $message->headers["to"] : null; $output->importance = isset($message->headers["x-priority"]) ? preg_replace("/\\D+/", "", $message->headers["x-priority"]) : null; $output->messageclass = "IPM.Note"; $output->subject = isset($message->headers["subject"]) ? $message->headers["subject"] : ""; $output->read = $stat["flags"]; $output->to = isset($message->headers["to"]) ? $message->headers["to"] : null; $output->cc = isset($message->headers["cc"]) ? $message->headers["cc"] : null; $output->from = isset($message->headers["from"]) ? $message->headers["from"] : null; $output->reply_to = isset($message->headers["reply-to"]) ? $message->headers["reply-to"] : null; // Attachments are only searched in the top-level part $n = 0; if (isset($message->parts)) { foreach ($message->parts as $part) { if (isset($part->disposition) && ($part->disposition == "attachment" || $part->disposition == "inline")) { $attachment = new SyncAttachment(); if (isset($part->body)) { $attachment->attsize = strlen($part->body); } if (isset($part->d_parameters['filename'])) { $attname = $part->d_parameters['filename']; } else { if (isset($part->ctype_parameters['name'])) { $attname = $part->ctype_parameters['name']; } else { if (isset($part->headers['content-description'])) { $attname = $part->headers['content-description']; } else { $attname = "unknown attachment"; } } } $attachment->displayname = $attname; $attachment->attname = $folderid . ":" . $id . ":" . $n; $attachment->attmethod = 1; $attachment->attoid = isset($part->headers['content-id']) ? $part->headers['content-id'] : ""; array_push($output->attachments, $attachment); } $n++; } } // unset mimedecoder & mail unset($mobj); unset($mail); return $output; } return false; }
function GetMessage($folderid, $id, $truncsize) { debugLog("KOLAB-GetMessage: (fid: '{$folderid}' id: '{$id}' truncsize: {$truncsize})"); // Get flags, etc $stat = $this->StatMessage($folderid, $id); if ($stat) { if ($this->kolabFolderType($folderid)) { //get the imap_id $imap_id = array_pop(explode("/", $stat['mod'])); //$imap_id=$stat['mod']; if (substr($folderid, 0, 7) == "VIRTUAL") { $folderid = $this->CacheIndexUid2FolderUid($id); debugLog("GetMessage Flmode: {$id} - > {$folderid}"); $this->Log("NOTICE GetMessage Flmode: {$id} - > {$folderid}"); } } else { $imap_id = $id; } $this->imap_reopenFolder($folderid); $mail = @imap_fetchheader($this->_mbox, $imap_id, FT_PREFETCHTEXT | FT_UID) . @imap_body($this->_mbox, $imap_id, FT_PEEK | FT_UID); $mobj = new Mail_mimeDecode($mail); $message = $mobj->decode(array('decode_headers' => true, 'decode_bodies' => true, 'include_bodies' => true, 'input' => $mail, 'crlf' => "\n", 'charset' => 'utf-8')); if ($this->kolabFolderType($folderid) == 1) { $output = $this->KolabReadContact($message, 0); $this->Log("Changed on Server C: {$folderid} /" . $id . "imap id : " . $imap_id); $this->Log(" : " . u2w($output->fileas)); $this->CacheCreateIndex($folderid, $id, $imap_id); return $output; } elseif ($this->kolabFolderType($folderid) == 2) { //bug #9 we must test if we want alarms or not // for the moment disable it if namespace <> INBOX $fa = $this->CacheReadFolderParam($folderid); $fa->setFolder($folderid); if ($fa->showAlarm($this->_devid)) { $output = $this->KolabReadEvent($message, $id, false); //alarm must be shown } else { $output = $this->KolabReadEvent($message, $id, true); } $this->Log("Changed on Server A: {$folderid}/" . $id); $this->Log(" : " . u2w($output->subject)); $this->CacheCreateIndex($folderid, $id, $imap_id); $this->CacheWriteSensitivity($id, $output->sensitivity); return $output; } elseif ($this->kolabFolderType($folderid) == 3) { $output = $this->KolabReadTask($message, $id); $this->Log("Changed on Server T: {$folderid} /" . $id); $this->Log(" : " . u2w($output->subject)); $this->CacheCreateIndex($folderid, $id, $imap_id); //rewrite completion $this->CacheWriteTaskCompleted($id, $output->completed); $this->CacheWriteSensitivity($id, $output->sensitivity); return $output; } else { $output = new SyncMail(); // decode body to truncate it $body = utf8_to_windows1252($this->getBody($message)); $truncsize = 2048; if (strlen($body) > $truncsize) { $body = substr($body, 0, $truncsize); $output->bodytruncated = 1; } else { $body = $body; $output->bodytruncated = 0; } $body = str_replace("\n", "\r\n", windows1252_to_utf8(str_replace("\r", "", $body))); $output->bodysize = strlen($body); $output->body = $body; $output->datereceived = isset($message->headers["date"]) ? strtotime($message->headers["date"]) : null; $output->displayto = isset($message->headers["to"]) ? $message->headers["to"] : null; $output->importance = isset($message->headers["x-priority"]) ? preg_replace("/\\D+/", "", $message->headers["x-priority"]) : null; $output->messageclass = "IPM.Note"; $output->subject = isset($message->headers["subject"]) ? $message->headers["subject"] : ""; $output->read = $stat["flags"]; $output->to = isset($message->headers["to"]) ? $message->headers["to"] : null; $output->cc = isset($message->headers["cc"]) ? $message->headers["cc"] : null; $output->from = isset($message->headers["from"]) ? $message->headers["from"] : null; $output->reply_to = isset($message->headers["reply-to"]) ? $message->headers["reply-to"] : null; // Attachments are only searched in the top-level part $n = 0; if (isset($message->parts)) { foreach ($message->parts as $part) { if (isset($part->disposition) && ($part->disposition == "attachment" || $part->disposition == "inline")) { $attachment = new SyncAttachment(); if (isset($part->body)) { $attachment->attsize = strlen($part->body); } if (isset($part->d_parameters['filename'])) { $attname = $part->d_parameters['filename']; } else { if (isset($part->ctype_parameters['name'])) { $attname = $part->ctype_parameters['name']; } else { if (isset($part->headers['content-description'])) { $attname = $part->headers['content-description']; } else { $attname = "unknown attachment"; } } } $attachment->displayname = $attname; $attachment->attname = $folderid . ":" . $id . ":" . $n; $attachment->attmethod = 1; $attachment->attoid = isset($part->headers['content-id']) ? $part->headers['content-id'] : ""; array_push($output->attachments, $attachment); } $n++; } } // unset mimedecoder & mail unset($mobj); unset($mail); return $output; } } return false; }
function GetFolder($id) { $folder = new SyncFolder(); $folder->serverid = $id; // explode hierarchy $fhir = explode(".", $id); // compare on lowercase strings $lid = strtolower($id); if ($lid == "inbox") { $folder->parentid = "0"; // Root $folder->displayname = "Inbox"; $folder->type = SYNC_FOLDER_TYPE_INBOX; } else { if ($lid == "drafts") { $folder->parentid = "0"; $folder->displayname = "Drafts"; $folder->type = SYNC_FOLDER_TYPE_DRAFTS; } else { if ($lid == "trash") { $folder->parentid = "0"; $folder->displayname = "Trash"; $folder->type = SYNC_FOLDER_TYPE_WASTEBASKET; $this->_wasteID = $id; } else { if ($lid == "sent" || $lid == "sent items" || $lid == IMAP_SENTFOLDER) { $folder->parentid = "0"; $folder->displayname = "Sent"; $folder->type = SYNC_FOLDER_TYPE_SENTMAIL; $this->_sentID = $id; } else { if ($lid == "inbox.drafts") { $folder->parentid = $fhir[0]; $folder->displayname = "Drafts"; $folder->type = SYNC_FOLDER_TYPE_DRAFTS; } else { if ($lid == "inbox.trash") { $folder->parentid = $fhir[0]; $folder->displayname = "Trash"; $folder->type = SYNC_FOLDER_TYPE_WASTEBASKET; $this->_wasteID = $id; } else { if ($lid == "inbox.sent") { $folder->parentid = $fhir[0]; $folder->displayname = "Sent"; $folder->type = SYNC_FOLDER_TYPE_SENTMAIL; $this->_sentID = $id; } else { if (count($fhir) > 1) { $folder->displayname = windows1252_to_utf8(imap_utf7_decode(array_pop($fhir))); $folder->parentid = implode(".", $fhir); } else { $folder->displayname = windows1252_to_utf8(imap_utf7_decode($id)); $folder->parentid = "0"; } $folder->type = SYNC_FOLDER_TYPE_OTHER; } } } } } } } //advanced debugging //debugLog("IMAP-GetFolder(id: '$id') -> " . print_r($folder, 1)); return $folder; }
function w2u($string) { return windows1252_to_utf8($string); }
function getSettings($request, $devid) { if (isset($request["userinformation"])) { $userdetails = mapi_zarafa_getuser($this->_defaultstore, $this->_user); if ($userdetails != false) { $response["userinformation"]["status"] = 1; $response["userinformation"]["emailaddresses"][] = $userdetails["emailaddress"]; } else { $response["userinformation"]["status"] = false; } } if (isset($request["oof"])) { $props = mapi_getprops($this->_defaultstore, array(PR_EC_OUTOFOFFICE, PR_EC_OUTOFOFFICE_MSG, PR_EC_OUTOFOFFICE_SUBJECT)); if ($props != false) { $response["oof"]["status"] = 1; $response["oof"]["oofstate"] = isset($props[PR_EC_OUTOFOFFICE]) ? $props[PR_EC_OUTOFOFFICE] ? 1 : 0 : 0; $oofmsg["appliesto"] = SYNC_SETTINGS_APPLIESTOINTERNAL; $oofmsg["replymessage"] = windows1252_to_utf8(isset($props[PR_EC_OUTOFOFFICE_MSG]) ? $props[PR_EC_OUTOFOFFICE_MSG] : ""); $oofmsg["enabled"] = isset($props[PR_EC_OUTOFOFFICE]) ? $props[PR_EC_OUTOFOFFICE] ? 1 : 0 : 0; $oofmsg["bodytype"] = $request["oof"]["bodytype"]; $response["oof"]["oofmsgs"][] = $oofmsg; // $this->settings["outofoffice"]["subject"] = windows1252_to_utf8(isset($props[PR_EC_OUTOFOFFICE_SUBJECT]) ? $props[PR_EC_OUTOFOFFICE_SUBJECT] : ""); } else { $response["oof"]["status"] = 0; } } return $response; }