From 8f09504306bde5d03e67590bd965fa21a9b1e308 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Fri, 9 Jan 2015 07:24:26 +0000 Subject: [PATCH] Make sure the correct identity is used for list command mailto actions --- .../plugins/listcommands/functions.php | 23 +++++++++++++++++-- .../plugins/listcommands/mailout.php | 2 ++ .../templates/default/mailout.tpl | 6 +++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/trunk/squirrelmail/plugins/listcommands/functions.php b/trunk/squirrelmail/plugins/listcommands/functions.php index 6c526c2a4..63fa24c6a 100644 --- a/trunk/squirrelmail/plugins/listcommands/functions.php +++ b/trunk/squirrelmail/plugins/listcommands/functions.php @@ -90,20 +90,39 @@ function plugin_listcommands_menu_do() { if ($proto == 'mailto') { + $identity = ''; + if (($cmd == 'post') || ($cmd == 'owner')) { $url = 'src/compose.php?'. (isset($startMessage)?'startMessage='.$startMessage.'&':''); } else { $url = "plugins/listcommands/mailout.php?action=$cmd&"; + + // try to find which identity the mail should come from + include_once(SM_PATH . 'functions/identity.php'); + $idents = get_identities(); + // ripped from src/compose.php + $identities = array(); + if (count($idents) > 1) { + foreach($idents as $nr=>$data) { + $enc_from_name = '"'.$data['full_name'].'" <'. $data['email_address'].'>'; + $identities[] = $enc_from_name; + } + + $identity_match = $message->rfc822_header->findAddress($identities); + if ($identity_match !== FALSE) { + $identity = $identity_match; + } + } } // if things like subject are given, peel them off and give // them to src/compose.php as is (not encoded) if (strpos($act, '?') > 0) { list($act, $parameters) = explode('?', $act, 2); - $parameters = '&' . $parameters; + $parameters = '&identity=' . $identity . '&' . $parameters; } else { - $parameters = ''; + $parameters = '&identity=' . $identity; } $url .= 'send_to=' . urlencode($act) . $parameters; diff --git a/trunk/squirrelmail/plugins/listcommands/mailout.php b/trunk/squirrelmail/plugins/listcommands/mailout.php index c94d875fc..0ef95076c 100644 --- a/trunk/squirrelmail/plugins/listcommands/mailout.php +++ b/trunk/squirrelmail/plugins/listcommands/mailout.php @@ -26,6 +26,7 @@ sqgetGlobalVar('send_to', $send_to, SQ_GET); sqgetGlobalVar('subject', $subject, SQ_GET); sqgetGlobalVar('body', $body, SQ_GET); sqgetGlobalVar('action', $action, SQ_GET); +sqgetGlobalVar('identity', $identity, SQ_GET); displayPageHeader($color, $mailbox); @@ -58,6 +59,7 @@ $oTemplate->assign('subject', $subject); $oTemplate->assign('body', $body); $oTemplate->assign('mailbox', $mailbox); $oTemplate->assign('idents', $idents); +$oTemplate->assign('identity', $identity); $oTemplate->display('plugins/listcommands/mailout.tpl'); $oTemplate->display('footer.tpl'); diff --git a/trunk/squirrelmail/plugins/listcommands/templates/default/mailout.tpl b/trunk/squirrelmail/plugins/listcommands/templates/default/mailout.tpl index 2aaa236f1..b6ec58889 100644 --- a/trunk/squirrelmail/plugins/listcommands/templates/default/mailout.tpl +++ b/trunk/squirrelmail/plugins/listcommands/templates/default/mailout.tpl @@ -41,8 +41,10 @@ extract($t); echo '