From 271efe53e084779a8141228c29b5819d1acd2762 Mon Sep 17 00:00:00 2001 From: Thomas Bruederli Date: Wed, 17 Oct 2012 22:42:35 +0200 Subject: Add user settings to open message view and compose form in new windows. This natevely implements the compose_newwindow plugin functionslity and more --- program/steps/addressbook/func.inc | 1 + program/steps/addressbook/mailto.inc | 2 +- program/steps/mail/compose.inc | 19 +++++++++++++++---- program/steps/mail/func.inc | 17 +++++------------ program/steps/mail/show.inc | 1 + program/steps/settings/func.inc | 24 +++++++++++++++++++++++- program/steps/settings/save_prefs.inc | 2 ++ 7 files changed, 48 insertions(+), 18 deletions(-) (limited to 'program/steps') diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc index 4ef4d1b51..3a0508025 100644 --- a/program/steps/addressbook/func.inc +++ b/program/steps/addressbook/func.inc @@ -87,6 +87,7 @@ if (!$RCMAIL->action && !$OUTPUT->ajax_call) { $OUTPUT->set_env('search_mods', $search_mods); $OUTPUT->set_env('address_sources', $js_list); $OUTPUT->set_env('writable_source', $writeable); + $OUTPUT->set_env('compose_extwin', $RCMAIL->config->get('compose_extwin',false)); $OUTPUT->set_pagetitle(rcube_label('addressbook')); $_SESSION['addressbooks_count'] = $count; diff --git a/program/steps/addressbook/mailto.inc b/program/steps/addressbook/mailto.inc index 3806c2c87..c3cbcadca 100644 --- a/program/steps/addressbook/mailto.inc +++ b/program/steps/addressbook/mailto.inc @@ -68,7 +68,7 @@ if (!empty($mailto)) $mailto_str = join(', ', $mailto); $mailto_id = substr(md5($mailto_str), 0, 16); $_SESSION['mailto'][$mailto_id] = urlencode($mailto_str); - $OUTPUT->redirect(array('task' => 'mail', '_action' => 'compose', '_mailto' => $mailto_id)); + $OUTPUT->command('open_compose_step', array('_mailto' => $mailto_id)); } else { $OUTPUT->show_message('nocontactsfound', 'warning'); diff --git a/program/steps/mail/compose.inc b/program/steps/mail/compose.inc index 691eca2db..24cd5e425 100644 --- a/program/steps/mail/compose.inc +++ b/program/steps/mail/compose.inc @@ -130,6 +130,7 @@ $OUTPUT->add_label('nosubject', 'nosenderwarning', 'norecipientwarning', 'nosubj 'fileuploaderror', 'sendmessage'); $OUTPUT->set_env('compose_id', $COMPOSE['id']); +$OUTPUT->set_pagetitle(rcube_label('compose')); // add config parameters to client script if (!empty($CONFIG['drafts_mbox'])) { @@ -606,7 +607,10 @@ function rcmail_compose_editor_mode() $html_editor = intval($RCMAIL->config->get('htmleditor')); - if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) { + if (isset($_POST['_is_html'])) { + $useHtml = !empty($_POST['_is_html']); + } + else if ($compose_mode == RCUBE_COMPOSE_DRAFT || $compose_mode == RCUBE_COMPOSE_EDIT) { $useHtml = $MESSAGE->has_html_part(false); } else if ($compose_mode == RCUBE_COMPOSE_REPLY) { @@ -1445,7 +1449,9 @@ function rcmail_receipt_checkbox($attrib) $attrib['value'] = '1'; $checkbox = new html_checkbox($attrib); - if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) + if (isset($_POST['_receipt'])) + $mdn_default = $_POST['_receipt']; + else if (in_array($compose_mode, array(RCUBE_COMPOSE_DRAFT, RCUBE_COMPOSE_EDIT))) $mdn_default = (bool) $MESSAGE->headers->mdn_to; else $mdn_default = $RCMAIL->config->get('mdn_default'); @@ -1472,8 +1478,13 @@ function rcmail_dsn_checkbox($attrib) $attrib['value'] = '1'; $checkbox = new html_checkbox($attrib); + if (isset($_POST['_dsn'])) + $dsn_value = $_POST['_dsn']; + else + $dsn_value = $RCMAIL->config->get('dsn_default'); + $out = $form_start ? "$form_start\n" : ''; - $out .= $checkbox->show($RCMAIL->config->get('dsn_default')); + $out .= $checkbox->show($dsn_value); $out .= $form_end ? "\n$form_end" : ''; return $out; @@ -1520,7 +1531,7 @@ function rcmail_store_target_selection($attrib) 'folder_filter' => 'mail', 'folder_rights' => 'w', ))); - return $select->show($COMPOSE['param']['sent_mbox'], $attrib); + return $select->show(isset($_POST['_store_target']) ? $_POST['_store_target'] : $COMPOSE['param']['sent_mbox'], $attrib); } diff --git a/program/steps/mail/func.inc b/program/steps/mail/func.inc index c21202588..c18d2cd13 100644 --- a/program/steps/mail/func.inc +++ b/program/steps/mail/func.inc @@ -101,18 +101,11 @@ if (empty($RCMAIL->action) || $RCMAIL->action == 'list') { $OUTPUT->set_env('quota', true); } - if ($CONFIG['delete_junk']) - $OUTPUT->set_env('delete_junk', true); - if ($CONFIG['flag_for_deletion']) - $OUTPUT->set_env('flag_for_deletion', true); - if ($CONFIG['read_when_deleted']) - $OUTPUT->set_env('read_when_deleted', true); - if ($CONFIG['skip_deleted']) - $OUTPUT->set_env('skip_deleted', true); - if ($CONFIG['display_next']) - $OUTPUT->set_env('display_next', true); - if ($CONFIG['forward_attachment']) - $OUTPUT->set_env('forward_attachment', true); + foreach (array('delete_junk','flag_for_deletion','read_when_deleted','skip_deleted','display_next','message_extwin','compose_extwin','forward_attachment') as $prop) { + if ($CONFIG[$prop]) + $OUTPUT->set_env($prop, true); + } + if ($CONFIG['trash_mbox']) $OUTPUT->set_env('trash_mailbox', $CONFIG['trash_mbox']); if ($CONFIG['drafts_mbox']) diff --git a/program/steps/mail/show.inc b/program/steps/mail/show.inc index 029bc5f8d..f89660719 100644 --- a/program/steps/mail/show.inc +++ b/program/steps/mail/show.inc @@ -59,6 +59,7 @@ if ($uid = get_input_value('_uid', RCUBE_INPUT_GET)) { $OUTPUT->set_env('permaurl', rcmail_url('show', array('_uid' => $MESSAGE->uid, '_mbox' => $mbox_name))); $OUTPUT->set_env('delimiter', $RCMAIL->storage->get_hierarchy_delimiter()); $OUTPUT->set_env('mailbox', $mbox_name); + $OUTPUT->set_env('compose_extwin', $RCMAIL->config->get('compose_extwin',false)); // mimetypes supported by the browser (default settings) $mimetypes = $RCMAIL->config->get('client_mimetypes', 'text/plain,text/html,text/xml,image/jpeg,image/gif,image/png,image/bmp,image/tiff,application/x-javascript,application/pdf,application/x-shockwave-flash'); diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index c60d17f30..e94630635 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -129,8 +129,8 @@ function rcmail_user_prefs($current=null) $sections['general'] = array('id' => 'general', 'section' => rcube_label('uisettings')); $sections['mailbox'] = array('id' => 'mailbox', 'section' => rcube_label('mailboxview')); - $sections['compose'] = array('id' => 'compose', 'section' => rcube_label('messagescomposition')); $sections['mailview'] = array('id' => 'mailview','section' => rcube_label('messagesdisplaying')); + $sections['compose'] = array('id' => 'compose', 'section' => rcube_label('messagescomposition')); $sections['addressbook'] = array('id' => 'addressbook','section' => rcube_label('addressbook')); $sections['folders'] = array('id' => 'folders', 'section' => rcube_label('specialfolders')); $sections['server'] = array('id' => 'server', 'section' => rcube_label('serversettings')); @@ -414,6 +414,17 @@ function rcmail_user_prefs($current=null) 'main' => array('name' => Q(rcube_label('mainoptions'))), ); + // show checkbox to open message view in new window + if (!isset($no_override['message_extwin'])) { + $field_id = 'rcmfd_message_extwin'; + $input_msgextwin = new html_checkbox(array('name' => '_message_extwin', 'id' => $field_id, 'value' => 1)); + + $blocks['main']['options']['message_extwin'] = array( + 'title' => html::label($field_id, Q(rcube_label('showinextwin'))), + 'content' => $input_msgextwin->show($config['message_extwin']?1:0), + ); + } + // show checkbox for HTML/plaintext messages if (!isset($no_override['prefer_html'])) { $field_id = 'rcmfd_htmlmsg'; @@ -483,6 +494,17 @@ function rcmail_user_prefs($current=null) 'sig' => array('name' => Q(rcube_label('signatureoptions'))), ); + // show checkbox to compose messages in a new window + if (!isset($no_override['compose_extwin'])) { + $field_id = 'rcmfdcompose_extwin'; + $input_compextwin = new html_checkbox(array('name' => '_compose_extwin', 'id' => $field_id, 'value' => 1)); + + $blocks['main']['options']['compose_extwin'] = array( + 'title' => html::label($field_id, Q(rcube_label('composeextwin'))), + 'content' => $input_compextwin->show($config['compose_extwin']?1:0), + ); + } + if (!isset($no_override['htmleditor'])) { $field_id = 'rcmfd_htmleditor'; $select_htmleditor = new html_select(array('name' => '_htmleditor', 'id' => $field_id)); diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc index d1627ecea..db7b134c4 100644 --- a/program/steps/settings/save_prefs.inc +++ b/program/steps/settings/save_prefs.inc @@ -59,6 +59,7 @@ switch ($CURR_SECTION) case 'mailview': $a_user_prefs = array( + 'message_extwin' => intval($_POST['_message_extwin']), 'prefer_html' => isset($_POST['_prefer_html']) ? TRUE : FALSE, 'inline_images' => isset($_POST['_inline_images']) ? TRUE : FALSE, 'show_images' => isset($_POST['_show_images']) ? intval($_POST['_show_images']) : 0, @@ -70,6 +71,7 @@ switch ($CURR_SECTION) case 'compose': $a_user_prefs = array( + 'compose_extwin' => intval($_POST['_compose_extwin']), 'htmleditor' => intval($_POST['_htmleditor']), '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, -- cgit v1.2.3