diff --git a/felamimail/inc/class.bofelamimail.inc.php b/felamimail/inc/class.bofelamimail.inc.php
new file mode 100644
index 0000000000..cbc697710b
--- /dev/null
+++ b/felamimail/inc/class.bofelamimail.inc.php
@@ -0,0 +1,1530 @@
+ True
+ );
+
+ var $mbox; // the mailbox identifier any function should use
+
+ // define some constants
+ // message types
+ var $type = array("text", "multipart", "message", "application", "audio", "image", "video", "other");
+
+ // message encodings
+ var $encoding = array("7bit", "8bit", "binary", "base64", "quoted-printable", "other");
+
+ // set to true, if php is compiled with multi byte string support
+ var $mbAvailable = FALSE;
+
+ // what type of mimeTypes do we want from the body(text/html, text/plain)
+ var $htmlOptions;
+
+ function bofelamimail($_displayCharset='iso-8859-1')
+ {
+ $this->restoreSessionData();
+
+ $this->foldername = $this->sessionData['mailbox'];
+ $this->accountid = $GLOBALS['phpgw_info']['user']['account_id'];
+
+ $this->bopreferences = CreateObject('felamimail.bopreferences');
+ $this->sofelamimail = CreateObject('felamimail.sofelamimail');
+ $this->botranslation = CreateObject('phpgwapi.translation');
+
+ $this->mailPreferences = $this->bopreferences->getPreferences();
+ $this->imapBaseDir = '';
+
+ $this->displayCharset = $_displayCharset;
+
+ // set some defaults
+ if(count($this->sessionData) == 0)
+ {
+ // this should be under user preferences
+ // sessionData empty
+ // no filter active
+ $this->sessionData['activeFilter'] = "-1";
+ // default mailbox INBOX
+ $this->sessionData['mailbox'] = "INBOX";
+ // default start message
+ $this->sessionData['startMessage'] = 1;
+ // default mailbox for preferences pages
+ $this->sessionData['preferences']['mailbox'] = "INBOX";
+ // default sorting
+ $this->sessionData['sort'] = $this->mailPreferences['sortOrder'];
+ $this->saveSessionData();
+ }
+
+ if (function_exists('mb_convert_encoding')) $this->mbAvailable = TRUE;
+
+ $this->htmlOptions = $this->mailPreferences['htmlOptions'];
+
+ $config = CreateObject('phpgwapi.config','felamimail');
+ $config->read_repository();
+ $this->profileID = $config->config_data['profileID'];
+
+ }
+
+ /**
+ * hook to add account
+ *
+ * this function is a wrapper function for emailadmin
+ *
+ * @param _hookValues contains the hook values as array
+ * @returns nothing
+ */
+ function addAccount($_hookValues)
+ {
+ if($this->profileID > 0 && is_numeric($this->profileID))
+ {
+ ExecMethod('emailadmin.bo.addAccount',$_hookValues,3,$this->profileID);
+ }
+ }
+
+ function adminMenu()
+ {
+ $data = Array
+ (
+ 'description' => 'email settings',
+ 'url' => '/index.php',
+ 'extradata' => 'menuaction=emailadmin.uiuserdata.editUserData'
+ );
+
+ //Do not modify below this line
+ global $menuData;
+
+ $menuData[] = $data;
+ }
+
+ function appendMessage($_folderName, $_header, $_body, $_flags)
+ {
+ #print "
$_header.$_body
";
+ $mailboxString = ExecMethod('emailadmin.bo.getMailboxString',$_folderName,3,$this->profileID);
+ $header = str_replace("\n","\r\n",$_header);
+ $body = str_replace("\n","\r\n",$_body);
+ $result = @imap_append($this->mbox, $mailboxString, "$header"."$body", $_flags);
+ #print imap_last_error();
+ return $result;
+ }
+
+ function closeConnection()
+ {
+ if(is_resource($this->mbox))
+ {
+ imap_close($this->mbox);
+ }
+ }
+
+ // creates the mailbox string needed for the various imap functions
+/* function createMailboxString($_folderName='')
+ {
+ $mailboxString = sprintf("{%s:%s%s/notls}%s",
+ $this->mailPreferences['imapServerAddress'],
+ $this->mailPreferences['imapPort'],
+ $this->mailPreferences['imapOptions'],
+ $_folderName);
+
+ return $this->encodeFolderName($mailboxString);
+ }*/
+
+ function compressFolder()
+ {
+ $prefs = $this->bopreferences->getPreferences();
+
+ $deleteOptions = $prefs['deleteOptions'];
+ $trashFolder = $prefs['trash_folder'];
+
+ if($this->sessionData['mailbox'] == $trashFolder && $deleteOptions == "move_to_trash")
+ {
+ // delete all messages in the trash folder
+ $mailboxString = ExecMethod('emailadmin.bo.getMailboxString',$this->sessionData['mailbox'],3,$this->profileID);
+ $status = imap_status ($this->mbox, $mailboxString, SA_ALL);
+ $numberOfMessages = $status->messages;
+ $msgList = "1:$numberOfMessages";
+ imap_delete($this->mbox, $msgList);
+ imap_expunge($this->mbox);
+ }
+ elseif($deleteOptions == "mark_as_deleted")
+ {
+ // delete all messages in the current folder which have the deleted flag set
+ imap_expunge($this->mbox);
+ }
+ }
+
+ function decodeFolderName($_folderName)
+ {
+ if($this->mbAvailable)
+ {
+ return mb_convert_encoding( $_folderName, $this->displayCharset, "UTF7-IMAP");
+ }
+
+ // if not
+ return @imap_utf7_decode($_folderName);
+ }
+
+ function decode_header($string)
+ {
+ #print "decode header: $string
";
+ $newString = '';
+ $elements=imap_mime_header_decode($string);
+ for($i=0;$icharset}
";
+ #echo "Text: {$elements[$i]->text}
";
+ if ($elements[$i]->charset == 'default')
+ $elements[$i]->charset = 'iso-8859-1';
+ $tempString = $this->botranslation->convert($elements[$i]->text,$elements[$i]->charset);
+ $newString .= $tempString;
+ }
+ return $newString;
+ }
+
+ function deleteAccount($_hookValues)
+ {
+ if($this->profileID > 0 && is_numeric($this->profileID))
+ {
+ ExecMethod('emailadmin.bo.deleteAccount',$_hookValues,3,$this->profileID);
+ }
+ }
+
+ function deleteMessages($_messageUID)
+ {
+ $caching = CreateObject('felamimail.bocaching',
+ $this->mailPreferences['imapServerAddress'],
+ $this->mailPreferences['username'],
+ $this->sessionData['mailbox']);
+
+ reset($_messageUID);
+ while(list($key, $value) = each($_messageUID))
+ {
+ if(!empty($msglist)) $msglist .= ",";
+ $msglist .= $value;
+ }
+
+ $prefs = $this->bopreferences->getPreferences();
+
+ $deleteOptions = $prefs['deleteOptions'];
+ $trashFolder = $prefs['trash_folder'];
+
+ if($this->sessionData['mailbox'] == $trashFolder && $deleteOptions == "move_to_trash")
+ {
+ $deleteOptions = "remove_immediately";
+ }
+
+ switch($deleteOptions)
+ {
+ case "move_to_trash":
+ if(!empty($trashFolder))
+ {
+ if (imap_mail_move ($this->mbox, $msglist, $this->encodeFolderName($trashFolder), CP_UID))
+ {
+ imap_expunge($this->mbox);
+ reset($_messageUID);
+ while(list($key, $value) = each($_messageUID))
+ {
+ $caching->removeFromCache($value);
+ }
+ }
+ else
+ {
+ print imap_last_error()."
";
+ }
+ }
+ break;
+
+ case "mark_as_deleted":
+ imap_delete($this->mbox, $msglist, FT_UID);
+ break;
+
+ case "remove_immediately":
+ imap_delete($this->mbox, $msglist, FT_UID);
+ imap_expunge ($this->mbox);
+ reset($_messageUID);
+ while(list($key, $value) = each($_messageUID))
+ {
+ $caching->removeFromCache($value);
+ }
+ break;
+ }
+ }
+
+ function encodeFolderName($_folderName)
+ {
+ if($this->mbAvailable)
+ {
+ return mb_convert_encoding( $_folderName, "UTF7-IMAP", $this->displayCharset );
+ }
+
+ // if not
+ return imap_utf7_encode($_folderName);
+ }
+
+ function encodeHeader($_string, $_encoding='q')
+ {
+ switch($_encoding)
+ {
+ case "q":
+ if(!preg_match("/[\x80-\xFF]/",$_string))
+ {
+ // nothing to quote, only 7 bit ascii
+ return $_string;
+ }
+
+ $string = imap_8bit($_string);
+ $stringParts = explode("=\r\n",$string);
+ while(list($key,$value) = each($stringParts))
+ {
+ if(!empty($retString)) $retString .= " ";
+ $value = str_replace(" ","_",$value);
+ // imap_8bit does not convert "?"
+ // it does not need, but it should
+ $value = str_replace("?","=3F",$value);
+ $retString .= "=?".strtoupper($this->displayCharset)."?Q?".$value."?=";
+ }
+ #exit;
+ return $retString;
+ break;
+ default:
+ return $_string;
+ }
+ }
+ function flagMessages($_flag, $_messageUID)
+ {
+ reset($_messageUID);
+ while(list($key, $value) = each($_messageUID))
+ {
+ if(!empty($msglist)) $msglist .= ",";
+ $msglist .= $value;
+ }
+
+ switch($_flag)
+ {
+ case "flagged":
+ $result = imap_setflag_full ($this->mbox, $msglist, "\\Flagged", ST_UID);
+ break;
+ case "read":
+ $result = imap_setflag_full ($this->mbox, $msglist, "\\Seen", ST_UID);
+ break;
+ case "answered":
+ $result = imap_setflag_full ($this->mbox, $msglist, "\\Answered", ST_UID);
+ break;
+ case "unflagged":
+ $result = imap_clearflag_full ($this->mbox, $msglist, "\\Flagged", ST_UID);
+ break;
+ case "unread":
+ $result = imap_clearflag_full ($this->mbox, $msglist, "\\Seen", ST_UID);
+ $result = imap_clearflag_full ($this->mbox, $msglist, "\\Answered", ST_UID);
+ break;
+ }
+
+
+ #print "Result: $result
";
+ }
+
+ // this function is based on a on "Building A PHP-Based Mail Client"
+ // http://www.devshed.com
+ // fetch a specific attachment from a message
+ function getAttachment($_uid, $_partID)
+ {
+ // parse message structure
+ $structure = imap_fetchstructure($this->mbox, $_uid, FT_UID);
+ $sections = array();
+ $this->parseMessage($sections, $structure, $_partID);
+
+ #_debug_array($sections);
+
+ $type = $sections[$_partID]["mimeType"];
+ $encoding = $sections[$_partID]["encoding"];
+ $filename = $sections[$_partID]["name"];
+
+ $attachment = imap_fetchbody($this->mbox, $_uid, $_partID, FT_UID);
+
+ switch ($encoding)
+ {
+ case ENCBASE64:
+ // use imap_base64 to decode
+ $attachment = imap_base64($attachment);
+ break;
+ case ENCQUOTEDPRINTABLE:
+ // use imap_qprint to decode
+ $attachment = imap_qprint($attachment);
+ break;
+ case ENCOTHER:
+ // not sure if this needs decoding at all
+ break;
+ default:
+ // it is either not encoded or we don't know about it
+ }
+
+ return array(
+ 'type' => $type,
+ 'encoding' => $encoding,
+ 'filename' => $filename,
+ 'attachment' => $attachment
+ );
+ }
+
+ function getEMailProfile()
+ {
+ $config = CreateObject('phpgwapi.config','felamimail');
+ $config->read_repository();
+ $felamimailConfig = $config->config_data;
+
+ #_debug_array($felamimailConfig);
+
+ if(!isset($felamimailConfig['profileID']))
+ {
+ return -1;
+ }
+ else
+ {
+ return intval($felamimailConfig['profileID']);
+ }
+ }
+
+ function getFolderStatus($_folderName)
+ {
+ // now we have the keys as values
+ $mailboxString = ExecMethod('emailadmin.bo.getMailboxString',$_folderName,3,$this->profileID);
+ $subscribedFolders = $this->getFolderList(true);
+ #print_r($subscribedFolders);
+ #print $subscribedFolders[$_folderName]." - $_folderName
";
+ if(isset($subscribedFolders[$_folderName]))
+ {
+ $retValue['subscribed'] = true;
+ }
+ else
+ {
+ $retValue['subscribed'] = false;
+ }
+
+ // get the current IMAP counters
+ $folderStatus = imap_status($this->mbox,$mailboxString,SA_ALL);
+
+ // merge a array and object to a array
+ $retValue = array_merge($retValue,$folderStatus);
+
+ return $retValue;
+ }
+
+ function getFolderList($_subscribedOnly=false)
+ {
+ $folders = array();
+ if(!is_resource($this->mbox))
+ {
+ return $folders;
+ }
+
+ $mailboxString = ExecMethod('emailadmin.bo.getMailboxString',$this->imapBaseDir,3,$this->profileID);
+
+
+ if($_subscribedOnly == 'true')
+ {
+ $list = imap_getsubscribed($this->mbox,$mailboxString,"*");
+ }
+ else
+ {
+ $list = imap_getmailboxes($this->mbox,$mailboxString,"*");
+ }
+
+ if(is_array($list))
+ {
+ // return always the inbox
+ $folders['INBOX'] = 'INBOX';
+ reset($list);
+ while (list($key, $val) = each($list))
+ {
+ // remove the {host:port/imap/...} part
+ $folderNameIMAP = $this->decodeFolderName(preg_replace("/{.*}/","",$val->name));
+ $folderParts = explode(".",$folderNameIMAP);
+ reset($folderParts);
+ $displayName = "";
+ #print_r($folderParts);print"
";
+ for($i=0; $imbox,$mailboxString,'INBOX')))
+ {
+ $folders['INBOX'] = 'INBOX';
+ return $folders;
+ }
+ return false;
+ }
+ }
+
+ function getHeaders($_startMessage, $_numberOfMessages, $_sort)
+ {
+
+ #printf ("this->bofelamimail->getHeaders start: %s
",date("H:i:s",mktime()));
+
+ $caching = CreateObject('felamimail.bocaching',
+ $this->mailPreferences['imapServerAddress'],
+ $this->mailPreferences['username'],
+ $this->sessionData['mailbox']);
+ $bofilter = CreateObject('felamimail.bofilter');
+ $transformdate = CreateObject('felamimail.transformdate');
+
+ $mailboxString = ExecMethod('emailadmin.bo.getMailboxString',$this->sessionData['mailbox'],3,$this->profileID);
+ $status = imap_status ($this->mbox, $mailboxString, SA_ALL);
+ $cachedStatus = $caching->getImapStatus();
+
+ // no data chached already?
+ // get all message informations from the imap server for this folder
+ if ($cachedStatus['uidnext'] == 0)
+ {
+ #print "nix gecached!!
";
+ #print "current UIDnext :".$cachedStatus['uidnext']."
";
+ #print "new UIDnext :".$status->uidnext."
";
+ for($i=1; $i<=$status->messages; $i++)
+ {
+ @set_time_limit();
+ $messageData['uid'] = imap_uid($this->mbox, $i);
+ $header = imap_headerinfo($this->mbox, $i);
+ // parse structure to see if attachments exist
+ // display icon if so
+ $structure = imap_fetchstructure($this->mbox, $i);
+ $sections = array();
+ $this->parseMessage($sections, $structure);
+
+ $messageData['date'] = $header->udate;
+ $messageData['subject'] = $header->subject;
+ $messageData['to_name'] = $header->to[0]->personal;
+ $messageData['to_address'] = $header->to[0]->mailbox."@".$header->to[0]->host;
+ $messageData['sender_name'] = $header->from[0]->personal;
+ $messageData['sender_address'] = $header->from[0]->mailbox."@".$header->from[0]->host;
+ $messageData['size'] = $header->Size;
+
+ $messageData['attachments'] = "false";
+ foreach($sections as $key => $value)
+ {
+ if($value['type'] == 'attachment')
+ {
+ $messageData['attachments'] = "true";
+ break;
+ }
+ }
+
+ // maybe it's already in the database
+ // lets remove it, sometimes the database gets out of sync
+ $caching->removeFromCache($messageData['uid']);
+
+ $caching->addToCache($messageData);
+
+ unset($messageData);
+ }
+
+ $caching->updateImapStatus($status);
+ }
+ // update cache, but only add new emails
+ elseif($status->uidnext != $cachedStatus['uidnext'])
+ {
+ #print "found new messages
";
+ #print "new uidnext: ".$status->uidnext." old uidnext: ".$cachedStatus['uidnext']."
";
+ $uidRange = $cachedStatus['uidnext'].":".$status->uidnext;
+ #print "$uidRange
";
+ $newHeaders = imap_fetch_overview($this->mbox,$uidRange,FT_UID);
+ $countNewHeaders = count($newHeaders);
+ for($i=0; $i<$countNewHeaders; $i++)
+ {
+ $messageData['uid'] = $newHeaders[$i]->uid;
+ $header = imap_headerinfo($this->mbox, $newHeaders[$i]->msgno);
+ // parse structure to see if attachments exist
+ // display icon if so
+ $structure = imap_fetchstructure($this->mbox, $newHeaders[$i]->msgno);
+ $sections = array();
+ $this->parseMessage($sections, $structure);
+
+ $messageData['date'] = $header->udate;
+ $messageData['subject'] = $header->subject;
+ $messageData['to_name'] = $header->to[0]->personal;
+ $messageData['to_address'] = $header->to[0]->mailbox."@".$header->to[0]->host;
+ $messageData['sender_name'] = $header->from[0]->personal;
+ $messageData['sender_address'] = $header->from[0]->mailbox."@".$header->from[0]->host;
+ $messageData['size'] = $header->Size;
+
+ $messageData['attachments'] = "false";
+ foreach($sections as $key => $value)
+ {
+ if($value['type'] == 'attachment')
+ {
+ $messageData['attachments'] = "true";
+ break;
+ }
+ }
+
+ // maybe it's already in the database
+ // lets remove it, sometimes the database gets out of sync
+ $caching->removeFromCache($messageData['uid']);
+
+ $caching->addToCache($messageData);
+
+ unset($messageData);
+ }
+ $caching->updateImapStatus($status);
+ }
+
+ // now let's do some clean up
+ // if we have more messages in the cache then in the imap box, some external
+ // imap client deleted some messages. It's better to erase the messages from the cache.
+ $displayHeaders = $caching->getHeaders();
+ if (count($displayHeaders) > $status->messages)
+ {
+ $messagesToRemove = count($displayHeaders) - $status->messages;
+ reset($displayHeaders);
+ for($i=0; $imbox,$displayHeaders[$i]['uid'],FT_UID);
+ if (count($header[0]) == 0)
+ {
+ $caching->removeFromCache($displayHeaders[$i]['uid']);
+ $removedMessages++;
+ }
+ if ($removedMessages == $messagesToRemove) break;
+ }
+ }
+
+ // now lets gets the important messages
+ $filterList = $bofilter->getFilterList();
+ $activeFilter = $bofilter->getActiveFilter();
+ $filter = $filterList[$activeFilter];
+ $displayHeaders = $caching->getHeaders($_startMessage, $_numberOfMessages, $_sort, $filter);
+
+ $count=0;
+ $countDisplayHeaders = count($displayHeaders);
+ for ($i=0;$i<$countDisplayHeaders;$i++)
+ {
+ $header = imap_fetch_overview($this->mbox,$displayHeaders[$i]['uid'],FT_UID);
+ #print $header[0]->date;print "
";
+ #print_r($displayHeaders[$i]);print "
";
+ #print_r($header);exit;
+
+ #$rawHeader = imap_fetchheader($this->mbox,$displayHeaders[$i]['uid'],FT_UID);
+ #$headers = $this->sofelamimail->fetchheader($rawHeader);
+
+ $retValue['header'][$count]['subject'] = $this->decode_header($header[0]->subject);
+ $retValue['header'][$count]['sender_name'] = $this->decode_header($displayHeaders[$i]['sender_name']);
+ $retValue['header'][$count]['sender_address'] = $this->decode_header($displayHeaders[$i]['sender_address']);
+ $retValue['header'][$count]['to_name'] = $this->decode_header($displayHeaders[$i]['to_name']);
+ $retValue['header'][$count]['to_address'] = $this->decode_header($displayHeaders[$i]['to_address']);
+ $retValue['header'][$count]['attachments'] = $displayHeaders[$i]['attachments'];
+ $retValue['header'][$count]['size'] = $header[0]->size;
+
+ $timestamp = $displayHeaders[$i]['date'];
+ $timestamp7DaysAgo =
+ mktime(date("H"), date("i"), date("s"), date("m"), date("d")-7, date("Y"));
+ $timestampNow =
+ mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
+ // date from the future
+ if($timestamp > $timestampNow)
+ {
+ $retValue['header'][$count]['date'] = date("Y-m-d",$timestamp);
+ }
+ // email from today, show only time
+ elseif (date("Y-m-d") == date("Y-m-d",$timestamp))
+ {
+ $retValue['header'][$count]['date'] = date("H:i:s",$timestamp);
+ }
+ // email from the last 7 days, show only weekday
+ elseif($timestamp7DaysAgo < $timestamp)
+ {
+ $retValue['header'][$count]['date'] = lang(date("l",$timestamp));
+ #$retValue['header'][$count]['date'] = date("Y-m-d H:i:s",$timestamp7DaysAgo)." - ".date("Y-m-d",$timestamp);
+ $retValue['header'][$count]['date'] = date("H:i:s",$timestamp)."(".lang(date("D",$timestamp)).")";
+ }
+ else
+ {
+ $retValue['header'][$count]['date'] = date("Y-m-d",$timestamp);
+ }
+ $retValue['header'][$count]['id'] = $header[0]->msgno;
+ $retValue['header'][$count]['uid'] = $displayHeaders[$i]['uid'];
+ $retValue['header'][$count]['recent'] = $header[0]->recent;
+ $retValue['header'][$count]['flagged'] = $header[0]->flagged;
+ $retValue['header'][$count]['answered'] = $header[0]->answered;
+ $retValue['header'][$count]['deleted'] = $header[0]->deleted;
+ $retValue['header'][$count]['seen'] = $header[0]->seen;
+ $retValue['header'][$count]['draft'] = $header[0]->draft;
+
+ $count++;
+ }
+
+ #printf ("this->bofelamimail->getHeaders done: %s
",date("H:i:s",mktime()));
+
+ if(is_array($retValue['header']))
+ {
+ #_debug_array($retValue['header']);
+ $retValue['info']['total'] = $caching->getMessageCounter($filter);
+ $retValue['info']['first'] = $_startMessage;
+ $retValue['info']['last'] = $_startMessage + $count - 1 ;
+ return $retValue;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ function getMailPreferences()
+ {
+ return $this->mailPreferences;
+ }
+
+ function getMessageAttachments($_uid, $_partID='')
+ {
+ $structure = imap_fetchstructure($this->mbox, $_uid, FT_UID);
+ $sections = array();
+ $this->parseMessage($sections, $structure, $_partID);
+ #if(isset($sections['attachment']) && is_array($sections['attachment']))
+ #{
+ # #_debug_array($structure['attachment']);
+ # return $sections['attachment'];
+ #}
+
+ $arrayData = array();
+ if(count($sections) > 0)
+ {
+ foreach($sections as $key => $value)
+ {
+ if($value['type'] == 'attachment')
+ {
+ $arrayData[] = $value;
+ }
+ }
+ if(count($arrayData) > 0)
+ {
+ return $arrayData;
+ }
+ }
+
+
+ return false;
+
+ }
+
+ function getMessageBody($_uid, $_htmlOptions = '', $_partID)
+ {
+ if($_htmlOptions != '')
+ $this->htmlOptions = $_htmlOptions;
+
+ $structure = imap_fetchstructure($this->mbox, $_uid, FT_UID);
+ #_debug_array($structure);
+ $sections = array();
+ $this->parseMessage($sections, $structure, $_partID);
+ #_debug_array($sections);
+
+ foreach($sections as $key => $value)
+ {
+ if($value['type'] == 'body')
+ {
+ #_debug_array($value);
+ // no mime message, only body available
+ if($key == 0)
+ {
+ $newPart = trim(imap_body($this->mbox, $_uid, FT_UID));
+ $encoding = $structure->encoding;
+
+ // find mimetype
+ if(strtolower($structure->subtype) == 'html')
+ {
+ $mimeType = 'text/html';
+ }
+ else
+ {
+ $mimeType = 'text/plain';
+ }
+
+ // find charset
+ if($structure->ifparameters)
+ {
+ foreach($structure->parameters as $value)
+ {
+ $parameter[strtolower($value->attribute)] =
+ strtolower($value->value);
+ }
+ $charSet = $parameter['charset'];
+ }
+ }
+ else
+ {
+ // select which part(text or html) to display from multipart/alternative
+ #_debug_array($sections);
+ if($sections[substr($key,0,-2)]['mimeType'] == "multipart/alternative")
+ {
+ switch($this->htmlOptions)
+ {
+ // prefer html part
+ // don't display text part
+ case 'always_display':
+ if($value['mimeType'] == 'text/plain')
+ continue 2;
+ break;
+
+ case 'only_if_no_text':
+ default:
+ if($value['mimeType'] == 'text/html')
+ continue 2;
+ break;
+ }
+ }
+ // don't diplay html emails at all
+ if($value['mimeType'] == 'text/html' &&
+ $this->htmlOptions != 'always_display' &&
+ $this->htmlOptions != 'only_if_no_text')
+ {
+ continue;
+ }
+ $newPart = imap_fetchbody($this->mbox, $_uid, $value["partID"], FT_UID);
+ #if($newPart == '')
+ #{
+ # #print "nothing
";
+ # // FIX ME
+ # // do this only if the parent sub type is multipart/mixed
+ # // and parent/parent is message/rfc
+ # $newPart = imap_fetchbody($this->mbox, $_uid, substr($value["partID"],0,-2), FT_UID);
+ # #$newPart = imap_fetchbody($this->mbox, $_uid, '2.2', FT_UID);
+ #}
+ $encoding = $value['encoding'];
+ $mimeType = $value['mimeType'];
+ $charSet = $value['charset'];
+ }
+
+ // MS-Outlookbug workaround (don't break links)
+ $newPart = preg_replace("!((http(s?)://)|((www|ftp)\.))(([^\n\t\r]+)([=](\r)?\n))+!i",
+ "$1$7",
+ $newPart);
+
+ // decode the file ...
+ switch ($encoding)
+ {
+ case ENCBASE64:
+ // use imap_base64 to decode
+ $newPart = imap_base64($newPart);
+ break;
+ case ENCQUOTEDPRINTABLE:
+ // use imap_qprint to decode
+ #$newPart = imap_qprint($newPart);
+ $newPart = quoted_printable_decode($newPart);
+ break;
+ case ENCOTHER:
+ // not sure if this needs decoding at all
+ break;
+ default:
+ // it is either not encoded or we don't know about it
+ break;
+ }
+
+ $bodyPart[] = array('body' => $newPart,
+ 'mimeType' => $mimeType,
+ 'charSet' => $charSet);
+ }
+ }
+
+ return $bodyPart;
+
+ }
+
+
+ function getMessageHeader($_uid, $_partID = '')
+ {
+ $msgno = imap_msgno($this->mbox, $_uid);
+ if($_partID == '')
+ {
+
+ $retValue = imap_header($this->mbox, $msgno);
+ }
+ else
+ {
+ // do it the hard way
+ // we need to fetch the headers of another part(message/rfcxxxx)
+ $headersPart = imap_fetchbody($this->mbox, $_uid, $_partID.".0", FT_UID);
+ $retValue = imap_rfc822_parse_headers($headersPart);
+ }
+ #_debug_array($retValue);
+ return $retValue;
+ }
+
+ function getMessageRawBody($_uid, $_partID = '')
+ {
+ if($_partID != '')
+ {
+ $body = imap_fetchbody($this->mbox, $_uid, $_partID, FT_UID);
+ }
+ else
+ {
+ $header = imap_fetchheader($this->mbox, $_uid, FT_UID);
+ $body = $header.imap_body($this->mbox, $_uid, FT_UID);
+ }
+
+ return $body;
+ }
+
+ function getMessageRawHeader($_uid, $_partID = '')
+ {
+ if(!$_partID == '')
+ {
+ return imap_fetchbody($this->mbox, $_uid, $_partID.'.0', FT_UID);
+ }
+ else
+ {
+ return imap_fetchheader($this->mbox, $_uid, FT_UID);
+ }
+ }
+
+ function getMessageStructure($_uid)
+ {
+ return imap_fetchstructure($this->mbox, $_uid, FT_UID);
+ }
+
+ // return the qouta of the users INBOX
+ function getQuotaRoot()
+ {
+ if(is_array($this->storageQuota))
+ {
+ return $this->storageQuota;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ function imap_createmailbox($_folderName, $_subscribe = False)
+ {
+ $mailboxString = ExecMethod('emailadmin.bo.getMailboxString',$_folderName,3,$this->profileID);
+
+ $result = @imap_createmailbox($this->mbox,$mailboxString);
+
+ if($_subscribe)
+ {
+ return @imap_subscribe($this->mbox,$mailboxString);
+ }
+
+ return $result;
+ }
+
+ function imap_deletemailbox($_folderName)
+ {
+ $mailboxString = ExecMethod('emailadmin.bo.getMailboxString',$_folderName,3,$this->profileID);
+
+ @imap_unsubscribe ($this->mbox, $mailboxString);
+
+ $result = imap_deletemailbox($this->mbox, $mailboxString);
+
+ #print imap_last_error();
+
+ return $result;
+ }
+
+ function imapGetQuota($_username)
+ {
+ $quota_value = @imap_get_quota($this->mbox, "user.".$_username);
+
+ if(is_array($quota_value) && count($quota_value) > 0)
+ {
+ return array('limit' => $quota_value['limit']/1024);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ function imap_get_quotaroot($_folderName)
+ {
+ return @imap_get_quotaroot($this->mbox, $_folderName);
+ }
+
+ function imap_renamemailbox($_oldMailboxName, $_newMailboxName)
+ {
+ if(strcasecmp("inbox",$_oldMailboxName) == 0 || strcasecmp("inbox",$_newMailboxName) == 0)
+ {
+ return False;
+ }
+
+ $oldMailboxName = ExecMethod('emailadmin.bo.getMailboxString',$_oldMailboxName,3,$this->profileID);
+
+ $newMailboxName = ExecMethod('emailadmin.bo.getMailboxString',$_newMailboxName,3,$this->profileID);
+
+ $result = @imap_renamemailbox($this->mbox,$oldMailboxName, $newMailboxName);
+
+ #print imap_last_error();
+
+ return $result;
+ }
+
+ function imapSetQuota($_username, $_quotaLimit)
+ {
+ if(is_numeric($_quotaLimit) && $_quotaLimit >= 0)
+ {
+ // enable quota
+ $quota_value = @imap_set_quota($this->mbox, "user.".$_username, $_quotaLimit*1024);
+ }
+ else
+ {
+ // disable quota
+ $quota_value = @imap_set_quota($this->mbox, "user.".$_username, -1);
+ }
+ }
+
+ function moveMessages($_foldername, $_messageUID)
+ {
+ $caching = CreateObject('felamimail.bocaching',
+ $this->mailPreferences['imapServerAddress'],
+ $this->mailPreferences['username'],
+ $this->sessionData['mailbox']);
+ $deleteOptions = $GLOBALS['phpgw_info']["user"]["preferences"]["felamimail"]["deleteOptions"];
+
+ reset($_messageUID);
+ while(list($key, $value) = each($_messageUID))
+ {
+ if(!empty($msglist)) $msglist .= ",";
+ $msglist .= $value;
+ }
+ #print $msglist."
";
+
+ #print "destination folder($_folderName): ".$this->encodeFolderName($_foldername)."
";
+
+ if (imap_mail_move ($this->mbox, $msglist, $this->encodeFolderName($_foldername), CP_UID))
+ {
+ #print "allet ok
";
+ if($deleteOptions != "mark_as_deleted")
+ {
+ imap_expunge($this->mbox);
+ reset($_messageUID);
+ while(list($key, $value) = each($_messageUID))
+ {
+ $caching->removeFromCache($value);
+ }
+ }
+ }
+ else
+ {
+ print imap_last_error()."
";
+ }
+
+ }
+
+ function openConnection($_folderName='', $_options=0, $_adminConnection=false)
+ {
+ if(!function_exists('imap_open'))
+ {
+ return lang('This PHP has no IMAP support compiled in!!');
+ }
+
+ if(!$this->mailPreferences['emailConfigValid'])
+ {
+ return lang('no valid emailprofile selected!!');
+ }
+
+ if($_folderName == '' && !$_adminConnection)
+ {
+ $_folderName = $this->sessionData['mailbox'];
+ }
+
+ if($_adminConnection)
+ {
+ $folderName = '';
+ $username = $this->mailPreferences['imapAdminUsername'];
+ $password = $this->mailPreferences['imapAdminPW'];
+ $options = '';
+ }
+ else
+ {
+ $folderName = $_folderName;
+ $username = $this->mailPreferences['username'];
+ $password = $this->mailPreferences['key'];
+ $options = $_options;
+ }
+
+ $mailboxString = ExecMethod('emailadmin.bo.getMailboxString',$_folderName,3,$this->profileID);
+
+ if(!$this->mbox = @imap_open ($mailboxString, $username, $password, $options))
+ {
+ return imap_last_error();
+ }
+ else
+ {
+ // get the quota for this mailboxbox
+ if (function_exists('imap_get_quotaroot') && !$_adminConnection)
+ {
+ $quota = @imap_get_quotaroot($this->mbox, $this->decodeFolderName($folderName));
+ if(is_array($quota['STORAGE']))
+ {
+ $storage = $this->storageQuota = $quota['STORAGE'];
+ }
+ }
+ #$_folderName = "user.lars.Asterisk";
+ #print "$_folderName
";
+ #imap_setacl($this->mbox, $_folderName, 'support', 'lrswipcda');
+ #print "";
+ #print_r(imap_getacl($this->mbox, $_folderName));
+ #print "
";
+ return True;
+ }
+
+ }
+
+ function parseMessage(&$_sections, $_structure, $_wantedPartID = '', $_currentPartID='')
+ {
+ #print "w: $_wantedPartID, c: $_currentPartID
";
+ #if($_currentPartID == '')
+ #{
+ # _debug_array($_structure);
+ # print "
";
+ #}
+ #_debug_array($_sections);
+ #if ($_currentPartID == '') _debug_array($_structure);
+ switch ($_structure->type)
+ {
+ case TYPETEXT:
+ if(!preg_match("/^$_wantedPartID/i",$_currentPartID))
+ {
+ break;
+ }
+ $mime_type = "text";
+ $data['encoding'] = $_structure->encoding;
+ $data['size'] = $_structure->bytes;
+ $data['partID'] = $_currentPartID;
+ $data["mimeType"] = $mime_type."/". strtolower($_structure->subtype);
+ $data["name"] = lang("unknown");
+ for ($lcv = 0; $lcv < count($_structure->parameters); $lcv++)
+ {
+ $param = $_structure->parameters[$lcv];
+ switch(strtolower($param->attribute))
+ {
+ case 'name':
+ $data["name"] = $param->value;
+ break;
+ case 'charset':
+ $data["charset"] = $param->value;
+ break;
+ }
+
+ }
+
+ // set this to zero, when we have a plaintext message
+ // if partID[0] is set, we have no attachments
+ if($_currentPartID == '') $_currentPartID = '0';
+
+ if (strtolower($_structure->disposition) == "attachment" ||
+ $data["name"] != lang("unknown"))
+ {
+ // treat it as attachment
+ // must be a attachment
+ $_sections[$_currentPartID] = $data;
+ $_sections[$_currentPartID]['type'] = 'attachment';
+ }
+ else
+ {
+ #print "found a body part $_currentPartID
";
+ // must be a body part
+ $_sections["$_currentPartID"] = $data;
+ $_sections["$_currentPartID"]['name'] = lang('body part')." $_currentPartID";
+ $_sections[$_currentPartID]['type'] = 'body';
+ }
+ #print "
";
+ #_debug_array($retData);
+ #print "
";
+ break;
+
+ case TYPEMULTIPART:
+ #print "found multipart
";
+ $mimeType = 'multipart';
+ // lets cycle trough all parts
+ $_sections[$_currentPartID]['mimeType'] = $mimeType."/". strtolower($_structure->subtype);
+
+ if($_currentPartID != '') $_currentPartID .= '.';
+
+ #print $_sections[$_currentPartID]['mimeType']."
";
+ for($i = 0; $i < count($_structure->parts); $i++)
+ {
+ $structureData = array();
+ $this->parseMessage($_sections, $_structure->parts[$i], $_wantedPartID, $_currentPartID.($i+1));
+ }
+ break;
+
+ case TYPEMESSAGE:
+ #print "found message $_currentPartID
";
+ #_debug_array($_structure);
+ #print "
";
+ // handle it as attachment
+ #print "$_wantedPartID : $_currentPartID
";
+ if(($_wantedPartID < $_currentPartID) ||
+ empty($_wantedPartID))
+ {
+ #print "add as attachment
";
+ $mime_type = "message";
+ $_sections[$_currentPartID]['encoding'] = $_structure->encoding;
+ $_sections[$_currentPartID]['size'] = $_structure->bytes;
+ $_sections[$_currentPartID]['partID'] = $_currentPartID;
+ $_sections[$_currentPartID]["mimeType"] = $mime_type."/". strtolower($_structure->subtype);
+ $_sections[$_currentPartID]["name"] = lang("unknown");
+ $_sections[$_currentPartID]['type'] = 'attachment';
+ if(!empty($_structure->description))
+ {
+ $_sections[$_currentPartID]["name"] = lang($_structure->description);
+ }
+
+ // has the structure dparameters ??
+ if($_structure->ifdparameters)
+ {
+ foreach($_structure->dparameters as $key => $value)
+ {
+ switch(strtolower($value->attribute))
+ {
+ case 'filename':
+ $_sections[$_currentPartID]["name"] = $value->value;
+ break;
+ }
+ }
+ }
+
+ // has the structure parameters ??
+ if($_structure->ifparameters)
+ {
+ foreach($_structure->parameters as $key => $value)
+ {
+ switch(strtolower($value->attribute))
+ {
+ case 'name':
+ $_sections[$_currentPartID]["name"] = $value->value;
+ break;
+ }
+ }
+ }
+
+
+ }
+ // recurse in it
+ else
+ {
+ #_debug_array($_structure);
+ for($i = 0; $i < count($_structure->parts); $i++)
+ {
+ # print "dive into Message
";
+ if($_structure->parts[$i]->type != TYPEMULTIPART)
+ $_currentPartID = $_currentPartID.'.'.($i+1);
+ $this->parseMessage($_sections, $_structure->parts[$i], $_wantedPartID, $_currentPartID);
+ # $this->parseMessage($_sections, $_structure->parts[0], $_wantedPartID, $_currentPartID);
+ # print "done diving
";
+ }
+ }
+ break;
+
+ case TYPEAPPLICATION:
+ if(!preg_match("/^$_wantedPartID/i",$_currentPartID))
+ {
+ break;
+ }
+ $mime_type = "application";
+ $_sections[$_currentPartID]['encoding'] = $_structure->encoding;
+ $_sections[$_currentPartID]['size'] = $_structure->bytes;
+ $_sections[$_currentPartID]['partID'] = $_currentPartID;
+ $_sections[$_currentPartID]["mimeType"] = $mime_type."/". strtolower($_structure->subtype);
+ $_sections[$_currentPartID]["name"] = lang("unknown");
+ $_sections[$_currentPartID]['type'] = 'attachment';
+ for ($lcv = 0; $lcv < count($_structure->dparameters); $lcv++)
+ {
+ $param = $_structure->dparameters[$lcv];
+ switch(strtolower($param->attribute))
+ {
+ case 'filename':
+ $_sections[$_currentPartID]["name"] = $param->value;
+ break;
+ }
+ }
+
+ for ($lcv = 0; $lcv < count($_structure->parameters); $lcv++)
+ {
+ $param = $_structure->parameters[$lcv];
+ switch(strtolower($param->attribute))
+ {
+ case 'name':
+ $_sections[$_currentPartID]["name"] = $param->value;
+ break;
+ }
+ }
+
+ break;
+
+ case TYPEAUDIO:
+ if(!preg_match("/^$_wantedPartID/i",$_currentPartID))
+ {
+ break;
+ }
+ $mime_type = "audio";
+ $_sections[$_currentPartID]['encoding'] = $_structure->encoding;
+ $_sections[$_currentPartID]['size'] = $_structure->bytes;
+ $_sections[$_currentPartID]['partID'] = $_currentPartID;
+ $_sections[$_currentPartID]["mimeType"] = $mime_type."/". strtolower($_structure->subtype);
+ $_sections[$_currentPartID]["name"] = lang("unknown");
+ $_sections[$_currentPartID]['type'] = 'attachment';
+ for ($lcv = 0; $lcv < count($_structure->dparameters); $lcv++)
+ {
+ $param = $_structure->dparameters[$lcv];
+ switch(strtolower($param->attribute))
+ {
+ case 'filename':
+ $_sections[$_currentPartID]["name"] = $param->value;
+ break;
+ }
+ }
+ break;
+
+ case TYPEIMAGE:
+ if(!preg_match("/^$_wantedPartID/i",$_currentPartID))
+ {
+ break;
+ }
+ #print "found image $_currentPartID
";
+ $mime_type = "image";
+ $_sections[$_currentPartID]['encoding'] = $_structure->encoding;
+ $_sections[$_currentPartID]['size'] = $_structure->bytes;
+ $_sections[$_currentPartID]['partID'] = $_currentPartID;
+ $_sections[$_currentPartID]["mimeType"] = $mime_type."/". strtolower($_structure->subtype);
+ $_sections[$_currentPartID]["name"] = lang("unknown");
+ $_sections[$_currentPartID]['type'] = 'attachment';
+ for ($lcv = 0; $lcv < count($_structure->dparameters); $lcv++)
+ {
+ $param = $_structure->dparameters[$lcv];
+ switch(strtolower($param->attribute))
+ {
+ case 'filename':
+ $_sections[$_currentPartID]["name"] = $param->value;
+ break;
+ }
+ }
+ break;
+
+ case TYPEVIDEO:
+ if(!preg_match("/^$_wantedPartID/i",$_currentPartID))
+ {
+ break;
+ }
+ $mime_type = "video";
+ $_sections[$_currentPartID]['encoding'] = $_structure->encoding;
+ $_sections[$_currentPartID]['size'] = $_structure->bytes;
+ $_sections[$_currentPartID]['partID'] = $_currentPartID;
+ $_sections[$_currentPartID]["mimeType"] = $mime_type."/". strtolower($_structure->subtype);
+ $_sections[$_currentPartID]["name"] = lang("unknown");
+ $_sections[$_currentPartID]['type'] = 'attachment';
+ for ($lcv = 0; $lcv < count($_structure->dparameters); $lcv++)
+ {
+ $param = $_structure->dparameters[$lcv];
+ switch(strtolower($param->attribute))
+ {
+ case 'filename':
+ $_sections[$_currentPartID]["name"] = $param->value;
+ break;
+ }
+ }
+ break;
+
+ case TYPEMODEL:
+ if(!preg_match("/^$_wantedPartID/i",$_currentPartID))
+ {
+ break;
+ }
+ $mime_type = "model";
+ $_sections[$_currentPartID]['encoding'] = $_structure->encoding;
+ $_sections[$_currentPartID]['size'] = $_structure->bytes;
+ $_sections[$_currentPartID]['partID'] = $_currentPartID;
+ $_sections[$_currentPartID]["mimeType"] = $mime_type."/". strtolower($_structure->subtype);
+ $_sections[$_currentPartID]["name"] = lang("unknown");
+ $_sections[$_currentPartID]['type'] = 'attachment';
+ for ($lcv = 0; $lcv < count($_structure->dparameters); $lcv++)
+ {
+ $param = $_structure->dparameters[$lcv];
+ switch(strtolower($param->attribute))
+ {
+ case 'filename':
+ $_sections[$_currentPartID]["name"] = $param->value;
+ break;
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+
+ #if ($_currentPartID == '') _debug_array($_sections);
+
+ #print "$_wantedPartID, $_currentPartID
";
+ #if($_currentPartID >= $_wantedPartID)
+ #{
+ # print "will add
";
+ # return $retData;
+ #}
+
+ }
+
+ function restoreSessionData()
+ {
+ $this->sessionData = $GLOBALS['phpgw']->session->appsession('session_data');
+ }
+
+ function saveFilter($_formData)
+ {
+ if(!empty($_formData['from']))
+ $data['from'] = $_formData['from'];
+ if(!empty($_formData['to']))
+ $data['to'] = $_formData['to'];
+ if(!empty($_formData['subject']))
+ $data['subject']= $_formData['subject'];
+ if($_formData['filterActive'] == "true")
+ {
+ $data['filterActive']= "true";
+ }
+
+ $this->sessionData['filter'] = $data;
+ $this->saveSessionData();
+ }
+
+ function saveSessionData()
+ {
+ $GLOBALS['phpgw']->session->appsession('session_data','',$this->sessionData);
+ }
+
+ function setEMailProfile($_profileID)
+ {
+ $config = CreateObject('phpgwapi.config','felamimail');
+ $config->read_repository();
+ $config->value('profileID',$_profileID);
+ $config->save_repository();
+ }
+
+ function subscribe($_folderName, $_status)
+ {
+ #$this->mailPreferences['imapServerAddress']
+ #$this->mailPreferences['imapPort'],
+
+ $folderName = $this->encodeFolderName($_folderName);
+ $folderName = "{".$this->mailPreferences['imapServerAddress'].":".$this->mailPreferences['imapPort']."}".$folderName;
+
+ if($_status == 'unsubscribe')
+ {
+ return imap_unsubscribe($this->mbox,$folderName);
+ }
+ else
+ {
+ return imap_subscribe($this->mbox,$folderName);
+ }
+ }
+
+ function toggleFilter()
+ {
+ if($this->sessionData['filter']['filterActive'] == 'true')
+ {
+ $this->sessionData['filter']['filterActive'] = 'false';
+ }
+ else
+ {
+ $this->sessionData['filter']['filterActive'] = 'true';
+ }
+ $this->saveSessionData();
+ }
+
+ function updateAccount($_hookValues)
+ {
+ if($this->profileID > 0 && is_numeric($this->profileID))
+ {
+ ExecMethod('emailadmin.bo.updateAccount',$_hookValues,3,$this->profileID);
+ }
+ }
+
+ /* inspired by http://de2.php.net/wordwrap
+ desolate19 at hotmail dot com */
+ function wordwrap($str, $cols, $cut)
+ {
+/*
+ // todo
+ // think about multibyte charsets
+ // think about links in html mode
+ $len = strlen($str);
+ $tag = 0;
+ $lineLenght = 0;
+
+ for ($i = 0; $i < $len; $i++)
+ {
+ $lineLenght++;
+ $chr = substr($str,$i,1);
+ if(ctype_cntrl($chr))
+ {
+ if(ord($chr) == 10)
+ $lineLenght = 0;
+ }
+ if ($chr == '<') {
+ $tag++;
+ } elseif ($chr == '>') {
+ $tag--;
+ } elseif ((!$tag) && (ctype_space($chr))) {
+ $wordlen = 0;
+ } elseif (!$tag) {
+ $wordlen++;
+ }
+
+ if ((!$tag) && (!$wordlen) && $lineLenght > $cols) {
+ //if ((!$tag) && ($wordlen) && (!($wordlen % $cols))) {
+ #print "add cut
";
+ $chr .= $cut;
+ $lineLenght = 0;
+ }
+ $result .= $chr;
+ }
+ return $result;
+*/
+ $lines = explode('\n', $str);
+ $newStr = '';
+ foreach($lines as $line)
+ {
+ // replace tabs by 8 space chars, or any tab only counts one char
+ $line = str_replace("\t"," ",$line);
+ $newStr .= wordwrap($line, $cols, $cut);
+ }
+ return $newStr;
+ }
+
+ }
+?>
diff --git a/felamimail/inc/class.uidisplay.inc.php b/felamimail/inc/class.uidisplay.inc.php
index 6c31ffd11d..810400145b 100644
--- a/felamimail/inc/class.uidisplay.inc.php
+++ b/felamimail/inc/class.uidisplay.inc.php
@@ -11,714 +11,218 @@
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\***************************************************************************/
-
- /**
- * copyright notice for the functions highlightQuotes and _countQuoteChars
- *
- * The Text:: class provides common methods for manipulating text.
- *
- * $Horde: horde/lib/Text.php,v 1.80 2003/09/16 23:06:15 jan Exp $
- *
- * Copyright 1999-2003 Jon Parise
- *
- * See the enclosed file COPYING for license information (LGPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
- *
- */
-
/* $Id$ */
- class uidisplay
+ class uicompose
{
var $public_functions = array
(
- 'display' => 'True',
- 'showHeader' => 'True',
- 'getAttachment' => 'True'
+ 'compose' => 'True',
+ 'reply' => 'True',
+ 'replyAll' => 'True',
+ 'forward' => 'True',
+ 'action' => 'True'
);
- function uidisplay()
+ function uicompose()
{
- $this->t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
$this->displayCharset = $GLOBALS['phpgw']->translation->charset();
- $this->bofelamimail = CreateObject('felamimail.bofelamimail',$this->displayCharset);
- $this->bofilter = CreateObject('felamimail.bofilter');
- $this->bopreferences = CreateObject('felamimail.bopreferences');
- $this->kses = CreateObject('phpgwapi.kses');
- $this->botranslation = CreateObject('phpgwapi.translation');
-
- $this->mailPreferences = $this->bopreferences->getPreferences();
-
- $this->bofelamimail->openConnection();
-
- $this->mailbox = $this->bofelamimail->sessionData['mailbox'];
- $this->sort = $this->bofelamimail->sessionData['sort'];
-
- $this->uid = $GLOBALS['HTTP_GET_VARS']['uid'];
-
- if(isset($GLOBALS['HTTP_GET_VARS']['part']) &&
- is_numeric($GLOBALS['HTTP_GET_VARS']['part']))
+ if (!isset($GLOBALS['HTTP_POST_VARS']['composeid']) && !isset($GLOBALS['HTTP_GET_VARS']['composeid']))
{
- $this->partID = $GLOBALS['HTTP_GET_VARS']['part'];
+ // create new compose session
+ $this->bocompose = CreateObject('felamimail.bocompose','',$this->displayCharset);
+ $this->composeID = $this->bocompose->getComposeID();
}
else
{
- $this->partID = 0;
- }
-
- $this->bocaching = CreateObject('felamimail.bocaching',
- $this->mailPreferences['imapServerAddress'],
- $this->mailPreferences['username'],
- $this->mailbox);
+ // reuse existing compose session
+ if (isset($GLOBALS['HTTP_POST_VARS']['composeid']))
+ $this->composeID = $GLOBALS['HTTP_POST_VARS']['composeid'];
+ else
+ $this->composeID = $GLOBALS['HTTP_GET_VARS']['composeid'];
+ $this->bocompose = CreateObject('felamimail.bocompose',$this->composeID,$this->displayCharset);
+ }
+ $this->t = CreateObject('phpgwapi.Template',PHPGW_APP_TPL);
+ $this->bofelamimail = CreateObject('felamimail.bofelamimail',$this->displayCharset);
+ $this->mailPreferences = ExecMethod('felamimail.bopreferences.getPreferences');
+ $this->t->set_unknowns('remove');
+
$this->rowColor[0] = $GLOBALS['phpgw_info']["theme"]["bg01"];
$this->rowColor[1] = $GLOBALS['phpgw_info']["theme"]["bg02"];
- if($GLOBALS['HTTP_GET_VARS']['showHeader'] == "false")
+
+ }
+
+ function unhtmlentities ($string)
+ {
+ $trans_tbl = get_html_translation_table (HTML_ENTITIES);
+ $trans_tbl = array_flip ($trans_tbl);
+ return strtr ($string, $trans_tbl);
+ }
+
+ function action()
+ {
+ $formData['to'] = $this->bocompose->stripSlashes($GLOBALS['HTTP_POST_VARS']['to']);
+ $formData['cc'] = $this->bocompose->stripSlashes($GLOBALS['HTTP_POST_VARS']['cc']);
+ $formData['bcc'] = $this->bocompose->stripSlashes($GLOBALS['HTTP_POST_VARS']['bcc']);
+ $formData['reply_to'] = $this->bocompose->stripSlashes($GLOBALS['HTTP_POST_VARS']['reply_to']);
+ $formData['subject'] = $this->bocompose->stripSlashes($GLOBALS['HTTP_POST_VARS']['subject']);
+ $formData['body'] = $this->bocompose->stripSlashes($GLOBALS['HTTP_POST_VARS']['body']);
+ $formData['priority'] = $this->bocompose->stripSlashes($GLOBALS['HTTP_POST_VARS']['priority']);
+ $formData['signature'] = $this->bocompose->stripSlashes($GLOBALS['HTTP_POST_VARS']['signature']);
+ $formData['mailbox'] = $GLOBALS['HTTP_GET_VARS']['mailbox'];
+
+ if (isset($GLOBALS['HTTP_POST_VARS']['send']))
{
- $this->bofelamimail->sessionData['showHeader'] = 'False';
- $this->bofelamimail->saveSessionData();
+ $action="send";
+ }
+ elseif (isset($GLOBALS['HTTP_POST_VARS']['addfile']))
+ {
+ $action="addfile";
+ }
+ elseif (isset($GLOBALS['HTTP_POST_VARS']['removefile']))
+ {
+ $action="removefile";
}
- }
-
- function createLinks($_data)
- {
-
- }
-
- function highlightQuotes($text, $level = 5)
- {
- // Use a global var since the class is called statically.
- $GLOBALS['_tmp_maxQuoteChars'] = 0;
-
- // Tack a newline onto the beginning of the string so that we
- // correctly highlight when the first character in the string
- // is a quote character.
- $text = "\n$text";
-
- preg_replace_callback("/^\s*((>\s?)+)/m", array(&$this, '_countQuoteChars'), $text);
-
- // Go through each level of quote block and put the
- // appropriate style around it. Important to work downwards so
- // blocks with fewer quote chars aren't matched until their
- // turn.
- for ($i = $GLOBALS['_tmp_maxQuoteChars']; $i > 0; $i--)
+ switch ($action)
{
- $text = preg_replace(
- // Finds a quote block across multiple newlines.
- "/(\n)( *(>\s?)\{$i}(?! ?>).*?)(\n|$)(?! *(> ?)\{$i})/s",
- '\1\2\4',$text);
- }
-
- /* Unset the global variable. */
- unset($GLOBALS['_tmp_maxQuoteChars']);
-
- /* Remove the leading newline we added above. */
- return substr($text, 1);
- }
-
- function _countQuoteChars($matches)
- {
- $num = count(preg_split('/>\s?/', $matches[1])) - 1;
- if ($num > $GLOBALS['_tmp_maxQuoteChars'])
- {
- $GLOBALS['_tmp_maxQuoteChars'] = $num;
- }
- }
-
- function display()
- {
- $partID = $_GET['part'];
- $transformdate = CreateObject('felamimail.transformdate');
- $htmlFilter = CreateObject('felamimail.htmlfilter');
-
- $headers = $this->bofelamimail->getMessageHeader($this->uid, $partID);
- $rawheaders = $this->bofelamimail->getMessageRawHeader($this->uid, $partID);
- $bodyParts = $this->bofelamimail->getMessageBody($this->uid,'',$partID);
- $attachments = $this->bofelamimail->getMessageAttachments($this->uid,$partID);
- $filterList = $this->bofilter->getFilterList();
- $activeFilter = $this->bofilter->getActiveFilter();
- $filter = $filterList[$activeFilter];
- $nextMessage = $this->bocaching->getNextMessage($this->uid, $this->sort, $filter);
-
- $webserverURL = $GLOBALS['phpgw_info']['server']['webserver_url'];
-
- #print "";print_r($rawheaders);print"
";exit;
-
- // add line breaks to $rawheaders
- $newRawHeaders = explode("\n",$rawheaders);
- reset($newRawHeaders);
- // find the Organization header
- // the header can also span multiple rows
- while(is_array($newRawHeaders) && list($key,$value) = each($newRawHeaders))
- {
- #print $value."
";
- if(preg_match("/Organization: (.*)/",$value,$matches))
- {
- $organization = $this->bofelamimail->decode_header(chop($matches[1]));
- #$organization = chop($matches[1]);
- continue;
- }
- if(!empty($organization) && preg_match("/^\s+(.*)/",$value,$matches))
- {
- $organization .= $this->bofelamimail->decode_header(chop($matches[1]));
+ case "addfile":
+ $formData['name'] = $GLOBALS['HTTP_POST_FILES']['attachfile']['name'];
+ $formData['type'] = $GLOBALS['HTTP_POST_FILES']['attachfile']['type'];
+ $formData['file'] = $GLOBALS['HTTP_POST_FILES']['attachfile']['tmp_name'];
+ $formData['size'] = $GLOBALS['HTTP_POST_FILES']['attachfile']['size'];
+ $this->bocompose->addAttachment($formData);
+ $this->compose();
break;
- }
- elseif(!empty($organization))
- {
+
+ case "removefile":
+ $formData['removeAttachments'] = $GLOBALS['HTTP_POST_VARS']['attachment'];
+ $this->bocompose->removeAttachment($formData);
+ $this->compose();
break;
- }
+
+ case "send":
+ if(!$this->bocompose->send($formData))
+ {
+ $this->compose();
+ return;
+ }
+
+ #$linkData = array
+ #(
+ # 'mailbox' => $GLOBALS['HTTP_GET_VARS']['mailbox'],
+ # 'startMessage' => '1'
+ #);
+ #$link = $GLOBALS['phpgw']->link('/felamimail/index.php',$linkData);
+ #$GLOBALS['phpgw']->redirect($link);
+ #$GLOBALS['phpgw']->common->phpgw_exit();
+ if($this->mailPreferences['messageNewWindow'])
+ {
+ print "";
+ }
+ else
+ {
+ ExecMethod('felamimail.uifelamimail.viewMainScreen');
+ }
+ break;
+ }
+ }
+
+ function compose($_focusElement="to")
+ {
+ // read the data from session
+ // all values are empty for a new compose window
+ $sessionData = $this->bocompose->getSessionData();
+ $preferences = ExecMethod('felamimail.bopreferences.getPreferences');
+ #_debug_array($preferences);
+
+ // is the to address set already?
+ if (!empty($GLOBALS['HTTP_GET_VARS']['send_to']))
+ {
+ $sessionData['to'] = base64_decode($_GET['send_to']);
}
- // reset $rawheaders
- $rawheaders = "";
- // create it new, with good line breaks
- reset($newRawHeaders);
- while(list($key,$value) = @each($newRawHeaders))
- {
- $rawheaders .= wordwrap($value,90,"\n ");
- }
+ $this->display_app_header();
- $this->bofelamimail->closeConnection();
-
- if(!isset($_GET['printable']))
- {
- $this->display_app_header();
- $this->t->set_file(array("displayMsg" => "view_message.tpl"));
- }
- else
- {
- $this->t->set_file(array("displayMsg" => "view_message_printable.tpl"));
- $this->t->set_var('charset',$GLOBALS['phpgw']->translation->charset());
- }
-
- $this->t->set_block('displayMsg','message_main');
- $this->t->set_block('displayMsg','message_header');
- $this->t->set_block('displayMsg','message_raw_header');
- $this->t->set_block('displayMsg','message_navbar');
- $this->t->set_block('displayMsg','message_onbehalfof');
- $this->t->set_block('displayMsg','message_cc');
- $this->t->set_block('displayMsg','message_attachement_row');
- $this->t->set_block('displayMsg','previous_message_block');
- $this->t->set_block('displayMsg','next_message_block');
- $this->t->set_block('displayMsg','message_org');
-
- $this->t->egroupware_hack = False;
+ $this->t->set_file(array("composeForm" => "composeForm.tpl"));
+ $this->t->set_block('composeForm','header','header');
+ $this->t->set_block('composeForm','body_input');
+ $this->t->set_block('composeForm','attachment','attachment');
+ $this->t->set_block('composeForm','attachment_row','attachment_row');
+ $this->t->set_block('composeForm','attachment_row_bold');
$this->translate();
-// if(!isset($GLOBALS['HTTP_GET_VARS']['printable']))
-// {
- // navbar
- $linkData = array
- (
- 'menuaction' => 'felamimail.uifelamimail.viewMainScreen'
- );
- if($this->mailPreferences['messageNewWindow'])
- {
- $this->t->set_var("link_message_list","javascript:window.close();");
- }
- else
- {
- $this->t->set_var("link_message_list",$GLOBALS['phpgw']->link('/felamimail/index.php',$linkData));
- }
-
- $linkData = array
- (
- 'menuaction' => 'felamimail.uicompose.compose'
- );
- $this->t->set_var("link_compose",$GLOBALS['phpgw']->link('/index.php',$linkData));
- $this->t->set_var('folder_name',$this->bofelamimail->sessionData['mailbox']);
-
- // return link to main message
- if($partID != '')
- {
- $linkData = array
- (
- 'menuaction' => 'felamimail.uidisplay.display',
- 'showHeader' => 'false',
- 'uid' => $this->uid
- );
- $this->t->set_var('link_mainmessage',''.lang('mainmessage').'');
- }
- else
- {
- $this->t->set_var('link_mainmessage','');
- }
+ $this->t->set_var("link_addressbook",$GLOBALS['phpgw']->link('/felamimail/addressbook.php'));
+ $this->t->set_var("focusElement",$_focusElement);
- $linkData = array
- (
- 'menuaction' => 'felamimail.uicompose.reply',
- 'reply_id' => $this->uid,
- );
- if($partID != '')
- $linkData['part_id'] = $partID;
- $this->t->set_var("link_reply",$GLOBALS['phpgw']->link('/index.php',$linkData));
-
- $linkData = array
- (
- 'menuaction' => 'felamimail.uicompose.replyAll',
- 'reply_id' => $this->uid,
- );
- if($partID != '')
- $linkData['part_id'] = $partID;
- $this->t->set_var("link_reply_all",$GLOBALS['phpgw']->link('/index.php',$linkData));
-
- $linkData = array
- (
- 'menuaction' => 'felamimail.uicompose.forward',
- 'reply_id' => $this->uid
- );
- if($partID != '')
- $linkData['part_id'] = $partID;
- $this->t->set_var("link_forward",$GLOBALS['phpgw']->link('/index.php',$linkData));
-
- $linkData = array
- (
- 'menuaction' => 'felamimail.uifelamimail.deleteMessage',
- 'message' => $this->uid
- );
- $this->t->set_var("link_delete",$GLOBALS['phpgw']->link('/index.php',$linkData));
-
- $linkData = array
- (
- 'menuaction' => 'felamimail.uidisplay.showHeader',
- 'uid' => $this->uid
- );
- $this->t->set_var("link_header",$GLOBALS['phpgw']->link('/index.php',$linkData));
-
- $linkData = array
- (
- 'menuaction' => 'felamimail.uidisplay.display',
- 'printable' => 1,
- 'uid' => $this->uid
- );
- if($partID != '')
- $linkData['part'] = $partID;
- $this->t->set_var("link_printable",$GLOBALS['phpgw']->link('/index.php',$linkData));
-
- if($nextMessage['previous'])
- {
- $linkData = array
- (
- 'menuaction' => 'felamimail.uidisplay.display',
- 'showHeader' => 'false',
- 'uid' => $nextMessage['previous']
- );
- $this->t->set_var('previous_url',$GLOBALS['phpgw']->link('/index.php',$linkData));
- $this->t->parse('previous_message','previous_message_block',True);
- }
- else
- {
- $this->t->set_var('previous_message',lang('previous message'));
- }
-
- if($nextMessage['next'])
- {
- $linkData = array
- (
- 'menuaction' => 'felamimail.uidisplay.display',
- 'showHeader' => 'false',
- 'uid' => $nextMessage['next']
- );
- $this->t->set_var('next_url',$GLOBALS['phpgw']->link('/index.php',$linkData));
- $this->t->parse('next_message','next_message_block',True);
- }
- else
- {
- $this->t->set_var('next_message',lang('next message'));
- }
-
- $langArray = array
- (
- 'lang_messagelist' => lang('Message List'),
- 'lang_compose' => lang('Compose'),
- 'lang_delete' => lang('Delete'),
- 'lang_forward' => lang('Forward'),
- 'lang_reply' => lang('Reply'),
- 'lang_reply_all' => lang('Reply All'),
- 'lang_back_to_folder' => lang('back to folder'),
- 'print_navbar' => '',
- 'app_image_path' => PHPGW_IMAGES
- );
- $this->t->set_var($langArray);
- $this->t->parse('navbar','message_navbar',True);
-/* }
+ $linkData = array
+ (
+ 'menuaction' => 'felamimail.uifelamimail.viewMainScreen'
+ );
+ if($this->mailPreferences['messageNewWindow'])
+ {
+ $this->t->set_var("link_message_list","javascript:window.close();");
+ }
else
- {
- $langArray = array
- (
- 'lang_print_this_page' => lang('print this page'),
- 'lang_close_this_page' => lang('close this page'),
- 'lang_printable' => '',
- 'lang_reply' => lang('Reply'),
- 'lang_reply_all' => lang('Reply All'),
- 'lang_back_to_folder' => lang('back to folder'),
- 'navbar' => '',
- 'app_image_path' => PHPGW_IMAGES
- );
- $this->t->set_var($langArray);
- $this->t->parse('print_navbar','message_navbar_print',True);
- }*/
+ {
+ $this->t->set_var("link_message_list",$GLOBALS['phpgw']->link('/felamimail/index.php',$linkData));
+ }
+
+ $linkData = array
+ (
+ 'menuaction' => 'felamimail.uicompose.action',
+ 'composeid' => $this->composeID
+ );
+ $this->t->set_var("link_action",$GLOBALS['phpgw']->link('/index.php',$linkData));
+ $this->t->set_var('folder_name',$this->bofelamimail->sessionData['mailbox']);
+
+ // check for some error messages from last posting attempt
+ if($errorInfo = $this->bocompose->getErrorInfo())
+ {
+ $this->t->set_var('errorInfo',"$errorInfo");
+ }
+ else
+ {
+ $this->t->set_var('errorInfo',' ');
+ }
// header
- // sent by a mailinglist??
- // parse the from header
- if($headers->senderaddress != $headers->fromaddress)
- {
- $senderAddress = $this->emailAddressToHTML($headers->senderaddress);
- $fromAddress = $this->emailAddressToHTML($headers->fromaddress);
- $this->t->set_var("from_data",$senderAddress);
- # " ".lang('on behalf of')." ".
- # $fromAddress);
- $this->t->set_var("onbehalfof_data",$fromAddress);
- $this->t->parse('on_behalf_of_part','message_onbehalfof',True);
- }
- else
- {
- $fromAddress = $this->emailAddressToHTML($headers->fromaddress);
- $this->t->set_var("from_data", $fromAddress);
- $this->t->set_var('on_behalf_of_part','');
- }
-
- // parse the to header
- $toAddress = $this->emailAddressToHTML($headers->toaddress);
- $this->t->set_var("to_data",$toAddress);
-
- // parse the cc header
- if($headers->ccaddress)
- {
- $ccAddress = $this->emailAddressToHTML($headers->ccaddress);
- $this->t->set_var("cc_data",$ccAddress);
- $this->t->parse('cc_data_part','message_cc',True);
- }
- else
- {
- $this->t->set_var("cc_data_part",'');
- }
+ $displayFrom = @htmlentities($preferences['emailAddress'][0][name].' <'.$preferences['emailAddress'][0][address].'>',ENT_QUOTES,$this->displayCharset);
+ $this->t->set_var("from",$displayFrom);
+ $this->t->set_var("to",@htmlentities($sessionData['to'],ENT_QUOTES,$this->displayCharset));
+ $this->t->set_var("cc",@htmlentities($sessionData['cc'],ENT_QUOTES,$this->displayCharset));
+ $this->t->set_var("bcc",@htmlentities($sessionData['bcc'],ENT_QUOTES,$this->displayCharset));
+ $this->t->set_var("reply_to",@htmlentities($sessionData['reply_to'],ENT_QUOTES,$this->displayCharset));
+ $this->t->set_var("subject",@htmlentities($sessionData['subject'],ENT_QUOTES,$this->displayCharset));
+ $this->t->set_var('addressbookImage',$GLOBALS['phpgw']->common->image('phpgwapi/templates/phpgw_website','users'));
+ $this->t->pparse("out","header");
- // parse the cc header
- if(!empty($organization))
- {
- $this->t->set_var("organization_data",$organization);
- $this->t->parse('org_part','message_org',True);
- }
- else
- {
- $this->t->set_var("org_part",'');
- }
-
- if (isset($headers->date))
- {
- $headers->date = ereg_replace(' ', ' ', $headers->date);
- $tmpdate = explode(' ', trim($headers->date));
- }
- else
- {
- $tmpdate = $date = array("","","","","","");
- }
-
- $this->t->set_var("date_data",
- @htmlspecialchars($GLOBALS['phpgw']->common->show_date($transformdate->getTimeStamp($tmpdate)),
- ENT_QUOTES,$this->displayCharset));
- $this->t->set_var("subject_data",
- @htmlspecialchars($this->bofelamimail->decode_header($headers->subject),
- ENT_QUOTES,$this->displayCharset));
- //if(isset($organization)) exit;
- $this->t->parse("header","message_header",True);
-
- $this->t->set_var("rawheader",@htmlentities($rawheaders,ENT_QUOTES,$this->displayCharset));
-
- #$this->kses->AddProtocol("http");
- $this->kses->AddHTML(
- "p",array(
- 'align' => array("minlen" => 1, 'maxlen' => 10)
- )
- );
- $this->kses->AddHTML("tbody");
- $this->kses->AddHTML("tt");
- $this->kses->AddHTML("br");
- $this->kses->AddHTML("b");
- $this->kses->AddHTML("i");
- $this->kses->AddHTML("strike");
- $this->kses->AddHTML("center");
- $this->kses->AddHTML(
- "font",array(
- "color" => array('maxlen' => 10)
- )
- );
- $this->kses->AddHTML(
- "hr",array(
- "class" => array('maxlen' => 20)
- )
- );
- $this->kses->AddHTML("div");
- $this->kses->AddHTML("ul");
- $this->kses->AddHTML(
- "ol",array(
- "type" => array('maxlen' => 20)
- )
- );
- $this->kses->AddHTML("li");
- $this->kses->AddHTML("h1");
- $this->kses->AddHTML("h2");
- $this->kses->AddHTML(
- "style",array(
- "type" => array('maxlen' => 20)
- )
- );
- $this->kses->AddHTML("select");
- $this->kses->AddHTML(
- "option",array(
- "value" => array('maxlen' => 45),
- "selected" => array()
- )
- );
-
- $this->kses->AddHTML(
- "a", array(
- "href" => array('maxlen' => 145, 'minlen' => 10),
- "name" => array('minlen' => 2),
- 'target' => array('maxlen' => 10)
- )
- );
-
- $this->kses->AddHTML(
- "pre", array(
- "wrap" => array('maxlen' => 10)
- )
- );
-
- // Allows 'td' tag with colspan|rowspan|class|style|width|nowrap attributes,
- // colspan has minval of 2 and maxval of 5
- // rowspan has minval of 3 and maxval of 6
- // class has minlen of 1 char and maxlen of 10 chars
- // style has minlen of 10 chars and maxlen of 100 chars
- // width has maxval of 100
- // nowrap is valueless
- $this->kses->AddHTML(
- "table",array(
- "class" => array("minlen" => 1, 'maxlen' => 20),
- "border" => array("minlen" => 1, 'maxlen' => 10),
- "cellpadding" => array("minlen" => 0, 'maxlen' => 10),
- "cellspacing" => array("minlen" => 0, 'maxlen' => 10),
- "width" => array("maxlen" => 5),
- "style" => array('minlen' => 10, 'maxlen' => 100),
- "bgcolor" => array('maxlen' => 10),
- "align" => array('maxlen' => 10),
- "valign" => array('maxlen' => 10),
- "bordercolor" => array('maxlen' => 10)
- )
- );
- $this->kses->AddHTML(
- "tr",array(
- "colspan" => array('minval' => 2, 'maxval' => 5),
- "rowspan" => array('minval' => 3, 'maxval' => 6),
- "class" => array("minlen" => 1, 'maxlen' => 20),
- "width" => array("maxlen" => 5),
- "style" => array('minlen' => 10, 'maxlen' => 100),
- "align" => array('maxlen' => 10),
- 'bgcolor' => array('maxlen' => 10),
- "valign" => array('maxlen' => 10),
- "nowrap" => array('valueless' => 'y')
- )
- );
- $this->kses->AddHTML(
- "td",array(
- "colspan" => array('minval' => 2, 'maxval' => 5),
- "rowspan" => array('minval' => 3, 'maxval' => 6),
- "class" => array("minlen" => 1, 'maxlen' => 20),
- "width" => array("maxlen" => 5),
- "style" => array('minlen' => 10, 'maxlen' => 100),
- "align" => array('maxlen' => 10),
- 'bgcolor' => array('maxlen' => 10),
- "valign" => array('maxlen' => 10),
- "nowrap" => array('valueless' => 'y')
- )
- );
- $this->kses->AddHTML(
- "th",array(
- "colspan" => array('minval' => 2, 'maxval' => 5),
- "rowspan" => array('minval' => 3, 'maxval' => 6),
- "class" => array("minlen" => 1, 'maxlen' => 20),
- "width" => array("maxlen" => 5),
- "style" => array('minlen' => 10, 'maxlen' => 100),
- "align" => array('maxlen' => 10),
- "valign" => array('maxlen' => 10),
- "nowrap" => array('valueless' => 'y')
- )
- );
- $this->kses->AddHTML(
- "span",array(
- "class" => array("minlen" => 1, 'maxlen' => 20)
- )
- );
- $this->kses->AddHTML(
- "blockquote",array(
- "class" => array("minlen" => 1, 'maxlen' => 20),
- "style" => array("minlen" => 1),
- "cite" => array('maxlen' => 30),
- "type" => array('maxlen' => 10),
- "dir" => array("minlen" => 1, 'maxlen' => 10)
- )
- );
-
-
-
- for($i=0; $ibotranslation->convert($bodyParts[$i]['body'],
- strtolower($bodyParts[$i]['charSet']));
-
- if($bodyParts[$i]['mimeType'] == 'text/plain')
- {
- $newBody = $bodyParts[$i]['body'];
-
- $newBody = @htmlentities($bodyParts[$i]['body'],ENT_QUOTES,$this->displayCharset);
- $newBody = $this->bofelamimail->wordwrap($newBody,90,"\n");
-
- // search http[s] links and make them as links available again
- // to understand what's going on here, have a look at
- // http://www.php.net/manual/en/function.preg-replace.php
-
- // create links for websites
- $newBody = preg_replace("/((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&,!\n,!>,\%,@,\*,#,:,~,\+]+)/ie",
- "'displayCharset\").'\" target=\"_blank\">$2$4$5'", $newBody);
-
- // create links for ftp sites
- $newBody = preg_replace("/((ftp:\/\/)|(ftp\.))([\w\.,-.,\/.,\?.,\=.,&]+)/i",
- "$1$3$4", $newBody);
-
- // create links for email addresses
- $linkData = array
- (
- 'menuaction' => 'felamimail.uicompose.compose'
- );
- $link = $GLOBALS['phpgw']->link('/index.php',$linkData);
- $newBody = preg_replace("/(?<=\s{1}|<)(([\w\.,-.,_.,0-9.]+)(@)([\w\.,-.,_.,0-9.]+))/ie",
- "'$0'", $newBody);
-
- $newBody = $this->highlightQuotes($newBody);
- $newBody = "".$newBody."
";
- }
- else
- {
- $newBody = $bodyParts[$i]['body'];
- $newBody = $this->highlightQuotes($newBody);
- $newBody = $this->kses->Parse($newBody);
-
- // create links for websites
- #$newBody = preg_replace("/(?)((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&,!\n,\%,@,\*,#,:,~,\+]+)/ie",
- # "'displayCharset\").'\" target=\"_blank\">$2$4$5'", $newBody);
- $newBody = preg_replace("/(?|\/|\")((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&,!\n,\%,@,\*,#,:,~,\+]+)/ie",
- "'displayCharset\").'\" target=\"_blank\">$2$4$5'", $newBody);
-
- // create links for websites
- $newBody = preg_replace("/href=(\"|\')((http(s?):\/\/)|(www\.))([\w,\-,\/,\?,\=,\.,&,!\n,\%,@,\(,\),\*,#,:,~,\+]+)(\"|\')/ie",
- "'href=\"$webserverURL/redirect.php?go='.@htmlentities(urlencode('http$4://$5$6'),ENT_QUOTES,\"$this->displayCharset\").'\" target=\"_blank\"'", $newBody);
-
- // create links for ftp sites
- $newBody = preg_replace("/href=(\"|\')((ftp:\/\/)|(ftp\.))([\w\.,-.,\/.,\?.,\=.,&]+)(\"|\')/i",
- "href=\"ftp://$4$5\" target=\"_blank\"", $newBody);
-
- // create links for email addresses
- $linkData = array
- (
- 'menuaction' => 'felamimail.uicompose.compose'
- );
- $link = $GLOBALS['phpgw']->link('/index.php',$linkData);
- $newBody = preg_replace("/href=(\"|\')mailto:([\w,\-,\/,\?,\=,\.,&,!\n,\%,@,\*,#,:,~,\+]+)(\"|\')/ie",
- "'href=\"$link&send_to='.base64_encode('$2').'\"'", $newBody);
- #print "".htmlentities($newBody)."
";
-
- $link = $GLOBALS['phpgw']->link('/index.php',$linkData);
- #$newBody = preg_replace("/(?$0'", $newBody);
- }
- $body .= $newBody;
- #print "
$body
";
- }
-
- // create links for windows shares
- // \\\\\\\\ == '\\' in real life!! :)
- $body = preg_replace("/(\\\\\\\\)([\w,\\\\,-]+)/i",
- "$1$2", $body);
-
-
- $this->t->set_var("body",$body);
+ // body
+ $this->t->set_var("body",$sessionData['body']);
$this->t->set_var("signature",$sessionData['signature']);
+ $this->t->pparse("out","body_input");
// attachments
- if(is_array($attachments))
- $this->t->set_var('attachment_count',count($attachments));
- else
- $this->t->set_var('attachment_count','0');
-
- if (is_array($attachments) && count($attachments) > 0)
+ if (is_array($sessionData['attachments']) && count($sessionData['attachments']) > 0)
{
$this->t->set_var('row_color',$this->rowColor[0]);
$this->t->set_var('name',lang('name'));
$this->t->set_var('type',lang('type'));
$this->t->set_var('size',lang('size'));
- #$this->t->parse('attachment_rows','attachment_row_bold',True);
- foreach ($attachments as $key => $value)
+ $this->t->parse('attachment_rows','attachment_row_bold',True);
+ while (list($key,$value) = each($sessionData['attachments']))
{
+ #print "$key : $value
";
$this->t->set_var('row_color',$this->rowColor[($key+1)%2]);
- $this->t->set_var('filename',@htmlentities($this->bofelamimail->decode_header($value['name']),ENT_QUOTES,$this->displayCharset));
- $this->t->set_var('mimetype',$value['mimeType']);
+ $this->t->set_var('name',$value['name']);
+ $this->t->set_var('type',$value['type']);
$this->t->set_var('size',$value['size']);
$this->t->set_var('attachment_number',$key);
-
- switch($value['mimeType'])
- {
- case 'message/rfc822':
- $linkData = array
- (
- 'menuaction' => 'felamimail.uidisplay.display',
- 'uid' => $this->uid,
- 'part' => $value['partID']
- );
- $target = '';
- break;
- case 'image/jpeg':
- case 'image/png':
- case 'image/gif':
- case 'application/pdf':
- $linkData = array
- (
- 'menuaction' => 'felamimail.uidisplay.getAttachment',
- 'uid' => $this->uid,
- 'part' => $value['partID']
- );
- $target = '_blank';
- break;
- default:
- $linkData = array
- (
- 'menuaction' => 'felamimail.uidisplay.getAttachment',
- 'uid' => $this->uid,
- 'part' => $value['partID']
- );
- $target = '';
- break;
- }
- $this->t->set_var("link_view",$GLOBALS['phpgw']->link('/index.php',$linkData));
- $this->t->set_var("target",$target);
-
- $linkData = array
- (
- 'menuaction' => 'felamimail.uidisplay.getAttachment',
- 'mode' => 'save',
- 'uid' => $this->uid,
- 'part' => $value['partID']
- );
- $this->t->set_var("link_save",$GLOBALS['phpgw']->link('/index.php',$linkData));
-
- $this->t->parse('attachment_rows','message_attachement_row',True);
+ $this->t->parse('attachment_rows','attachment_row',True);
}
}
else
@@ -726,159 +230,52 @@
$this->t->set_var('attachment_rows','');
}
- #$this->t->pparse("out","message_attachment_rows");
-
- // print it out
- $this->t->pparse("out","message_main");
-
+ $this->t->pparse("out","attachment");
}
function display_app_header()
{
- if(!@is_object($GLOBALS['phpgw']->js))
- {
- $GLOBALS['phpgw']->js = CreateObject('phpgwapi.javascript');
- }
- $GLOBALS['phpgw']->js->validate_file('tabs','tabs');
- $GLOBALS['phpgw']->js->validate_file('jscode','view_message','felamimail');
- $GLOBALS['phpgw']->js->set_onload('javascript:initAll();');
-
$GLOBALS['phpgw']->common->phpgw_header();
if(!$this->mailPreferences['messageNewWindow'])
- {
echo parse_navbar();
- }
- }
-
- function emailAddressToHTML($_emailAddress)
- {
- // create some nice formated HTML for senderaddress
- if($_emailAddress == 'undisclosed-recipients: ;')
- return $_emailAddress;
-
- $addressData = imap_rfc822_parse_adrlist
- ($this->bofelamimail->decode_header($_emailAddress),'');
- if(is_array($addressData))
- {
- $senderAddress = '';
- while(list($key,$val)=each($addressData))
- {
- if(!empty($senderAddress)) $senderAddress .= ", ";
- if(!empty($val->personal))
- {
- $tempSenderAddress = $val->mailbox."@".$val->host;
- $newSenderAddress = imap_rfc822_write_address($val->mailbox,
- $val->host,
- $val->personal);
- $linkData = array
- (
- 'menuaction' => 'felamimail.uicompose.compose',
- 'send_to' => base64_encode($newSenderAddress)
- );
- $link = $GLOBALS['phpgw']->link('/index.php',$linkData);
- $senderAddress .= sprintf('%s',
- $link,
- @htmlentities($newSenderAddress,ENT_QUOTES,$this->displayCharset),
- @htmlentities($val->personal,ENT_QUOTES,$this->displayCharset));
- $linkData = array
- (
- 'menuaction' => 'addressbook.uiaddressbook.add_email',
- 'add_email' => $tempSenderAddress,
- 'name' => $val->personal,
- 'referer' => $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']
- );
- $urlAddToAddressbook = $GLOBALS['phpgw']->link('/index.php',$linkData);
- $image = $GLOBALS['phpgw']->common->image('felamimail','sm_envelope');
- $senderAddress .= sprintf('
- ',
- $urlAddToAddressbook,
- $image,
- lang('add to addressbook'),
- lang('add to addressbook'));
- }
- else
- {
- $tempSenderAddress = $val->mailbox."@".$val->host;
- $linkData = array
- (
- 'menuaction' => 'felamimail.uicompose.compose',
- 'send_to' => base64_encode($tempSenderAddress)
- );
- $link = $GLOBALS['phpgw']->link('/index.php',$linkData);
- $senderAddress .= sprintf('%s',
- $link,@htmlentities($tempSenderAddress,ENT_QUOTES,$this->displayCharset));
- $linkData = array
- (
- 'menuaction' => 'addressbook.uiaddressbook.add_email',
- 'add_email' => $tempSenderAddress,
- 'referer' => $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']
- );
- $urlAddToAddressbook = $GLOBALS['phpgw']->link('/index.php',$linkData);
- $image = $GLOBALS['phpgw']->common->image('felamimail','sm_envelope');
- $senderAddress .= sprintf('
- ',
- $urlAddToAddressbook,
- $image,
- lang('add to addressbook'),
- lang('add to addressbook'));
- }
- }
- return $senderAddress;
- }
-
- // if something goes wrong, just return the original address
- return $_emailAddress;
}
- function getAttachment()
+ function forward()
{
-
- $part = $GLOBALS['HTTP_GET_VARS']['part'];
-
- $attachment = $this->bofelamimail->getAttachment($this->uid,$part);
-
- $this->bofelamimail->closeConnection();
-
- header ("Content-Type: ".$attachment['type']."; name=\"".$attachment['filename']."\"");
- if($GLOBALS['HTTP_GET_VARS']['mode'] == "save")
- {
- // ask for download
- header ("Content-Disposition: attachment; filename=\"".$attachment['filename']."\"");
- }
- else
- {
- // display it
- header ("Content-Disposition: inline; filename=\"".$attachment['filename']."\"");
- }
- header("Expires: 0");
- // the next headers are for IE and SSL
- header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
- header("Pragma: public");
+ $replyID = $GLOBALS['HTTP_GET_VARS']['reply_id'];
+ $partID = $_GET['part_id'];
- echo $attachment['attachment'];
-
- $GLOBALS['phpgw']->common->phpgw_exit();
- exit;
-
+ if (!empty($replyID))
+ {
+ // this fill the session data with the values from the original email
+ $this->bocompose->getForwardData($replyID, $partID,
+ $this->bofelamimail->sessionData['mailbox']);
+ }
+ $this->compose();
+ }
+
+ function reply()
+ {
+ $replyID = $_GET['reply_id'];
+ $partID = $_GET['part_id'];
+ if (!empty($replyID))
+ {
+ // this fill the session data with the values from the original email
+ $this->bocompose->getReplyData('single', $replyID, $partID);
+ }
+ $this->compose(@htmlentities('body'));
}
- function showHeader()
+ function replyAll()
{
- if($this->bofelamimail->sessionData['showHeader'] == 'True')
+ $replyID = $GLOBALS['HTTP_GET_VARS']['reply_id'];
+ $partID = $_GET['part_id'];
+ if (!empty($replyID))
{
- $this->bofelamimail->sessionData['showHeader'] = 'False';
+ // this fill the session data with the values from the original email
+ $this->bocompose->getReplyData('all', $replyID, $partID);
}
- else
- {
- $this->bofelamimail->sessionData['showHeader'] = 'True';
- }
- $this->bofelamimail->saveSessionData();
-
- $this->display();
+ $this->compose('body');
}
function translate()
@@ -902,20 +299,6 @@
$this->t->set_var("lang_high",lang('high'));
$this->t->set_var("lang_low",lang('low'));
$this->t->set_var("lang_signature",lang('signature'));
- $this->t->set_var("lang_compose",lang('compose'));
- $this->t->set_var("lang_date",lang('date'));
- $this->t->set_var("lang_view",lang('view'));
- $this->t->set_var("lang_organization",lang('organization'));
- $this->t->set_var("lang_save",lang('save'));
- $this->t->set_var("lang_printable",lang('print it'));
- $this->t->set_var("lang_reply",lang('reply'));
- $this->t->set_var("lang_reply_all",lang('reply all'));
- $this->t->set_var("lang_forward",lang('forward'));
- $this->t->set_var("lang_delete",lang('delete'));
- $this->t->set_var("lang_previous_message",lang('previous message'));
- $this->t->set_var("lang_next_message",lang('next message'));
- $this->t->set_var("lang_organisation",lang('organisation'));
- $this->t->set_var("lang_on_behalf_of",lang('on behalf of'));
$this->t->set_var("th_bg",$GLOBALS['phpgw_info']["theme"]["th_bg"]);
$this->t->set_var("bg01",$GLOBALS['phpgw_info']["theme"]["bg01"]);