def _sympaAdd(self, virtual, alias, dest, status, domain): """ Add an sympa alias""" cur = self.getCursor() alias = latin12p(alias) virtual = latin12p(virtual) dest = latin12p(dest) cur.execute("insert into sympa (virtual, alias, dest, status, domain) values(%s, %s, %s, %s, %s)", (virtual, alias, dest, status, domain))
def virtualExist(self, virtual): """ Return true if this virtual exists """ cur = self.getCursor() cur.execute("select alias from virtual where alias=%s", latin12p(virtual)) if cur.fetchone(): return True return False
def aliasExist(self, alias): """ Return True or False wether an aliase already exists """ cur = self.getCursor() cur.execute("select alias from alias where alias=%s", latin12p(alias)) if cur.fetchone(): return True return False
def addVirtual(self,alias,dest,user=None,status=1): """ Adds an virtual entry """ cur = self.getCursor() try: domain = alias.split("@")[1] except IndexError: domain = "" if user: cur.execute("insert into virtual (alias,dest,username,domain) values(%s,%s,%s,%s)", (latin12p(alias),latin12p(dest),user,latin12p(domain))) else: cur.execute("insert into virtual (alias,dest,domain) values(%s,%s,%s)", (latin12p(alias),latin12p(dest),latin12p(domain)))
def addSympa(self, company, prefix, domain, listname): """ Add aliases and virtuals for a sympa mailing list """ # Aliases cur = self.getCursor() alias = prefix+"-"+listname domain = latin12p(domain) virtual = listname+"@"+domain dest = '"| /usr/lib/sympa/bin/queue %s@%s"' % (listname, domain) self._sympaAdd(virtual, alias, dest, 1, domain) for i in ["request", "subscribe", "unsubscribe"]: virtual = listname+"-"+i+"@"+domain alias = prefix+"-"+listname+"-"+i dest = '"| /usr/lib/sympa/bin/queue %s-%s@%s"' % (listname, i, domain) self._sympaAdd(virtual, alias, dest, 1, domain) virtual = "sympa"+"@"+domain alias = prefix+"-"+domain.replace(".","-")+"-"+"sympa" dest = '"| /usr/lib/sympa/bin/queue sympa@'+domain+'"' self._sympaAdd(virtual, alias, dest, 1, domain)
def updateVirtual(self,id ,dest, status): """ Updates a virtual alias""" cur = self.getCursor() cur.execute("update virtual set dest=%s, status=%s where id=%s",(latin12p(dest), status, id))
def aliasEdit(self,id,alias,dest,status): """ Edit an alias """ cur = self.getCursor() cur.execute("update alias set alias=%s, dest=%s, status=%s where id=%s", (latin12p(alias),latin12p(dest),status,id))
def aliasAdd(self,alias,dest,status): """ Add an alias""" cur = self.getCursor() cur.execute("insert into alias (alias,dest,status) values(%s,%s,%s)", (latin12p(alias),latin12p(dest),status))