+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 change_user_email(userdesc, perms, vhost, from_email, to_email):
+ """ Change the email of a user
+ @root
+ """
+ from_email = from_email.lower()
+ to_email = to_email.lower()
+ for list in Utils.list_names():
+ try:
+ mlist = MailList.MailList(list, lock=0)
+ except:
+ continue
+ try:
+ mlist.Lock()
+ mlist.ApprovedChangeMemberAddress(from_email, to_email, 0)
+ mlist.Save()
+ mlist.Unlock()
+ except:
+ mlist.Unlock()
+ return 1
+
+