diff options
author | Aleksander Machniak <alec@alec.pl> | 2013-09-10 15:50:24 +0200 |
---|---|---|
committer | Aleksander Machniak <alec@alec.pl> | 2013-09-10 15:50:24 +0200 |
commit | 6128ad7e962a8f9bf82a1ef87e4efbe36d719d92 (patch) | |
tree | e5c821362f87ff7c71bd2100a764e03fa01a1554 /program | |
parent | 6b87f8e023011e1f10c899d1d1d27f8309ceda52 (diff) |
Support full address specification in contact email fields.
Now input address is extracted automatically, so user can
just paste full address copied from another place. Other clients
have such feature e.g. Kontact.
Diffstat (limited to 'program')
-rw-r--r-- | program/steps/addressbook/save.inc | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/program/steps/addressbook/save.inc b/program/steps/addressbook/save.inc index bd6c14bca..1628f5b0f 100644 --- a/program/steps/addressbook/save.inc +++ b/program/steps/addressbook/save.inc @@ -59,9 +59,18 @@ foreach ($GLOBALS['CONTACT_COLTYPES'] as $col => $colprop) { } // assign values and subtypes else if (is_array($_POST[$fname])) { - $values = get_input_value($fname, RCUBE_INPUT_POST, true); + $values = get_input_value($fname, RCUBE_INPUT_POST, true); $subtypes = get_input_value('_subtype_' . $col, RCUBE_INPUT_POST); + foreach ($values as $i => $val) { + if ($col == 'email') { + // extract email from full address specification, e.g. "Name" <addr@domain.tld> + $addr = rcube_mime::decode_address_list($val, 1, false); + if (!empty($addr) && ($addr = array_pop($addr)) && $addr['mailto']) { + $val = $addr['mailto']; + } + } + $subtype = $subtypes[$i] ? ':'.$subtypes[$i] : ''; $a_record[$col.$subtype][] = $val; } |