summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2016-02-07 11:40:02 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2016-02-07 11:40:02 +0100
commit9b3d1e8d7eb47c48f7fe4a51d0a6b3c7d4060358 (patch)
tree77eb22c121f294071e11e6434528676631634be6
parent6f8c9e5f15cb1fdb986fc9a8ce4f3fd8e13e9d4d (diff)
downloadpykolab-9b3d1e8d7eb47c48f7fe4a51d0a6b3c7d4060358.tar.gz
Allow three locations for the specification of folders to automatically create when a user is added:
# The section in the configuration that is named after the child or alias domain used for the result attribute of the user, # The section in the configuration that is named after the primary domain used for the result attribute of the user, # The default section, [kolab] This means that, for example: ``` [kolab] auto_createfolders = [ { 'Some folder': {} } ] [primary.tld] auto_createfolders = [ { 'Not another folder': {} } ] [alias.tld] auto_createfolders = [ { 'Yes please another folder': {} } ] ``` A user with a result attribute (`mail` by default) value of `john@alias.tld` will have a folder named *Yes please another folder*, and `john@primary.tld` will get a folder named *Not another folder*.
-rw-r--r--pykolab/imap/__init__.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index 21d918b..3126808 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -522,6 +522,9 @@ class IMAP(object):
if not hasattr(self, 'domain'):
self.domain == None
+ if self.domain == None and len(mailbox_base_name.split('@')) > 1:
+ self.domain = mailbox_base_name.split('@')[1]
+
if not self.domain == None:
if conf.has_option(self.domain, "autocreate_folders"):
_additional_folders = conf.get_raw(
@@ -529,6 +532,19 @@ class IMAP(object):
"autocreate_folders"
)
+ else:
+ auth = Auth()
+ auth.connect()
+ domains = auth._list_domains(self.domain)
+ auth.disconnect()
+ if len(domains) > 0:
+ (primary,secondaries) = domains[1]
+ if conf.has_option(primary, "autocreate_folders"):
+ _additional_folders = conf.get_raw(
+ primary,
+ "autocreate_folders"
+ )
+
if _additional_folders == None:
if conf.has_option('kolab', "autocreate_folders"):
_additional_folders = conf.get_raw(