summaryrefslogtreecommitdiff
path: root/program/steps/settings
diff options
context:
space:
mode:
authorCyrill von Wattenwyl <cvw@adfinis.com>2014-09-02 11:20:52 +0200
committerCyrill von Wattenwyl <cvw@adfinis.com>2014-09-02 11:20:52 +0200
commit11a40dd1fef6c5b78b054617caba4325f95ee386 (patch)
treede2e1d7efd6423ef4d1256dd5c90a972ad172719 /program/steps/settings
parent187fd666aa2f32dedfe544d69b7cb213698197f2 (diff)
parentba084313bfc9c7a5a83e0611fe4376543cc1653d (diff)
Merge branch 'master' of https://github.com/roundcube/roundcubemail
Conflicts: plugins/password/config.inc.php.dist
Diffstat (limited to 'program/steps/settings')
-rw-r--r--program/steps/settings/about.inc6
-rw-r--r--program/steps/settings/delete_identity.inc55
-rw-r--r--program/steps/settings/edit_folder.inc49
-rw-r--r--program/steps/settings/edit_identity.inc16
-rw-r--r--program/steps/settings/edit_response.inc2
-rw-r--r--program/steps/settings/folders.inc198
-rw-r--r--program/steps/settings/func.inc35
-rw-r--r--program/steps/settings/identities.inc22
-rw-r--r--program/steps/settings/responses.inc10
-rw-r--r--program/steps/settings/save_folder.inc25
-rw-r--r--program/steps/settings/save_identity.inc34
-rw-r--r--program/steps/settings/save_prefs.inc1
-rw-r--r--program/steps/settings/upload.inc144
13 files changed, 425 insertions, 172 deletions
diff --git a/program/steps/settings/about.inc b/program/steps/settings/about.inc
index 026bfc1a2..73d0b0f0d 100644
--- a/program/steps/settings/about.inc
+++ b/program/steps/settings/about.inc
@@ -50,7 +50,7 @@ function rcmail_plugins_list($attrib)
$attrib['id'] = 'rcmpluginlist';
}
- $plugins = array_filter((array) $RCMAIL->config->get('plugins'));
+ $plugins = array_filter($RCMAIL->plugins->active_plugins);
$plugin_info = array();
foreach ($plugins as $name) {
@@ -61,8 +61,8 @@ function rcmail_plugins_list($attrib)
// 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 (is_array($info['require']) && !empty($info['require'])) {
+ foreach ($info['require'] as $req_name) {
if (!isset($plugin_info[$req_name]) && ($req_info = $RCMAIL->plugins->get_info($req_name))) {
$plugin_info[$req_name] = $req_info;
}
diff --git a/program/steps/settings/delete_identity.inc b/program/steps/settings/delete_identity.inc
deleted file mode 100644
index f77620438..000000000
--- a/program/steps/settings/delete_identity.inc
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-/*
- +-----------------------------------------------------------------------+
- | program/steps/settings/delete_identity.inc |
- | |
- | This file is part of the Roundcube Webmail client |
- | 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. |
- | See the README file for a full license statement. |
- | |
- | PURPOSE: |
- | Delete the submitted identities (IIDs) from the database |
- | |
- +-----------------------------------------------------------------------+
- | Author: Thomas Bruederli <roundcube@gmail.com> |
- +-----------------------------------------------------------------------+
-*/
-
-$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;
-}
-
-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'];
-
- 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();
- }
-}
-
-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 6b7bd08d2..202578676 100644
--- a/program/steps/settings/edit_folder.inc
+++ b/program/steps/settings/edit_folder.inc
@@ -38,22 +38,20 @@ function rcmail_folder_form($attrib)
$storage = $RCMAIL->get_storage();
// edited folder name (empty in create-folder mode)
- $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true);
- $mbox_imap = rcube_charset::convert($mbox, RCUBE_CHARSET, 'UTF7-IMAP');
+ $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_GPC, true);
// predefined path for new folder
- $parent = rcube_utils::get_input_value('_path', rcube_utils::INPUT_GPC, true);
- $parent_imap = rcube_charset::convert($parent, RCUBE_CHARSET, 'UTF7-IMAP');
+ $parent = rcube_utils::get_input_value('_path', rcube_utils::INPUT_GPC, true);
$threading_supported = $storage->get_capability('THREAD');
$delimiter = $storage->get_hierarchy_delimiter();
// Get mailbox parameters
if (strlen($mbox)) {
- $options = rcmail_folder_options($mbox_imap);
+ $options = rcmail_folder_options($mbox);
$namespace = $storage->get_namespace();
- $path = explode($delimiter, $mbox_imap);
+ $path = explode($delimiter, $mbox);
$folder = array_pop($path);
$path = implode($delimiter, $path);
$folder = rcube_charset::convert($folder, 'UTF7-IMAP');
@@ -62,7 +60,7 @@ function rcmail_folder_form($attrib)
}
else {
$options = array();
- $path = $parent_imap;
+ $path = $parent;
// allow creating subfolders of INBOX folder
if ($path == 'INBOX') {
@@ -88,7 +86,7 @@ function rcmail_folder_form($attrib)
// Location (name)
if ($options['protected']) {
- $foldername = str_replace($delimiter, ' &raquo; ', rcube::Q($RCMAIL->localize_folderpath($mbox_imap)));
+ $foldername = str_replace($delimiter, ' &raquo; ', rcube::Q($RCMAIL->localize_folderpath($mbox)));
}
else if ($options['norename']) {
$foldername = rcube::Q($folder);
@@ -101,7 +99,7 @@ function rcmail_folder_form($attrib)
$foldername = $foldername->show($folder);
if ($options['special']) {
- $foldername .= '&nbsp;(' . rcube::Q($RCMAIL->localize_foldername($mbox_imap)) .')';
+ $foldername .= '&nbsp;(' . rcube::Q($RCMAIL->localize_foldername($mbox)) .')';
}
}
@@ -122,7 +120,7 @@ function rcmail_folder_form($attrib)
}
else {
$selected = isset($_POST['_parent']) ? $_POST['_parent'] : $path_id;
- $exceptions = array($mbox_imap);
+ $exceptions = array($mbox);
// Exclude 'prefix' namespace from parent folders list (#1488349)
// If INBOX. namespace exists, folders created as INBOX subfolders
@@ -132,9 +130,9 @@ function rcmail_folder_form($attrib)
}
$select = $RCMAIL->folder_selector(array(
+ 'id' => '_parent',
'name' => '_parent',
'noselection' => '---',
- 'realnames' => false,
'maxlength' => 150,
'unsubscribed' => true,
'skip_noinferiors' => true,
@@ -154,17 +152,19 @@ function rcmail_folder_form($attrib)
);
// Settings: threading
- if ($threading_supported && ($mbox_imap == 'INBOX' || (!$options['noselect'] && !$options['is_root']))) {
- $select = new html_select(array('name' => '_viewmode', 'id' => '_listmode'));
+ if ($threading_supported && ($mbox == 'INBOX' || (!$options['noselect'] && !$options['is_root']))) {
+ $select = new html_select(array('name' => '_viewmode', 'id' => '_viewmode'));
$select->add($RCMAIL->gettext('list'), 0);
$select->add($RCMAIL->gettext('threads'), 1);
if (isset($_POST['_viewmode'])) {
$value = (int) $_POST['_viewmode'];
}
- else if (strlen($mbox_imap)) {
- $a_threaded = $RCMAIL->config->get('message_threading', array());
- $value = (int) isset($a_threaded[$mbox_imap]);
+ else if (strlen($mbox)) {
+ $a_threaded = $RCMAIL->config->get('message_threading', array());
+ $default_mode = $RCMAIL->config->get('default_list_mode', 'list');
+
+ $value = (int) (isset($a_threaded[$mbox]) ? $a_threaded[$mbox] : $default_mode == 'threads');
}
$form['props']['fieldsets']['settings']['content']['viewmode'] = array(
@@ -211,14 +211,14 @@ function rcmail_folder_form($attrib)
'content' => array()
);
- if ((!$options['noselect'] && !$options['is_root']) || $mbox_imap == 'INBOX') {
- $msgcount = $storage->count($mbox_imap, 'ALL', true, false);
+ if ((!$options['noselect'] && !$options['is_root']) || $mbox == 'INBOX') {
+ $msgcount = $storage->count($mbox, 'ALL', true, false);
// Size
if ($msgcount) {
// create link with folder-size command
$onclick = sprintf("return %s.command('folder-size', '%s', this)",
- rcmail_output::JS_OBJECT_NAME, rcube::JQ($mbox_imap));
+ rcmail_output::JS_OBJECT_NAME, rcube::JQ($mbox));
$size = html::a(array('href' => '#', 'onclick' => $onclick,
'id' => 'folder-size'), $RCMAIL->gettext('getfoldersize'));
}
@@ -248,7 +248,7 @@ function rcmail_folder_form($attrib)
// Allow plugins to modify folder form content
$plugin = $RCMAIL->plugins->exec_hook('folder_form',
array('form' => $form, 'options' => $options,
- 'name' => $mbox_imap, 'parent_name' => $parent_imap));
+ 'name' => $mbox, 'parent_name' => $parent));
$form = $plugin['form'];
@@ -261,7 +261,7 @@ function rcmail_folder_form($attrib)
$out = "$form_start\n";
// Create form output
- foreach ($form as $tab) {
+ foreach ($form as $idx => $tab) {
if (!empty($tab['fieldsets']) && is_array($tab['fieldsets'])) {
$content = '';
foreach ($tab['fieldsets'] as $fieldset) {
@@ -276,7 +276,7 @@ function rcmail_folder_form($attrib)
$content = rcmail_get_form_part($tab, $attrib);
}
- if ($content && sizeof($form) > 1) {
+ if ($idx != 'props') {
$out .= html::tag('fieldset', null, html::tag('legend', null, rcube::Q($tab['name'])) . $content) ."\n";
}
else {
@@ -287,6 +287,11 @@ function rcmail_folder_form($attrib)
$out .= "\n$form_end";
$RCMAIL->output->set_env('messagecount', (int) $msgcount);
+ $RCMAIL->output->set_env('folder', $mbox);
+
+ if ($mbox !== null && empty($_POST)) {
+ $RCMAIL->output->command('parent.set_quota', $RCMAIL->quota_content(null, $mbox));
+ }
return $out;
}
diff --git a/program/steps/settings/edit_identity.inc b/program/steps/settings/edit_identity.inc
index 3f7b6a58a..cd7ba5fa6 100644
--- a/program/steps/settings/edit_identity.inc
+++ b/program/steps/settings/edit_identity.inc
@@ -52,9 +52,9 @@ else {
$OUTPUT->include_script('list.js');
$OUTPUT->add_handler('identityform', 'rcube_identity_form');
$OUTPUT->set_env('identities_level', IDENTITIES_LEVEL);
-$OUTPUT->add_label('deleteidentityconfirm');
+$OUTPUT->add_label('deleteidentityconfirm', 'uploading');
-$OUTPUT->set_pagetitle($RCMAIL->gettext(($RCMAIL->action == 'add-identity' ? 'newidentity' : 'edititem')));
+$OUTPUT->set_pagetitle($RCMAIL->gettext(($RCMAIL->action == 'add-identity' ? 'addidentity' : 'editidentity')));
if ($RCMAIL->action == 'add-identity' && $OUTPUT->template_exists('identityadd')) {
$OUTPUT->send('identityadd');
@@ -96,7 +96,7 @@ function rcube_identity_form($attrib)
'spellcheck' => true),
'html_signature' => array('type' => 'checkbox',
'label' => $RCMAIL->gettext('htmlsignature'),
- 'onclick' => 'return rcmail_toggle_editor(this, \'rcmfd_signature\');'),
+ 'onclick' => 'return rcmail.command(\'toggle-editor\', {id: \'rcmfd_signature\', html: this.checked}, \'\', event)'),
))
);
@@ -176,5 +176,15 @@ function rcube_identity_form($attrib)
$out .= $form_end;
+ // add image upload form
+ $max_filesize = $RCMAIL->upload_init($RCMAIL->config->get('identity_image_size', 64) * 1024);
+ $upload_form_id = 'identityImageUpload';
+
+ $out .= '<form id="' . $upload_form_id . '" style="display: none">'
+ . html::div('hint', $RCMAIL->gettext(array('name' => 'maxuploadsize', 'vars' => array('size' => $max_filesize))))
+ . '</form>';
+
+ $RCMAIL->output->add_gui_object('uploadform', $upload_form_id);
+
return $out;
}
diff --git a/program/steps/settings/edit_response.inc b/program/steps/settings/edit_response.inc
index 6d3c3dc41..10dec1096 100644
--- a/program/steps/settings/edit_response.inc
+++ b/program/steps/settings/edit_response.inc
@@ -72,7 +72,7 @@ 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->set_pagetitle($RCMAIL->gettext($RCMAIL->action == 'add-response' ? 'addresponse' : 'editresponse'));
$OUTPUT->send('responseedit');
diff --git a/program/steps/settings/folders.inc b/program/steps/settings/folders.inc
index 1bcfb4cfc..14e41d607 100644
--- a/program/steps/settings/folders.inc
+++ b/program/steps/settings/folders.inc
@@ -20,14 +20,12 @@
+-----------------------------------------------------------------------+
*/
-// WARNING: folder names in UI are encoded with RCUBE_CHARSET
-
// init IMAP connection
$STORAGE = $RCMAIL->get_storage();
// subscribe mailbox
if ($RCMAIL->action == 'subscribe') {
- $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true, 'UTF7-IMAP');
+ $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
if (strlen($mbox)) {
$result = $STORAGE->subscribe(array($mbox));
@@ -58,7 +56,8 @@ if ($RCMAIL->action == 'subscribe') {
}
// unsubscribe mailbox
else if ($RCMAIL->action == 'unsubscribe') {
- $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true, 'UTF7-IMAP');
+ $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
+
if (strlen($mbox)) {
$result = $STORAGE->unsubscribe(array($mbox));
if ($result)
@@ -69,8 +68,7 @@ else if ($RCMAIL->action == 'unsubscribe') {
}
// delete an existing mailbox
else if ($RCMAIL->action == 'delete-folder') {
- $mbox_utf8 = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
- $mbox = rcube_charset::convert($mbox_utf8, RCUBE_CHARSET, 'UTF7-IMAP');
+ $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
if (strlen($mbox)) {
$plugin = $RCMAIL->plugins->exec_hook('folder_delete', array('name' => $mbox));
@@ -90,7 +88,7 @@ else if ($RCMAIL->action == 'delete-folder') {
if ($OUTPUT->ajax_call && $deleted) {
// Remove folder and subfolders rows
- $OUTPUT->command('remove_folder_row', $mbox_utf8, true);
+ $OUTPUT->command('remove_folder_row', $mbox);
$OUTPUT->show_message('folderdeleted', 'confirmation');
// Clear content frame
$OUTPUT->command('subscription_select');
@@ -102,13 +100,10 @@ else if ($RCMAIL->action == 'delete-folder') {
}
// rename an existing mailbox
else if ($RCMAIL->action == 'rename-folder') {
- $name_utf8 = trim(rcube_utils::get_input_value('_folder_newname', rcube_utils::INPUT_POST, true));
- $oldname_utf8 = rcube_utils::get_input_value('_folder_oldname', rcube_utils::INPUT_POST, true);
-
- if (strlen($name_utf8) && strlen($oldname_utf8)) {
- $name = rcube_charset::convert($name_utf8, RCUBE_CHARSET, 'UTF7-IMAP');
- $oldname = rcube_charset::convert($oldname_utf8, RCUBE_CHARSET, 'UTF7-IMAP');
+ $name = trim(rcube_utils::get_input_value('_folder_newname', rcube_utils::INPUT_POST, true));
+ $oldname = rcube_utils::get_input_value('_folder_oldname', rcube_utils::INPUT_POST, true);
+ if (strlen($name) && strlen($oldname)) {
$rename = rcmail_rename_folder($oldname, $name);
}
@@ -121,8 +116,7 @@ else if ($RCMAIL->action == 'rename-folder') {
}
// clear mailbox
else if ($RCMAIL->action == 'purge') {
- $mbox_utf8 = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
- $mbox = rcube_charset::convert($mbox_utf8, RCUBE_CHARSET, 'UTF7-IMAP');
+ $mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
$delimiter = $STORAGE->get_hierarchy_delimiter();
$trash_mbox = $RCMAIL->config->get('trash_mbox');
$trash_regexp = '/^' . preg_quote($trash . $delimiter, '/') . '/';
@@ -134,7 +128,7 @@ else if ($RCMAIL->action == 'purge') {
$success = $STORAGE->delete_message('*', $mbox);
$delete = true;
}
- // copy to Trash
+ // move to Trash
else {
$success = $STORAGE->move_message('1:*', $trash_mbox, $mbox);
$delete = false;
@@ -144,13 +138,13 @@ else if ($RCMAIL->action == 'purge') {
$OUTPUT->set_env('messagecount', 0);
if ($delete) {
$OUTPUT->show_message('folderpurged', 'confirmation');
- $OUTPUT->command('set_quota', $RCMAIL->quota_content());
+ $OUTPUT->command('set_quota', $RCMAIL->quota_content(null, $mbox));
}
else {
$OUTPUT->show_message('messagemoved', 'confirmation');
}
$_SESSION['unseen_count'][$mbox] = 0;
- $OUTPUT->command('show_folder', $mbox_utf8, null, true);
+ $OUTPUT->command('show_folder', $mbox, null, true);
}
else {
$RCMAIL->display_server_error('errorsaving');
@@ -177,11 +171,9 @@ if ($OUTPUT->ajax_call) {
}
$OUTPUT->set_pagetitle($RCMAIL->gettext('folders'));
-$OUTPUT->include_script('list.js');
$OUTPUT->set_env('prefix_ns', $STORAGE->get_namespace('prefix'));
-if ($STORAGE->get_capability('QUOTA')) {
- $OUTPUT->set_env('quota', true);
-}
+$OUTPUT->set_env('quota', (bool) $STORAGE->get_capability('QUOTA'));
+$OUTPUT->include_script('treelist.js');
// add some labels to client
$OUTPUT->add_label('deletefolderconfirm', 'purgefolderconfirm', 'folderdeleting',
@@ -189,8 +181,9 @@ $OUTPUT->add_label('deletefolderconfirm', 'purgefolderconfirm', 'folderdeleting'
// register UI objects
$OUTPUT->add_handlers(array(
- 'foldersubscription' => 'rcube_subscription_form',
+ 'foldersubscription' => 'rcmail_subscription_form',
'folderframe' => 'rcmail_folder_frame',
+ 'folderfilter' => 'rcmail_folder_filter',
'quotadisplay' => array($RCMAIL, 'quota_display'),
));
@@ -198,22 +191,15 @@ $OUTPUT->send('folders');
// build table with all folders listed by server
-function rcube_subscription_form($attrib)
+function rcmail_subscription_form($attrib)
{
global $RCMAIL, $OUTPUT;
list($form_start, $form_end) = get_form_tags($attrib, 'folders');
unset($attrib['form']);
- if (!$attrib['id'])
+ if (!$attrib['id']) {
$attrib['id'] = 'rcmSubscriptionlist';
-
- $table = new html_table();
-
- if ($attrib['noheader'] !== true && $attrib['noheader'] != "true") {
- // add table header
- $table->add_header('name', $RCMAIL->gettext('foldername'));
- $table->add_header('subscribed', '');
}
$STORAGE = $RCMAIL->get_storage();
@@ -227,7 +213,6 @@ function rcube_subscription_form($attrib)
$namespace = $STORAGE->get_namespace();
$special_folders = array_flip(array_merge(array('inbox' => 'INBOX'), $STORAGE->get_special_folders()));
$protect_default = $RCMAIL->config->get('protect_default_folders');
- $a_js_folders = array();
$seen = array();
$list_folders = array();
@@ -272,19 +257,16 @@ function rcube_subscription_form($attrib)
unset($seen);
- // add drop-target representing 'root'
- $table->add_row(array('id' => 'mailboxroot', 'class' => 'virtual root'));
- $table->add('name', '&nbsp;');
- $table->add(null, '&nbsp;');
-
- $a_js_folders['mailboxroot'] = array('', '', true);
-
$checkbox_subscribe = new html_checkbox(array(
'name' => '_subscribed[]',
'title' => $RCMAIL->gettext('changesubscription'),
'onclick' => rcmail_output::JS_OBJECT_NAME.".command(this.checked?'subscribe':'unsubscribe',this.value)",
));
+ $js_folders = array();
+ $folders = array();
+ $collapsed = $RCMAIL->config->get('collapsed_folders');
+
// create list of available folders
foreach ($list_folders as $i => $folder) {
$idx = $i + 1;
@@ -292,11 +274,10 @@ function rcube_subscription_form($attrib)
$subscribed = $sub_key !== false;
$protected = $protect_default && isset($special_folders[$folder['id']]);
$noselect = false;
- $classes = array($i%2 ? 'even' : 'odd');
+ $classes = array();
$folder_utf8 = rcube_charset::convert($folder['id'], 'UTF7-IMAP');
- $display_folder = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $folder['level'])
- . rcube::Q($protected ? $RCMAIL->localize_foldername($folder['id']) : $folder['name']);
+ $display_folder = rcube::Q($protected ? $RCMAIL->localize_foldername($folder['id']) : $folder['name']);
if ($folder['virtual']) {
$classes[] = 'virtual';
@@ -352,25 +333,85 @@ function rcube_subscription_form($attrib)
}
}
- $table->add_row(array('id' => 'rcmrow'.$idx, 'class' => join(' ', $classes),
- 'foldername' => $folder['id']));
+ $is_collapsed = strpos($collapsed, '&'.rawurlencode($folder['id']).'&') !== false;
+ $folder_id = rcube_utils::html_identifier($folder['id'], true);
- $table->add('name', $display_folder);
- $table->add('subscribed', $checkbox_subscribe->show(($subscribed ? $folder_utf8 : ''),
- array('value' => $folder_utf8, 'disabled' => $disabled ? 'disabled' : '')));
+ if ($folder_class = $RCMAIL->folder_classname($folder['id'])) {
+ $classes[] = $folder_class;
+ }
- $a_js_folders['rcmrow'.$idx] = array($folder_utf8,
- $display_folder, $protected || $folder['virtual']);
+ $folders[$folder['id']] = array(
+ 'idx' => $folder_id,
+ 'folder_imap' => $folder['id'],
+ 'folder' => $folder_utf8,
+ 'display' => $display_folder,
+ 'protected' => $protected || $folder['virtual'],
+ 'class' => join(' ', $classes),
+ 'subscribed' => $subscribed,
+ 'level' => $folder['level'],
+ 'collapsed' => $is_collapsed,
+ 'content' => html::a(array('href' => '#'), $display_folder)
+ . $checkbox_subscribe->show(($subscribed ? $folder['id'] : ''),
+ array('value' => $folder['id'], 'disabled' => $disabled ? 'disabled' : ''))
+ );
}
- $RCMAIL->plugins->exec_hook('folders_list', array('table' => $table));
+ $plugin = $RCMAIL->plugins->exec_hook('folders_list', array('list' => $folders));
+
+ // add drop-target representing 'root'
+ $root = array(
+ 'idx' => rcube_utils::html_identifier('*', true),
+ 'folder_imap' => '*',
+ 'folder' => '',
+ 'display' => '',
+ 'protected' => true,
+ 'class' => 'root',
+ 'content' => '<span>&nbsp;</span>',
+ );
+
+ $folders = array();
+ $plugin['list'] = array_values($plugin['list']);
+
+ array_unshift($plugin['list'], $root);
+
+ for ($i = 0, $length = count($plugin['list']); $i<$length; $i++) {
+ $folders[] = rcmail_folder_tree_element($plugin['list'], $i, $js_folders);
+ }
$OUTPUT->add_gui_object('subscriptionlist', $attrib['id']);
- $OUTPUT->set_env('subscriptionrows', $a_js_folders);
+ $OUTPUT->set_env('subscriptionrows', $js_folders);
$OUTPUT->set_env('defaultfolders', array_keys($special_folders));
+ $OUTPUT->set_env('collapsed_folders', $collapsed);
$OUTPUT->set_env('delimiter', $delimiter);
- return $form_start . $table->show($attrib) . $form_end;
+ return $form_start . html::tag('ul', $attrib, implode('', $folders), html::$common_attrib) . $form_end;
+}
+
+function rcmail_folder_tree_element($folders, &$key, &$js_folders)
+{
+ $data = $folders[$key];
+ $idx = 'rcmli' . $data['idx'];
+
+ $js_folders[$data['folder_imap']] = array($data['folder'], $data['display'], $data['protected']);
+ $content = $data['content'];
+ $attribs = array(
+ 'id' => $idx,
+ 'class' => trim($data['class'] . ' mailbox')
+ );
+
+ $children = array();
+ while ($folders[$key+1] && $folders[$key+1]['level'] > $data['level']) {
+ $key++;
+ $children[] = rcmail_folder_tree_element($folders, $key, $js_folders);
+ }
+
+ if (!empty($children)) {
+ $content .= html::div('treetoggle ' . ($data['collapsed'] ? 'collapsed' : 'expanded'), '&nbsp;')
+ . html::tag('ul', array('style' => ($data['collapsed'] ? "display:none" : null)),
+ implode("\n", $children));
+ }
+
+ return html::tag('li', $attribs, $content);
}
function rcmail_folder_frame($attrib)
@@ -384,6 +425,50 @@ function rcmail_folder_frame($attrib)
return $OUTPUT->frame($attrib, true);
}
+function rcmail_folder_filter($attrib)
+{
+ global $RCMAIL;
+
+ $storage = $RCMAIL->get_storage();
+ $namespace = $storage->get_namespace();
+
+ if (empty($namespace['personal']) && empty($namespace['shared']) && empty($namespace['other'])) {
+ return '';
+ }
+
+ if (!$attrib['id']) {
+ $attrib['id'] = 'rcmfolderfilter';
+ }
+
+ $attrib['onchange'] = rcmail_output::JS_OBJECT_NAME . '.folder_filter(this.value)';
+
+ $roots = array();
+ $select = new html_select($attrib);
+ $select->add($RCMAIL->gettext('all'), '---');
+
+ foreach (array_keys($namespace) as $type) {
+ foreach ((array)$namespace[$type] as $ns) {
+ $root = rtrim($ns[0], $ns[1]);
+ $label = $RCMAIL->gettext('namespace.' . $type);
+
+ if (count($namespace[$type]) > 1) {
+ $label .= ' (' . rcube_charset::convert($root, 'UTF7-IMAP', RCUBE_CHARSET) . ')';
+ }
+
+ $select->add($label, $root);
+
+ if (strlen($root)) {
+ $roots[] = $root;
+ }
+ }
+ }
+
+ $RCMAIL->output->add_gui_object('foldersfilter', $attrib['id']);
+ $RCMAIL->output->set_env('ns_roots', $roots);
+
+ return $select->show();
+}
+
function rcmail_rename_folder($oldname, $newname)
{
global $RCMAIL;
@@ -406,16 +491,17 @@ function rcmail_rename_folder($oldname, $newname)
$a_threaded = (array) $RCMAIL->config->get('message_threading', array());
$oldprefix = '/^' . preg_quote($oldname . $delimiter, '/') . '/';
- foreach (array_keys($a_threaded) as $key) {
+ foreach ($a_threaded as $key => $val) {
if ($key == $oldname) {
unset($a_threaded[$key]);
- $a_threaded[$newname] = true;
+ $a_threaded[$newname] = $val;
}
else if (preg_match($oldprefix, $key)) {
unset($a_threaded[$key]);
- $a_threaded[preg_replace($oldprefix, $newname.$delimiter, $key)] = true;
+ $a_threaded[preg_replace($oldprefix, $newname.$delimiter, $key)] = $val;
}
}
+
$RCMAIL->user->save_prefs(array('message_threading' => $a_threaded));
// #1488692: update session
diff --git a/program/steps/settings/func.inc b/program/steps/settings/func.inc
index 4b4575f10..0b2039a78 100644
--- a/program/steps/settings/func.inc
+++ b/program/steps/settings/func.inc
@@ -44,6 +44,8 @@ $RCMAIL->register_action_map(array(
'add-response' => 'edit_response.inc',
'save-response' => 'edit_response.inc',
'delete-response' => 'responses.inc',
+ 'delete-identity' => 'identities.inc',
+ 'upload-display' => 'upload.inc',
));
@@ -343,7 +345,7 @@ function rcmail_user_prefs($current = null)
if (is_array($meta) && $meta['name']) {
$skinname = $meta['name'];
$author_link = $meta['url'] ? html::a(array('href' => $meta['url'], 'target' => '_blank'), rcube::Q($meta['author'])) : rcube::Q($meta['author']);
- $license_link = $meta['license-url'] ? html::a(array('href' => $meta['license-url'], 'target' => '_blank'), rcube::Q($meta['license'])) : rcube::Q($meta['license']);
+ $license_link = $meta['license-url'] ? html::a(array('href' => $meta['license-url'], 'target' => '_blank', 'tabindex' => '-1'), rcube::Q($meta['license'])) : rcube::Q($meta['license']);
}
$skinnames[] = mb_strtolower($skinname);
@@ -916,6 +918,20 @@ function rcmail_user_prefs($current = null)
);
}
+ if (!isset($no_override['compose_save_localstorage'])) {
+ if (!$current) {
+ continue 2;
+ }
+
+ $field_id = 'rcmfd_compose_save_localstorage';
+ $input = new html_checkbox(array('name' => '_compose_save_localstorage', 'id' => $field_id, 'value' => 1));
+
+ $blocks['advanced']['options']['compose_save_localstorage'] = array(
+ 'title' => html::label($field_id, rcube::Q($RCMAIL->gettext('savelocalstorage'))),
+ 'content' => $input->show($config['compose_save_localstorage']?1:0),
+ );
+ }
+
break;
// Addressbook config
@@ -1300,21 +1316,20 @@ function rcmail_update_folder_row($name, $oldname=null, $subscribe=false, $class
$protect_folders = $RCMAIL->config->get('protect_default_folders');
$storage = $RCMAIL->get_storage();
$delimiter = $storage->get_hierarchy_delimiter();
- $name_utf8 = rcube_charset::convert($name, 'UTF7-IMAP');
- $protected = $protect_folders && $storage->is_special_folder($name);
+ $name_utf8 = rcube_charset::convert($name, 'UTF7-IMAP');
+ $protected = $protect_folders && $storage->is_special_folder($name);
$foldersplit = explode($delimiter, $storage->mod_folder($name));
$level = count($foldersplit) - 1;
- $display_name = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level)
- . rcube::Q($protected ? $RCMAIL->localize_foldername($name) : rcube_charset::convert($foldersplit[$level], 'UTF7-IMAP'));
+ $display_name = $protected ? $RCMAIL->localize_foldername($name) : rcube_charset::convert($foldersplit[$level], 'UTF7-IMAP');
+ $class_name = trim($class_name . ' mailbox');
if ($oldname === null) {
- $OUTPUT->command('add_folder_row', $name_utf8, $display_name, $protected, $subscribe,
- false, $class_name);
+ $OUTPUT->command('add_folder_row', $name, $name_utf8, $display_name, $protected, $subscribe,
+ $class_name);
}
else {
- $OUTPUT->command('replace_folder_row', rcube_charset::convert($oldname, 'UTF7-IMAP'),
- $name_utf8, $display_name, $protected, $class_name);
+ $OUTPUT->command('replace_folder_row', $oldname, $name, $name_utf8, $display_name, $protected, $class_name);
}
}
@@ -1332,7 +1347,7 @@ 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' => 'manageresponses'),
);
// get all identites from DB and define list of cols to be displayed
diff --git a/program/steps/settings/identities.inc b/program/steps/settings/identities.inc
index e19c16c79..f43edc1f7 100644
--- a/program/steps/settings/identities.inc
+++ b/program/steps/settings/identities.inc
@@ -19,6 +19,28 @@
+-----------------------------------------------------------------------+
*/
+if ($RCMAIL->action == 'delete-identity' && $OUTPUT->ajax_call) {
+ $iid = rcube_utils::get_input_value('_iid', rcube_utils::INPUT_POST);
+
+ 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'];
+
+ if ($deleted > 0 && $deleted !== false) {
+ $OUTPUT->show_message('deletedsuccessfully', 'confirmation', null, false);
+ $OUTPUT->command('remove_identity', $iid);
+ }
+ else {
+ $msg = $plugin['message'] ? $plugin['message'] : ($deleted < 0 ? 'nodeletelastidentity' : 'errorsaving');
+ $OUTPUT->show_message($msg, 'error', null, false);
+ }
+ }
+
+ $OUTPUT->send();
+}
+
+
define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0)));
$OUTPUT->set_pagetitle($RCMAIL->gettext('identities'));
diff --git a/program/steps/settings/responses.inc b/program/steps/settings/responses.inc
index 06093b3b8..117e17f97 100644
--- a/program/steps/settings/responses.inc
+++ b/program/steps/settings/responses.inc
@@ -51,8 +51,8 @@ if (!empty($_POST['_insert'])) {
$RCMAIL->output->send();
}
-if ($RCMAIL->action == 'delete-response') {
- if ($key = rcube_utils::get_input_value('_key', rcube_utils::INPUT_GPC)) {
+if ($RCMAIL->action == 'delete-response' && $RCMAIL->output->ajax_call) {
+ if ($key = rcube_utils::get_input_value('_key', rcube_utils::INPUT_POST)) {
$responses = $RCMAIL->get_compose_responses(false, true);
foreach ($responses as $i => $response) {
if (empty($response['key']))
@@ -70,9 +70,7 @@ if ($RCMAIL->action == 'delete-response') {
$RCMAIL->output->command('remove_response', $key);
}
- if ($RCMAIL->output->ajax_call) {
- $RCMAIL->output->send();
- }
+ $RCMAIL->output->send();
}
@@ -95,7 +93,7 @@ function rcmail_responses_list($attrib)
{
global $RCMAIL, $OUTPUT;
- $attrib += array('id' => 'rcmresponseslist', 'tagname' => 'table', 'cols' => 1);
+ $attrib += array('id' => 'rcmresponseslist', 'tagname' => 'table');
$plugin = $RCMAIL->plugins->exec_hook('responses_list', array(
'list' => $RCMAIL->get_compose_responses(true),
diff --git a/program/steps/settings/save_folder.inc b/program/steps/settings/save_folder.inc
index d1449bb38..b8fc49060 100644
--- a/program/steps/settings/save_folder.inc
+++ b/program/steps/settings/save_folder.inc
@@ -24,12 +24,10 @@
// 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);
-
+$name = trim(rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST, true));
+$path = rcube_utils::get_input_value('_parent', rcube_utils::INPUT_POST, true);
+$old_imap = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
$name_imap = rcube_charset::convert($name, RCUBE_CHARSET, 'UTF7-IMAP');
-$old_imap = rcube_charset::convert($old, RCUBE_CHARSET, 'UTF7-IMAP');
// $path is in UTF7-IMAP already
$delimiter = $STORAGE->get_hierarchy_delimiter();
@@ -96,7 +94,7 @@ else {
}
// create a new mailbox
-if (!$error && !strlen($old)) {
+if (!$error && !strlen($old_imap)) {
$folder['subscribe'] = true;
$plugin = $RCMAIL->plugins->exec_hook('folder_create', array('record' => $folder));
@@ -115,15 +113,13 @@ if (!$error && !strlen($old)) {
if (isset($_POST['_viewmode'])) {
$a_threaded = (array) $RCMAIL->config->get('message_threading', array());
- if ($_POST['_viewmode'])
- $a_threaded[$folder['name']] = true;
- else
- unset($a_threaded[$folder['name']]);
+ $a_threaded[$folder['name']] = (bool) $_POST['_viewmode'];
$RCMAIL->user->save_prefs(array('message_threading' => $a_threaded));
}
rcmail_update_folder_row($folder['name'], null, $folder['subscribe'], $folder['class']);
+
$OUTPUT->show_message('foldercreated', 'confirmation');
// reset folder preview frame
$OUTPUT->command('subscription_select');
@@ -167,19 +163,18 @@ else if (!$error) {
}
else if (preg_match($oldprefix, $key)) {
unset($a_threaded[$key]);
- $a_threaded[preg_replace($oldprefix, $folder['name'].$delimiter, $key)] = true;
+ $a_threaded[preg_replace($oldprefix, $folder['name'].$delimiter, $key)] = $val;
}
}
}
- if ($_POST['_viewmode'])
- $a_threaded[$folder['name']] = true;
- else
- unset($a_threaded[$folder['name']]);
+
+ $a_threaded[$folder['name']] = (bool) $_POST['_viewmode'];
$RCMAIL->user->save_prefs(array('message_threading' => $a_threaded));
}
$OUTPUT->show_message('folderupdated', 'confirmation');
+ $OUTPUT->set_env('folder', $folder['name']);
if ($rename) {
// #1488692: update session
diff --git a/program/steps/settings/save_identity.inc b/program/steps/settings/save_identity.inc
index 77245b988..de0c84c91 100644
--- a/program/steps/settings/save_identity.inc
+++ b/program/steps/settings/save_identity.inc
@@ -79,8 +79,11 @@ foreach ($email_checks as $email) {
}
}
-// XSS protection in HTML signature (#1489251)
if (!empty($save_data['signature']) && !empty($save_data['html_signature'])) {
+ // replace uploaded images with data URIs
+ $save_data['signature'] = rcmail_attach_images($save_data['signature']);
+
+ // XSS protection in HTML signature (#1489251)
$save_data['signature'] = rcmail_wash_html($save_data['signature']);
// clear POST data of signature, we want to use safe content
@@ -191,6 +194,35 @@ else {
/**
+ * Attach uploaded images into signature as data URIs
+ */
+function rcmail_attach_images($html)
+{
+ global $RCMAIL;
+
+ $offset = 0;
+ $regexp = '/\s(poster|src)\s*=\s*[\'"]*\S+upload-display\S+file=rcmfile([0-9]+)[\s\'"]*/';
+
+ while (preg_match($regexp, $html, $matches, 0, $offset)) {
+ $file_id = $matches[2];
+ $data_uri = ' ';
+
+ if ($file_id && ($file = $_SESSION['identity']['files'][$file_id])) {
+ $file = $RCMAIL->plugins->exec_hook('attachment_get', $file);
+
+ $data_uri .= 'src="data:' . $file['mimetype'] . ';base64,';
+ $data_uri .= base64_encode($file['data'] ? $file['data'] : file_get_contents($file['path']));
+ $data_uri .= '" ';
+ }
+
+ $html = str_replace($matches[0], $data_uri, $html);
+ $offset += strlen($data_uri) - strlen($matches[0]) + 1;
+ }
+
+ return $html;
+}
+
+/**
* Sanity checks/cleanups on HTML body of signature
*/
function rcmail_wash_html($html)
diff --git a/program/steps/settings/save_prefs.inc b/program/steps/settings/save_prefs.inc
index 7a17f21f4..f0ce9c9a3 100644
--- a/program/steps/settings/save_prefs.inc
+++ b/program/steps/settings/save_prefs.inc
@@ -90,6 +90,7 @@ case 'compose':
'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_save_localstorage' => intval($_POST['_compose_save_localstorage']),
);
break;
diff --git a/program/steps/settings/upload.inc b/program/steps/settings/upload.inc
new file mode 100644
index 000000000..41e19f8fa
--- /dev/null
+++ b/program/steps/settings/upload.inc
@@ -0,0 +1,144 @@
+<?php
+
+/*
+ +-----------------------------------------------------------------------+
+ | program/steps/settings/upload.inc |
+ | |
+ | This file is part of the Roundcube Webmail client |
+ | Copyright (C) 2005-2014, The Roundcube Dev Team |
+ | |
+ | Licensed under the GNU General Public License version 3 or |
+ | any later version with exceptions for skins & plugins. |
+ | See the README file for a full license statement. |
+ | |
+ | PURPOSE: |
+ | Handles image uploads |
+ | |
+ +-----------------------------------------------------------------------+
+ | Author: Aleksander Machniak <alec@alec.pl> |
+ +-----------------------------------------------------------------------+
+*/
+
+// Upload progress update
+if (!empty($_GET['_progress'])) {
+ $RCMAIL->upload_progress();
+}
+
+$from = rcube_utils::get_input_value('_from', rcube_utils::INPUT_GET);
+$type = str_replace('edit-', '', $from);
+
+if ($RCMAIL->action == 'upload-display') {
+ $id = 'undefined';
+
+ if (preg_match('/^rcmfile(\w+)$/', $_GET['_file'], $regs)) {
+ $id = $regs[1];
+ }
+
+ $RCMAIL->display_uploaded_file($_SESSION[$type]['files'][$id]);
+
+ exit;
+}
+
+
+// Supported image format types
+$IMAGE_TYPES = explode(',', 'jpeg,jpg,jp2,tiff,tif,bmp,eps,gif,png,png8,png24,png32,svg,ico');
+
+// clear all stored output properties (like scripts and env vars)
+$OUTPUT->reset();
+
+$max_size = $RCMAIL->config->get($type . '_image_size', 64) * 1024;
+$post_size = $RCMAIL->show_bytes(parse_bytes(ini_get('upload_max_filesize')));
+$uploadid = rcube_utils::get_input_value('_uploadid', rcube_utils::INPUT_GET);
+
+
+if (is_array($_FILES['_file']['tmp_name'])) {
+ $multiple = count($_FILES['_file']['tmp_name']) > 1;
+
+ foreach ($_FILES['_file']['tmp_name'] as $i => $filepath) {
+ // Process uploaded attachment if there is no error
+ $err = $_FILES['_file']['error'][$i];
+
+ if (!$err) {
+ if ($max_size < $_FILES['_file']['size'][$i]) {
+ $err = 'size_error';
+ }
+ // check image file type
+ else {
+ $image = new rcube_image($filepath);
+ $imageprop = $image->props();
+
+ if (!in_array(strtolower($imageprop['type']), $IMAGE_TYPES)) {
+ $err = 'type_error';
+ }
+ }
+ }
+
+ // save uploaded image in storage backend
+ if (!$err) {
+ $attachment = $RCMAIL->plugins->exec_hook('attachment_upload', array(
+ 'path' => $filepath,
+ 'size' => $_FILES['_file']['size'][$i],
+ 'name' => $_FILES['_file']['name'][$i],
+ 'mimetype' => 'image/' . $imageprop['type'],
+ 'group' => $type,
+ ));
+ }
+
+ if (!$err && $attachment['status'] && !$attachment['abort']) {
+ $id = $attachment['id'];
+
+ // store new file in session
+ unset($attachment['status'], $attachment['abort']);
+ $RCMAIL->session->append($type . '.files', $id, $attachment);
+
+ $content = rcube::Q($attachment['name']);
+
+ $OUTPUT->command('add2attachment_list', "rcmfile$id", array(
+ 'html' => $content,
+ 'name' => $attachment['name'],
+ 'mimetype' => $attachment['mimetype'],
+ 'classname' => rcube_utils::file2class($attachment['mimetype'], $attachment['name']),
+ 'complete' => true
+ ),
+ $uploadid
+ );
+ }
+ else {
+ if ($err == 'type_error') {
+ $msg = $RCMAIL->gettext('invalidimageformat');
+ }
+ else if ($err == 'size_error') {
+ $msg = $RCMAIL->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $max_size)));
+ }
+ else if ($err == UPLOAD_ERR_INI_SIZE || $err == UPLOAD_ERR_FORM_SIZE) {
+ $msg = $RCMAIL->gettext(array('name' => 'filesizeerror', 'vars' => array('size' => $post_size)));
+ }
+ else if ($attachment['error']) {
+ $msg = $attachment['error'];
+ }
+ else {
+ $msg = $RCMAIL->gettext('fileuploaderror');
+ }
+
+ $OUTPUT->command('display_message', $msg, 'error');
+ }
+ }
+}
+else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+ // if filesize exceeds post_max_size then $_FILES array is empty,
+ // show filesizeerror instead of fileuploaderror
+ if ($maxsize = ini_get('post_max_size')) {
+ $msg = $RCMAIL->gettext(array(
+ 'name' => 'filesizeerror',
+ 'vars' => array('size' => $RCMAIL->show_bytes(parse_bytes($maxsize)))
+ ));
+ }
+ else {
+ $msg = $RCMAIL->gettext('fileuploaderror');
+ }
+
+ $OUTPUT->command('display_message', $msg, 'error');
+ $OUTPUT->command('remove_from_attachment_list', $uploadid);
+}
+
+$OUTPUT->send('iframe');