diff options
Diffstat (limited to 'program')
-rw-r--r-- | program/steps/settings/about.inc | 127 | ||||
-rw-r--r-- | program/steps/settings/delete_identity.inc | 38 | ||||
-rw-r--r-- | program/steps/settings/edit_folder.inc | 27 | ||||
-rw-r--r-- | program/steps/settings/edit_identity.inc | 252 | ||||
-rw-r--r-- | program/steps/settings/edit_prefs.inc | 84 | ||||
-rw-r--r-- | program/steps/settings/edit_response.inc | 19 | ||||
-rw-r--r-- | program/steps/settings/folders.inc | 4 | ||||
-rw-r--r-- | program/steps/settings/func.inc | 71 | ||||
-rw-r--r-- | program/steps/settings/identities.inc | 27 | ||||
-rw-r--r-- | program/steps/settings/responses.inc | 19 | ||||
-rw-r--r-- | program/steps/settings/save_folder.inc | 5 | ||||
-rw-r--r-- | program/steps/settings/save_identity.inc | 218 | ||||
-rw-r--r-- | program/steps/settings/save_prefs.inc | 236 |
13 files changed, 578 insertions, 549 deletions
diff --git a/program/steps/settings/about.inc b/program/steps/settings/about.inc index eae4da842..026bfc1a2 100644 --- a/program/steps/settings/about.inc +++ b/program/steps/settings/about.inc @@ -5,8 +5,8 @@ | program/steps/settings/about.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2011, The Roundcube Dev Team | - | Copyright (C) 2011, Kolab Systems AG | + | Copyright (C) 2005-2013, The Roundcube Dev Team | + | Copyright (C) 2011-2013, Kolab Systems AG | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -21,78 +21,83 @@ */ +$OUTPUT->set_pagetitle($RCMAIL->gettext('about')); + +$OUTPUT->add_handler('supportlink', 'rcmail_supportlink'); +$OUTPUT->add_handler('pluginlist', 'rcmail_plugins_list'); + +$OUTPUT->send('about'); + + + function rcmail_supportlink($attrib) { - global $RCMAIL; + global $RCMAIL; - if ($url = $RCMAIL->config->get('support_url')) { - $label = $attrib['label'] ? $attrib['label'] : 'support'; - $attrib['href'] = $url; - return html::a($attrib, $RCMAIL->gettext($label)); - } + if ($url = $RCMAIL->config->get('support_url')) { + $label = $attrib['label'] ? $attrib['label'] : 'support'; + $attrib['href'] = $url; + + return html::a($attrib, $RCMAIL->gettext($label)); + } } function rcmail_plugins_list($attrib) { - global $RCMAIL; - - if (!$attrib['id']) - $attrib['id'] = 'rcmpluginlist'; - - $plugins = array_filter((array) $RCMAIL->config->get('plugins')); - $plugin_info = array(); - - foreach ($plugins as $name) { - if ($info = $RCMAIL->plugins->get_info($name)) - $plugin_info[$name] = $info; - } - - // load info from required plugins, too - foreach ($plugin_info as $name => $info) { - if (is_array($info['required']) && !empty($info['required'])) { - foreach ($info['required'] as $req_name) { - if (!isset($plugin_info[$req_name]) && ($req_info = $RCMAIL->plugins->get_info($req_name))) - $plugin_info[$req_name] = $req_info; - } - } - } + global $RCMAIL; - if (empty($plugin_info)) { - return ''; - } + if (!$attrib['id']) { + $attrib['id'] = 'rcmpluginlist'; + } - ksort($plugin_info, SORT_LOCALE_STRING); + $plugins = array_filter((array) $RCMAIL->config->get('plugins')); + $plugin_info = array(); - $table = new html_table($attrib); + foreach ($plugins as $name) { + if ($info = $RCMAIL->plugins->get_info($name)) { + $plugin_info[$name] = $info; + } + } - // add table header - $table->add_header('name', $RCMAIL->gettext('plugin')); - $table->add_header('version', $RCMAIL->gettext('version')); - $table->add_header('license', $RCMAIL->gettext('license')); - $table->add_header('source', $RCMAIL->gettext('source')); + // load info from required plugins, too + foreach ($plugin_info as $name => $info) { + if (is_array($info['required']) && !empty($info['required'])) { + foreach ($info['required'] as $req_name) { + if (!isset($plugin_info[$req_name]) && ($req_info = $RCMAIL->plugins->get_info($req_name))) { + $plugin_info[$req_name] = $req_info; + } + } + } + } - foreach ($plugin_info as $name => $data) { - $uri = $data['src_uri'] ? $data['src_uri'] : $data['uri']; - if ($uri && stripos($uri, 'http') !== 0) { - $uri = 'http://' . $uri; + if (empty($plugin_info)) { + return ''; } - $table->add_row(); - $table->add('name', rcube::Q($data['name'] ? $data['name'] : $name)); - $table->add('version', rcube::Q($data['version'])); - $table->add('license', $data['license_uri'] ? html::a(array('target' => '_blank', href=> rcube::Q($data['license_uri'])), - rcube::Q($data['license'])) : $data['license']); - $table->add('source', $uri ? html::a(array('target' => '_blank', href=> rcube::Q($uri)), - rcube::Q($RCMAIL->gettext('download'))) : ''); - } + ksort($plugin_info, SORT_LOCALE_STRING); + + $table = new html_table($attrib); + + // add table header + $table->add_header('name', $RCMAIL->gettext('plugin')); + $table->add_header('version', $RCMAIL->gettext('version')); + $table->add_header('license', $RCMAIL->gettext('license')); + $table->add_header('source', $RCMAIL->gettext('source')); + + foreach ($plugin_info as $name => $data) { + $uri = $data['src_uri'] ? $data['src_uri'] : $data['uri']; + if ($uri && stripos($uri, 'http') !== 0) { + $uri = 'http://' . $uri; + } + + $table->add_row(); + $table->add('name', rcube::Q($data['name'] ? $data['name'] : $name)); + $table->add('version', rcube::Q($data['version'])); + $table->add('license', $data['license_uri'] ? html::a(array('target' => '_blank', href=> rcube::Q($data['license_uri'])), + rcube::Q($data['license'])) : $data['license']); + $table->add('source', $uri ? html::a(array('target' => '_blank', href=> rcube::Q($uri)), + rcube::Q($RCMAIL->gettext('download'))) : ''); + } - return $table->show(); + return $table->show(); } - - -$OUTPUT->set_pagetitle($RCMAIL->gettext('about')); - -$OUTPUT->add_handler('supportlink', 'rcmail_supportlink'); -$OUTPUT->add_handler('pluginlist', 'rcmail_plugins_list'); - -$OUTPUT->send('about'); diff --git a/program/steps/settings/delete_identity.inc b/program/steps/settings/delete_identity.inc index 85d128c8f..f77620438 100644 --- a/program/steps/settings/delete_identity.inc +++ b/program/steps/settings/delete_identity.inc @@ -5,7 +5,7 @@ | program/steps/settings/delete_identity.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2009, The Roundcube Dev Team | + | Copyright (C) 2005-2013, The Roundcube Dev Team | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -23,29 +23,33 @@ $iid = rcube_utils::get_input_value('_iid', rcube_utils::INPUT_GPC); // check request token if (!$OUTPUT->ajax_call && !$RCMAIL->check_request(rcube_utils::INPUT_GPC)) { - $OUTPUT->show_message('invalidrequest', 'error'); - $RCMAIL->overwrite_action('identities'); - return; + $OUTPUT->show_message('invalidrequest', 'error'); + $RCMAIL->overwrite_action('identities'); + return; } -if ($iid && preg_match('/^[0-9]+(,[0-9]+)*$/', $iid)) -{ - $plugin = $RCMAIL->plugins->exec_hook('identity_delete', array('id' => $iid)); +if ($iid && preg_match('/^[0-9]+(,[0-9]+)*$/', $iid)) { + $plugin = $RCMAIL->plugins->exec_hook('identity_delete', array('id' => $iid)); - $deleted = !$plugin['abort'] ? $RCMAIL->user->delete_identity($iid) : $plugin['result']; + $deleted = !$plugin['abort'] ? $RCMAIL->user->delete_identity($iid) : $plugin['result']; - if ($deleted > 0 && $deleted !== false) - $OUTPUT->show_message('deletedsuccessfully', 'confirmation', null, false); - else - $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : ($deleted < 0 ? 'nodeletelastidentity' : 'errorsaving'), 'error', null, false); + if ($deleted > 0 && $deleted !== false) { + $OUTPUT->show_message('deletedsuccessfully', 'confirmation', null, false); + } + else { + $msg = $plugin['message'] ? $plugin['message'] : ($deleted < 0 ? 'nodeletelastidentity' : 'errorsaving'); + $OUTPUT->show_message($msg, 'error', null, false); + } - // send response - if ($OUTPUT->ajax_call) - $OUTPUT->send(); + // send response + if ($OUTPUT->ajax_call) { + $OUTPUT->send(); + } } -if ($OUTPUT->ajax_call) - exit; +if ($OUTPUT->ajax_call) { + exit; +} // go to identities page $RCMAIL->overwrite_action('identities'); diff --git a/program/steps/settings/edit_folder.inc b/program/steps/settings/edit_folder.inc index ff28d04c8..fc6b2cd16 100644 --- a/program/steps/settings/edit_folder.inc +++ b/program/steps/settings/edit_folder.inc @@ -5,7 +5,7 @@ | program/steps/settings/edit_folder.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2009, The Roundcube Dev Team | + | Copyright (C) 2005-2013, The Roundcube Dev Team | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -19,6 +19,16 @@ +-----------------------------------------------------------------------+ */ +// register UI objects +$OUTPUT->add_handlers(array( + 'folderdetails' => 'rcmail_folder_form', +)); + +$OUTPUT->add_label('nonamewarning'); + +$OUTPUT->send('folderedit'); + + // WARNING: folder names in UI are encoded with RCUBE_CHARSET function rcmail_folder_form($attrib) @@ -256,7 +266,8 @@ function rcmail_folder_form($attrib) foreach ($tab['fieldsets'] as $fieldset) { $subcontent = rcmail_get_form_part($fieldset, $attrib); if ($subcontent) { - $content .= html::tag('fieldset', null, html::tag('legend', null, rcube::Q($fieldset['name'])) . $subcontent) ."\n"; + $subcontent = html::tag('legend', null, rcube::Q($fieldset['name'])) . $subcontent; + $content .= html::tag('fieldset', null, $subcontent) ."\n"; } } } @@ -300,15 +311,3 @@ function rcmail_get_form_part($form, $attrib = array()) return $content; } - - -//$OUTPUT->set_pagetitle($RCMAIL->gettext('folders')); - -// register UI objects -$OUTPUT->add_handlers(array( - 'folderdetails' => 'rcmail_folder_form', -)); - -$OUTPUT->add_label('nonamewarning'); - -$OUTPUT->send('folderedit'); diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc index 974acb42a..f208c8a05 100644 --- a/program/steps/settings/edit_identity.inc +++ b/program/steps/settings/edit_identity.inc @@ -5,7 +5,7 @@ | program/steps/settings/edit_identity.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2011, The Roundcube Dev Team | + | Copyright (C) 2005-2013, The Roundcube Dev Team | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -23,152 +23,158 @@ define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0))); // edit-identity if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='edit-identity') { - $IDENTITY_RECORD = $RCMAIL->user->get_identity(rcube_utils::get_input_value('_iid', rcube_utils::INPUT_GPC)); - - if (is_array($IDENTITY_RECORD)) - $OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']); - else { - $OUTPUT->show_message('dberror', 'error'); - // go to identities page - $RCMAIL->overwrite_action('identities'); - return; - } + $id = rcube_utils::get_input_value('_iid', rcube_utils::INPUT_GPC); + $IDENTITY_RECORD = $RCMAIL->user->get_identity($id); + + if (is_array($IDENTITY_RECORD)) { + $OUTPUT->set_env('iid', $IDENTITY_RECORD['identity_id']); + } + else { + $OUTPUT->show_message('dberror', 'error'); + // go to identities page + $RCMAIL->overwrite_action('identities'); + return; + } } // add-identity else { - if (IDENTITIES_LEVEL > 1) { - $OUTPUT->show_message('opnotpermitted', 'error'); - // go to identities page - $RCMAIL->overwrite_action('identities'); - return; - } - else if (IDENTITIES_LEVEL == 1) { - $IDENTITY_RECORD['email'] = $RCMAIL->get_user_email(); - } + if (IDENTITIES_LEVEL > 1) { + $OUTPUT->show_message('opnotpermitted', 'error'); + // go to identities page + $RCMAIL->overwrite_action('identities'); + return; + } + else if (IDENTITIES_LEVEL == 1) { + $IDENTITY_RECORD['email'] = $RCMAIL->get_user_email(); + } +} + +$OUTPUT->include_script('list.js'); +$OUTPUT->add_handler('identityform', 'rcube_identity_form'); +$OUTPUT->set_env('identities_level', IDENTITIES_LEVEL); +$OUTPUT->add_label('deleteidentityconfirm'); + +$OUTPUT->set_pagetitle($RCMAIL->gettext(($RCMAIL->action == 'add-identity' ? 'newidentity' : 'edititem'))); + +if ($RCMAIL->action == 'add-identity' && $OUTPUT->template_exists('identityadd')) { + $OUTPUT->send('identityadd'); } +$OUTPUT->send('identityedit'); + function rcube_identity_form($attrib) { - global $IDENTITY_RECORD, $RCMAIL, $OUTPUT; - - // Add HTML editor script(s) - $RCMAIL->html_editor('identity'); - - // add some labels to client - $OUTPUT->add_label('noemailwarning', 'nonamewarning', 'converting', 'editorwarning'); - - $i_size = !empty($attrib['size']) ? $attrib['size'] : 40; - $t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6; - $t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40; - - // list of available cols - $form = array( - 'addressing' => array( - 'name' => $RCMAIL->gettext('settings'), - 'content' => array( - 'name' => array('type' => 'text', 'size' => $i_size), - 'email' => array('type' => 'text', 'size' => $i_size), - 'organization' => array('type' => 'text', 'size' => $i_size), - 'reply-to' => array('type' => 'text', 'size' => $i_size), - 'bcc' => array('type' => 'text', 'size' => $i_size), - 'standard' => array('type' => 'checkbox', 'label' => $RCMAIL->gettext('setdefault')), - )), - 'signature' => array( - 'name' => $RCMAIL->gettext('signature'), - 'content' => array( - 'signature' => array('type' => 'textarea', 'size' => $t_cols, 'rows' => $t_rows, - 'spellcheck' => true), - 'html_signature' => array('type' => 'checkbox', 'label' => $RCMAIL->gettext('htmlsignature'), - 'onclick' => 'return rcmail_toggle_editor(this, \'rcmfd_signature\');'), - )) - ); - - // Enable TinyMCE editor - if ($IDENTITY_RECORD['html_signature']) { - $form['signature']['content']['signature']['class'] = 'mce_editor'; - $form['signature']['content']['signature']['is_escaped'] = true; - - // Correctly handle HTML entities in HTML editor (#1488483) - $IDENTITY_RECORD['signature'] = htmlspecialchars($IDENTITY_RECORD['signature'], ENT_NOQUOTES, RCUBE_CHARSET); - } - - // disable some field according to access level - if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3) { - $form['addressing']['content']['email']['disabled'] = true; - $form['addressing']['content']['email']['class'] = 'disabled'; - } - - if (IDENTITIES_LEVEL == 4) { - foreach($form['addressing']['content'] as $formfield => $value){ - $form['addressing']['content'][$formfield]['disabled'] = true; - $form['addressing']['content'][$formfield]['class'] = 'disabled'; + global $IDENTITY_RECORD, $RCMAIL, $OUTPUT; + + // Add HTML editor script(s) + $RCMAIL->html_editor('identity'); + + // add some labels to client + $OUTPUT->add_label('noemailwarning', 'nonamewarning', 'converting', 'editorwarning'); + + $i_size = !empty($attrib['size']) ? $attrib['size'] : 40; + $t_rows = !empty($attrib['textarearows']) ? $attrib['textarearows'] : 6; + $t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40; + + // list of available cols + $form = array( + 'addressing' => array( + 'name' => $RCMAIL->gettext('settings'), + 'content' => array( + 'name' => array('type' => 'text', 'size' => $i_size), + 'email' => array('type' => 'text', 'size' => $i_size), + 'organization' => array('type' => 'text', 'size' => $i_size), + 'reply-to' => array('type' => 'text', 'size' => $i_size), + 'bcc' => array('type' => 'text', 'size' => $i_size), + 'standard' => array('type' => 'checkbox', 'label' => $RCMAIL->gettext('setdefault')), + )), + 'signature' => array( + 'name' => $RCMAIL->gettext('signature'), + 'content' => array( + 'signature' => array('type' => 'textarea', 'size' => $t_cols, 'rows' => $t_rows, + 'spellcheck' => true), + 'html_signature' => array('type' => 'checkbox', + 'label' => $RCMAIL->gettext('htmlsignature'), + 'onclick' => 'return rcmail_toggle_editor(this, \'rcmfd_signature\');'), + )) + ); + + // Enable TinyMCE editor + if ($IDENTITY_RECORD['html_signature']) { + $form['signature']['content']['signature']['class'] = 'mce_editor'; + $form['signature']['content']['signature']['is_escaped'] = true; + + // Correctly handle HTML entities in HTML editor (#1488483) + $IDENTITY_RECORD['signature'] = htmlspecialchars($IDENTITY_RECORD['signature'], ENT_NOQUOTES, RCUBE_CHARSET); } - } - $IDENTITY_RECORD['email'] = rcube_utils::idn_to_utf8($IDENTITY_RECORD['email']); + // disable some field according to access level + if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3) { + $form['addressing']['content']['email']['disabled'] = true; + $form['addressing']['content']['email']['class'] = 'disabled'; + } - // Allow plugins to modify identity form content - $plugin = $RCMAIL->plugins->exec_hook('identity_form', array( - 'form' => $form, 'record' => $IDENTITY_RECORD)); + if (IDENTITIES_LEVEL == 4) { + foreach($form['addressing']['content'] as $formfield => $value){ + $form['addressing']['content'][$formfield]['disabled'] = true; + $form['addressing']['content'][$formfield]['class'] = 'disabled'; + } + } - $form = $plugin['form']; - $IDENTITY_RECORD = $plugin['record']; + $IDENTITY_RECORD['email'] = rcube_utils::idn_to_utf8($IDENTITY_RECORD['email']); - // Set form tags and hidden fields - list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', - intval($IDENTITY_RECORD['identity_id']), - array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id'])); + // Allow plugins to modify identity form content + $plugin = $RCMAIL->plugins->exec_hook('identity_form', array( + 'form' => $form, 'record' => $IDENTITY_RECORD)); - unset($plugin); - unset($attrib['form'], $attrib['id']); + $form = $plugin['form']; + $IDENTITY_RECORD = $plugin['record']; - // return the complete edit form as table - $out = "$form_start\n"; + // Set form tags and hidden fields + list($form_start, $form_end) = get_form_tags($attrib, 'save-identity', + intval($IDENTITY_RECORD['identity_id']), + array('name' => '_iid', 'value' => $IDENTITY_RECORD['identity_id'])); - foreach ($form as $fieldset) { - if (empty($fieldset['content'])) - continue; + unset($plugin); + unset($attrib['form'], $attrib['id']); - $content = ''; - if (is_array($fieldset['content'])) { - $table = new html_table(array('cols' => 2)); - foreach ($fieldset['content'] as $col => $colprop) { - $colprop['id'] = 'rcmfd_'.$col; + // return the complete edit form as table + $out = "$form_start\n"; - $label = !empty($colprop['label']) ? $colprop['label'] : - $RCMAIL->gettext(str_replace('-', '', $col)); + foreach ($form as $fieldset) { + if (empty($fieldset['content'])) { + continue; + } - $value = !empty($colprop['value']) ? $colprop['value'] : - rcube_output::get_edit_field($col, $IDENTITY_RECORD[$col], $colprop, $colprop['type']); + $content = ''; + if (is_array($fieldset['content'])) { + $table = new html_table(array('cols' => 2)); - $table->add('title', html::label($colprop['id'], rcube::Q($label))); - $table->add(null, $value); - } - $content = $table->show($attrib); - } - else { - $content = $fieldset['content']; - } + foreach ($fieldset['content'] as $col => $colprop) { + $colprop['id'] = 'rcmfd_'.$col; - $out .= html::tag('fieldset', null, html::tag('legend', null, rcube::Q($fieldset['name'])) . $content) ."\n"; - } + $label = !empty($colprop['label']) ? $colprop['label'] : + $RCMAIL->gettext(str_replace('-', '', $col)); - $out .= $form_end; + $value = !empty($colprop['value']) ? $colprop['value'] : + rcube_output::get_edit_field($col, $IDENTITY_RECORD[$col], $colprop, $colprop['type']); - return $out; -} + $table->add('title', html::label($colprop['id'], rcube::Q($label))); + $table->add(null, $value); + } -$OUTPUT->include_script('list.js'); -$OUTPUT->add_handler('identityform', 'rcube_identity_form'); -$OUTPUT->set_env('identities_level', IDENTITIES_LEVEL); -$OUTPUT->add_label('deleteidentityconfirm'); - -$OUTPUT->set_pagetitle($RCMAIL->gettext(($RCMAIL->action=='add-identity' ? 'newidentity' : 'edititem'))); - -if ($RCMAIL->action=='add-identity' && $OUTPUT->template_exists('identityadd')) - $OUTPUT->send('identityadd'); + $content = $table->show($attrib); + } + else { + $content = $fieldset['content']; + } -$OUTPUT->send('identityedit'); + $content = html::tag('legend', null, rcube::Q($fieldset['name'])) . $content; + $out .= html::tag('fieldset', null, $content) . "\n"; + } + $out .= $form_end; + return $out; +} diff --git a/program/steps/settings/edit_prefs.inc b/program/steps/settings/edit_prefs.inc index 93e27aedc..05f4db6a6 100644 --- a/program/steps/settings/edit_prefs.inc +++ b/program/steps/settings/edit_prefs.inc @@ -5,7 +5,7 @@ | program/steps/settings/edit_prefs.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2007, The Roundcube Dev Team | + | Copyright (C) 2005-2013, The Roundcube Dev Team | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -19,65 +19,65 @@ +-----------------------------------------------------------------------+ */ -if (!$OUTPUT->ajax_call) - $OUTPUT->set_pagetitle($RCMAIL->gettext('preferences')); +if (!$OUTPUT->ajax_call) { + $OUTPUT->set_pagetitle($RCMAIL->gettext('preferences')); +} -$CURR_SECTION = rcube_utils::get_input_value('_section', rcube_utils::INPUT_GPC); +$CURR_SECTION = rcube_utils::get_input_value('_section', rcube_utils::INPUT_GPC); list($SECTIONS,) = rcmail_user_prefs($CURR_SECTION); +// register UI objects +$OUTPUT->add_handlers(array( + 'userprefs' => 'rcmail_user_prefs_form', + 'sectionname' => 'rcmail_prefs_section_name', +)); + +$OUTPUT->send('settingsedit'); + + + function rcmail_user_prefs_form($attrib) { - global $RCMAIL, $CURR_SECTION, $SECTIONS; + global $RCMAIL, $CURR_SECTION, $SECTIONS; - // add some labels to client - $RCMAIL->output->add_label('nopagesizewarning'); + // add some labels to client + $RCMAIL->output->add_label('nopagesizewarning'); - unset($attrib['form']); + unset($attrib['form']); - list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs', null, - array('name' => '_section', 'value' => $CURR_SECTION)); + list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs', null, + array('name' => '_section', 'value' => $CURR_SECTION)); - $out = $form_start; + $out = $form_start; - foreach ($SECTIONS[$CURR_SECTION]['blocks'] as $class => $block) { - if (!empty($block['options'])) { - $table = new html_table(array('cols' => 2)); + foreach ($SECTIONS[$CURR_SECTION]['blocks'] as $class => $block) { + if (!empty($block['options'])) { + $table = new html_table(array('cols' => 2)); - foreach ($block['options'] as $option) { - if (isset($option['title'])) { - $table->add('title', $option['title']); - $table->add(null, $option['content']); + foreach ($block['options'] as $option) { + if (isset($option['title'])) { + $table->add('title', $option['title']); + $table->add(null, $option['content']); + } + else { + $table->add(array('colspan' => 2), $option['content']); + } + } + + $out .= html::tag('fieldset', $class, html::tag('legend', null, $block['name']) . $table->show($attrib)); } - else { - $table->add(array('colspan' => 2), $option['content']); + else if (!empty($block['content'])) { + $out .= html::tag('fieldset', null, html::tag('legend', null, $block['name']) . $block['content']); } - } - - $out .= html::tag('fieldset', $class, html::tag('legend', null, $block['name']) . $table->show($attrib)); } - else if (!empty($block['content'])) { - $out .= html::tag('fieldset', null, html::tag('legend', null, $block['name']) . $block['content']); - } - } - return $out . $form_end; + return $out . $form_end; } function rcmail_prefs_section_name() { - global $SECTIONS, $CURR_SECTION; - - return $SECTIONS[$CURR_SECTION]['section']; -} - - -// register UI objects -$OUTPUT->add_handlers(array( - 'userprefs' => 'rcmail_user_prefs_form', - 'sectionname' => 'rcmail_prefs_section_name', -)); - -$OUTPUT->send('settingsedit'); - + global $SECTIONS, $CURR_SECTION; + return $SECTIONS[$CURR_SECTION]['section']; +} diff --git a/program/steps/settings/edit_response.inc b/program/steps/settings/edit_response.inc index 371d7ecc4..760f28290 100644 --- a/program/steps/settings/edit_response.inc +++ b/program/steps/settings/edit_response.inc @@ -70,6 +70,12 @@ if ($RCMAIL->action == 'save-response' && isset($_POST['_name']) && !$RESPONSE_R } } +$OUTPUT->set_env('readonly', !empty($RESPONSE_RECORD['static'])); +$OUTPUT->add_handler('responseform', 'rcube_response_form'); +$OUTPUT->set_pagetitle($RCMAIL->gettext($RCMAIL->action == 'add-response' ? 'savenewresponse' : 'editresponse')); + +$OUTPUT->send('responseedit'); + function rcube_response_form($attrib) { @@ -88,20 +94,15 @@ function rcube_response_form($attrib) $label = $RCMAIL->gettext('responsename'); $table->add('title', html::label('ffname', rcube::Q($RCMAIL->gettext('responsename')))); - $table->add(null, rcube_output::get_edit_field('name', $RESPONSE_RECORD['name'], array('id' => 'ffname', 'size' => $attrib['size'], 'disabled' => $disabled), 'text')); + $table->add(null, rcube_output::get_edit_field('name', $RESPONSE_RECORD['name'], + array('id' => 'ffname', 'size' => $attrib['size'], 'disabled' => $disabled), 'text')); $table->add('title', html::label('fftext', rcube::Q($RCMAIL->gettext('responsetext')))); - $table->add(null, rcube_output::get_edit_field('text', $RESPONSE_RECORD['text'], array('id' => 'fftext', 'size' => $attrib['textareacols'], 'rows' => $attrib['textarearows'], 'disabled' => $disabled), 'textarea')); + $table->add(null, rcube_output::get_edit_field('text', $RESPONSE_RECORD['text'], + array('id' => 'fftext', 'size' => $attrib['textareacols'], 'rows' => $attrib['textarearows'], 'disabled' => $disabled), 'textarea')); $out .= $table->show($attrib); $out .= $form_end; return $out; } - -$OUTPUT->set_env('readonly', !empty($RESPONSE_RECORD['static'])); -$OUTPUT->add_handler('responseform', 'rcube_response_form'); -$OUTPUT->set_pagetitle($RCMAIL->gettext($RCMAIL->action == 'add-response' ? 'savenewresponse' : 'editresponse')); - -$OUTPUT->send('responseedit'); - diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc index 1c249b133..b09ea03ce 100644 --- a/program/steps/settings/folders.inc +++ b/program/steps/settings/folders.inc @@ -378,8 +378,9 @@ function rcmail_folder_frame($attrib) { global $OUTPUT; - if (!$attrib['id']) + if (!$attrib['id']) { $attrib['id'] = 'rcmfolderframe'; + } return $OUTPUT->frame($attrib, true); } @@ -428,4 +429,3 @@ function rcmail_rename_folder($oldname, $newname) return false; } - diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc index c504e6c40..418f8b043 100644 --- a/program/steps/settings/func.inc +++ b/program/steps/settings/func.inc @@ -5,7 +5,7 @@ | program/steps/settings/func.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2012, The Roundcube Dev Team | + | Copyright (C) 2005-2013, The Roundcube Dev Team | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -23,6 +23,30 @@ if (!$OUTPUT->ajax_call) { $OUTPUT->set_pagetitle($RCMAIL->gettext('preferences')); } +// register UI objects +$OUTPUT->add_handlers(array( + 'settingstabs' => 'rcmail_settings_tabs', + 'prefsframe' => 'rcmail_preferences_frame', + 'sectionslist' => 'rcmail_sections_list', + 'identitieslist' => 'rcmail_identities_list', +)); + +// register action aliases +$RCMAIL->register_action_map(array( + 'folders' => 'folders.inc', + 'rename-folder' => 'folders.inc', + 'delete-folder' => 'folders.inc', + 'subscribe' => 'folders.inc', + 'unsubscribe' => 'folders.inc', + 'purge' => 'folders.inc', + 'folder-size' => 'folders.inc', + 'add-identity' => 'edit_identity.inc', + 'add-response' => 'edit_response.inc', + 'save-response' => 'edit_response.inc', + 'delete-response' => 'responses.inc', +)); + + // similar function as /steps/settings/identities.inc::rcmail_identity_frame() function rcmail_preferences_frame($attrib) { @@ -1273,12 +1297,14 @@ function rcmail_update_folder_row($name, $oldname=null, $subscribe=false, $class $display_name = str_repeat(' ', $level) . rcube::Q($protected ? $RCMAIL->localize_foldername($name) : rcube_charset::convert($foldersplit[$level], 'UTF7-IMAP')); - if ($oldname === null) + if ($oldname === null) { $OUTPUT->command('add_folder_row', $name_utf8, $display_name, $protected, $subscribe, false, $class_name); - else + } + else { $OUTPUT->command('replace_folder_row', rcube_charset::convert($oldname, 'UTF7-IMAP'), $name_utf8, $display_name, $protected, $class_name); + } } /** @@ -1295,18 +1321,18 @@ function rcmail_settings_tabs($attrib) array('command' => 'preferences', 'type' => 'link', 'label' => 'preferences', 'title' => 'editpreferences'), array('command' => 'folders', 'type' => 'link', 'label' => 'folders', 'title' => 'managefolders'), array('command' => 'identities', 'type' => 'link', 'label' => 'identities', 'title' => 'manageidentities'), - array('command' => 'responses', 'type' => 'link', 'label' => 'responses', 'title' => 'editresponses'), + array('command' => 'responses', 'type' => 'link', 'label' => 'responses', 'title' => 'editresponses'), ); // get all identites from DB and define list of cols to be displayed $plugin = $RCMAIL->plugins->exec_hook('settings_actions', array( 'actions' => $default_actions, - 'attrib' => $attrib, + 'attrib' => $attrib, )); - $attrib = $plugin['attrib']; + $attrib = $plugin['attrib']; $tagname = $attrib['tagname']; - $tabs = array(); + $tabs = array(); foreach ($plugin['actions'] as $k => $action) { if (!$action['command'] && !$action['href'] && $action['action']) { @@ -1314,13 +1340,15 @@ function rcmail_settings_tabs($attrib) } $button = $OUTPUT->button($action); - $attr = $attrib; + $attr = $attrib; $cmd = $action['action'] ? $action['action'] : $action['command']; - $id = $action['id'] ? $action['id'] : $cmd; + $id = $action['id'] ? $action['id'] : $cmd; + if (!empty($id)) { $attr['id'] = preg_replace('/[^a-z0-9]/i', '', $attrib['idprefix'] . $id); } + $classnames = array($attrib['class']); if (!empty($action['class'])) { $classnames[] = $action['class']; @@ -1331,33 +1359,10 @@ function rcmail_settings_tabs($attrib) if ($RCMAIL->action == $cmd) { $classnames[] = $attrib['selclass']; } + $attr['class'] = join(' ', $classnames); $tabs[] = html::tag($tagname, $attr, $button, html::$common_attrib); } return join('', $tabs); } - - -// register UI objects -$OUTPUT->add_handlers(array( - 'settingstabs' => 'rcmail_settings_tabs', - 'prefsframe' => 'rcmail_preferences_frame', - 'sectionslist' => 'rcmail_sections_list', - 'identitieslist' => 'rcmail_identities_list', -)); - -// register action aliases -$RCMAIL->register_action_map(array( - 'folders' => 'folders.inc', - 'rename-folder' => 'folders.inc', - 'delete-folder' => 'folders.inc', - 'subscribe' => 'folders.inc', - 'unsubscribe' => 'folders.inc', - 'purge' => 'folders.inc', - 'folder-size' => 'folders.inc', - 'add-identity' => 'edit_identity.inc', - 'add-response' => 'edit_response.inc', - 'save-response' => 'edit_response.inc', - 'delete-response' => 'responses.inc', -)); diff --git a/program/steps/settings/identities.inc b/program/steps/settings/identities.inc index 7072acf72..e19c16c79 100644 --- a/program/steps/settings/identities.inc +++ b/program/steps/settings/identities.inc @@ -5,7 +5,7 @@ | program/steps/settings/identities.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2007, The Roundcube Dev Team | + | Copyright (C) 2005-2013, The Roundcube Dev Team | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -24,20 +24,21 @@ define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0))); $OUTPUT->set_pagetitle($RCMAIL->gettext('identities')); $OUTPUT->include_script('list.js'); - -// similar function as /steps/addressbook/func.inc::rcmail_contact_frame() -function rcmail_identity_frame($attrib) - { - global $OUTPUT; - - if (!$attrib['id']) - $attrib['id'] = 'rcmIdentityFrame'; - - return $OUTPUT->frame($attrib, true); - } - $OUTPUT->add_handler('identityframe', 'rcmail_identity_frame'); $OUTPUT->set_env('identities_level', IDENTITIES_LEVEL); $OUTPUT->add_label('deleteidentityconfirm'); $OUTPUT->send('identities'); + + +// similar function as /steps/addressbook/func.inc::rcmail_contact_frame() +function rcmail_identity_frame($attrib) +{ + global $OUTPUT; + + if (!$attrib['id']) { + $attrib['id'] = 'rcmIdentityFrame'; + } + + return $OUTPUT->frame($attrib, true); +} diff --git a/program/steps/settings/responses.inc b/program/steps/settings/responses.inc index 45d1405f7..fcc9c9a10 100644 --- a/program/steps/settings/responses.inc +++ b/program/steps/settings/responses.inc @@ -51,7 +51,6 @@ if (!empty($_POST['_insert'])) { $RCMAIL->output->send(); } - if ($RCMAIL->action == 'delete-response') { if ($key = rcube_utils::get_input_value('_key', rcube_utils::INPUT_GPC)) { $responses = $RCMAIL->get_compose_responses(false, true); @@ -80,6 +79,14 @@ if ($RCMAIL->action == 'delete-response') { $OUTPUT->set_pagetitle($RCMAIL->gettext('responses')); $OUTPUT->include_script('list.js'); +$OUTPUT->add_handlers(array( + 'responseframe' => 'rcmail_response_frame', + 'responseslist' => 'rcmail_responses_list', +)); +$OUTPUT->add_label('deleteresponseconfirm'); + +$OUTPUT->send('responses'); + /** * @@ -105,7 +112,6 @@ function rcmail_responses_list($attrib) return $out; } - // similar function as /steps/addressbook/func.inc::rcmail_contact_frame() function rcmail_response_frame($attrib) { @@ -116,13 +122,6 @@ function rcmail_response_frame($attrib) } $OUTPUT->set_env('contentframe', $attrib['id']); + return $OUTPUT->frame($attrib, true); } - -$OUTPUT->add_handlers(array( - 'responseframe' => 'rcmail_response_frame', - 'responseslist' => 'rcmail_responses_list', -)); -$OUTPUT->add_label('deleteresponseconfirm'); - -$OUTPUT->send('responses'); diff --git a/program/steps/settings/save_folder.inc b/program/steps/settings/save_folder.inc index f876ff8e0..f720735e0 100644 --- a/program/steps/settings/save_folder.inc +++ b/program/steps/settings/save_folder.inc @@ -1,6 +1,6 @@ <?php -/** +/* +-----------------------------------------------------------------------+ | program/steps/settings/save_folder.inc | | | @@ -24,7 +24,6 @@ // init IMAP connection $STORAGE = $RCMAIL->get_storage(); - $name = trim(rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST, true)); $old = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true); $path = rcube_utils::get_input_value('_parent', rcube_utils::INPUT_POST, true); @@ -98,7 +97,6 @@ else { // create a new mailbox if (!$error && !strlen($old)) { - $folder['subscribe'] = true; $plugin = $RCMAIL->plugins->exec_hook('folder_create', array('record' => $folder)); @@ -136,7 +134,6 @@ if (!$error && !strlen($old)) { $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error', null, false); } } - // update a mailbox else if (!$error) { $plugin = $RCMAIL->plugins->exec_hook('folder_update', array('record' => $folder)); diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc index 5bd04003d..1584c5f00 100644 --- a/program/steps/settings/save_identity.inc +++ b/program/steps/settings/save_identity.inc @@ -5,7 +5,7 @@ | program/steps/settings/save_identity.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2009, The Roundcube Dev Team | + | Copyright (C) 2005-2013, The Roundcube Dev Team | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -21,161 +21,173 @@ define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0))); -$a_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'standard', 'signature', 'html_signature'); +$a_save_cols = array('name', 'email', 'organization', 'reply-to', 'bcc', 'standard', 'signature', 'html_signature'); $a_boolean_cols = array('standard', 'html_signature'); $updated = $default_id = false; // check input if (IDENTITIES_LEVEL != 4 && (empty($_POST['_name']) || (empty($_POST['_email']) && IDENTITIES_LEVEL != 1 && IDENTITIES_LEVEL != 3))) { - $OUTPUT->show_message('formincomplete', 'warning'); - $RCMAIL->overwrite_action('edit-identity'); - return; + $OUTPUT->show_message('formincomplete', 'warning'); + $RCMAIL->overwrite_action('edit-identity'); + return; } $save_data = array(); foreach ($a_save_cols as $col) { - $fname = '_'.$col; - if (isset($_POST[$fname])) - $save_data[$col] = rcube_utils::get_input_value($fname, rcube_utils::INPUT_POST, true); + $fname = '_'.$col; + if (isset($_POST[$fname])) { + $save_data[$col] = rcube_utils::get_input_value($fname, rcube_utils::INPUT_POST, true); + } } // set "off" values for checkboxes that were not checked, and therefore // not included in the POST body. foreach ($a_boolean_cols as $col) { - $fname = '_' . $col; - if (!isset($_POST[$fname])) - $save_data[$col] = 0; + $fname = '_' . $col; + if (!isset($_POST[$fname])) { + $save_data[$col] = 0; + } } // unset email address if user has no rights to change it if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3) { - unset($save_data['email']); + unset($save_data['email']); } // unset all fields except signature else if (IDENTITIES_LEVEL == 4) { - foreach ($save_data as $idx => $value) { - if ($idx != 'signature' && $idx != 'html_signature') { - unset($save_data[$idx]); + foreach ($save_data as $idx => $value) { + if ($idx != 'signature' && $idx != 'html_signature') { + unset($save_data[$idx]); + } } - } } // Validate e-mail addresses $email_checks = array(rcube_utils::idn_to_ascii($save_data['email'])); foreach (array('reply-to', 'bcc') as $item) { - foreach (rcube_mime::decode_address_list($save_data[$item], null, false) as $rcpt) - $email_checks[] = rcube_utils::idn_to_ascii($rcpt['mailto']); + foreach (rcube_mime::decode_address_list($save_data[$item], null, false) as $rcpt) { + $email_checks[] = rcube_utils::idn_to_ascii($rcpt['mailto']); + } } foreach ($email_checks as $email) { - if ($email && !rcube_utils::check_email($email)) { - // show error message - $OUTPUT->show_message('emailformaterror', 'error', array('email' => rcube_utils::idn_to_utf8($email)), false); - $RCMAIL->overwrite_action('edit-identity'); - return; - } + if ($email && !rcube_utils::check_email($email)) { + // show error message + $OUTPUT->show_message('emailformaterror', 'error', array('email' => rcube_utils::idn_to_utf8($email)), false); + $RCMAIL->overwrite_action('edit-identity'); + return; + } } // XSS protection in HTML signature (#1489251) if (!empty($save_data['signature']) && !empty($save_data['html_signature'])) { - $save_data['signature'] = rcmail_wash_html($save_data['signature']); + $save_data['signature'] = rcmail_wash_html($save_data['signature']); - // clear POST data of signature, we want to use safe content - // when the form is displayed again - unset($_POST['_signature']); + // clear POST data of signature, we want to use safe content + // when the form is displayed again + unset($_POST['_signature']); } // update an existing contact if ($_POST['_iid']) { - $iid = rcube_utils::get_input_value('_iid', rcube_utils::INPUT_POST); - - if (in_array(IDENTITIES_LEVEL, array(1,3,4))) { - // merge with old identity data, fixes #1488834 - $identity = $RCMAIL->user->get_identity($iid); - $save_data = array_merge($identity, $save_data); - unset($save_data['changed'], $save_data['del'], $save_data['user_id'], $save_data['identity_id']); - } - - $plugin = $RCMAIL->plugins->exec_hook('identity_update', array('id' => $iid, 'record' => $save_data)); - $save_data = $plugin['record']; - - if ($save_data['email']) - $save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']); - if (!$plugin['abort']) - $updated = $RCMAIL->user->update_identity($iid, $save_data); - else - $updated = $plugin['result']; - - if ($updated) { - $OUTPUT->show_message('successfullysaved', 'confirmation'); - - if (!empty($save_data['standard'])) - $default_id = $iid; - - if ($_POST['_framed']) { - // update the changed col in list - $OUTPUT->command('parent.update_identity_row', $iid, rcube::Q(trim($save_data['name'] . ' <' . rcube_utils::idn_to_utf8($save_data['email']) .'>'))); + $iid = rcube_utils::get_input_value('_iid', rcube_utils::INPUT_POST); + + if (in_array(IDENTITIES_LEVEL, array(1,3,4))) { + // merge with old identity data, fixes #1488834 + $identity = $RCMAIL->user->get_identity($iid); + $save_data = array_merge($identity, $save_data); + + unset($save_data['changed'], $save_data['del'], $save_data['user_id'], $save_data['identity_id']); + } + + $plugin = $RCMAIL->plugins->exec_hook('identity_update', array('id' => $iid, 'record' => $save_data)); + $save_data = $plugin['record']; + + if ($save_data['email']) { + $save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']); } - } - else { - // show error message - $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error', null, false); - $RCMAIL->overwrite_action('edit-identity'); - return; - } -} + if (!$plugin['abort']) + $updated = $RCMAIL->user->update_identity($iid, $save_data); + else + $updated = $plugin['result']; + + if ($updated) { + $OUTPUT->show_message('successfullysaved', 'confirmation'); + + if (!empty($save_data['standard'])) { + $default_id = $iid; + } + + if ($_POST['_framed']) { + // update the changed col in list + $name = $save_data['name'] . ' <' . rcube_utils::idn_to_utf8($save_data['email']) .'>'; + $OUTPUT->command('parent.update_identity_row', $iid, rcube::Q(trim($name))); + } + } + else { + // show error message + $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error', null, false); + $RCMAIL->overwrite_action('edit-identity'); + return; + } +} // insert a new identity record else if (IDENTITIES_LEVEL < 2) { - if (IDENTITIES_LEVEL == 1) { - $save_data['email'] = $RCMAIL->get_user_email(); - } + if (IDENTITIES_LEVEL == 1) { + $save_data['email'] = $RCMAIL->get_user_email(); + } - $plugin = $RCMAIL->plugins->exec_hook('identity_create', array('record' => $save_data)); - $save_data = $plugin['record']; + $plugin = $RCMAIL->plugins->exec_hook('identity_create', array('record' => $save_data)); + $save_data = $plugin['record']; - if ($save_data['email']) - $save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']); + if ($save_data['email']) { + $save_data['email'] = rcube_utils::idn_to_ascii($save_data['email']); + } - if (!$plugin['abort']) - $insert_id = $save_data['email'] ? $RCMAIL->user->insert_identity($save_data) : null; - else - $insert_id = $plugin['result']; + if (!$plugin['abort']) + $insert_id = $save_data['email'] ? $RCMAIL->user->insert_identity($save_data) : null; + else + $insert_id = $plugin['result']; - if ($insert_id) { - $OUTPUT->show_message('successfullysaved', 'confirmation', null, false); + if ($insert_id) { + $OUTPUT->show_message('successfullysaved', 'confirmation', null, false); - $_GET['_iid'] = $insert_id; + $_GET['_iid'] = $insert_id; - if (!empty($save_data['standard'])) - $default_id = $insert_id; + if (!empty($save_data['standard'])) { + $default_id = $insert_id; + } - if ($_POST['_framed']) { - // add a new row to the list - $OUTPUT->command('parent.update_identity_row', $insert_id, rcube::Q(trim($save_data['name'] . ' <' . rcube_utils::idn_to_utf8($save_data['email']) .'>')), true); + if ($_POST['_framed']) { + // add a new row to the list + $name = $save_data['name'] . ' <' . rcube_utils::idn_to_utf8($save_data['email']) .'>'; + $OUTPUT->command('parent.update_identity_row', $insert_id, rcube::Q(trim($name)), true); + } + } + else { + // show error message + $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error', null, false); + $RCMAIL->overwrite_action('edit-identity'); + return; } - } - else { - // show error message - $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error', null, false); - $RCMAIL->overwrite_action('edit-identity'); - return; - } } -else - $OUTPUT->show_message('opnotpermitted', 'error'); - +else { + $OUTPUT->show_message('opnotpermitted', 'error'); +} // mark all other identities as 'not-default' -if ($default_id) - $RCMAIL->user->set_default($default_id); +if ($default_id) { + $RCMAIL->user->set_default($default_id); +} // go to next step if (!empty($_REQUEST['_framed'])) { - $RCMAIL->overwrite_action('edit-identity'); + $RCMAIL->overwrite_action('edit-identity'); +} +else { + $RCMAIL->overwrite_action('identities'); } -else - $RCMAIL->overwrite_action('identities'); /** @@ -190,11 +202,11 @@ function rcmail_wash_html($html) // clean HTML with washhtml by Frederic Motte $wash_opts = array( - 'show_washed' => false, - 'allow_remote' => 1, - 'charset' => RCUBE_CHARSET, + 'show_washed' => false, + 'allow_remote' => 1, + 'charset' => RCUBE_CHARSET, 'html_elements' => array('body', 'link'), - 'html_attribs' => array('rel', 'type'), + 'html_attribs' => array('rel', 'type'), ); // initialize HTML washer @@ -211,5 +223,5 @@ function rcmail_wash_html($html) // remove unwanted comments and tags (produced by washtml) $html = preg_replace(array('/<!--[^>]+-->/', '/<\/?body>/'), '', $html); - return $html; + return $html; } diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc index 325c66ae8..f71eee39a 100644 --- a/program/steps/settings/save_prefs.inc +++ b/program/steps/settings/save_prefs.inc @@ -5,7 +5,7 @@ | program/steps/settings/save_prefs.inc | | | | This file is part of the Roundcube Webmail client | - | Copyright (C) 2005-2009, The Roundcube Dev Team | + | Copyright (C) 2005-2013, The Roundcube Dev Team | | | | Licensed under the GNU General Public License version 3 or | | any later version with exceptions for skins & plugins. | @@ -20,190 +20,190 @@ */ $CURR_SECTION = rcube_utils::get_input_value('_section', rcube_utils::INPUT_POST); - $a_user_prefs = array(); // set options for specified section -switch ($CURR_SECTION) -{ - case 'general': +switch ($CURR_SECTION) { +case 'general': $a_user_prefs = array( - 'language' => isset($_POST['_language']) ? rcube_utils::get_input_value('_language', rcube_utils::INPUT_POST) : $CONFIG['language'], - 'timezone' => isset($_POST['_timezone']) ? rcube_utils::get_input_value('_timezone', rcube_utils::INPUT_POST) : $CONFIG['timezone'], - 'date_format' => isset($_POST['_date_format']) ? rcube_utils::get_input_value('_date_format', rcube_utils::INPUT_POST) : $CONFIG['date_format'], - 'time_format' => isset($_POST['_time_format']) ? rcube_utils::get_input_value('_time_format', rcube_utils::INPUT_POST) : ($CONFIG['time_format'] ? $CONFIG['time_format'] : 'H:i'), - 'prettydate' => isset($_POST['_pretty_date']) ? TRUE : FALSE, - 'refresh_interval' => isset($_POST['_refresh_interval']) ? intval($_POST['_refresh_interval'])*60 : $CONFIG['refresh_interval'], - 'standard_windows' => isset($_POST['_standard_windows']) ? TRUE : FALSE, - 'skin' => isset($_POST['_skin']) ? rcube_utils::get_input_value('_skin', rcube_utils::INPUT_POST) : $CONFIG['skin'], + 'language' => isset($_POST['_language']) ? rcube_utils::get_input_value('_language', rcube_utils::INPUT_POST) : $CONFIG['language'], + 'timezone' => isset($_POST['_timezone']) ? rcube_utils::get_input_value('_timezone', rcube_utils::INPUT_POST) : $CONFIG['timezone'], + 'date_format' => isset($_POST['_date_format']) ? rcube_utils::get_input_value('_date_format', rcube_utils::INPUT_POST) : $CONFIG['date_format'], + 'time_format' => isset($_POST['_time_format']) ? rcube_utils::get_input_value('_time_format', rcube_utils::INPUT_POST) : ($CONFIG['time_format'] ? $CONFIG['time_format'] : 'H:i'), + 'prettydate' => isset($_POST['_pretty_date']) ? true : false, + 'refresh_interval' => isset($_POST['_refresh_interval']) ? intval($_POST['_refresh_interval'])*60 : $CONFIG['refresh_interval'], + 'standard_windows' => isset($_POST['_standard_windows']) ? true : false, + 'skin' => isset($_POST['_skin']) ? rcube_utils::get_input_value('_skin', rcube_utils::INPUT_POST) : $CONFIG['skin'], ); // compose derived date/time format strings if ((isset($_POST['_date_format']) || isset($_POST['_time_format'])) && $a_user_prefs['date_format'] && $a_user_prefs['time_format']) { - $a_user_prefs['date_short'] = 'D ' . $a_user_prefs['time_format']; - $a_user_prefs['date_long'] = $a_user_prefs['date_format'] . ' ' . $a_user_prefs['time_format']; + $a_user_prefs['date_short'] = 'D ' . $a_user_prefs['time_format']; + $a_user_prefs['date_long'] = $a_user_prefs['date_format'] . ' ' . $a_user_prefs['time_format']; } - break; + break; - case 'mailbox': +case 'mailbox': $a_user_prefs = array( - 'preview_pane' => isset($_POST['_preview_pane']) ? TRUE : FALSE, - 'preview_pane_mark_read' => isset($_POST['_preview_pane_mark_read']) ? intval($_POST['_preview_pane_mark_read']) : $CONFIG['preview_pane_mark_read'], - 'autoexpand_threads' => isset($_POST['_autoexpand_threads']) ? intval($_POST['_autoexpand_threads']) : 0, - 'mdn_requests' => isset($_POST['_mdn_requests']) ? intval($_POST['_mdn_requests']) : 0, - 'check_all_folders' => isset($_POST['_check_all_folders']) ? TRUE : FALSE, - 'mail_pagesize' => is_numeric($_POST['_mail_pagesize']) ? max(2, intval($_POST['_mail_pagesize'])) : $CONFIG['mail_pagesize'], + 'preview_pane' => isset($_POST['_preview_pane']) ? true : false, + 'preview_pane_mark_read' => isset($_POST['_preview_pane_mark_read']) ? intval($_POST['_preview_pane_mark_read']) : $CONFIG['preview_pane_mark_read'], + 'autoexpand_threads' => isset($_POST['_autoexpand_threads']) ? intval($_POST['_autoexpand_threads']) : 0, + 'mdn_requests' => isset($_POST['_mdn_requests']) ? intval($_POST['_mdn_requests']) : 0, + 'check_all_folders' => isset($_POST['_check_all_folders']) ? true : false, + 'mail_pagesize' => is_numeric($_POST['_mail_pagesize']) ? max(2, intval($_POST['_mail_pagesize'])) : $CONFIG['mail_pagesize'], ); - break; + break; - case 'mailview': +case 'mailview': $a_user_prefs = array( - 'message_extwin' => intval($_POST['_message_extwin']), - 'message_show_email' => isset($_POST['_message_show_email']) ? TRUE : FALSE, - '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, - 'display_next' => isset($_POST['_display_next']) ? TRUE : FALSE, - 'default_charset' => rcube_utils::get_input_value('_default_charset', rcube_utils::INPUT_POST), + 'message_extwin' => intval($_POST['_message_extwin']), + 'message_show_email' => isset($_POST['_message_show_email']) ? true : false, + '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, + 'display_next' => isset($_POST['_display_next']) ? true : false, + 'default_charset' => rcube_utils::get_input_value('_default_charset', rcube_utils::INPUT_POST), ); - break; + break; - case 'compose': +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, - 'force_7bit' => isset($_POST['_force_7bit']) ? TRUE : FALSE, - 'mdn_default' => isset($_POST['_mdn_default']) ? TRUE : FALSE, - 'dsn_default' => isset($_POST['_dsn_default']) ? TRUE : FALSE, - 'reply_same_folder' => isset($_POST['_reply_same_folder']) ? TRUE : FALSE, - 'spellcheck_before_send' => isset($_POST['_spellcheck_before_send']) ? TRUE : FALSE, - 'spellcheck_ignore_syms' => isset($_POST['_spellcheck_ignore_syms']) ? TRUE : FALSE, - 'spellcheck_ignore_nums' => isset($_POST['_spellcheck_ignore_nums']) ? TRUE : FALSE, - 'spellcheck_ignore_caps' => isset($_POST['_spellcheck_ignore_caps']) ? TRUE : FALSE, - 'show_sig' => isset($_POST['_show_sig']) ? intval($_POST['_show_sig']) : 1, - 'reply_mode' => isset($_POST['_reply_mode']) ? intval($_POST['_reply_mode']) : 0, - 'strip_existing_sig' => isset($_POST['_strip_existing_sig']), - 'default_font' => rcube_utils::get_input_value('_default_font', rcube_utils::INPUT_POST), - 'default_font_size' => rcube_utils::get_input_value('_default_font_size', rcube_utils::INPUT_POST), - 'reply_all_mode' => intval($_POST['_reply_all_mode']), - 'forward_attachment' => !empty($_POST['_forward_attachment']), + '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, + 'force_7bit' => isset($_POST['_force_7bit']) ? true : false, + 'mdn_default' => isset($_POST['_mdn_default']) ? true : false, + 'dsn_default' => isset($_POST['_dsn_default']) ? true : false, + 'reply_same_folder' => isset($_POST['_reply_same_folder']) ? true : false, + 'spellcheck_before_send' => isset($_POST['_spellcheck_before_send']) ? true : false, + 'spellcheck_ignore_syms' => isset($_POST['_spellcheck_ignore_syms']) ? true : false, + 'spellcheck_ignore_nums' => isset($_POST['_spellcheck_ignore_nums']) ? true : false, + 'spellcheck_ignore_caps' => isset($_POST['_spellcheck_ignore_caps']) ? true : false, + 'show_sig' => isset($_POST['_show_sig']) ? intval($_POST['_show_sig']) : 1, + 'reply_mode' => isset($_POST['_reply_mode']) ? intval($_POST['_reply_mode']) : 0, + 'strip_existing_sig' => isset($_POST['_strip_existing_sig']), + 'default_font' => rcube_utils::get_input_value('_default_font', rcube_utils::INPUT_POST), + 'default_font_size' => rcube_utils::get_input_value('_default_font_size', rcube_utils::INPUT_POST), + 'reply_all_mode' => intval($_POST['_reply_all_mode']), + 'forward_attachment' => !empty($_POST['_forward_attachment']), ); - break; + break; - case 'addressbook': +case 'addressbook': $a_user_prefs = array( - 'default_addressbook' => rcube_utils::get_input_value('_default_addressbook', rcube_utils::INPUT_POST, true), - 'autocomplete_single' => isset($_POST['_autocomplete_single']) ? TRUE : FALSE, - 'addressbook_sort_col' => rcube_utils::get_input_value('_addressbook_sort_col', rcube_utils::INPUT_POST), - 'addressbook_name_listing' => intval(rcube_utils::get_input_value('_addressbook_name_listing', rcube_utils::INPUT_POST)), - 'addressbook_pagesize' => is_numeric($_POST['_addressbook_pagesize']) ? max(2, intval($_POST['_addressbook_pagesize'])) : $CONFIG['addressbook_pagesize'], + 'default_addressbook' => rcube_utils::get_input_value('_default_addressbook', rcube_utils::INPUT_POST, true), + 'autocomplete_single' => isset($_POST['_autocomplete_single']) ? true : false, + 'addressbook_sort_col' => rcube_utils::get_input_value('_addressbook_sort_col', rcube_utils::INPUT_POST), + 'addressbook_name_listing' => intval(rcube_utils::get_input_value('_addressbook_name_listing', rcube_utils::INPUT_POST)), + 'addressbook_pagesize' => is_numeric($_POST['_addressbook_pagesize']) ? max(2, intval($_POST['_addressbook_pagesize'])) : $CONFIG['addressbook_pagesize'], ); - break; + break; - case 'server': +case 'server': $a_user_prefs = array( - 'read_when_deleted' => isset($_POST['_read_when_deleted']) ? TRUE : FALSE, - 'skip_deleted' => isset($_POST['_skip_deleted']) ? TRUE : FALSE, - 'flag_for_deletion' => isset($_POST['_flag_for_deletion']) ? TRUE : FALSE, - 'delete_always' => isset($_POST['_delete_always']) ? TRUE : FALSE, - 'delete_junk' => isset($_POST['_delete_junk']) ? TRUE : FALSE, - 'logout_purge' => isset($_POST['_logout_purge']) ? TRUE : FALSE, - 'logout_expunge' => isset($_POST['_logout_expunge']) ? TRUE : FALSE, + 'read_when_deleted' => isset($_POST['_read_when_deleted']) ? true : false, + 'skip_deleted' => isset($_POST['_skip_deleted']) ? true : false, + 'flag_for_deletion' => isset($_POST['_flag_for_deletion']) ? true : false, + 'delete_always' => isset($_POST['_delete_always']) ? true : false, + 'delete_junk' => isset($_POST['_delete_junk']) ? true : false, + 'logout_purge' => isset($_POST['_logout_purge']) ? true : false, + 'logout_expunge' => isset($_POST['_logout_expunge']) ? true : false, ); - break; + break; - case 'folders': +case 'folders': $a_user_prefs = array( - 'show_real_foldernames' => - isset($_POST['_show_real_foldernames']) ? TRUE : FALSE, - 'drafts_mbox' => rcube_utils::get_input_value('_drafts_mbox', rcube_utils::INPUT_POST, true), - 'sent_mbox' => rcube_utils::get_input_value('_sent_mbox', rcube_utils::INPUT_POST, true), - 'junk_mbox' => rcube_utils::get_input_value('_junk_mbox', rcube_utils::INPUT_POST, true), - 'trash_mbox' => rcube_utils::get_input_value('_trash_mbox', rcube_utils::INPUT_POST, true), + 'show_real_foldernames' => isset($_POST['_show_real_foldernames']) ? true : false, + 'drafts_mbox' => rcube_utils::get_input_value('_drafts_mbox', rcube_utils::INPUT_POST, true), + 'sent_mbox' => rcube_utils::get_input_value('_sent_mbox', rcube_utils::INPUT_POST, true), + 'junk_mbox' => rcube_utils::get_input_value('_junk_mbox', rcube_utils::INPUT_POST, true), + 'trash_mbox' => rcube_utils::get_input_value('_trash_mbox', rcube_utils::INPUT_POST, true), ); - break; + break; } $plugin = rcmail::get_instance()->plugins->exec_hook('preferences_save', - array('prefs' => $a_user_prefs, 'section' => $CURR_SECTION)); + array('prefs' => $a_user_prefs, 'section' => $CURR_SECTION)); $a_user_prefs = $plugin['prefs']; // don't override these parameters -foreach ((array)$CONFIG['dont_override'] as $p) - $a_user_prefs[$p] = $CONFIG[$p]; +foreach ((array)$CONFIG['dont_override'] as $p) { + $a_user_prefs[$p] = $CONFIG[$p]; +} // verify some options -switch ($CURR_SECTION) -{ - case 'general': - +switch ($CURR_SECTION) { +case 'general': // switch UI language if (isset($_POST['_language']) && $a_user_prefs['language'] != $_SESSION['language']) { - $RCMAIL->load_language($a_user_prefs['language']); - $OUTPUT->command('reload', 500); + $RCMAIL->load_language($a_user_prefs['language']); + $OUTPUT->command('reload', 500); } // switch skin (if valid, otherwise unset the pref and fall back to default) if (!$OUTPUT->set_skin($a_user_prefs['skin'])) - unset($a_user_prefs['skin']); + unset($a_user_prefs['skin']); else if ($RCMAIL->config->get('skin') != $a_user_prefs['skin']) - $OUTPUT->command('reload', 500); + $OUTPUT->command('reload', 500); $a_user_prefs['timezone'] = (string) $a_user_prefs['timezone']; if (!empty($a_user_prefs['refresh_interval']) && !empty($CONFIG['min_refresh_interval'])) { - if ($a_user_prefs['refresh_interval'] < $CONFIG['min_refresh_interval']) { - $a_user_prefs['refresh_interval'] = $CONFIG['min_refresh_interval']; - } + if ($a_user_prefs['refresh_interval'] < $CONFIG['min_refresh_interval']) { + $a_user_prefs['refresh_interval'] = $CONFIG['min_refresh_interval']; + } } break; - case 'mailbox': - +case 'mailbox': // force min size - if ($a_user_prefs['mail_pagesize'] < 1) - $a_user_prefs['mail_pagesize'] = 10; + if ($a_user_prefs['mail_pagesize'] < 1) { + $a_user_prefs['mail_pagesize'] = 10; + } - if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['mail_pagesize'] > $CONFIG['max_pagesize'])) - $a_user_prefs['mail_pagesize'] = (int) $CONFIG['max_pagesize']; + if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['mail_pagesize'] > $CONFIG['max_pagesize'])) { + $a_user_prefs['mail_pagesize'] = (int) $CONFIG['max_pagesize']; + } break; - case 'addressbook': - +case 'addressbook': // force min size - if ($a_user_prefs['addressbook_pagesize'] < 1) - $a_user_prefs['addressbook_pagesize'] = 10; + if ($a_user_prefs['addressbook_pagesize'] < 1) { + $a_user_prefs['addressbook_pagesize'] = 10; + } - if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['addressbook_pagesize'] > $CONFIG['max_pagesize'])) - $a_user_prefs['addressbook_pagesize'] = (int) $CONFIG['max_pagesize']; + if (isset($CONFIG['max_pagesize']) && ($a_user_prefs['addressbook_pagesize'] > $CONFIG['max_pagesize'])) { + $a_user_prefs['addressbook_pagesize'] = (int) $CONFIG['max_pagesize']; + } break; - case 'folders': - +case 'folders': // special handling for 'default_folders' if (in_array('default_folders', (array)$CONFIG['dont_override'])) { - foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) - $a_user_prefs[$p] = $CONFIG[$p]; - } else { - $a_user_prefs['default_folders'] = array('INBOX'); - foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) { - if ($a_user_prefs[$p]) - $a_user_prefs['default_folders'][] = $a_user_prefs[$p]; - } + foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) { + $a_user_prefs[$p] = $CONFIG[$p]; + } + } + else { + $a_user_prefs['default_folders'] = array('INBOX'); + foreach (array('drafts_mbox','sent_mbox','junk_mbox','trash_mbox') as $p) { + if ($a_user_prefs[$p]) { + $a_user_prefs['default_folders'][] = $a_user_prefs[$p]; + } + } } break; @@ -211,14 +211,14 @@ switch ($CURR_SECTION) // Save preferences if (!$plugin['abort']) - $saved = $RCMAIL->user->save_prefs($a_user_prefs); + $saved = $RCMAIL->user->save_prefs($a_user_prefs); else - $saved = $plugin['result']; + $saved = $plugin['result']; if ($saved) - $OUTPUT->show_message('successfullysaved', 'confirmation'); + $OUTPUT->show_message('successfullysaved', 'confirmation'); else - $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error'); + $OUTPUT->show_message($plugin['message'] ? $plugin['message'] : 'errorsaving', 'error'); // display the form again $RCMAIL->overwrite_action('edit-prefs'); |