summaryrefslogtreecommitdiff
path: root/program/steps
diff options
context:
space:
mode:
authorthomascube <thomas@roundcube.net>2009-11-02 09:58:14 +0000
committerthomascube <thomas@roundcube.net>2009-11-02 09:58:14 +0000
commit0207c45c90818e7c7df64ea52c61050850dee13d (patch)
tree89264d9dde1ca6337c4a5887084f66fb29a1c46b /program/steps
parent31ddb5e5c2dccffea5a8b947eca7b62d79d9c338 (diff)
More options for top posting feature (#1484272) using patch from Phil Weir
Diffstat (limited to 'program/steps')
-rw-r--r--program/steps/mail/compose.inc45
-rw-r--r--program/steps/settings/func.inc47
-rw-r--r--program/steps/settings/save_prefs.inc6
3 files changed, 61 insertions, 37 deletions
diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc
index 0f4b6ac81..3a8a776fe 100644
--- a/program/steps/mail/compose.inc
+++ b/program/steps/mail/compose.inc
@@ -103,6 +103,7 @@ if (!empty($CONFIG['drafts_mbox'])) {
}
// set current mailbox in client environment
$OUTPUT->set_env('mailbox', $IMAP->get_mailbox_name());
+$OUTPUT->set_env('sig_above', $CONFIG['sig_above']);
$OUTPUT->set_env('top_posting', $CONFIG['top_posting']);
// get reference message and set compose mode
@@ -117,12 +118,15 @@ else if ($msg_uid = $_SESSION['compose']['param']['draft_uid']) {
$compose_mode = RCUBE_COMPOSE_DRAFT;
}
-if (!$CONFIG['show_sig'])
+$config_show_sig = $RCMAIL->config->get('show_sig', 1);
+if ($config_show_sig == 1)
$OUTPUT->set_env('show_sig', true);
-else if ($CONFIG['show_sig'] == 2 && empty($compose_mode))
+else if ($config_show_sig == 2 && (empty($compose_mode) || $compose_mode == RCUBE_COMPOSE_EDIT || $compose_mode == RCUBE_COMPOSE_DRAFT))
$OUTPUT->set_env('show_sig', true);
-else if ($CONFIG['show_sig'] == 3 && ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD))
+else if ($config_show_sig == 3 && ($compose_mode == RCUBE_COMPOSE_REPLY || $compose_mode == RCUBE_COMPOSE_FORWARD))
$OUTPUT->set_env('show_sig', true);
+else
+ $OUTPUT->set_env('show_sig', false);
if (!empty($msg_uid))
{
@@ -518,18 +522,14 @@ function rcmail_compose_body($attrib)
function rcmail_create_reply_body($body, $bodyIsHtml)
{
- global $MESSAGE;
-
- $rcmail = rcmail::get_instance();
+ global $RCMAIL, $MESSAGE;
- if (! $bodyIsHtml)
- {
+ if (!$bodyIsHtml) {
// try to remove the signature
- if (!$rcmail->config->get('top_posting') && ($sp = strrpos($body, '-- ')) !== false && ($sp == 0 || $body{$sp-1} == "\n"))
- {
+ if ($RCMAIL->config->get('strip_existing_sig', true) && ($sp = strrpos($body, '-- ')) !== false && ($sp == 0 || $body{$sp-1} == "\n")) {
if ($body{$sp+3}==' ' || $body{$sp+3}=="\n" || $body{$sp+3}=="\r")
$body = substr($body, 0, max(0, $sp-1));
- }
+ }
// soft-wrap message first
$body = rcmail_wrap_quoted($body, 75);
@@ -541,15 +541,15 @@ function rcmail_create_reply_body($body, $bodyIsHtml)
$a_lines = preg_split('/\r?\n/', $body);
// add > to each line
- for($n=0; $n<sizeof($a_lines); $n++) {
+ for ($n=0; $n<sizeof($a_lines); $n++) {
if (strpos($a_lines[$n], '>')===0)
$a_lines[$n] = '>'.$a_lines[$n];
else
$a_lines[$n] = '> '.$a_lines[$n];
- }
+ }
$body = join("\n", $a_lines);
- }
+ }
// add title line(s)
$prefix = rc_wordwrap(sprintf("On %s, %s wrote:\n",
@@ -557,12 +557,11 @@ function rcmail_create_reply_body($body, $bodyIsHtml)
$MESSAGE->get_header('from')), 76);
$suffix = '';
-
- if ($rcmail->config->get('top_posting'))
+
+ if ($RCMAIL->config->get('top_posting'))
$prefix = "\n\n\n" . $prefix;
}
- else
- {
+ else {
// save inline images to files
$cid_map = rcmail_write_inline_attachments($MESSAGE);
// set is_safe flag (we need this for html body washing)
@@ -573,12 +572,12 @@ function rcmail_create_reply_body($body, $bodyIsHtml)
// build reply (quote content)
$prefix = sprintf("On %s, %s wrote:<br />\n",
$MESSAGE->headers->date,
- htmlspecialchars(Q($MESSAGE->get_header('from'), 'replace'), ENT_COMPAT, $rcmail->output->get_charset()));
+ htmlspecialchars(Q($MESSAGE->get_header('from'), 'replace'), ENT_COMPAT, $RCMAIL->output->get_charset()));
$prefix .= '<blockquote type="cite" style="padding-left:5px; border-left:#1010ff 2px solid; margin-left:5px; width:100%">';
-
- if ($rcmail->config->get('top_posting')) {
- $prefix = "<p></p>" . $prefix;
- $suffix = "</blockquote>";
+
+ if ($RCMAIL->config->get('top_posting')) {
+ $prefix = "<p></p>" . $prefix;
+ $suffix = "</blockquote>";
}
else {
$suffix = "</blockquote><p></p>";
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index e451d57d5..30a795194 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -409,6 +409,7 @@ function rcmail_user_prefs($current=null)
$blocks = array(
'main' => array('name' => Q(rcube_label('mainoptions'))),
+ 'sig' => array('name' => Q(rcube_label('signatureoptions'))),
);
// Show checkbox for HTML Editor
@@ -443,7 +444,7 @@ function rcmail_user_prefs($current=null)
$select_param_folding->add(rcube_label('2047folding'), 2);
$blocks['main']['options']['mime_param_folding'] = array(
- 'advanced' => true,
+ 'advanced' => true,
'title' => html::label($field_id, Q(rcube_label('mimeparamfolding'))),
'content' => $select_param_folding->show($config['mime_param_folding']),
);
@@ -451,25 +452,47 @@ function rcmail_user_prefs($current=null)
if (!isset($no_override['top_posting'])) {
$field_id = 'rcmfd_top_posting';
- $input_topposting = new html_checkbox(array('name' => '_top_posting', 'id' => $field_id, 'value' => 1));
+ $select_replymode = new html_select(array('name' => '_top_posting', 'id' => $field_id));
+ $select_replymode->add(rcube_label('replybottomposting'), 0);
+ $select_replymode->add(rcube_label('replytopposting'), 1);
$blocks['main']['options']['top_posting'] = array(
- 'title' => html::label($field_id, Q(rcube_label('top_posting'))),
- 'content' => $input_topposting->show($config['top_posting']?1:0),
+ 'title' => html::label($field_id, Q(rcube_label('whenreplying'))),
+ 'content' => $select_replymode->show($config['top_posting']?1:0),
);
}
if (!isset($no_override['show_sig'])) {
$field_id = 'rcmfd_show_sig';
$select_show_sig = new html_select(array('name' => '_show_sig', 'id' => $field_id));
- $select_show_sig->add(rcube_label('always'), 0);
- $select_show_sig->add(rcube_label('never'), 1);
- $select_show_sig->add(rcube_label('new_msg_only'), 2);
- $select_show_sig->add(rcube_label('reply_forward_only'), 3);
-
- $blocks['main']['options']['show_sig'] = array(
- 'title' => html::label($field_id, Q(rcube_label('auto_add_sig'))),
- 'content' => $select_show_sig->show(intval($config['show_sig'])),
+ $select_show_sig->add(rcube_label('never'), 0);
+ $select_show_sig->add(rcube_label('always'), 1);
+ $select_show_sig->add(rcube_label('newmessageonly'), 2);
+ $select_show_sig->add(rcube_label('replyandforwardonly'), 3);
+
+ $blocks['sig']['options']['show_sig'] = array(
+ 'title' => html::label($field_id, Q(rcube_label('autoaddsignature'))),
+ 'content' => $select_show_sig->show($config['show_sig']),
+ );
+ }
+
+ if (!isset($no_override['sig_above'])) {
+ $field_id = 'rcmfd_sig_above';
+ $input_sigabove = new html_checkbox(array('name' => '_sig_above', 'id' => $field_id, 'value' => 1));
+
+ $blocks['sig']['options']['sig_above'] = array(
+ 'title' => html::label($field_id, Q(rcube_label('replysignatureabove'))),
+ 'content' => $input_sigabove->show($config['sig_above']?1:0),
+ );
+ }
+
+ if (!isset($no_override['strip_existing_sig'])) {
+ $field_id = 'rcmfd_strip_existing_sig';
+ $input_stripexistingsig = new html_checkbox(array('name' => '_strip_existing_sig', 'id' => $field_id, 'value' => 1));
+
+ $blocks['sig']['options']['strip_existing_sig'] = array(
+ 'title' => html::label($field_id, Q(rcube_label('replyremovesignature'))),
+ 'content' => $input_stripexistingsig->show($config['strip_existing_sig']?1:0),
);
}
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
index e38a695a4..824e8f6c4 100644
--- a/program/steps/settings/save_prefs.inc
+++ b/program/steps/settings/save_prefs.inc
@@ -62,8 +62,10 @@ switch ($CURR_SECTION)
'htmleditor' => isset($_POST['_htmleditor']) ? TRUE : FALSE,
'draft_autosave' => isset($_POST['_draft_autosave']) ? intval($_POST['_draft_autosave']) : 0,
'mime_param_folding' => isset($_POST['_mime_param_folding']) ? intval($_POST['_mime_param_folding']) : 0,
- 'show_sig' => isset($_POST['_show_sig']) ? intval($_POST['_show_sig']) : 0,
- 'top_posting' => isset($_POST['_top_posting']) ? TRUE : FALSE,
+ 'show_sig' => isset($_POST['_show_sig']) ? intval($_POST['_show_sig']) : 1,
+ 'top_posting' => !empty($_POST['_top_posting']),
+ 'strip_existing_sig' => isset($_POST['_strip_existing_sig']),
+ 'sig_above' => isset($_POST['_sig_above']) && !empty($_POST['_top_posting']),
);
break;