From 15cf4fa9251f01313b5eb5cf1a91ec10643d42cb Mon Sep 17 00:00:00 2001
From: Aleksander Machniak <alec@alec.pl>
Date: Wed, 21 Nov 2012 13:55:34 -0500
Subject: [PATCH] Rename rcube_bc.inc to bc.php for consistency
---
program/steps/settings/edit_folder.inc | 189 ++++++++++++++++++++++++++---------------------
1 files changed, 104 insertions(+), 85 deletions(-)
diff --git a/program/steps/settings/edit_folder.inc b/program/steps/settings/edit_folder.inc
index 36e3df0..cd23727 100644
--- a/program/steps/settings/edit_folder.inc
+++ b/program/steps/settings/edit_folder.inc
@@ -6,7 +6,10 @@
| |
| This file is part of the Roundcube Webmail client |
| Copyright (C) 2005-2009, The Roundcube Dev Team |
- | Licensed under the GNU GPL |
+ | |
+ | 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 |
@@ -14,19 +17,15 @@
+-----------------------------------------------------------------------+
| Author: Aleksander Machniak <alec@alec.pl> |
+-----------------------------------------------------------------------+
-
- $Id$
-
*/
// WARNING: folder names in UI are encoded with RCMAIL_CHARSET
-// init IMAP connection
-$RCMAIL->imap_connect();
-
-function rcube_folder_form($attrib)
+function rcmail_folder_form($attrib)
{
global $RCMAIL;
+
+ $storage = $RCMAIL->get_storage();
// edited folder name (empty in create-folder mode)
$mbox = trim(get_input_value('_mbox', RCUBE_INPUT_GPC, true));
@@ -36,25 +35,38 @@
$parent = trim(get_input_value('_path', RCUBE_INPUT_GPC, true));
$parent_imap = rcube_charset_convert($parent, RCMAIL_CHARSET, 'UTF7-IMAP');
- $delimiter = $RCMAIL->imap->get_hierarchy_delimiter();
- $special = (strlen($mbox_imap) && in_array($mbox_imap, (array) $RCMAIL->config->get('default_imap_folders')));
- $protected = ($special && $RCMAIL->config->get('protect_default_folders'));
- $threading_supported = $RCMAIL->imap->get_capability('THREAD');
+ $threading_supported = $storage->get_capability('THREAD');
+ $delimiter = $storage->get_hierarchy_delimiter();
- // Get mailbox stats (messages count, etc.), mailbox name and parent
+ // Get mailbox parameters
if (strlen($mbox)) {
- $msgcount = $RCMAIL->imap->messagecount($mbox_imap, 'ALL', true, false);
+ $options = rcmail_folder_options($mbox_imap);
+ $namespace = $storage->get_namespace();
$path = explode($delimiter, $mbox_imap);
$folder = array_pop($path);
$path = implode($delimiter, $path);
-
$folder = rcube_charset_convert($folder, 'UTF7-IMAP');
$hidden_fields = array('name' => '_mbox', 'value' => $mbox);
}
else {
- $path = $parent_imap;
+ $options = array();
+ $path = $parent_imap;
+
+ // 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();
@@ -65,8 +77,12 @@
);
// Location (name)
- if ($protected)
- $foldername = rcmail_localize_foldername($mbox_imap);
+ if ($options['protected']) {
+ $foldername = Q(str_replace($delimiter, ' » ', rcmail_localize_folderpath($mbox_imap)));
+ }
+ else if ($options['norename']) {
+ $foldername = Q($folder);
+ }
else {
if (isset($_POST['_name']))
$folder = trim(get_input_value('_name', RCUBE_INPUT_POST, true));
@@ -74,8 +90,9 @@
$foldername = new html_inputfield(array('name' => '_name', 'id' => '_name', 'size' => 30));
$foldername = $foldername->show($folder);
- if ($special)
- $foldername .= ' (' . rcmail_localize_foldername($mbox_imap) .')';
+ if ($options['special']) {
+ $foldername .= ' (' . Q(rcmail_localize_foldername($mbox_imap)) .')';
+ }
}
$form['props']['fieldsets']['location'] = array(
@@ -88,19 +105,35 @@
),
);
- if (strlen($path)) {
- $radio1 = new html_radiobutton(array('name' => '_parent', 'value' => ''));
- $radio2 = new html_radiobutton(array('name' => '_parent', 'value' => $path));
- $selected = isset($_POST['_parent']) ? $_POST['_parent'] : $path;
+ 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_imap);
- $html_path = str_replace($delimiter, ' » ', rcmail_localize_folderpath($path));
+ // 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);
+ }
- $folderpath = $radio1->show($selected) . Q(rcube_label('none')) . ' '
- .$radio2->show($selected) . Q($html_path);
+ $select = rcmail_mailbox_select(array(
+ 'name' => '_parent',
+ 'noselection' => '---',
+ 'realnames' => false,
+ 'maxlength' => 150,
+ 'unsubscribed' => true,
+ 'skip_noinferiors' => true,
+ 'exceptions' => $exceptions,
+ ));
$form['props']['fieldsets']['location']['content']['path'] = array(
'label' => rcube_label('parentfolder'),
- 'value' => $folderpath,
+ 'value' => $select->show($selected),
);
}
@@ -110,7 +143,7 @@
);
// Settings: threading
- if ($threading_supported) {
+ if ($threading_supported && ($mbox_imap == 'INBOX' || (!$options['noselect'] && !$options['is_root']))) {
$select = new html_select(array('name' => '_viewmode', 'id' => '_listmode'));
$select->add(rcube_label('list'), 0);
$select->add(rcube_label('threads'), 1);
@@ -164,41 +197,54 @@
// Number of messages
$form['props']['fieldsets']['info'] = array(
'name' => rcube_label('info'),
- 'content' => array(
- 'count' => array(
- 'label' => rcube_label('messagecount'),
- 'value' => (int) $msgcount,
- ),
- ),
+ 'content' => array()
);
- // Size
- if ($msgcount) {
- // create link with folder-size command
- $onclick = sprintf("return %s.command('folder-size', '%s', this)",
- JS_OBJECT_NAME, JQ($mbox_imap));
- $size = html::a(array('href' => '#', 'onclick' => $onclick, 'id' => 'folder-size'),
- rcube_label('getfoldersize'));
+ if ((!$options['noselect'] && !$options['is_root']) || $mbox_imap == 'INBOX') {
+ $msgcount = $storage->count($mbox_imap, 'ALL', true, false);
+
+ // Size
+ if ($msgcount) {
+ // create link with folder-size command
+ $onclick = sprintf("return %s.command('folder-size', '%s', this)",
+ JS_OBJECT_NAME, JQ($mbox_imap));
+ $size = html::a(array('href' => '#', 'onclick' => $onclick,
+ 'id' => 'folder-size'), rcube_label('getfoldersize'));
+ }
+ else {
+ // no messages -> zero size
+ $size = 0;
+ }
+
+ $form['props']['fieldsets']['info']['content']['count'] = array(
+ 'label' => rcube_label('messagecount'),
+ 'value' => (int) $msgcount
+ );
+ $form['props']['fieldsets']['info']['content']['size'] = array(
+ 'label' => rcube_label('size'),
+ 'value' => $size,
+ );
}
- else {
- // no messages -> zero size
- $size = 0;
+
+ // 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' => rcube_label('foldertype'),
+ 'value' => rcube_label($options['namespace'] . 'folder'));
}
- $form['props']['fieldsets']['info']['content']['size'] = array(
- 'label' => rcube_label('size'),
- 'value' => $size,
- );
}
// Allow plugins to modify folder form content
- $plugin = $RCMAIL->plugins->exec_hook('folder_form', array('form' => $form));
+ $plugin = $RCMAIL->plugins->exec_hook('folder_form',
+ array('form' => $form, 'options' => $options,
+ 'name' => $mbox_imap, 'parent_name' => $parent_imap));
$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']);
+ unset($attrib['form'], $attrib['id']);
// return the complete edit form as table
$out = "$form_start\n";
@@ -208,17 +254,17 @@
if (!empty($tab['fieldsets']) && is_array($tab['fieldsets'])) {
$content = '';
foreach ($tab['fieldsets'] as $fieldset) {
- $subcontent = rcmail_get_form_part($fieldset);
+ $subcontent = rcmail_get_form_part($fieldset, $attrib);
if ($subcontent) {
$content .= html::tag('fieldset', null, html::tag('legend', null, Q($fieldset['name'])) . $subcontent) ."\n";
}
}
}
else {
- $content = rcmail_get_form_part($tab);
+ $content = rcmail_get_form_part($tab, $attrib);
}
- if ($content) {
+ if ($content) {
$out .= html::tag('fieldset', null, html::tag('legend', null, Q($tab['name'])) . $content) ."\n";
}
}
@@ -230,7 +276,7 @@
return $out;
}
-function rcmail_get_form_part($form)
+function rcmail_get_form_part($form, $attrib = array())
{
$content = '';
@@ -240,10 +286,10 @@
$colprop['id'] = '_'.$col;
$label = !empty($colprop['label']) ? $colprop['label'] : rcube_label($col);
- $table->add('title', sprintf('<label for="%s">%s</label>', $colprop['id'], Q($label)));
+ $table->add('title', html::label($colprop['id'], Q($label)));
$table->add(null, $colprop['value']);
}
- $content = $table->show();
+ $content = $table->show($attrib);
}
else {
$content = $form['content'];
@@ -252,39 +298,12 @@
return $content;
}
-function rcmail_localize_folderpath($path)
-{
- global $RCMAIL;
-
- $protect_folders = $RCMAIL->config->get('protect_default_folders');
- $default_folders = (array) $RCMAIL->config->get('default_imap_folders');
- $delimiter = $RCMAIL->imap->get_hierarchy_delimiter();
- $path = explode($delimiter, $path);
- $result = array();
-
- foreach ($path as $idx => $dir) {
- $directory = implode($delimiter, array_slice($path, 0, $idx+1));
- if ($protect_folders && in_array($directory, $default_folders)) {
- unset($result);
- $result[] = rcmail_localize_foldername($directory);
- }
- else if ($protect_folders && in_array($dir, $default_folders)) {
- $result[] = rcmail_localize_foldername($dir);
- }
- else {
- $result[] = rcube_charset_convert($dir, 'UTF7-IMAP');
- }
- }
-
- return implode($delimiter, $result);
-}
-
//$OUTPUT->set_pagetitle(rcube_label('folders'));
// register UI objects
$OUTPUT->add_handlers(array(
- 'folderdetails' => 'rcube_folder_form',
+ 'folderdetails' => 'rcmail_folder_form',
));
$OUTPUT->add_label('nonamewarning');
--
Gitblit v1.9.1