diff --git a/modoboa/extensions/webmail/static/webmail/js/webmail.js b/modoboa/extensions/webmail/static/webmail/js/webmail.js
index c9c745bea..d60e2cfec 100644
--- a/modoboa/extensions/webmail/static/webmail/js/webmail.js
+++ b/modoboa/extensions/webmail/static/webmail/js/webmail.js
@@ -536,7 +536,7 @@ Webmail.prototype = {
return;
}
$parent = $ul;
- mailbox = $parent.attr("name") + this.hdelimiter + mailbox;
+ mailbox = $parent.attr("name") + this.options.hdelimiter + mailbox;
} else {
$parent = $("#mboxes_container").children("ul");
}
@@ -549,8 +549,8 @@ Webmail.prototype = {
* If needed, the mailbox will be moved to its new location.
*/
rename_mailbox: function(oldname, newname, oldparent, newparent) {
- var oldpattern = (oldparent) ? oldparent + this.hdelimiter + oldname : oldname;
- var newpattern = (newparent) ? newparent + this.hdelimiter + newparent : newname;
+ var oldpattern = (oldparent) ? oldparent + this.options.hdelimiter + oldname : oldname;
+ var newpattern = (newparent) ? newparent + this.options.hdelimiter + newname : newname;
var $link = $("#folders").find('a[href="' + oldpattern + '"]');
if (oldname != newname) {
@@ -560,14 +560,13 @@ Webmail.prototype = {
$link.parent("li").attr("name", newpattern);
$link.prepend($i);
$link.attr("href", newpattern);
- this.navobject.setparam("mbox", newname).update(false, true);
+ this.navobject.setparam("mbox", newpattern).update(false, true);
}
if (oldparent != newparent) {
- var newlocation = (newparent) ? newparent + this.hdelimiter + newname : newname;
this.remove_mbox_from_tree($link.parent("li"));
this.add_mailbox_to_tree(newparent, newname);
if (this.navobject.getparam("action") == "listmailbox") {
- this.navobject.setparam("mbox", newlocation).update();
+ this.navobject.setparam("mbox", newpattern).update();
} else {
this.select_mailbox("INBOX");
}
diff --git a/modoboa/extensions/webmail/templates/webmail/folder.html b/modoboa/extensions/webmail/templates/webmail/folder.html
index 717997f59..e0c03b57e 100644
--- a/modoboa/extensions/webmail/templates/webmail/folder.html
+++ b/modoboa/extensions/webmail/templates/webmail/folder.html
@@ -4,7 +4,7 @@
- {% print_mailboxes mboxes selected withunseen selectonly %}
+ {% print_mailboxes mboxes selected withunseen selectonly hdelimiter %}
{% endblock %}
diff --git a/modoboa/extensions/webmail/templatetags/webextras.py b/modoboa/extensions/webmail/templatetags/webextras.py
index 7efffbb13..03a85cf2e 100644
--- a/modoboa/extensions/webmail/templatetags/webextras.py
+++ b/modoboa/extensions/webmail/templatetags/webextras.py
@@ -119,7 +119,7 @@ def listmailbox_menu(selection, folder, user):
))
@register.simple_tag
-def print_mailboxes(tree, selected=None, withunseen=False, selectonly=False):
+def print_mailboxes(tree, selected=None, withunseen=False, selectonly=False, hdelimiter='.'):
"""Display a tree of mailboxes and sub-mailboxes
:param tree: the mailboxes to display
@@ -129,7 +129,7 @@ def print_mailboxes(tree, selected=None, withunseen=False, selectonly=False):
for mbox in tree:
cssclass = ""
name = mbox["path"] if mbox.has_key("sub") else mbox["name"]
- label = separate_mailbox(mbox["name"])[0]
+ label = separate_mailbox(mbox["name"], hdelimiter)[0]
if selected == name:
cssclass = "active"
result += "\n" % (name, cssclass)
@@ -157,7 +157,7 @@ def print_mailboxes(tree, selected=None, withunseen=False, selectonly=False):
'selectfolder' if selectonly else 'loadfolder', extra_attrs, iclass, label)
if mbox.has_key("sub") and len(mbox["sub"]):
result += "" % (mbox["path"], ul_state) \
- + print_mailboxes(mbox["sub"], selected, withunseen, selectonly) + "
\n"
+ + print_mailboxes(mbox["sub"], selected, withunseen, selectonly, hdelimiter) + "\n"
result += "\n"
return result
diff --git a/modoboa/extensions/webmail/views.py b/modoboa/extensions/webmail/views.py
index 968ee4436..113b831da 100644
--- a/modoboa/extensions/webmail/views.py
+++ b/modoboa/extensions/webmail/views.py
@@ -134,7 +134,8 @@ def newfolder(request, tplname="webmail/folder.html"):
"action_classes": "submit",
"withunseen": False,
"selectonly": True,
- "mboxes": mbc.getmboxes(request.user)}
+ "mboxes": mbc.getmboxes(request.user),
+ "hdelimiter": mbc.hdelimiter}
if request.method == "POST":
form = FolderForm(request.POST)
@@ -164,14 +165,15 @@ def editfolder(request, tplname="webmail/folder.html"):
"action_label" : _("Update"),
"action_classes" : "submit",
"withunseen" : False,
- "selectonly" : True}
+ "selectonly" : True,
+ "hdelimiter": mbc.hdelimiter}
if request.method == "POST":
form = FolderForm(request.POST)
if form.is_valid():
pf = request.POST.get("parent_folder", None)
ctx["selected"] = pf
- oldname, oldparent = separate_mailbox(request.POST["oldname"])
+ oldname, oldparent = separate_mailbox(request.POST["oldname"], sep=mbc.hdelimiter)
res = dict(status="ok", respmsg=_("Mailbox updated"))
if form.cleaned_data["name"] != oldname \
or (pf != oldparent):
@@ -193,7 +195,7 @@ def editfolder(request, tplname="webmail/folder.html"):
name = request.GET.get("name", None)
if name is None:
raise WebmailError(_("Invalid request"))
- shortname, parent = separate_mailbox(name)
+ shortname, parent = separate_mailbox(name, sep=mbc.hdelimiter)
ctx["mboxes"] = mbc.getmboxes(request.user, until_mailbox=parent)
ctx["form"] = FolderForm()
ctx["form"].fields["oldname"].initial = name