Make sure the correct identity is used for list command mailto actions

This commit is contained in:
pdontthink 2015-01-09 07:24:26 +00:00
parent 8bf71bfb91
commit 8f09504306
3 changed files with 27 additions and 4 deletions

View file

@ -90,20 +90,39 @@ function plugin_listcommands_menu_do() {
if ($proto == 'mailto') { if ($proto == 'mailto') {
$identity = '';
if (($cmd == 'post') || ($cmd == 'owner')) { if (($cmd == 'post') || ($cmd == 'owner')) {
$url = 'src/compose.php?'. $url = 'src/compose.php?'.
(isset($startMessage)?'startMessage='.$startMessage.'&':''); (isset($startMessage)?'startMessage='.$startMessage.'&':'');
} else { } else {
$url = "plugins/listcommands/mailout.php?action=$cmd&"; $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 // if things like subject are given, peel them off and give
// them to src/compose.php as is (not encoded) // them to src/compose.php as is (not encoded)
if (strpos($act, '?') > 0) { if (strpos($act, '?') > 0) {
list($act, $parameters) = explode('?', $act, 2); list($act, $parameters) = explode('?', $act, 2);
$parameters = '&amp;' . $parameters; $parameters = '&amp;identity=' . $identity . '&amp;' . $parameters;
} else { } else {
$parameters = ''; $parameters = '&amp;identity=' . $identity;
} }
$url .= 'send_to=' . urlencode($act) . $parameters; $url .= 'send_to=' . urlencode($act) . $parameters;

View file

@ -26,6 +26,7 @@ sqgetGlobalVar('send_to', $send_to, SQ_GET);
sqgetGlobalVar('subject', $subject, SQ_GET); sqgetGlobalVar('subject', $subject, SQ_GET);
sqgetGlobalVar('body', $body, SQ_GET); sqgetGlobalVar('body', $body, SQ_GET);
sqgetGlobalVar('action', $action, SQ_GET); sqgetGlobalVar('action', $action, SQ_GET);
sqgetGlobalVar('identity', $identity, SQ_GET);
displayPageHeader($color, $mailbox); displayPageHeader($color, $mailbox);
@ -58,6 +59,7 @@ $oTemplate->assign('subject', $subject);
$oTemplate->assign('body', $body); $oTemplate->assign('body', $body);
$oTemplate->assign('mailbox', $mailbox); $oTemplate->assign('mailbox', $mailbox);
$oTemplate->assign('idents', $idents); $oTemplate->assign('idents', $idents);
$oTemplate->assign('identity', $identity);
$oTemplate->display('plugins/listcommands/mailout.tpl'); $oTemplate->display('plugins/listcommands/mailout.tpl');
$oTemplate->display('footer.tpl'); $oTemplate->display('footer.tpl');

View file

@ -41,8 +41,10 @@ extract($t);
echo '<select name="identity" id="identity">'; echo '<select name="identity" id="identity">';
foreach($idents as $nr=>$data) { foreach($idents as $nr=>$data) {
echo '<option value="' . $nr . '">' . echo '<option '
sm_encode_html_special_chars( . ($identity == $nr ? ' selected="selected" ' : '')
. 'value="' . $nr . '">'
. sm_encode_html_special_chars(
$data['full_name'].' <'. $data['full_name'].' <'.
$data['email_address'] . '>') . $data['email_address'] . '>') .
"</option>\n"; "</option>\n";