From 9012fb313321efb09c3e18956fd7d130a906e718 Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Mon, 25 Jan 2010 17:17:17 +0000 Subject: [PATCH] better control of subject length and preview Header region, adding addressbook add action to preview --- felamimail/inc/class.bofelamimail.inc.php | 2 +- felamimail/inc/class.uidisplay.inc.php | 34 +++++++------- felamimail/inc/class.uiwidgets.inc.php | 56 +++++++++++++++++++---- 3 files changed, 65 insertions(+), 27 deletions(-) diff --git a/felamimail/inc/class.bofelamimail.inc.php b/felamimail/inc/class.bofelamimail.inc.php index c406f97f77..33b32a4d0d 100644 --- a/felamimail/inc/class.bofelamimail.inc.php +++ b/felamimail/inc/class.bofelamimail.inc.php @@ -433,7 +433,7 @@ } } - function decode_header($_string) + static function decode_header($_string) { return $GLOBALS['egw']->translation->decodeMailHeader($_string,self::$displayCharset); } diff --git a/felamimail/inc/class.uidisplay.inc.php b/felamimail/inc/class.uidisplay.inc.php index 3baa9d677d..e6888e7340 100644 --- a/felamimail/inc/class.uidisplay.inc.php +++ b/felamimail/inc/class.uidisplay.inc.php @@ -411,24 +411,24 @@ // sent by a mailinglist?? // parse the from header if($envelope['FROM'][0] != $envelope['SENDER'][0]) { - $senderAddress = $this->emailAddressToHTML($envelope['SENDER']); - $fromAddress = $this->emailAddressToHTML($envelope['FROM'], $organization); + $senderAddress = self::emailAddressToHTML($envelope['SENDER']); + $fromAddress = self::emailAddressToHTML($envelope['FROM'], $organization); $this->t->set_var("from_data",$senderAddress); $this->t->set_var("onbehalfof_data",$fromAddress); $this->t->parse('on_behalf_of_part','message_onbehalfof',True); } else { - $fromAddress = $this->emailAddressToHTML($envelope['FROM'], $organization); + $fromAddress = self::emailAddressToHTML($envelope['FROM'], $organization); $this->t->set_var("from_data", $fromAddress); $this->t->set_var('on_behalf_of_part',''); } // parse the to header - $toAddress = $this->emailAddressToHTML($envelope['TO']); + $toAddress = self::emailAddressToHTML($envelope['TO']); $this->t->set_var("to_data",$toAddress); // parse the cc header if(count($envelope['CC'])) { - $ccAddress = $this->emailAddressToHTML($envelope['CC']); + $ccAddress = self::emailAddressToHTML($envelope['CC']); $this->t->set_var("cc_data",$ccAddress); $this->t->parse('cc_data_part','message_cc',True); } else { @@ -437,7 +437,7 @@ // parse the bcc header if(count($envelope['BCC'])) { - $bccAddress = $this->emailAddressToHTML($envelope['BCC']); + $bccAddress = self::emailAddressToHTML($envelope['BCC']); $this->t->set_var("bcc_data",$bccAddress); $this->t->parse('bcc_data_part','message_bcc',True); } else { @@ -755,7 +755,7 @@ $GLOBALS['egw']->common->egw_header(); } - function emailAddressToHTML($_emailAddress, $_organisation='', $allwaysShowMailAddress=false, $showAddToAdrdessbookLink=true) { + static function emailAddressToHTML($_emailAddress, $_organisation='', $allwaysShowMailAddress=false, $showAddToAdrdessbookLink=true) { #_debug_array($_emailAddress); // create some nice formated HTML for senderaddress #if($_emailAddress['EMAIL'] == 'undisclosed-recipients: ;') @@ -780,8 +780,8 @@ if($addressData['PERSONAL_NAME'] != 'NIL') { $newSenderAddress = $addressData['RFC822_EMAIL'] != 'NIL' ? $addressData['RFC822_EMAIL'] : $addressData['EMAIL']; - $newSenderAddress = $this->bofelamimail->decode_header($newSenderAddress); - $decodedPersonalName = $this->bofelamimail->decode_header($addressData['PERSONAL_NAME']); + $newSenderAddress = bofelamimail::decode_header($newSenderAddress); + $decodedPersonalName = bofelamimail::decode_header($addressData['PERSONAL_NAME']); $realName = $decodedPersonalName; // add mailaddress @@ -800,8 +800,8 @@ $link = $GLOBALS['egw']->link('/index.php',$linkData); $senderAddress .= sprintf('%s', $link, - @htmlentities($newSenderAddress,ENT_QUOTES,$this->displayCharset), - @htmlentities($realName, ENT_QUOTES, $this->displayCharset)); + @htmlentities($newSenderAddress,ENT_QUOTES,bofelamimail::$displayCharset), + @htmlentities($realName, ENT_QUOTES, bofelamimail::$displayCharset)); $linkData = array ( 'menuaction' => 'addressbook.addressbook_ui.edit', @@ -839,7 +839,7 @@ ); $link = $GLOBALS['egw']->link('/index.php',$linkData); $senderAddress .= sprintf('%s', - $link,@htmlentities($addressData['EMAIL'], ENT_QUOTES, $this->displayCharset)); + $link,@htmlentities($addressData['EMAIL'], ENT_QUOTES, bofelamimail::$displayCharset)); //TODO: This uses old addressbook code, which should be removed in Version 1.4 //Please use addressbook.addressbook_ui.edit with proper paramenters $linkData = array @@ -1196,24 +1196,24 @@ $this->translate(); if($envelope['FROM'][0] != $envelope['SENDER'][0]) { - $senderAddress = $this->emailAddressToHTML($envelope['SENDER'], '', true, false); - $fromAddress = $this->emailAddressToHTML($envelope['FROM'], $organization, true, false); + $senderAddress = self::emailAddressToHTML($envelope['SENDER'], '', true, false); + $fromAddress = self::emailAddressToHTML($envelope['FROM'], $organization, true, false); $this->t->set_var("from_data",$senderAddress); $this->t->set_var("onbehalfof_data",$fromAddress); $this->t->parse('on_behalf_of_part','message_onbehalfof',True); } else { - $fromAddress = $this->emailAddressToHTML($envelope['FROM'], $organization, true, false); + $fromAddress = self::emailAddressToHTML($envelope['FROM'], $organization, true, false); $this->t->set_var("from_data", $fromAddress); $this->t->set_var('on_behalf_of_part',''); } // parse the to header - $toAddress = $this->emailAddressToHTML($envelope['TO'], '', true, false); + $toAddress = self::emailAddressToHTML($envelope['TO'], '', true, false); $this->t->set_var("to_data",$toAddress); // parse the cc header if(count($envelope['CC'])) { - $ccAddress = $this->emailAddressToHTML($envelope['CC'], '', true, false); + $ccAddress = self::emailAddressToHTML($envelope['CC'], '', true, false); $this->t->set_var("cc_data",$ccAddress); $this->t->parse('cc_data_part','message_cc',True); } else { diff --git a/felamimail/inc/class.uiwidgets.inc.php b/felamimail/inc/class.uiwidgets.inc.php index 110ca0cbd6..11623d9f34 100644 --- a/felamimail/inc/class.uiwidgets.inc.php +++ b/felamimail/inc/class.uiwidgets.inc.php @@ -513,20 +513,56 @@ // sent or drafts or template folder if (!empty($headerData['to_name'])) { $sender_name = $headerData['to_name']; - $full_address = $headerData['to_name'].' <'.$headerData['to_address'].'>'; + $sender_address = $headerData['to_address']; + $full_address = $headerData['to_name'].' <'.$headerData['to_address'].'>'; } else { $sender_name = $headerData['to_address']; + $sender_address = $headerData['to_address']; $full_address = $headerData['to_address']; } } else { if (!empty($headerData['sender_name'])) { $sender_name = $headerData['sender_name']; - $full_address = $headerData['sender_name'].' <'.$headerData['sender_address'].'>'; + $sender_address = $headerData['sender_address']; + $full_address = $headerData['sender_name'].' <'.$headerData['sender_address'].'>'; } else { $sender_name = $headerData['sender_address']; + $sender_address = $headerData['sender_address']; $full_address = $headerData['sender_address']; } } + //$fromAddress = uidisplay::emailAddressToHTML(array('PERSONAL_NAME'=>$sender_name,'EMAIL'=>$sender_address,'RFC822_EMAIL'=>$full_address),''); + if ($GLOBALS['egw_info']['user']['apps']['addressbook']) { + $addresslinkData = array ( + 'menuaction' => 'addressbook.addressbook_ui.edit', + 'presets[email]' => $sender_address, + 'referer' => $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING'] + ); + $decodedPersonalName = $sender_name; + if (!empty($decodedPersonalName)) { + if($spacePos = strrpos($decodedPersonalName, ' ')) { + $addresslinkData['presets[n_family]'] = substr($decodedPersonalName, $spacePos+1); + $addresslinkData['presets[n_given]'] = substr($decodedPersonalName, 0, $spacePos); + } else { + $addresslinkData['presets[n_family]'] = $decodedPersonalName; + } + $addresslinkData['presets[n_fn]'] = $decodedPersonalName; + } + + $urlAddToAddressbook = $GLOBALS['egw']->link('/index.php',$addresslinkData); + $onClick = "window.open(this,this.target,'dependent=yes,width=850,height=440,location=no,menubar=no,toolbar=no,scrollbars=yes,status=yes'); return false;"; + $image = $GLOBALS['egw']->common->image('felamimail','sm_envelope'); + $fromAddress .= sprintf(' + %s', + $urlAddToAddressbook, + $onClick, + $image, + lang('add to addressbook'), + lang('add to addressbook')); + } + $linkData = array ( 'menuaction' => 'felamimail.uidisplay.display', 'showHeader' => 'false', @@ -560,18 +596,20 @@ ); //_debug_array($GLOBALS['egw']->link('/index.php',$linkData)); - $IFRAMEBody = " - -
- ".($_folderType > 0?lang('to'):lang('from')).':'.$full_address .'
'. + $IFRAMEBody = " + + - -
+ ".($_folderType > 0?lang('to'):lang('from')).':'.$full_address.' '.($fromAddress?$fromAddress:'') .'
'. lang('date').':'.$GLOBALS['egw']->common->show_date($headerData['date']/*,$GLOBALS['egw_info']['user']['preferences']['common']['dateformat']*/)."
".lang('subject').":".$subject."
+ $image - ".$this->navbarSeparator().$this->displayMessageActions($headerData, $_folderName, $_icServer,true)." + + + ".$this->navbarSeparator().$this->displayMessageActions($headerData, $_folderName, $_icServer,true)." +