From 2ef139180cb33f04cb067bd121058b5d959b3061 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 10 Dec 2009 12:19:31 -0700 Subject: [PATCH] Combine some code; clean up address fields before saving draft --- imp/compose-dimp.php | 60 ++++++++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 32 deletions(-) diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 949a3a128..588070aec 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -74,6 +74,7 @@ if (count($_POST)) { switch ($action) { case 'auto_save_draft': case 'save_draft': + case 'send_message': /* Set up the From address based on the identity. */ try { $from = $identity->getFromLine(null, Horde_Util::getFormData('from')); @@ -82,49 +83,43 @@ if (count($_POST)) { break; } $header['from'] = $from; + $header['to'] = $imp_ui->getAddressList(Horde_Util::getFormData('to')); + if ($prefs->getValue('compose_cc')) { + $header['cc'] = $imp_ui->getAddressList(Horde_Util::getFormData('cc')); + } + if ($prefs->getValue('compose_bcc')) { + $header['bcc'] = $imp_ui->getAddressList(Horde_Util::getFormData('bcc')); + } /* Save the draft. */ - try { - $old_uid = $imp_compose->getMetadata('draft_uid'); - - $res = $imp_compose->saveDraft($header, Horde_Util::getFormData('message', ''), Horde_Nls::getCharset(), Horde_Util::getFormData('html')); - $result->success = 1; - - /* Delete existing draft. */ - $imp_ui->removeDraft($old_uid); - - if ($action == 'auto_save_draft') { - $notification->push(_("Draft automatically saved."), 'horde.message'); - } else { - $notification->push($res); + if (($action == 'auto_save_draft') || + ($action == 'save_draft')) { + try { + $old_uid = $imp_compose->getMetadata('draft_uid'); + + $res = $imp_compose->saveDraft($header, Horde_Util::getFormData('message', ''), Horde_Nls::getCharset(), Horde_Util::getFormData('html')); + $result->success = 1; + + /* Delete existing draft. */ + $imp_ui->removeDraft($old_uid); + + if ($action == 'auto_save_draft') { + $notification->push(_("Draft automatically saved."), 'horde.message'); + } else { + $notification->push($res); + } + } catch (IMP_Compose_Exception $e) { + $notification->push($e, 'horde.error'); } - } catch (IMP_Compose_Exception $e) { - $notification->push($e, 'horde.error'); + break; } - break; - case 'send_message': if ($compose_disable) { break; } - try { - $from = $identity->getFromLine(null, Horde_Util::getFormData('from')); - } catch (Horde_Exception $e) { - $notification->push($e); - break; - } - $header['from'] = $from; $header['replyto'] = $identity->getValue('replyto_addr'); - $header['to'] = $imp_ui->getAddressList(Horde_Util::getFormData('to')); - if ($prefs->getValue('compose_cc')) { - $header['cc'] = $imp_ui->getAddressList(Horde_Util::getFormData('cc')); - } - if ($prefs->getValue('compose_bcc')) { - $header['bcc'] = $imp_ui->getAddressList(Horde_Util::getFormData('bcc')); - } - $message = Horde_Util::getFormData('message'); $html = Horde_Util::getFormData('html'); @@ -184,6 +179,7 @@ if (count($_POST)) { if (!empty($res)) { $result->folder = $res['a'][0]; } + break; } Horde::sendHTTPResponse(Horde::prepareResponse($result, $GLOBALS['imp_notify']), 'json'); -- 2.11.0