From: Florent Bruneau Date: Sun, 3 Oct 2010 20:14:42 +0000 (+0200) Subject: Add get_all_user_lists() to MM RPC. X-Git-Tag: xorg/1.0.1~105 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=d1c13dbf717545aab2c80434deccda318cbdc310;p=platal.git Add get_all_user_lists() to MM RPC. Signed-off-by: Florent Bruneau --- diff --git a/bin/lists.rpc.py b/bin/lists.rpc.py index c3cac82..8441ed4 100755 --- a/bin/lists.rpc.py +++ b/bin/lists.rpc.py @@ -812,6 +812,7 @@ def check_options(userdesc, perms, vhost, listname, correct=False): def get_all_lists(userdesc, perms, vhost): """ Get all the list for the given vhost + @root """ prefix = vhost.lower()+VHOST_SEP names = Utils.list_names() @@ -823,6 +824,31 @@ def get_all_lists(userdesc, perms, vhost): result.append(name.replace(prefix, '')) return result +def get_all_user_lists(userdesc, perms, vhost, email): + """ Get all the lists for the given user + @root + """ + names = Utils.list_names() + names.sort() + result = [] + for name in names: + try: + mlist = MailList.MailList(name, lock=0) + ismember = email in mlist.getRegularMemberKeys() + isowner = email in mlist.owner + if not ismember and not isowner: + continue + host = mlist.internal_name().split(VHOST_SEP)[0].lower() + result.append({ 'list': mlist.real_name, + 'addr': mlist.real_name.lower() + '@' + host, + 'host': host, + 'own' : isowner, + 'sub' : ismember + }) + except Exception, e: + continue + return result + def create_list(userdesc, perms, vhost, listname, desc, advertise, modlevel, inslevel, owners, members): """ Create a new list. @root @@ -1014,6 +1040,7 @@ server.register_function(set_admin_options) server.register_function(check_options) # create + del server.register_function(get_all_lists) +server.register_function(get_all_user_lists) server.register_function(create_list) server.register_function(delete_list) # utilisateurs.php