Make sure the correct identity is used for list command mailto actions
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 9 Jan 2015 07:24:26 +0000 (07:24 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Fri, 9 Jan 2015 07:24:26 +0000 (07:24 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@14492 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/listcommands/functions.php
plugins/listcommands/mailout.php
plugins/listcommands/templates/default/mailout.tpl

index 6c526c2a49ff4e72a6aa03293cb85ca8dea6bd07..63fa24c6acb0f76c0117e29ea88b3ad05d297200 100644 (file)
@@ -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.'&amp;':'');
             } else {
                 $url = "plugins/listcommands/mailout.php?action=$cmd&amp;";
+
+                // 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 = '&amp;' . $parameters;
+               $parameters = '&amp;identity=' . $identity . '&amp;' . $parameters;
             } else {
-               $parameters = '';
+               $parameters = '&amp;identity=' . $identity;
             }
 
             $url .= 'send_to=' . urlencode($act) . $parameters;
index c94d875fc733dfd4abf2f97fd85ab90ac412db36..0ef95076c2795e6fb5ee0c43e9d8c823d24c0868 100644 (file)
@@ -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');
index 2aaa236f134915dbcf6ea4e2091e86bacf1f9354..b6ec5888930160691c9b84010d10be66c96450a2 100644 (file)
@@ -41,8 +41,10 @@ extract($t);
     echo '<select name="identity" id="identity">';
     
     foreach($idents as $nr=>$data) {
-        echo '<option value="' . $nr . '">' .
-            sm_encode_html_special_chars(
+        echo '<option '
+           . ($identity == $nr ? ' selected="selected" ' : '')
+           . 'value="' . $nr . '">'
+           . sm_encode_html_special_chars(
                     $data['full_name'].' <'.
                     $data['email_address'] . '>') .
             "</option>\n";