def POST(self, profile_type, mail): self.profile_type = web.safestr(profile_type) self.mail = str(mail) self.domain = self.mail.split('@', 1)[-1] i = web.input( mailForwardingAddress=[], moderators=[], ) aliasLib = aliaslib.Alias() result = aliasLib.update( profile_type=self.profile_type, mail=self.mail, data=i, ) if result[0] is True: raise web.seeother('/profile/alias/%s/%s?msg=UPDATED' % ( self.profile_type, self.mail, )) else: raise web.seeother('/profile/alias/%s/%s?msg=%s' % (self.profile_type, self.mail, result[1]))
def POST(self, domain): i = web.input(_unicode=False, mail=[]) self.domain = web.safestr(domain) self.mails = i.get('mail', []) self.action = i.get('action', None) msg = i.get('msg', None) aliasLib = aliaslib.Alias() if self.action == 'delete': result = aliasLib.delete( domain=self.domain, mails=self.mails, ) msg = 'DELETED' elif self.action == 'disable': result = aliasLib.enableOrDisableAccount( domain=self.domain, accounts=self.mails, active=False, ) msg = 'DISABLED' elif self.action == 'enable': result = aliasLib.enableOrDisableAccount( domain=self.domain, accounts=self.mails, active=True, ) msg = 'ENABLED' else: result = (False, 'INVALID_ACTION') if result[0] is True: raise web.seeother('/aliases/%s?msg=%s' % ( self.domain, msg, )) else: raise web.seeother('/aliases/%s?msg=%s' % ( self.domain, web.urlquote(result[1]), ))
def POST(self, domain): i = web.input() # Get domain name, username, cn. self.cur_domain = web.safestr(i.get('domainName', '')) self.username = web.safestr(i.get('listname', '')) self.mail = self.username + '@' + self.cur_domain if self.cur_domain != domain: return (False, 'PERMISSION_DENIED') aliasLib = aliaslib.Alias() result = aliasLib.add(domain=self.cur_domain, data=i) if result[0] is True: raise web.seeother('/profile/alias/general/%s?msg=CREATED' % (self.mail)) else: raise web.seeother('/create/alias/%s?msg=%s' % (self.cur_domain, web.urlquote(result[1])))
def GET(self, domain, cur_page=1): self.domain = web.safestr(domain) cur_page = int(cur_page) or 1 aliasLib = aliaslib.Alias() result = aliasLib.listAccounts( domain=self.domain, cur_page=cur_page, ) if result[0] is True: (total, records) = (result[1], result[2]) return web.render( 'dbmail_mysql/alias/list.html', cur_domain=self.domain, cur_page=cur_page, total=total, aliases=records, msg=web.input().get('msg', None), ) else: raise web.seeother('/domains?msg=%s' % web.urlquote(result[1]))
def GET(self, profile_type, mail): i = web.input() self.mail = web.safestr(mail) self.cur_domain = self.mail.split('@', 1)[-1] self.profile_type = web.safestr(profile_type) if not iredutils.isEmail(self.mail): raise web.seeother('/domains?msg=INVALID_USER') if not iredutils.isDomain(self.cur_domain): raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME') aliasLib = aliaslib.Alias() qr = aliasLib.profile(domain=self.cur_domain, mail=self.mail) if qr[0] is True: self.profile = qr[1] else: raise web.seeother('/aliases/%s?msg=%s' % (self.cur_domain, web.urlquote(qr[1]))) # Get list of alias members. qr = aliasLib.getAliasMembers(mail=self.mail) if qr[0] is True: members = qr[1] else: raise web.seeother('/aliases/%s?msg=%s' % (self.cur_domain, web.urlquote(qr[1]))) return web.render( 'dbmail_mysql/alias/profile.html', cur_domain=self.cur_domain, mail=self.mail, profile_type=self.profile_type, profile=self.profile, members=members, msg=i.get('msg'), )
def GET(self, profile_type, domain): i = web.input() self.domain = web.safestr(domain.split('/', 1)[0]) self.profile_type = web.safestr(profile_type) domainLib = domainlib.Domain() result = domainLib.profile(domain=self.domain) if result[0] is not True: raise web.seeother('/domains?msg=' + web.urlquote(result[1])) else: self.profile = result[1] allAdmins = [] # Get all admins. domainAdmins = [] # Get domain admins. aliasDomains = [] # Get all alias domains. allAliases = [] # Get all mail aliases. # profile_type == 'throttle' throttleOfSender = {} throttleOfRecipient = {} adminLib = adminlib.Admin() # Get all admins. qr = adminLib.getAllAdmins(columns=['username', 'name']) if qr[0] is True: allAdmins = qr[1] # Get domain admins. qr = domainLib.getDomainAdmins(domain=self.domain, mailOnly=True) if qr[0] is True: domainAdmins = qr[1] # Get alias domains. qr = domainLib.getAllAliasDomains( self.domain, namesOnly=True, ) if qr[0] is True: aliasDomains = qr[1] # Get all mail aliases. mailsOfAllAliases = [] aliasLib = aliaslib.Alias() qr = aliasLib.getAllAliases(domain=self.domain, columns=[ 'name', 'alias', ]) if qr[0] is True: allAliases = qr[1] for ali in allAliases: mailsOfAllAliases += [ali.alias] # Get sender/recipient throttle data from policyd database. if session.get('enablePolicyd'): throttleLib = throttle.Throttle() result_throttle = throttleLib.getThrottling( sender='@' + self.domain, recipient='@' + self.domain) if result_throttle[0] is True: throttleOfSender = result_throttle[1] throttleOfRecipient = result_throttle[2] return web.render( 'dbmail_mysql/domain/profile.html', cur_domain=self.domain, profile_type=self.profile_type, profile=self.profile, allAdmins=allAdmins, domainAdmins=domainAdmins, aliasDomains=aliasDomains, allAliases=allAliases, mailsOfAllAliases=mailsOfAllAliases, throttleOfSender=throttleOfSender, throttleOfRecipient=throttleOfRecipient, msg=i.get('msg'), )
def GET(self, profile_type, mail): i = web.input() self.mail = str(mail).lower() self.cur_domain = self.mail.split('@', 1)[-1] self.profile_type = str(profile_type) # profile_type == 'throttle' throttleOfSender = {} throttleOfRecipient = {} if self.mail.startswith('@') and iredutils.isDomain(self.cur_domain): # Catchall account. raise web.seeother('/profile/domain/catchall/%s' % (self.cur_domain)) if not iredutils.isEmail(self.mail): raise web.seeother('/domains?msg=INVALID_USER') if not iredutils.isDomain(self.cur_domain): raise web.seeother('/domains?msg=INVALID_DOMAIN_NAME') userLib = userlib.User() qr = userLib.profile(domain=self.cur_domain, mail=self.mail) if qr[0] is True: self.profile = qr[1] else: raise web.seeother('/users/%s?msg=%s' % (self.cur_domain, web.urlquote(qr[1]))) del qr # Get mail alias addresses. qr = userLib.getUserAliasAddresses(domain=self.cur_domain, mail=self.mail) if qr[0] is True: self.userAliasAddresses = qr[1] else: raise web.seeother('/users/%s?msg=%s' % (self.cur_domain, web.urlquote(qr[1]))) del qr # Get mail forwarding addresses. qr = userLib.getMailForwardingAddresses(domain=self.cur_domain, mail=self.mail) if qr[0] is True: self.mailForwardingAddresses = qr[1] else: raise web.seeother('/users/%s?msg=%s' % (self.cur_domain, web.urlquote(qr[1]))) del qr # Get all aliases under same domain. allAliases = [] aliasLib = aliaslib.Alias() qr = aliasLib.getAllAliases(domain=self.cur_domain, columns=['name', 'alias', 'deliver_to']) if qr[0] is True: allAliases = qr[1] if session.get('enablePolicyd'): # Get sender/recipient throttle data from policyd database. throttleLib = throttle.Throttle() result_throttle = throttleLib.getThrottling(sender=self.mail, recipient=self.mail) if result_throttle[0] is True: throttleOfSender = result_throttle[1] throttleOfRecipient = result_throttle[2] return web.render( 'dbmail_mysql/user/profile.html', cur_domain=self.cur_domain, mail=self.mail, profile_type=self.profile_type, profile=self.profile, userAliasAddresses=self.userAliasAddresses, mailForwardingAddresses=self.mailForwardingAddresses, allAliases=allAliases, throttleOfSender=throttleOfSender, throttleOfRecipient=throttleOfRecipient, msg=i.get('msg'), )