}
-@define('IMP_BASE', dirname(__FILE__));
$compose_page = true;
$session_control = 'netscape';
-require_once IMP_BASE . '/lib/base.php';
+require_once dirname(__FILE__) . '/lib/base.php';
require_once 'Horde/Help.php';
require_once 'Horde/Identity.php';
require_once 'Horde/Text/Filter.php';
$thismailbox = Util::getFormData('thismailbox');
/* Check for duplicate submits. */
-if (isset($conf['token'])) {
- /* If there is a configured token system, set it up. */
- $tokenSource = Horde_Token::factory(
- $conf['token']['driver'],
- Horde::getDriverConfig('token', $conf['token']['driver']));
-} else {
- /* Default to the file system if no config. */
- $tokenSource = Horde_Token::factory('file');
-}
if ($token = Util::getFormData('compose_formToken')) {
+ $tokenSource = isset($conf['token'])
+ ? Horde_Token::factory($conf['token']['driver'], Horde::getDriverConfig('token', $conf['token']['driver']))
+ : Horde_Token::factory('file');
+
$verified = $tokenSource->verify($token);
/* Notify and reset the actionID. */
if (is_a($verified, 'PEAR_Error')) {
$vcard = $imp_compose->attachVCard((bool) Util::getFormData('vcard'), $identity->getValue('fullname'));
if (is_a($vcard, 'PEAR_Error')) {
- // TODO: notification
+ $notification->push($vcard);
}
/* Init IMP_UI_Compose:: object. */
$get_sig = false;
$code = $sent->getCode();
$notification->push($sent, strpos($code, 'horde.') === 0 ? $code : 'horde.error');
- if ($sent->getUserInfo() == 'pgp_symmetric_passphrase_dialog') {
+ switch ($sent->getUserInfo()) {
+ case 'pgp_symmetric_passphrase_dialog':
$pgp_symmetric_passphrase_dialog = true;
- } elseif ($sent->getUserInfo() == 'pgp_passphrase_dialog') {
+ break;
+
+ case 'pgp_passphrase_dialog':
$pgp_passphrase_dialog = true;
- } elseif ($sent->getUserInfo() == 'smime_passphrase_dialog') {
+ break;
+
+ case 'smime_passphrase_dialog':
$smime_passphrase_dialog = true;
+ break;
}
break;
}
case 'selectlist_process':
$select_id = Util::getFormData('selectlist_selectid');
- if (!empty($select_id)) {
- if ($registry->hasMethod('files/selectlistResults') &&
- $registry->hasMethod('files/returnFromSelectlist')) {
- $filelist = $registry->call('files/selectlistResults', array($select_id));
- if ($filelist && !is_a($filelist, 'PEAR_Error')) {
- $i = 0;
- foreach ($filelist as $val) {
- $data = $registry->call('files/returnFromSelectlist', array($select_id, $i++));
- if ($data && !is_a($data, 'PEAR_Error')) {
- $part = new Horde_Mime_Part();
- $part->setContents($data);
- $part->setName(reset($val));
- $res = $imp_compose->addMIMEPartAttachment($part);
- if (is_a($res, 'PEAR_Error')) {
- $notification->push($res, 'horde.error');
- }
+ if (!empty($select_id) &&
+ $registry->hasMethod('files/selectlistResults') &&
+ $registry->hasMethod('files/returnFromSelectlist')) {
+ $filelist = $registry->call('files/selectlistResults', array($select_id));
+ if ($filelist && !is_a($filelist, 'PEAR_Error')) {
+ $i = 0;
+ foreach ($filelist as $val) {
+ $data = $registry->call('files/returnFromSelectlist', array($select_id, $i++));
+ if ($data && !is_a($data, 'PEAR_Error')) {
+ $part = new Horde_Mime_Part();
+ $part->setContents($data);
+ $part->setName(reset($val));
+ $res = $imp_compose->addMIMEPartAttachment($part);
+ if (is_a($res, 'PEAR_Error')) {
+ $notification->push($res, 'horde.error');
}
}
}
/* Get the message cache ID. */
$composeCacheID = $imp_compose->getCacheId();
-/* Has this page been reloaded? */
-$reloaded = Util::getFormData('reloaded');
-
/* Are we in redirect mode? */
$redirect = in_array($actionID, array('redirect_compose', 'redirect_expand_addr'));
/* If this is the first page load for this compose item, add auto BCC
* addresses. */
-if (!$reloaded && ($actionID != 'draft')) {
+if (!$token && ($actionID != 'draft')) {
$header['bcc'] = Horde_Mime_Address::addrArray2String($identity->getBccAddresses());
}
/* If PGP encryption is set by default, and we have a recipient list on first
* load, make sure we have public keys for all recipients. */
$encrypt_options = Util::getFormData('encrypt_options');
-$use_pgp = $prefs->getValue('use_pgp');
-if ($use_pgp) {
+if ($prefs->getValue('use_pgp')) {
$default_encrypt = $prefs->getValue('default_encrypt');
- if (!$reloaded &&
+ if (!$token &&
in_array($default_encrypt, array(IMP::PGP_ENCRYPT, IMP::PGP_SIGNENC))) {
$addrs = $imp_compose->recipientList($header);
if (!is_a($addrs, 'PEAR_Error') && !empty($addrs['list'])) {
'var redirect = ' . intval($redirect),
'var rtemode = ' . intval($rtemode),
'var smf_check = ' . intval($smf_check),
- 'var reloaded = ' . intval($reloaded),
+ 'var reloaded = ' . intval($token)
);
/* Create javascript identities array. */
$js_code[] = 'var identities = ' . Horde_Serialize::serialize($js_ident, SERIALIZE_JSON, NLS::getCharset());
}
-Horde::addScriptFile('prototype.js', 'horde', true);
-Horde::addScriptFile('compose.js', 'imp', true);
-require IMP_TEMPLATES . '/common-header.inc';
-IMP::addInlineScript($js_code);
-if ($showmenu) {
- IMP::menu();
-}
/* Set up the base template now. */
$t = new IMP_Template();
$t->set('help', Help::link('imp', 'compose-to'));
}
- echo $t->fetch(IMP_TEMPLATES . '/compose/redirect.html');
+ $template_output = $t->fetch(IMP_TEMPLATES . '/compose/redirect.html');
} else {
if (!($reply_type = Util::getFormData('reply_type'))) {
switch ($actionID) {
'mailbox' => htmlspecialchars($imp_mbox['mailbox']),
'thismailbox' => $thismailbox,
'attachmentAction' => '',
- 'reloaded' => 1,
'oldrtemode' => $rtemode,
'rtemode' => $rtemode,
'index' => $index
if ($readonly_sentmail) {
$notification->push(sprintf(_("Cannot save sent-mail message to \"%s\" as that mailbox is read-only.", $sent_mail_folder), 'horde.warning'));
}
- $t->set('ssm_selected', ($reloaded) ? ($save_sent_mail == 'on') : $identity->saveSentmail());
+ $t->set('ssm_selected', $token ? ($save_sent_mail == 'on') : $identity->saveSentmail());
$t->set('ssm_label', Horde::label('ssm', _("Sa_ve a copy in ")));
if ($smf = Util::getFormData('sent_mail_folder')) {
$sent_mail_folder = $smf;
}
}
- echo $t->fetch(IMP_TEMPLATES . '/compose/compose.html');
+ $template_output = $t->fetch(IMP_TEMPLATES . '/compose/compose.html');
}
-/* Load RTE. */
+Horde::addScriptFile('prototype.js', 'horde', true);
+Horde::addScriptFile('compose.js', 'imp', true);
+require IMP_TEMPLATES . '/common-header.inc';
+IMP::addInlineScript($js_code);
+if ($showmenu) {
+ IMP::menu();
+}
+echo $template_output;
if ($rtemode && !$redirect) {
echo $imp_ui->initRTE();
}
-
require $registry->get('templates', 'horde') . '/common-footer.inc';