Thomas Bruederli wrote:
An attempt to fix feature request #1457344, select parent folder when creating new folder.
[...]
To use it in the settings part we have to move it to include/main.inc. Don't forget to move the related functions rcmail_build_folder_tree(), rcmail_render_folder_tree_html() and rcmail_render_folder_tree_select() as well.
OK, rewritten. The patch is slightly (4 times) larger now :)
Renaming of folders is a bit weird, I'm not yet sure how that is supposed to be done now.
Robin
--- program/include/main.inc (revision 456) +++ program/include/main.inc (working copy) @@ -2036,4 +2036,213 @@ console(sprintf("%s: %0.4f sec", $label, $diff)); }
+// return the mailboxlist in HTML +function rcmail_mailbox_list($attrib)
array('style', 'class', 'id');
rcube_label($attrib['noselection']));
rcmail_build_folder_tree($a_mailboxes, $folder, $delimiter);
+// create a hierarchical array of the mailbox list +function rcmail_build_folder_tree(&$arrFolders, $folder, $delm='/', $path='')
'name' => rcube_charset_convert($currentFolder, 'UTF-7'),
'folders' => array());
+// return html for a structured list <ul> for the mailbox tree +function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox_name, $maxlength, $nestLevel=0)
$foldername = rcube_label($folder_lc);
{
$foldername = $folder['name'];
// shorten the folder name to a given length
if ($maxlength && $maxlength>1)
{
$fname = abbrevate_string($foldername, $maxlength);
if ($fname != $foldername)
$title = ' title="'.Q($foldername).'"';
$foldername = $fname;
}
}
$foldername .= sprintf(' (%d)', $unread_count);
$class_name = 'sent';
$class_name = 'drafts';
$class_name = 'trash';
$class_name = 'junk';
$out .= sprintf('<li id="rcmbx%s" class="mailbox %s %s%s%s"><a href="%s&_mbox=%s"'.
' onclick="return %s.command(\'list\',\'%s\')"'.
' onmouseover="return %s.focus_mailbox(\'%s\')"' .
' onmouseout="return %s.unfocus_mailbox(\'%s\')"' .
' onmouseup="return %s.mbox_mouse_up(\'%s\')"%s>%s</a>',
$folder_css,
$class_name,
$zebra_class,
$unread_count ? ' unread' : '',
$folder['id']==$mbox_name ? ' selected' : '',
$COMM_PATH,
urlencode($folder['id']),
$JS_OBJECT_NAME,
$js_name,
$JS_OBJECT_NAME,
$js_name,
$JS_OBJECT_NAME,
$js_name,
$JS_OBJECT_NAME,
$js_name,
$title,
Q($foldername));
$out .= "\n<ul>\n" . rcmail_render_folder_tree_html($folder['folders'], $special, $mbox_name, $maxlength, $nestLevel+1) . "</ul>\n";
+// return html for a flat list <select> for the mailbox tree +function rcmail_render_folder_tree_select(&$arrFolders, &$special, &$mbox_name, $maxlength, $nestLevel=0)
$foldername = rcube_label($folder_lc);
{
$foldername = $folder['name'];
// shorten the folder name to a given length
if ($maxlength && $maxlength>1)
$foldername = abbrevate_string($foldername, $maxlength);
}
$out .= sprintf('<option value="%s">%s%s</option>'."\n",
htmlspecialchars($folder['id']),
str_repeat(' ', $nestLevel*4),
Q($foldername));
$out .= rcmail_render_folder_tree_select($folder['folders'], $special, $mbox_name, $maxlength, $nestLevel+1);
?> Index: program/localization/nl_NL/labels.inc =================================================================== --- program/localization/nl_NL/labels.inc (revision 456) +++ program/localization/nl_NL/labels.inc (working copy) @@ -224,6 +224,7 @@
$labels['folder'] = 'Map'; $labels['folders'] = 'Mappen'; +$labels['parentfolder'] = 'Hoofdmap'; $labels['foldername'] = 'Mapnaam'; $labels['subscribed'] = 'Geabonneerd'; $labels['create'] = 'Nieuw'; Index: program/localization/en_US/labels.inc =================================================================== --- program/localization/en_US/labels.inc (revision 456) +++ program/localization/en_US/labels.inc (working copy) @@ -223,6 +223,7 @@
$labels['folder'] = 'Folder'; $labels['folders'] = 'Folders'; +$labels['parentfolder'] = 'Parent folder'; $labels['foldername'] = 'Folder name'; $labels['subscribed'] = 'Subscribed'; $labels['create'] = 'Create'; Index: program/js/app.js =================================================================== --- program/js/app.js (revision 456) +++ program/js/app.js (working copy) @@ -2426,10 +2426,13 @@
var form;
if ((form = this.gui_objects.editform) && form.elements['_folder_name'])
{ name = form.elements['_folder_name'].value;
fparent = form.elements['mailboxlist'].value;
}
if (name)
this.http_request('create-folder', '_name='+urlencode(name), true);
this.http_request('create-folder', '_name='+urlencode(name)+'&_parent='+urlencode(fparent), true);
else if (form.elements['_folder_name'])
form.elements['_folder_name'].focus();
};--- program/steps/settings/manage_folders.inc (revision 456) +++ program/steps/settings/manage_folders.inc (working copy) @@ -47,18 +47,24 @@ else if ($_action=='create-folder') { if (!empty($_GET['_name']))
{
$name = trim(get_input_value('_name', RCUBE_INPUT_GET, FALSE, 'UTF-7'));
if (!empty($_GET['_parent']) && $_GET['_parent'])
$name = trim(get_input_value('_parent', RCUBE_INPUT_GET, FALSE, 'UTF-7')) . $IMAP->delimiter . $name;
$create = $IMAP->create_mailbox($name, TRUE);
}
if ($create && $REMOTE_REQUEST) {
JQ(rcube_charset_convert($create, 'UTF-7')));
JQ($display_create));
rcube_remote_response($commands);
}
else if (!$create && $REMOTE_REQUEST)
{@@ -167,7 +173,9 @@ $zebra_class = $i%2 ? 'even' : 'odd'; $folder_js = JQ($folder); $folder_js_enc = JQ(rcube_charset_convert($folder, 'UTF-7'));
$display_folder = str_repeat(' ', substr_count($folder, $IMAP->delimiter)).preg_replace('/.*'.preg_quote($IMAP->delimiter).'/', '', rcube_charset_convert($folder, 'UTF-7'));
$folder_html = $CONFIG['protect_default_folders'] && in_array($folder, $CONFIG['default_imap_folders']) ? rcube_label(strtolower($folder)) : $display_folder;
if (!$protected) $a_js_folders['rcmrow'.($i+1)] = array($folder_js, $folder_js_enc);
@@ -239,6 +247,7 @@ return $out; }
function rcube_rename_folder_form($attrib) { global $CONFIG, $IMAP, $JS_OBJECT_NAME; Index: program/steps/mail/func.inc =================================================================== --- program/steps/mail/func.inc (revision 456) +++ program/steps/mail/func.inc (working copy) @@ -74,222 +74,7 @@ if ($CONFIG['junk_mbox']) $OUTPUT->add_script(sprintf("%s.set_env('junk_mailbox', '%s');", $JS_OBJECT_NAME, $CONFIG['junk_mbox']));
-// return the mailboxlist in HTML -function rcmail_mailbox_list($attrib)
{
global $IMAP, $CONFIG, $OUTPUT, $JS_OBJECT_NAME, $COMM_PATH;
static $s_added_script = FALSE;
static $a_mailboxes;
// add some labels to client
rcube_add_label('purgefolderconfirm');
rcube_add_label('deletemessagesconfirm');
-// $mboxlist_start = rcube_timer();
array('style', 'class', 'id');
rcube_label($attrib['noselection']));
-// rcube_print_time($mboxlist_start, 'list_mailboxes()');
rcmail_build_folder_tree($a_mailboxes, $folder, $delimiter);
-// var_dump($a_mailboxes);
-// rcube_print_time($mboxlist_start, 'render_folder_tree()');
-// create a hierarchical array of the mailbox list -function rcmail_build_folder_tree(&$arrFolders, $folder, $delm='/', $path='')
'name' => rcube_charset_convert($currentFolder, 'UTF-7'),
'folders' => array());
-// return html for a structured list <ul> for the mailbox tree -function rcmail_render_folder_tree_html(&$arrFolders, &$special, &$mbox_name, $maxlength, $nestLevel=0)
$foldername = rcube_label($folder_lc);
{
$foldername = $folder['name'];
// shorten the folder name to a given length
if ($maxlength && $maxlength>1)
{
$fname = abbrevate_string($foldername, $maxlength);
if ($fname != $foldername)
$title = ' title="'.Q($foldername).'"';
$foldername = $fname;
}
}
$foldername .= sprintf(' (%d)', $unread_count);
$class_name = 'sent';
$class_name = 'drafts';
$class_name = 'trash';
$class_name = 'junk';
' onclick="return %s.command(\'list\',\'%s\')"'.
' onmouseover="return %s.focus_mailbox(\'%s\')"' .
' onmouseout="return %s.unfocus_mailbox(\'%s\')"' .
' onmouseup="return %s.mbox_mouse_up(\'%s\')"%s>%s</a>',
$folder_css,
$class_name,
$zebra_class,
$unread_count ? ' unread' : '',
$folder['id']==$mbox_name ? ' selected' : '',
$COMM_PATH,
urlencode($folder['id']),
$JS_OBJECT_NAME,
$js_name,
$JS_OBJECT_NAME,
$js_name,
$JS_OBJECT_NAME,
$js_name,
$JS_OBJECT_NAME,
$js_name,
$title,
Q($foldername));
$out .= "\n<ul>\n" . rcmail_render_folder_tree_html($folder['folders'], $special, $mbox_name, $maxlength, $nestLevel+1) . "</ul>\n";
-// return html for a flat list <select> for the mailbox tree -function rcmail_render_folder_tree_select(&$arrFolders, &$special, &$mbox_name, $maxlength, $nestLevel=0)
$foldername = rcube_label($folder_lc);
{
$foldername = $folder['name'];
// shorten the folder name to a given length
if ($maxlength && $maxlength>1)
$foldername = abbrevate_string($foldername, $maxlength);
}
htmlspecialchars($folder['id']),
str_repeat(' ', $nestLevel*4),
Q($foldername));
$out .= rcmail_render_folder_tree_select($folder['folders'], $special, $mbox_name, $maxlength, $nestLevel+1);
// return the message list as HTML table function rcmail_message_list($attrib) { Index: skins/default/templates/managefolders.html =================================================================== --- skins/default/templates/managefolders.html (revision 456) +++ skins/default/templates/managefolders.html (working copy) @@ -25,9 +25,25 @@
<div class="boxtitle"><roundcube:label name="createfolder" /></div>
<div class="settingspart"> +<table border="0" cellspacing="0" cellpadding="1"> +<tr> +<td> +<roundcube:label name="parentfolder" />: +</td> +<td> +<roundcube:object name="mailboxlist" type="select" noSelection="none" maxlength="25" class="mboxlist" /> +</td> +</tr> +<tr> +<td> <roundcube:label name="foldername" />: +</td> +<td> <roundcube:object name="createfolder" form="subscriptionform" /> <roundcube:button command="create-folder" type="input" class="button" label="create" /> +</td> +</tr> +</table> </div> </div>