Show spam aliases #
This commit is contained in:
103
data/web/rc/program/steps/settings/about.inc
Normal file
103
data/web/rc/program/steps/settings/about.inc
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/steps/settings/about.inc |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| 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. |
|
||||
| See the README file for a full license statement. |
|
||||
| |
|
||||
| PURPOSE: |
|
||||
| Display license information about program and enabled plugins |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Aleksander Machniak <alec@alec.pl> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
$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;
|
||||
|
||||
if ($url = $RCMAIL->config->get('support_url')) {
|
||||
$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($RCMAIL->plugins->active_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['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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($plugin_info)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
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['uri'];
|
||||
if ($uri && stripos($uri, 'http') !== 0) {
|
||||
$uri = 'http://' . $uri;
|
||||
}
|
||||
|
||||
$table->add_row();
|
||||
$table->add('name', rcube::Q($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();
|
||||
}
|
321
data/web/rc/program/steps/settings/edit_folder.inc
Normal file
321
data/web/rc/program/steps/settings/edit_folder.inc
Normal file
@@ -0,0 +1,321 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/steps/settings/edit_folder.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: |
|
||||
| Provide functionality to create/edit a folder |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Aleksander Machniak <alec@alec.pl> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
// 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)
|
||||
{
|
||||
global $RCMAIL;
|
||||
|
||||
$storage = $RCMAIL->get_storage();
|
||||
|
||||
// edited folder name (empty in create-folder mode)
|
||||
$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);
|
||||
|
||||
$threading_supported = $storage->get_capability('THREAD');
|
||||
$delimiter = $storage->get_hierarchy_delimiter();
|
||||
|
||||
// Get mailbox parameters
|
||||
if (strlen($mbox)) {
|
||||
$options = rcmail_folder_options($mbox);
|
||||
$namespace = $storage->get_namespace();
|
||||
|
||||
$path = explode($delimiter, $mbox);
|
||||
$folder = array_pop($path);
|
||||
$path = implode($delimiter, $path);
|
||||
$folder = rcube_charset::convert($folder, 'UTF7-IMAP');
|
||||
|
||||
$hidden_fields = array('name' => '_mbox', 'value' => $mbox);
|
||||
}
|
||||
else {
|
||||
$options = array();
|
||||
$path = $parent;
|
||||
|
||||
// allow creating subfolders of INBOX folder
|
||||
if ($path == 'INBOX') {
|
||||
$path = $storage->mod_folder($path, 'in');
|
||||
}
|
||||
}
|
||||
|
||||
// remove personal namespace prefix
|
||||
if (strlen($path)) {
|
||||
$path_id = $path;
|
||||
$path = $storage->mod_folder($path.$delimiter);
|
||||
if ($path[strlen($path)-1] == $delimiter) {
|
||||
$path = substr($path, 0, -1);
|
||||
}
|
||||
}
|
||||
|
||||
$form = array();
|
||||
|
||||
// General tab
|
||||
$form['props'] = array(
|
||||
'name' => $RCMAIL->gettext('properties'),
|
||||
);
|
||||
|
||||
// Location (name)
|
||||
if ($options['protected']) {
|
||||
$foldername = str_replace($delimiter, ' » ', rcube::Q($RCMAIL->localize_folderpath($mbox)));
|
||||
}
|
||||
else if ($options['norename']) {
|
||||
$foldername = rcube::Q($folder);
|
||||
}
|
||||
else {
|
||||
if (isset($_POST['_name']))
|
||||
$folder = trim(rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST, true));
|
||||
|
||||
$foldername = new html_inputfield(array('name' => '_name', 'id' => '_name', 'size' => 30));
|
||||
$foldername = $foldername->show($folder);
|
||||
|
||||
if ($options['special']) {
|
||||
$foldername .= ' (' . rcube::Q($RCMAIL->localize_foldername($mbox)) .')';
|
||||
}
|
||||
}
|
||||
|
||||
$form['props']['fieldsets']['location'] = array(
|
||||
'name' => $RCMAIL->gettext('location'),
|
||||
'content' => array(
|
||||
'name' => array(
|
||||
'label' => $RCMAIL->gettext('foldername'),
|
||||
'value' => $foldername,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if (!empty($options) && ($options['norename'] || $options['protected'])) {
|
||||
// prevent user from moving folder
|
||||
$hidden_path = new html_hiddenfield(array('name' => '_parent', 'value' => $path));
|
||||
$form['props']['fieldsets']['location']['content']['name']['value'] .= $hidden_path->show();
|
||||
}
|
||||
else {
|
||||
$selected = isset($_POST['_parent']) ? $_POST['_parent'] : $path_id;
|
||||
$exceptions = array($mbox);
|
||||
|
||||
// Exclude 'prefix' namespace from parent folders list (#1488349)
|
||||
// If INBOX. namespace exists, folders created as INBOX subfolders
|
||||
// will be listed at the same level - selecting INBOX as a parent does nothing
|
||||
if ($prefix = $storage->get_namespace('prefix')) {
|
||||
$exceptions[] = substr($prefix, 0, -1);
|
||||
}
|
||||
|
||||
$select = $RCMAIL->folder_selector(array(
|
||||
'id' => '_parent',
|
||||
'name' => '_parent',
|
||||
'noselection' => '---',
|
||||
'maxlength' => 150,
|
||||
'unsubscribed' => true,
|
||||
'skip_noinferiors' => true,
|
||||
'exceptions' => $exceptions,
|
||||
'additional' => strlen($selected) ? array($selected) : null,
|
||||
));
|
||||
|
||||
$form['props']['fieldsets']['location']['content']['path'] = array(
|
||||
'label' => $RCMAIL->gettext('parentfolder'),
|
||||
'value' => $select->show($selected),
|
||||
);
|
||||
}
|
||||
|
||||
// Settings
|
||||
$form['props']['fieldsets']['settings'] = array(
|
||||
'name' => $RCMAIL->gettext('settings'),
|
||||
);
|
||||
|
||||
// Settings: threading
|
||||
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)) {
|
||||
$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(
|
||||
'label' => $RCMAIL->gettext('listmode'),
|
||||
'value' => $select->show($value),
|
||||
);
|
||||
}
|
||||
/*
|
||||
// Settings: sorting column
|
||||
$select = new html_select(array('name' => '_sortcol', 'id' => '_sortcol'));
|
||||
$select->add($RCMAIL->gettext('nonesort'), '');
|
||||
$select->add($RCMAIL->gettext('arrival'), 'arrival');
|
||||
$select->add($RCMAIL->gettext('sentdate'), 'date');
|
||||
$select->add($RCMAIL->gettext('subject'), 'subject');
|
||||
$select->add($RCMAIL->gettext('fromto'), 'from');
|
||||
$select->add($RCMAIL->gettext('replyto'), 'replyto');
|
||||
$select->add($RCMAIL->gettext('cc'), 'cc');
|
||||
$select->add($RCMAIL->gettext('size'), 'size');
|
||||
|
||||
$value = isset($_POST['_sortcol']) ? $_POST['_sortcol'] : '';
|
||||
|
||||
$form['props']['fieldsets']['settings']['content']['sortcol'] = array(
|
||||
'label' => $RCMAIL->gettext('listsorting'),
|
||||
'value' => $select->show($value),
|
||||
);
|
||||
|
||||
// Settings: sorting order
|
||||
$select = new html_select(array('name' => '_sortord', 'id' => '_sortord'));
|
||||
$select->add($RCMAIL->gettext('asc'), 'ASC');
|
||||
$select->add($RCMAIL->gettext('desc'), 'DESC');
|
||||
|
||||
$value = isset($_POST['_sortord']) ? $_POST['_sortord'] : '';
|
||||
|
||||
$form['props']['fieldsets']['settings']['content']['sortord'] = array(
|
||||
'label' => $RCMAIL->gettext('listorder'),
|
||||
'value' => $select->show(),
|
||||
);
|
||||
*/
|
||||
// Information (count, size) - Edit mode
|
||||
if (strlen($mbox)) {
|
||||
// Number of messages
|
||||
$form['props']['fieldsets']['info'] = array(
|
||||
'name' => $RCMAIL->gettext('info'),
|
||||
'content' => array()
|
||||
);
|
||||
|
||||
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));
|
||||
$size = html::a(array('href' => '#', 'onclick' => $onclick,
|
||||
'id' => 'folder-size'), $RCMAIL->gettext('getfoldersize'));
|
||||
}
|
||||
else {
|
||||
// no messages -> zero size
|
||||
$size = 0;
|
||||
}
|
||||
|
||||
$form['props']['fieldsets']['info']['content']['count'] = array(
|
||||
'label' => $RCMAIL->gettext('messagecount'),
|
||||
'value' => (int) $msgcount
|
||||
);
|
||||
$form['props']['fieldsets']['info']['content']['size'] = array(
|
||||
'label' => $RCMAIL->gettext('size'),
|
||||
'value' => $size,
|
||||
);
|
||||
}
|
||||
|
||||
// show folder type only if we have non-private namespaces
|
||||
if (!empty($namespace['shared']) || !empty($namespace['others'])) {
|
||||
$form['props']['fieldsets']['info']['content']['foldertype'] = array(
|
||||
'label' => $RCMAIL->gettext('foldertype'),
|
||||
'value' => $RCMAIL->gettext($options['namespace'] . 'folder'));
|
||||
}
|
||||
}
|
||||
|
||||
// Allow plugins to modify folder form content
|
||||
$plugin = $RCMAIL->plugins->exec_hook('folder_form',
|
||||
array('form' => $form, 'options' => $options,
|
||||
'name' => $mbox, 'parent_name' => $parent));
|
||||
|
||||
$form = $plugin['form'];
|
||||
|
||||
// Set form tags and hidden fields
|
||||
list($form_start, $form_end) = get_form_tags($attrib, 'save-folder', null, $hidden_fields);
|
||||
|
||||
unset($attrib['form'], $attrib['id']);
|
||||
|
||||
// return the complete edit form as table
|
||||
$out = "$form_start\n";
|
||||
|
||||
// Create form output
|
||||
foreach ($form as $idx => $tab) {
|
||||
if (!empty($tab['fieldsets']) && is_array($tab['fieldsets'])) {
|
||||
$content = '';
|
||||
foreach ($tab['fieldsets'] as $fieldset) {
|
||||
$subcontent = rcmail_get_form_part($fieldset, $attrib);
|
||||
if ($subcontent) {
|
||||
$subcontent = html::tag('legend', null, rcube::Q($fieldset['name'])) . $subcontent;
|
||||
$content .= html::tag('fieldset', null, $subcontent) ."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$content = rcmail_get_form_part($tab, $attrib);
|
||||
}
|
||||
|
||||
if ($idx != 'props') {
|
||||
$out .= html::tag('fieldset', null, html::tag('legend', null, rcube::Q($tab['name'])) . $content) ."\n";
|
||||
}
|
||||
else {
|
||||
$out .= $content ."\n";
|
||||
}
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
||||
|
||||
function rcmail_get_form_part($form, $attrib = array())
|
||||
{
|
||||
global $RCMAIL;
|
||||
|
||||
$content = '';
|
||||
|
||||
if (is_array($form['content']) && !empty($form['content'])) {
|
||||
$table = new html_table(array('cols' => 2));
|
||||
foreach ($form['content'] as $col => $colprop) {
|
||||
$colprop['id'] = '_'.$col;
|
||||
$label = $colprop['label'] ?: $RCMAIL->gettext($col);
|
||||
|
||||
$table->add('title', html::label($colprop['id'], rcube::Q($label)));
|
||||
$table->add(null, $colprop['value']);
|
||||
}
|
||||
$content = $table->show($attrib);
|
||||
}
|
||||
else {
|
||||
$content = $form['content'];
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
192
data/web/rc/program/steps/settings/edit_identity.inc
Normal file
192
data/web/rc/program/steps/settings/edit_identity.inc
Normal file
@@ -0,0 +1,192 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/steps/settings/edit_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: |
|
||||
| Show edit form for a identity record or to add a new one |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
define('IDENTITIES_LEVEL', intval($RCMAIL->config->get('identities_level', 0)));
|
||||
|
||||
// edit-identity
|
||||
if (($_GET['_iid'] || $_POST['_iid']) && $RCMAIL->action=='edit-identity') {
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
$OUTPUT->include_script('list.js');
|
||||
$OUTPUT->add_handler('identityform', 'rcube_identity_form');
|
||||
$OUTPUT->set_env('identities_level', IDENTITIES_LEVEL);
|
||||
$OUTPUT->add_label('deleteidentityconfirm', 'uploading');
|
||||
|
||||
$OUTPUT->set_pagetitle($RCMAIL->gettext(($RCMAIL->action == 'add-identity' ? 'addidentity' : 'editidentity')));
|
||||
|
||||
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', 'converting', 'editorwarning');
|
||||
|
||||
$i_size = $attrib['size'] ?: 40;
|
||||
$t_rows = $attrib['textarearows'] ?: 6;
|
||||
$t_cols = $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.command(\'toggle-editor\', {id: \'rcmfd_signature\', html: this.checked}, \'\', event)'),
|
||||
))
|
||||
);
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// hide "default" checkbox if only one identity is allowed
|
||||
if (IDENTITIES_LEVEL > 1) {
|
||||
unset($form['addressing']['content']['standard']);
|
||||
}
|
||||
|
||||
// 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';
|
||||
}
|
||||
}
|
||||
|
||||
$IDENTITY_RECORD['email'] = rcube_utils::idn_to_utf8($IDENTITY_RECORD['email']);
|
||||
|
||||
// Allow plugins to modify identity form content
|
||||
$plugin = $RCMAIL->plugins->exec_hook('identity_form', array(
|
||||
'form' => $form, 'record' => $IDENTITY_RECORD));
|
||||
|
||||
$form = $plugin['form'];
|
||||
$IDENTITY_RECORD = $plugin['record'];
|
||||
|
||||
// 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']));
|
||||
|
||||
unset($plugin);
|
||||
unset($attrib['form'], $attrib['id']);
|
||||
|
||||
// return the complete edit form as table
|
||||
$out = "$form_start\n";
|
||||
|
||||
foreach ($form as $fieldset) {
|
||||
if (empty($fieldset['content'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$content = '';
|
||||
if (is_array($fieldset['content'])) {
|
||||
$table = new html_table(array('cols' => 2));
|
||||
|
||||
foreach ($fieldset['content'] as $col => $colprop) {
|
||||
$colprop['id'] = 'rcmfd_'.$col;
|
||||
|
||||
$label = $colprop['label'] ?: $RCMAIL->gettext(str_replace('-', '', $col));
|
||||
$value = $colprop['value'] ?: rcube_output::get_edit_field($col, $IDENTITY_RECORD[$col], $colprop, $colprop['type']);
|
||||
|
||||
$table->add('title', html::label($colprop['id'], rcube::Q($label)));
|
||||
$table->add(null, $value);
|
||||
}
|
||||
|
||||
$content = $table->show($attrib);
|
||||
}
|
||||
else {
|
||||
$content = $fieldset['content'];
|
||||
}
|
||||
|
||||
$content = html::tag('legend', null, rcube::Q($fieldset['name'])) . $content;
|
||||
$out .= html::tag('fieldset', null, $content) . "\n";
|
||||
}
|
||||
|
||||
$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;
|
||||
}
|
87
data/web/rc/program/steps/settings/edit_prefs.inc
Normal file
87
data/web/rc/program/steps/settings/edit_prefs.inc
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/steps/settings/edit_prefs.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: |
|
||||
| Provide functionality for user's settings & preferences |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
if (!$OUTPUT->ajax_call) {
|
||||
$OUTPUT->set_pagetitle($RCMAIL->gettext('preferences'));
|
||||
}
|
||||
|
||||
$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;
|
||||
|
||||
// add some labels to client
|
||||
$RCMAIL->output->add_label('nopagesizewarning');
|
||||
|
||||
unset($attrib['form']);
|
||||
|
||||
list($form_start, $form_end) = get_form_tags($attrib, 'save-prefs', null,
|
||||
array('name' => '_section', 'value' => $CURR_SECTION));
|
||||
|
||||
$out = $form_start;
|
||||
|
||||
if(!empty($SECTIONS[$CURR_SECTION]['header'])) {
|
||||
$out .= html::div(array('id' => 'preferences-header', 'class' =>'boxcontent'), $SECTIONS[$CURR_SECTION]['header']);
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
else {
|
||||
$table->add(array('colspan' => 2), $option['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;
|
||||
}
|
||||
|
||||
function rcmail_prefs_section_name()
|
||||
{
|
||||
global $SECTIONS, $CURR_SECTION;
|
||||
|
||||
return $SECTIONS[$CURR_SECTION]['section'];
|
||||
}
|
107
data/web/rc/program/steps/settings/edit_response.inc
Normal file
107
data/web/rc/program/steps/settings/edit_response.inc
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/steps/settings/edit_response.inc |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 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: |
|
||||
| Show edit form for a canned response record or to add a new one |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
$responses = $RCMAIL->get_compose_responses();
|
||||
|
||||
// edit-response
|
||||
if (($key = rcube_utils::get_input_value('_key', rcube_utils::INPUT_GPC))) {
|
||||
foreach ($responses as $i => $response) {
|
||||
if ($response['key'] == $key) {
|
||||
$RESPONSE_RECORD = $response;
|
||||
$RESPONSE_RECORD['index'] = $i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// save response
|
||||
if ($RCMAIL->action == 'save-response' && isset($_POST['_name']) && !$RESPONSE_RECORD['static']) {
|
||||
$name = trim(rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST));
|
||||
$text = trim(rcube_utils::get_input_value('_text', rcube_utils::INPUT_POST, true));
|
||||
|
||||
if (!empty($name) && !empty($text)) {
|
||||
$dupes = 0;
|
||||
foreach ($responses as $i => $resp) {
|
||||
if ($RESPONSE_RECORD && $RESPONSE_RECORD['index'] === $i)
|
||||
continue;
|
||||
if (strcasecmp($name, preg_replace('/\s\(\d+\)$/', '', $resp['name'])) == 0)
|
||||
$dupes++;
|
||||
}
|
||||
if ($dupes) { // require a unique name
|
||||
$name .= ' (' . ++$dupes . ')';
|
||||
}
|
||||
|
||||
$response = array('name' => $name, 'text' => $text, 'format' => 'text', 'key' => substr(md5($name), 0, 16));
|
||||
if ($RESPONSE_RECORD && $responses[$RESPONSE_RECORD['index']]) {
|
||||
$responses[$RESPONSE_RECORD['index']] = $response;
|
||||
}
|
||||
else {
|
||||
$responses[] = $response;
|
||||
}
|
||||
|
||||
$responses = array_filter($responses, function($item){ return empty($item['static']); });
|
||||
if ($RCMAIL->user->save_prefs(array('compose_responses' => array_values($responses)))) {
|
||||
$RCMAIL->output->show_message('successfullysaved', 'confirmation');
|
||||
$RCMAIL->output->command('parent.update_response_row', $response, $key);
|
||||
$RCMAIL->overwrite_action('edit-response');
|
||||
$RESPONSE_RECORD = $response;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$RCMAIL->output->show_message('formincomplete', 'error');
|
||||
}
|
||||
}
|
||||
|
||||
$OUTPUT->set_env('readonly', !empty($RESPONSE_RECORD['static']));
|
||||
$OUTPUT->add_handler('responseform', 'rcube_response_form');
|
||||
$OUTPUT->set_pagetitle($RCMAIL->gettext($RCMAIL->action == 'add-response' ? 'addresponse' : 'editresponse'));
|
||||
|
||||
$OUTPUT->send('responseedit');
|
||||
|
||||
|
||||
function rcube_response_form($attrib)
|
||||
{
|
||||
global $RCMAIL, $RESPONSE_RECORD;
|
||||
|
||||
// Set form tags and hidden fields
|
||||
$disabled = !empty($RESPONSE_RECORD['static']);
|
||||
$key = $RESPONSE_RECORD['key'];
|
||||
list($form_start, $form_end) = get_form_tags($attrib, 'save-response', $key, array('name' => '_key', 'value' => $key));
|
||||
unset($attrib['form'], $attrib['id']);
|
||||
|
||||
// return the complete edit form as table
|
||||
$out = "$form_start\n";
|
||||
|
||||
$table = new html_table(array('cols' => 2));
|
||||
|
||||
$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('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'));
|
||||
|
||||
$out .= $table->show($attrib);
|
||||
$out .= $form_end;
|
||||
|
||||
return $out;
|
||||
}
|
521
data/web/rc/program/steps/settings/folders.inc
Normal file
521
data/web/rc/program/steps/settings/folders.inc
Normal file
@@ -0,0 +1,521 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/steps/settings/folders.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: |
|
||||
| Provide functionality of folders management |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
| Author: Aleksander Machniak <alec@alec.pl> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
// 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);
|
||||
|
||||
if (strlen($mbox)) {
|
||||
$result = $STORAGE->subscribe(array($mbox));
|
||||
|
||||
// Handle virtual (non-existing) folders
|
||||
if (!$result && $STORAGE->get_error_code() == -1 &&
|
||||
$STORAGE->get_response_code() == rcube_storage::TRYCREATE
|
||||
) {
|
||||
$result = $STORAGE->create_folder($mbox, true);
|
||||
if ($result) {
|
||||
// @TODO: remove 'virtual' class of folder's row
|
||||
}
|
||||
}
|
||||
|
||||
if ($result) {
|
||||
// Handle subscription of protected folder (#1487656)
|
||||
if ($RCMAIL->config->get('protect_default_folders')
|
||||
&& $STORAGE->is_special_folder($mbox)
|
||||
) {
|
||||
$OUTPUT->command('disable_subscription', $mbox);
|
||||
}
|
||||
|
||||
$OUTPUT->show_message('foldersubscribed', 'confirmation');
|
||||
}
|
||||
else {
|
||||
$RCMAIL->display_server_error('errorsaving');
|
||||
$OUTPUT->command('reset_subscription', $mbox, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// unsubscribe mailbox
|
||||
else if ($RCMAIL->action == 'unsubscribe') {
|
||||
$mbox = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
|
||||
|
||||
if (strlen($mbox)) {
|
||||
$result = $STORAGE->unsubscribe(array($mbox));
|
||||
|
||||
if ($result) {
|
||||
$OUTPUT->show_message('folderunsubscribed', 'confirmation');
|
||||
}
|
||||
else {
|
||||
$RCMAIL->display_server_error('errorsaving');
|
||||
$OUTPUT->command('reset_subscription', $mbox, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
// delete an existing mailbox
|
||||
else if ($RCMAIL->action == 'delete-folder') {
|
||||
$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));
|
||||
|
||||
if (!$plugin['abort']) {
|
||||
$deleted = $STORAGE->delete_folder($plugin['name']);
|
||||
}
|
||||
else {
|
||||
$deleted = $plugin['result'];
|
||||
}
|
||||
|
||||
// #1488692: update session
|
||||
if ($deleted && $_SESSION['mbox'] === $mbox) {
|
||||
$RCMAIL->session->remove('mbox');
|
||||
}
|
||||
}
|
||||
|
||||
if ($OUTPUT->ajax_call && $deleted) {
|
||||
// Remove folder and subfolders rows
|
||||
$OUTPUT->command('remove_folder_row', $mbox);
|
||||
$OUTPUT->show_message('folderdeleted', 'confirmation');
|
||||
// Clear content frame
|
||||
$OUTPUT->command('subscription_select');
|
||||
$OUTPUT->command('set_quota', $RCMAIL->quota_content());
|
||||
}
|
||||
else if (!$deleted) {
|
||||
$RCMAIL->display_server_error('errorsaving');
|
||||
}
|
||||
}
|
||||
// rename an existing mailbox
|
||||
else if ($RCMAIL->action == 'rename-folder') {
|
||||
$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);
|
||||
}
|
||||
|
||||
if ($rename && $OUTPUT->ajax_call) {
|
||||
rcmail_update_folder_row($name, $oldname);
|
||||
}
|
||||
else if (!$rename) {
|
||||
$RCMAIL->display_server_error('errorsaving');
|
||||
}
|
||||
}
|
||||
// clear mailbox
|
||||
else if ($RCMAIL->action == 'purge') {
|
||||
$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, '/') . '/';
|
||||
|
||||
// we should only be purging trash (or their subfolders)
|
||||
if (!strlen($trash_mbox) || $mbox === $trash_mbox
|
||||
|| preg_match($trash_regexp, $mbox)
|
||||
) {
|
||||
$success = $STORAGE->delete_message('*', $mbox);
|
||||
$delete = true;
|
||||
}
|
||||
// move to Trash
|
||||
else {
|
||||
$success = $STORAGE->move_message('1:*', $trash_mbox, $mbox);
|
||||
$delete = false;
|
||||
}
|
||||
|
||||
if ($success) {
|
||||
$OUTPUT->set_env('messagecount', 0);
|
||||
if ($delete) {
|
||||
$OUTPUT->show_message('folderpurged', 'confirmation');
|
||||
$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, null, true);
|
||||
}
|
||||
else {
|
||||
$RCMAIL->display_server_error('errorsaving');
|
||||
}
|
||||
}
|
||||
// get mailbox size
|
||||
else if ($RCMAIL->action == 'folder-size') {
|
||||
$name = rcube_utils::get_input_value('_mbox', rcube_utils::INPUT_POST, true);
|
||||
|
||||
$size = $STORAGE->folder_size($name);
|
||||
|
||||
// @TODO: check quota and show percentage usage of specified mailbox?
|
||||
|
||||
if ($size !== false) {
|
||||
$OUTPUT->command('folder_size_update', $RCMAIL->show_bytes($size));
|
||||
}
|
||||
else {
|
||||
$RCMAIL->display_server_error();
|
||||
}
|
||||
}
|
||||
|
||||
if ($OUTPUT->ajax_call) {
|
||||
$OUTPUT->send();
|
||||
}
|
||||
|
||||
$OUTPUT->set_pagetitle($RCMAIL->gettext('folders'));
|
||||
$OUTPUT->set_env('prefix_ns', $STORAGE->get_namespace('prefix'));
|
||||
$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',
|
||||
'foldermoving', 'foldersubscribing', 'folderunsubscribing', 'quota');
|
||||
|
||||
// register UI objects
|
||||
$OUTPUT->add_handlers(array(
|
||||
'foldersubscription' => 'rcmail_subscription_form',
|
||||
'folderframe' => 'rcmail_folder_frame',
|
||||
'folderfilter' => 'rcmail_folder_filter',
|
||||
'quotadisplay' => array($RCMAIL, 'quota_display'),
|
||||
));
|
||||
|
||||
$OUTPUT->send('folders');
|
||||
|
||||
|
||||
// build table with all folders listed by server
|
||||
function rcmail_subscription_form($attrib)
|
||||
{
|
||||
global $RCMAIL, $OUTPUT;
|
||||
|
||||
list($form_start, $form_end) = get_form_tags($attrib, 'folders');
|
||||
unset($attrib['form']);
|
||||
|
||||
if (!$attrib['id']) {
|
||||
$attrib['id'] = 'rcmSubscriptionlist';
|
||||
}
|
||||
|
||||
$STORAGE = $RCMAIL->get_storage();
|
||||
|
||||
// get folders from server
|
||||
$STORAGE->clear_cache('mailboxes', true);
|
||||
|
||||
$a_unsubscribed = $STORAGE->list_folders();
|
||||
$a_subscribed = $STORAGE->list_folders_subscribed('', '*', null, null, true); // unsorted
|
||||
$delimiter = $STORAGE->get_hierarchy_delimiter();
|
||||
$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');
|
||||
$seen = array();
|
||||
$list_folders = array();
|
||||
|
||||
// pre-process folders list
|
||||
foreach ($a_unsubscribed as $i => $folder) {
|
||||
$folder_id = $folder;
|
||||
$folder = $STORAGE->mod_folder($folder);
|
||||
$foldersplit = explode($delimiter, $folder);
|
||||
$name = rcube_charset::convert(array_pop($foldersplit), 'UTF7-IMAP');
|
||||
$parent_folder = join($delimiter, $foldersplit);
|
||||
$level = count($foldersplit);
|
||||
|
||||
// add any necessary "virtual" parent folders
|
||||
if ($parent_folder && !isset($seen[$parent_folder])) {
|
||||
for ($i=1; $i<=$level; $i++) {
|
||||
$ancestor_folder = join($delimiter, array_slice($foldersplit, 0, $i));
|
||||
if ($ancestor_folder && !$seen[$ancestor_folder]++) {
|
||||
$ancestor_name = rcube_charset::convert($foldersplit[$i-1], 'UTF7-IMAP');
|
||||
$list_folders[] = array(
|
||||
'id' => $ancestor_folder,
|
||||
'name' => $ancestor_name,
|
||||
'level' => $i-1,
|
||||
'virtual' => true,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle properly INBOX.INBOX situation
|
||||
if (isset($seen[$folder])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$seen[$folder]++;
|
||||
|
||||
$list_folders[] = array(
|
||||
'id' => $folder_id,
|
||||
'name' => $name,
|
||||
'level' => $level,
|
||||
);
|
||||
}
|
||||
|
||||
unset($seen);
|
||||
|
||||
$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 = (string) $RCMAIL->config->get('collapsed_folders');
|
||||
|
||||
// create list of available folders
|
||||
foreach ($list_folders as $i => $folder) {
|
||||
$sub_key = array_search($folder['id'], $a_subscribed);
|
||||
$subscribed = $sub_key !== false;
|
||||
$protected = $folder['id'] == 'INBOX' || ($protect_default && isset($special_folders[$folder['id']]));
|
||||
$noselect = false;
|
||||
$classes = array();
|
||||
|
||||
$folder_utf8 = rcube_charset::convert($folder['id'], 'UTF7-IMAP');
|
||||
$display_folder = rcube::Q($protected ? $RCMAIL->localize_foldername($folder['id']) : $folder['name']);
|
||||
|
||||
if ($folder['virtual']) {
|
||||
$classes[] = 'virtual';
|
||||
}
|
||||
|
||||
// Check \Noselect flag (of existing folder)
|
||||
if (!$protected && in_array($folder['id'], $a_unsubscribed)) {
|
||||
$attrs = $STORAGE->folder_attributes($folder['id']);
|
||||
$noselect = in_array_nocase('\\Noselect', $attrs);
|
||||
}
|
||||
|
||||
$disabled = (($protected && $subscribed) || $noselect);
|
||||
|
||||
// Below we will disable subscription option for "virtual" folders
|
||||
// according to namespaces, but only if they aren't already subscribed.
|
||||
// User should be able to unsubscribe from the folder
|
||||
// even if it doesn't exists or is not accessible (OTRS:1000059)
|
||||
if (!$subscribed && !$disabled && !empty($namespace) && $folder['virtual']) {
|
||||
// check if the folder is a namespace prefix, then disable subscription option on it
|
||||
if (!$disabled && $folder['level'] == 0) {
|
||||
$fname = $folder['id'] . $delimiter;
|
||||
foreach ($namespace as $ns) {
|
||||
if (is_array($ns)) {
|
||||
foreach ($ns as $item) {
|
||||
if ($item[0] === $fname) {
|
||||
$disabled = true;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if the folder is an other users virtual-root folder, then disable subscription option on it
|
||||
if (!$disabled && $folder['level'] == 1 && !empty($namespace['other'])) {
|
||||
$parts = explode($delimiter, $folder['id']);
|
||||
$fname = $parts[0] . $delimiter;
|
||||
foreach ($namespace['other'] as $item) {
|
||||
if ($item[0] === $fname) {
|
||||
$disabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// check if the folder is shared, then disable subscription option on it (if not subscribed already)
|
||||
if (!$disabled) {
|
||||
$tmp_ns = array_merge((array)$namespace['other'], (array)$namespace['shared']);
|
||||
foreach ($tmp_ns as $item) {
|
||||
if (strlen($item[0]) && strpos($folder['id'], $item[0]) === 0) {
|
||||
$disabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$is_collapsed = strpos($collapsed, '&'.rawurlencode($folder['id']).'&') !== false;
|
||||
$folder_id = rcube_utils::html_identifier($folder['id'], true);
|
||||
|
||||
if ($folder_class = $RCMAIL->folder_classname($folder['id'])) {
|
||||
$classes[] = $folder_class;
|
||||
}
|
||||
|
||||
$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' : ''))
|
||||
);
|
||||
}
|
||||
|
||||
$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> </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', $js_folders);
|
||||
$OUTPUT->set_env('defaultfolders', array_keys($special_folders));
|
||||
$OUTPUT->set_env('collapsed_folders', $collapsed);
|
||||
$OUTPUT->set_env('delimiter', $delimiter);
|
||||
|
||||
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'), ' ')
|
||||
. html::tag('ul', array('style' => ($data['collapsed'] ? "display:none" : null)),
|
||||
implode("\n", $children));
|
||||
}
|
||||
|
||||
return html::tag('li', $attribs, $content);
|
||||
}
|
||||
|
||||
function rcmail_folder_frame($attrib)
|
||||
{
|
||||
global $OUTPUT;
|
||||
|
||||
if (!$attrib['id']) {
|
||||
$attrib['id'] = 'rcmfolderframe';
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
$storage = $RCMAIL->get_storage();
|
||||
$delimiter = $storage->get_hierarchy_delimiter();
|
||||
|
||||
$plugin = $RCMAIL->plugins->exec_hook('folder_rename', array(
|
||||
'oldname' => $oldname, 'newname' => $newname));
|
||||
|
||||
if (!$plugin['abort']) {
|
||||
$renamed = $storage->rename_folder($oldname, $newname);
|
||||
}
|
||||
else {
|
||||
$renamed = $plugin['result'];
|
||||
}
|
||||
|
||||
// update per-folder options for modified folder and its subfolders
|
||||
if ($renamed) {
|
||||
$a_threaded = (array) $RCMAIL->config->get('message_threading', array());
|
||||
$oldprefix = '/^' . preg_quote($oldname . $delimiter, '/') . '/';
|
||||
|
||||
foreach ($a_threaded as $key => $val) {
|
||||
if ($key == $oldname) {
|
||||
unset($a_threaded[$key]);
|
||||
$a_threaded[$newname] = $val;
|
||||
}
|
||||
else if (preg_match($oldprefix, $key)) {
|
||||
unset($a_threaded[$key]);
|
||||
$a_threaded[preg_replace($oldprefix, $newname.$delimiter, $key)] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
$RCMAIL->user->save_prefs(array('message_threading' => $a_threaded));
|
||||
|
||||
// #1488692: update session
|
||||
if ($_SESSION['mbox'] === $oldname) {
|
||||
$_SESSION['mbox'] = $newname;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
1422
data/web/rc/program/steps/settings/func.inc
Normal file
1422
data/web/rc/program/steps/settings/func.inc
Normal file
File diff suppressed because it is too large
Load Diff
66
data/web/rc/program/steps/settings/identities.inc
Normal file
66
data/web/rc/program/steps/settings/identities.inc
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/steps/settings/identities.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: |
|
||||
| Manage identities of a user account |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
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'] ?: ($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'));
|
||||
$OUTPUT->include_script('list.js');
|
||||
|
||||
$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);
|
||||
}
|
131
data/web/rc/program/steps/settings/responses.inc
Normal file
131
data/web/rc/program/steps/settings/responses.inc
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/steps/settings/responses.inc |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 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: |
|
||||
| Manage and save canned response texts |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
if (!empty($_POST['_insert'])) {
|
||||
$name = trim(rcube_utils::get_input_value('_name', rcube_utils::INPUT_POST));
|
||||
$text = trim(rcube_utils::get_input_value('_text', rcube_utils::INPUT_POST, true));
|
||||
|
||||
if (!empty($name) && !empty($text)) {
|
||||
$dupes = 0;
|
||||
$responses = $RCMAIL->get_compose_responses(false, true);
|
||||
foreach ($responses as $resp) {
|
||||
if (strcasecmp($name, preg_replace('/\s\(\d+\)$/', '', $resp['name'])) == 0)
|
||||
$dupes++;
|
||||
}
|
||||
if ($dupes) { // require a unique name
|
||||
$name .= ' (' . ++$dupes . ')';
|
||||
}
|
||||
|
||||
$response = array('name' => $name, 'text' => $text, 'format' => 'text', 'key' => substr(md5($name), 0, 16));
|
||||
$responses[] = $response;
|
||||
|
||||
if ($RCMAIL->user->save_prefs(array('compose_responses' => $responses))) {
|
||||
$RCMAIL->output->command('add_response_item', $response);
|
||||
$RCMAIL->output->command('display_message', $RCMAIL->gettext('successfullysaved'), 'confirmation');
|
||||
}
|
||||
else {
|
||||
$RCMAIL->output->command('display_message', $RCMAIL->gettext('errorsaving'), 'error');
|
||||
}
|
||||
}
|
||||
|
||||
// send response
|
||||
$RCMAIL->output->send();
|
||||
}
|
||||
|
||||
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']))
|
||||
$response['key'] = substr(md5($response['name']), 0, 16);
|
||||
if ($response['key'] == $key) {
|
||||
unset($responses[$i]);
|
||||
$deleted = $RCMAIL->user->save_prefs(array('compose_responses' => $responses));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($deleted) {
|
||||
$RCMAIL->output->command('display_message', $RCMAIL->gettext('deletedsuccessfully'), 'confirmation');
|
||||
$RCMAIL->output->command('remove_response', $key);
|
||||
}
|
||||
|
||||
$RCMAIL->output->send();
|
||||
}
|
||||
|
||||
|
||||
$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');
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function rcmail_responses_list($attrib)
|
||||
{
|
||||
global $RCMAIL, $OUTPUT;
|
||||
|
||||
$attrib += array('id' => 'rcmresponseslist', 'tagname' => 'table');
|
||||
|
||||
$plugin = $RCMAIL->plugins->exec_hook('responses_list', array(
|
||||
'list' => $RCMAIL->get_compose_responses(true),
|
||||
'cols' => array('name')
|
||||
));
|
||||
|
||||
$out = $RCMAIL->table_output($attrib, $plugin['list'], $plugin['cols'], 'key');
|
||||
|
||||
$readonly_responses = array();
|
||||
foreach ($plugin['list'] as $item) {
|
||||
if (!empty($item['static'])) {
|
||||
$readonly_responses[] = $item['key'];
|
||||
}
|
||||
}
|
||||
|
||||
// set client env
|
||||
$OUTPUT->add_gui_object('responseslist', $attrib['id']);
|
||||
$OUTPUT->set_env('readonly_responses', $readonly_responses);
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
// similar function as /steps/addressbook/func.inc::rcmail_contact_frame()
|
||||
function rcmail_response_frame($attrib)
|
||||
{
|
||||
global $OUTPUT;
|
||||
|
||||
if (!$attrib['id']) {
|
||||
$attrib['id'] = 'rcmResponseFrame';
|
||||
}
|
||||
|
||||
$OUTPUT->set_env('contentframe', $attrib['id']);
|
||||
|
||||
return $OUTPUT->frame($attrib, true);
|
||||
}
|
202
data/web/rc/program/steps/settings/save_folder.inc
Normal file
202
data/web/rc/program/steps/settings/save_folder.inc
Normal file
@@ -0,0 +1,202 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/steps/settings/save_folder.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: |
|
||||
| Provide functionality to create/edit a folder |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Aleksander Machniak <alec@alec.pl> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
// WARNING: folder names in UI are encoded with RCUBE_CHARSET
|
||||
|
||||
// init IMAP connection
|
||||
$STORAGE = $RCMAIL->get_storage();
|
||||
|
||||
$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');
|
||||
// $path is in UTF7-IMAP already
|
||||
|
||||
$delimiter = $STORAGE->get_hierarchy_delimiter();
|
||||
$options = strlen($old_imap) ? rcmail_folder_options($old_imap) : array();
|
||||
|
||||
// Folder name checks
|
||||
if ($options['protected'] || $options['norename']) {
|
||||
}
|
||||
else if (!strlen($name)) {
|
||||
$error = $RCMAIL->gettext('namecannotbeempty');
|
||||
}
|
||||
else if (mb_strlen($name) > 128) {
|
||||
$error = $RCMAIL->gettext('nametoolong');
|
||||
}
|
||||
else if ($name[0] == '.' && $RCMAIL->config->get('imap_skip_hidden_folders')) {
|
||||
$error = $RCMAIL->gettext('namedotforbidden');
|
||||
}
|
||||
else {
|
||||
// these characters are problematic e.g. when used in LIST/LSUB
|
||||
foreach (array($delimiter, '%', '*') as $char) {
|
||||
if (strpos($name, $delimiter) !== false) {
|
||||
$error = $RCMAIL->gettext('forbiddencharacter') . " ($char)";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
$OUTPUT->command('display_message', $error, 'error');
|
||||
}
|
||||
else {
|
||||
if ($options['protected'] || $options['norename']) {
|
||||
$name_imap = $old_imap;
|
||||
}
|
||||
else if (strlen($path)) {
|
||||
$name_imap = $path . $delimiter . $name_imap;
|
||||
}
|
||||
else {
|
||||
$name_imap = $STORAGE->mod_folder($name_imap, 'in');
|
||||
}
|
||||
}
|
||||
|
||||
// Check access rights to the parent folder
|
||||
if (!$error && strlen($path) && (!strlen($old_imap) || $old_imap != $name_imap)
|
||||
&& $STORAGE->get_capability('ACL')
|
||||
) {
|
||||
$parent_opts = $STORAGE->folder_info($path);
|
||||
if ($parent_opts['namespace'] != 'personal'
|
||||
&& (empty($parent_opts['rights']) || !preg_match('/[ck]/', implode($parent_opts['rights'])))
|
||||
) {
|
||||
$error = $RCMAIL->gettext('parentnotwritable');
|
||||
}
|
||||
}
|
||||
|
||||
if ($error) {
|
||||
$OUTPUT->command('display_message', $error, 'error');
|
||||
}
|
||||
else {
|
||||
$folder['name'] = $name_imap;
|
||||
$folder['oldname'] = $old_imap;
|
||||
$folder['class'] = '';
|
||||
$folder['options'] = $options;
|
||||
$folder['settings'] = array(
|
||||
// List view mode: 0-list, 1-threads
|
||||
'view_mode' => (int) rcube_utils::get_input_value('_viewmode', rcube_utils::INPUT_POST),
|
||||
'sort_column' => rcube_utils::get_input_value('_sortcol', rcube_utils::INPUT_POST),
|
||||
'sort_order' => rcube_utils::get_input_value('_sortord', rcube_utils::INPUT_POST),
|
||||
);
|
||||
}
|
||||
|
||||
// create a new mailbox
|
||||
if (!$error && !strlen($old_imap)) {
|
||||
$folder['subscribe'] = true;
|
||||
|
||||
$plugin = $RCMAIL->plugins->exec_hook('folder_create', array('record' => $folder));
|
||||
|
||||
$folder = $plugin['record'];
|
||||
|
||||
if (!$plugin['abort']) {
|
||||
$created = $STORAGE->create_folder($folder['name'], $folder['subscribe']);
|
||||
}
|
||||
else {
|
||||
$created = $plugin['result'];
|
||||
}
|
||||
|
||||
if ($created) {
|
||||
// Save folder settings
|
||||
if (isset($_POST['_viewmode'])) {
|
||||
$a_threaded = (array) $RCMAIL->config->get('message_threading', array());
|
||||
|
||||
$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');
|
||||
$OUTPUT->send('iframe');
|
||||
}
|
||||
else {
|
||||
// show error message
|
||||
$OUTPUT->show_message($plugin['message'] ?: 'errorsaving', 'error', null, false);
|
||||
}
|
||||
}
|
||||
// update a mailbox
|
||||
else if (!$error) {
|
||||
$plugin = $RCMAIL->plugins->exec_hook('folder_update', array('record' => $folder));
|
||||
|
||||
$folder = $plugin['record'];
|
||||
$rename = ($folder['oldname'] != $folder['name']);
|
||||
|
||||
if (!$plugin['abort']) {
|
||||
if ($rename) {
|
||||
$updated = $STORAGE->rename_folder($folder['oldname'], $folder['name']);
|
||||
}
|
||||
else {
|
||||
$updated = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$updated = $plugin['result'];
|
||||
}
|
||||
|
||||
if ($updated) {
|
||||
// Update folder settings,
|
||||
if (isset($_POST['_viewmode'])) {
|
||||
$a_threaded = (array) $RCMAIL->config->get('message_threading', array());
|
||||
|
||||
// In case of name change update names of childrens in settings
|
||||
if ($rename) {
|
||||
$oldprefix = '/^' . preg_quote($folder['oldname'] . $delimiter, '/') . '/';
|
||||
foreach ($a_threaded as $key => $val) {
|
||||
if ($key == $folder['oldname']) {
|
||||
unset($a_threaded[$key]);
|
||||
}
|
||||
else if (preg_match($oldprefix, $key)) {
|
||||
unset($a_threaded[$key]);
|
||||
$a_threaded[preg_replace($oldprefix, $folder['name'].$delimiter, $key)] = $val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$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
|
||||
if ($_SESSION['mbox'] === $folder['oldname']) {
|
||||
$_SESSION['mbox'] = $folder['name'];
|
||||
}
|
||||
rcmail_update_folder_row($folder['name'], $folder['oldname'], $folder['subscribe'], $folder['class']);
|
||||
$OUTPUT->send('iframe');
|
||||
}
|
||||
else if (!empty($folder['class'])) {
|
||||
rcmail_update_folder_row($folder['name'], $folder['oldname'], $folder['subscribe'], $folder['class']);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// show error message
|
||||
$OUTPUT->show_message($plugin['message'] ?: 'errorsaving', 'error', null, false);
|
||||
}
|
||||
}
|
||||
|
||||
$RCMAIL->overwrite_action('edit-folder');
|
266
data/web/rc/program/steps/settings/save_identity.inc
Normal file
266
data/web/rc/program/steps/settings/save_identity.inc
Normal file
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/steps/settings/save_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: |
|
||||
| Save an identity record or to add a new one |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
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_boolean_cols = array('standard', 'html_signature');
|
||||
$updated = $default_id = false;
|
||||
|
||||
// check input
|
||||
if (empty($_POST['_email']) && (IDENTITIES_LEVEL == 0 || IDENTITIES_LEVEL == 2)) {
|
||||
$OUTPUT->show_message('noemailwarning', '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);
|
||||
}
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
// make the identity a "default" if only one identity is allowed
|
||||
if (IDENTITIES_LEVEL > 1) {
|
||||
$save_data['standard'] = 1;
|
||||
}
|
||||
|
||||
// unset email address if user has no rights to change it
|
||||
if (IDENTITIES_LEVEL == 1 || IDENTITIES_LEVEL == 3) {
|
||||
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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 ($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 (!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
|
||||
// when the form is displayed again
|
||||
unset($_POST['_signature']);
|
||||
}
|
||||
|
||||
// update an existing identity
|
||||
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
|
||||
$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'] ?: '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();
|
||||
}
|
||||
|
||||
$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 (!$plugin['abort'])
|
||||
$insert_id = $save_data['email'] ? $RCMAIL->user->insert_identity($save_data) : null;
|
||||
else
|
||||
$insert_id = $plugin['result'];
|
||||
|
||||
if ($insert_id) {
|
||||
$RCMAIL->plugins->exec_hook('identity_create_after', array('id' => $insert_id, 'record' => $save_data));
|
||||
|
||||
$OUTPUT->show_message('successfullysaved', 'confirmation', null, false);
|
||||
|
||||
$_GET['_iid'] = $insert_id;
|
||||
|
||||
if (!empty($save_data['standard'])) {
|
||||
$default_id = $insert_id;
|
||||
}
|
||||
|
||||
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'] ?: 'errorsaving', 'error', null, false);
|
||||
$RCMAIL->overwrite_action('edit-identity');
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$OUTPUT->show_message('opnotpermitted', 'error');
|
||||
}
|
||||
|
||||
// mark all other identities as 'not-default'
|
||||
if ($default_id) {
|
||||
$RCMAIL->user->set_default($default_id);
|
||||
}
|
||||
|
||||
// go to next step
|
||||
if (!empty($_REQUEST['_framed'])) {
|
||||
$RCMAIL->overwrite_action('edit-identity');
|
||||
}
|
||||
else {
|
||||
$RCMAIL->overwrite_action('identities');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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(\w+)[\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_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)
|
||||
{
|
||||
// Add header with charset spec., washtml cannot work without that
|
||||
$html = '<html><head>'
|
||||
. '<meta http-equiv="Content-Type" content="text/html; charset='.RCUBE_CHARSET.'" />'
|
||||
. '</head><body>' . $html . '</body></html>';
|
||||
|
||||
// clean HTML with washhtml by Frederic Motte
|
||||
$wash_opts = array(
|
||||
'show_washed' => false,
|
||||
'allow_remote' => 1,
|
||||
'charset' => RCUBE_CHARSET,
|
||||
'html_elements' => array('body', 'link'),
|
||||
'html_attribs' => array('rel', 'type'),
|
||||
);
|
||||
|
||||
// initialize HTML washer
|
||||
$washer = new rcube_washtml($wash_opts);
|
||||
|
||||
//$washer->add_callback('form', 'rcmail_washtml_callback');
|
||||
//$washer->add_callback('style', 'rcmail_washtml_callback');
|
||||
|
||||
// Remove non-UTF8 characters (#1487813)
|
||||
$html = rcube_charset::clean($html);
|
||||
|
||||
$html = $washer->wash($html);
|
||||
|
||||
// remove unwanted comments and tags (produced by washtml)
|
||||
$html = preg_replace(array('/<!--[^>]+-->/', '/<\/?body>/'), '', $html);
|
||||
|
||||
return $html;
|
||||
}
|
223
data/web/rc/program/steps/settings/save_prefs.inc
Normal file
223
data/web/rc/program/steps/settings/save_prefs.inc
Normal file
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
+-----------------------------------------------------------------------+
|
||||
| program/steps/settings/save_prefs.inc |
|
||||
| |
|
||||
| This file is part of the Roundcube Webmail client |
|
||||
| Copyright (C) 2005-2016, 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: |
|
||||
| Save user preferences to DB and to the current session |
|
||||
| |
|
||||
+-----------------------------------------------------------------------+
|
||||
| Author: Thomas Bruederli <roundcube@gmail.com> |
|
||||
| Author: Aleksander Machniak <alec@alec.pl> |
|
||||
+-----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
$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':
|
||||
$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']),
|
||||
'refresh_interval' => isset($_POST['_refresh_interval']) ? intval($_POST['_refresh_interval'])*60 : $CONFIG['refresh_interval'],
|
||||
'standard_windows' => isset($_POST['_standard_windows']),
|
||||
'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'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'mailbox':
|
||||
$a_user_prefs = array(
|
||||
'mail_read_time' => isset($_POST['_mail_read_time']) ? intval($_POST['_mail_read_time']) : $CONFIG['mail_read_time'],
|
||||
'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']),
|
||||
'mail_pagesize' => is_numeric($_POST['_mail_pagesize']) ? max(2, intval($_POST['_mail_pagesize'])) : $CONFIG['mail_pagesize'],
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case 'mailview':
|
||||
$a_user_prefs = array(
|
||||
'message_extwin' => intval($_POST['_message_extwin']),
|
||||
'message_show_email' => isset($_POST['_message_show_email']),
|
||||
'prefer_html' => isset($_POST['_prefer_html']),
|
||||
'inline_images' => isset($_POST['_inline_images']),
|
||||
'show_images' => isset($_POST['_show_images']) ? intval($_POST['_show_images']) : 0,
|
||||
'display_next' => isset($_POST['_display_next']),
|
||||
'default_charset' => rcube_utils::get_input_value('_default_charset', rcube_utils::INPUT_POST),
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
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']),
|
||||
'mdn_default' => isset($_POST['_mdn_default']),
|
||||
'dsn_default' => isset($_POST['_dsn_default']),
|
||||
'reply_same_folder' => isset($_POST['_reply_same_folder']),
|
||||
'spellcheck_before_send' => isset($_POST['_spellcheck_before_send']),
|
||||
'spellcheck_ignore_syms' => isset($_POST['_spellcheck_ignore_syms']),
|
||||
'spellcheck_ignore_nums' => isset($_POST['_spellcheck_ignore_nums']),
|
||||
'spellcheck_ignore_caps' => isset($_POST['_spellcheck_ignore_caps']),
|
||||
'show_sig' => isset($_POST['_show_sig']) ? intval($_POST['_show_sig']) : 1,
|
||||
'reply_mode' => isset($_POST['_reply_mode']) ? intval($_POST['_reply_mode']) : 0,
|
||||
'sig_below' => isset($_POST['_sig_below']),
|
||||
'strip_existing_sig' => isset($_POST['_strip_existing_sig']),
|
||||
'sig_separator' => isset($_POST['_sig_separator']),
|
||||
'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_save_localstorage' => intval($_POST['_compose_save_localstorage']),
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
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']),
|
||||
'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;
|
||||
|
||||
case 'server':
|
||||
$a_user_prefs = array(
|
||||
'read_when_deleted' => isset($_POST['_read_when_deleted']),
|
||||
'skip_deleted' => isset($_POST['_skip_deleted']),
|
||||
'flag_for_deletion' => isset($_POST['_flag_for_deletion']),
|
||||
'delete_always' => isset($_POST['_delete_always']),
|
||||
'delete_junk' => isset($_POST['_delete_junk']),
|
||||
'logout_purge' => isset($_POST['_logout_purge']),
|
||||
'logout_expunge' => isset($_POST['_logout_expunge']),
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case 'folders':
|
||||
$a_user_prefs = array(
|
||||
'show_real_foldernames' => isset($_POST['_show_real_foldernames']),
|
||||
// stop using SPECIAL-USE (#4782)
|
||||
'lock_special_folders' => !in_array('lock_special_folders', (array) $CONFIG['dont_override']),
|
||||
);
|
||||
|
||||
foreach (rcube_storage::$folder_types as $type) {
|
||||
$a_user_prefs[$type . '_mbox'] = rcube_utils::get_input_value('_' . $type . '_mbox', rcube_utils::INPUT_POST, true);
|
||||
};
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
$plugin = rcmail::get_instance()->plugins->exec_hook('preferences_save',
|
||||
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];
|
||||
}
|
||||
|
||||
|
||||
// verify some options
|
||||
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);
|
||||
}
|
||||
|
||||
// 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']);
|
||||
else if ($RCMAIL->config->get('skin') != $a_user_prefs['skin'])
|
||||
$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'];
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'mailbox':
|
||||
// force min size
|
||||
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'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'addressbook':
|
||||
// force min size
|
||||
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'];
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'folders':
|
||||
$storage = $RCMAIL->get_storage();
|
||||
$specials = array();
|
||||
|
||||
foreach (rcube_storage::$folder_types as $type) {
|
||||
$specials[$type] = $a_user_prefs[$type . '_mbox'];
|
||||
}
|
||||
|
||||
$storage->set_special_folders($specials);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// Save preferences
|
||||
if (!$plugin['abort'])
|
||||
$saved = $RCMAIL->user->save_prefs($a_user_prefs);
|
||||
else
|
||||
$saved = $plugin['result'];
|
||||
|
||||
if ($saved)
|
||||
$OUTPUT->show_message('successfullysaved', 'confirmation');
|
||||
else
|
||||
$OUTPUT->show_message($plugin['message'] ?: 'errorsaving', 'error');
|
||||
|
||||
// display the form again
|
||||
$RCMAIL->overwrite_action('edit-prefs');
|
144
data/web/rc/program/steps/settings/upload.inc
Normal file
144
data/web/rc/program/steps/settings/upload.inc
Normal file
@@ -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 = preg_replace('/(add|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(rcube_utils::max_upload_size());
|
||||
$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');
|
Reference in New Issue
Block a user