Changeset View
Changeset View
Standalone View
Standalone View
pykolab/imap/__init__.py
Show First 20 Lines • Show All 810 Lines • ▼ Show 20 Lines | def has_folder(self, folder): | ||||
folders = self.imap.lm(self.folder_utf7(folder)) | folders = self.imap.lm(self.folder_utf7(folder)) | ||||
log.debug(_("Looking for folder '%s', we found folders: %r") % (folder,[self.folder_utf8(x) for x in folders]), level=8) | log.debug(_("Looking for folder '%s', we found folders: %r") % (folder,[self.folder_utf8(x) for x in folders]), level=8) | ||||
# Greater then one, this folder may have subfolders. | # Greater then one, this folder may have subfolders. | ||||
if len(folders) > 0: | if len(folders) > 0: | ||||
return True | return True | ||||
else: | else: | ||||
return False | return False | ||||
def _set_kolab_mailfolder_acls(self, acls): | def _set_kolab_mailfolder_acls(self, acls, folder=None, update=False): | ||||
# special case, folder has no ACLs assigned and update was requested, | |||||
# remove all existing ACL entries | |||||
if update is True and isinstance(acls, list) and len(acls) == 0: | |||||
acls = self.list_acls(folder) | |||||
for subject in acls: | |||||
log.debug( | |||||
_("Removing ACL rights %s for subject %s on folder " + \ | |||||
"%s") % (acls[subject], subject, folder), level=8) | |||||
self.set_acl(folder, subject, '') | |||||
return | |||||
if isinstance(acls, basestring): | if isinstance(acls, basestring): | ||||
acls = [ acls ] | acls = [ acls ] | ||||
old_acls = None | |||||
for acl in acls: | for acl in acls: | ||||
exec("acl = %s" % (acl)) | exec("acl = %s" % (acl)) | ||||
folder = acl[0] | subject = acl[0] | ||||
subject = acl[1] | rights = acl[1] | ||||
rights = acl[2] | if len(acl) == 3: | ||||
if len(acl) == 4: | epoch = acl[2] | ||||
epoch = acl[3] | |||||
else: | else: | ||||
epoch = (int)(time.time()) + 3600 | epoch = (int)(time.time()) + 3600 | ||||
# update mode, check existing entries | |||||
if update is True: | |||||
if old_acls is None: | |||||
old_acls = self.list_acls(folder) | |||||
for old_subject in old_acls: | |||||
old_acls[old_subject] = old_acls[old_subject] | |||||
if subject in old_acls: | |||||
old_acls[subject] = None | |||||
if epoch > (int)(time.time()): | if epoch > (int)(time.time()): | ||||
log.debug( | log.debug( | ||||
_("Setting ACL rights %s for subject %s on folder " + \ | _("Setting ACL rights %s for subject %s on folder " + \ | ||||
"%s") % (rights,subject,folder), level=8) | "%s") % (rights,subject,folder), level=8) | ||||
self.set_acl( | self.set_acl( | ||||
folder, | folder, | ||||
"%s" % (subject), | "%s" % (subject), | ||||
"%s" % (rights) | "%s" % (rights) | ||||
) | ) | ||||
else: | else: | ||||
log.debug( | log.debug( | ||||
_("Removing ACL rights %s for subject %s on folder " + \ | _("Removing ACL rights %s for subject %s on folder " + \ | ||||
"%s") % (rights,subject,folder), level=8) | "%s") % (rights,subject,folder), level=8) | ||||
self.set_acl( | self.set_acl( | ||||
folder, | folder, | ||||
"%s" % (subject), | "%s" % (subject), | ||||
"" | "" | ||||
) | ) | ||||
# update mode, unset removed ACL entries | |||||
if old_acls is not None: | |||||
for subject in old_acls: | |||||
if old_acls[subject] is not None: | |||||
log.debug( | |||||
_("Removing ACL rights %s for subject %s on folder " + \ | |||||
"%s") % (old_acls[subject], subject, folder), level=8) | |||||
self.set_acl(folder, subject, '') | |||||
pass | pass | ||||
""" Blah functions """ | """ Blah functions """ | ||||
def move_user_folders(self, users=[], domain=None): | def move_user_folders(self, users=[], domain=None): | ||||
for user in users: | for user in users: | ||||
if type(user) == dict: | if type(user) == dict: | ||||
if user.has_key('old_mail'): | if user.has_key('old_mail'): | ||||
▲ Show 20 Lines • Show All 290 Lines • Show Last 20 Lines |