def handle_no_list(msg=''): # Print something useful if no list was given. doc = Document() doc.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) header = _('Mailman Administrative Database Error') doc.SetTitle(header) doc.AddItem(Header(2, header)) doc.AddItem(msg) url = Utils.ScriptURL('admin', absolute=1) link = Link(url, _('list of available mailing lists.')).Format() doc.AddItem(_('You must specify a list name. Here is the %(link)s')) doc.AddItem('<hr>') doc.AddItem(MailmanLogo()) print doc.Format()
def GetMailmanFooter(self): ownertext = Utils.ObscureEmail(self.GetOwnerEmail(), 1) # Remove the .Format() when htmlformat conversion is done. realname = self.real_name hostname = self.host_name listinfo_link = Link(self.GetScriptURL('listinfo'), realname).Format() owner_link = Link('mailto:' + self.GetOwnerEmail(), ownertext).Format() innertext = _('%(listinfo_link)s list run by %(owner_link)s') return Container( '<hr>', Address( Container( innertext, '<br>', Link(self.GetScriptURL('admin'), _('%(realname)s administrative interface')), _(' (requires authorization)'), '<br>', Link(Utils.ScriptURL('listinfo'), _('Overview of all %(hostname)s mailing lists')), '<p>', MailmanLogo()))).Format()
table.AddRow([ _('''You have successfully deleted the mailing list <b>%(listname)s</b>.''') ]) else: sitelist = Utils.get_site_email(mlist.host_name) table.AddRow([ _('''There were some problems deleting the mailing list <b>%(listname)s</b>. Contact your site administrator at %(sitelist)s for details.''') ]) doc.AddItem(table) doc.AddItem('<hr>') doc.AddItem( _('Return to the ') + Link(Utils.ScriptURL('listinfo'), _('general list overview')).Format()) doc.AddItem( _('<br>Return to the ') + Link(Utils.ScriptURL( 'admin'), _('administrative list overview')).Format()) doc.AddItem(MailmanLogo()) def request_deletion(doc, mlist, errmsg=None): realname = mlist.real_name title = _('Permanently remove mailing list <em>%(realname)s</em>') doc.SetTitle(_('Permanently remove mailing list %(realname)s')) table = Table(border=0, width='100%') table.AddRow([Center(Bold(FontAttr(title, size='+1')))]) table.AddCellInfo(table.GetCurrentRowIndex(), 0,
def listinfo_overview(msg=''): # Present the general listinfo overview hostname = Utils.get_domain() # Set up the document and assign it the correct language. The only one we # know about at the moment is the server's default. doc = Document() doc.set_language(mm_cfg.DEFAULT_SERVER_LANGUAGE) legend = _("%(hostname)s Mailing Lists") doc.SetTitle(legend) table = Table(border=0, width="100%") table.AddRow([Center(Header(2, legend))]) table.AddCellInfo(table.GetCurrentRowIndex(), 0, colspan=2, bgcolor=mm_cfg.WEB_HEADER_COLOR) # Skip any mailing lists that isn't advertised. advertised = [] listnames = Utils.list_names() listnames.sort() for name in listnames: mlist = MailList.MailList(name, lock=0) if mlist.advertised: if mm_cfg.VIRTUAL_HOST_OVERVIEW and ( mlist.web_page_url.find('/%s/' % hostname) == -1 and mlist.web_page_url.find('/%s:' % hostname) == -1): # List is for different identity of this host - skip it. continue else: advertised.append( (mlist.GetScriptURL('listinfo'), mlist.real_name, Utils.websafe(mlist.description))) if msg: greeting = FontAttr(msg, color="ff5060", size="+1") else: greeting = FontAttr(_('Welcome!'), size='+2') welcome = [greeting] mailmanlink = Link(mm_cfg.MAILMAN_URL, _('Mailman')).Format() if not advertised: welcome.extend( _('''<p>There currently are no publicly-advertised %(mailmanlink)s mailing lists on %(hostname)s.''')) else: welcome.append( _('''<p>Below is a listing of all the public mailing lists on %(hostname)s. Click on a list name to get more information about the list, or to subscribe, unsubscribe, and change the preferences on your subscription.''')) # set up some local variables adj = msg and _('right') or '' siteowner = Utils.get_site_email() welcome.extend( (_(''' To visit the general information page for an unadvertised list, open a URL similar to this one, but with a '/' and the %(adj)s list name appended. <p>List administrators, you can visit '''), Link(Utils.ScriptURL('admin'), _('the list admin overview page')), _(''' to find the management interface for your list. <p>If you are having trouble using the lists, please contact '''), Link('mailto:' + siteowner, siteowner), '.<p>')) table.AddRow([apply(Container, welcome)]) table.AddCellInfo(max(table.GetCurrentRowIndex(), 0), 0, colspan=2) if advertised: table.AddRow([' ', ' ']) table.AddRow([ Bold(FontAttr(_('List'), size='+2')), Bold(FontAttr(_('Description'), size='+2')) ]) highlight = 1 for url, real_name, description in advertised: table.AddRow([ Link(url, Bold(real_name)), description or Italic(_('[no description available]')) ]) if highlight and mm_cfg.WEB_HIGHLIGHT_COLOR: table.AddRowInfo(table.GetCurrentRowIndex(), bgcolor=mm_cfg.WEB_HIGHLIGHT_COLOR) highlight = not highlight doc.AddItem(table) doc.AddItem('<hr>') doc.AddItem(MailmanLogo()) print doc.Format()
def process_request(doc, cgidata, mlist): password = cgidata.getfirst('password', '').strip() try: delarchives = int(cgidata.getfirst('delarchives', '0')) except ValueError: delarchives = 0 # Removing a list is limited to the list-creator (a.k.a. list-destroyer), # the list-admin, or the site-admin. Don't use WebAuthenticate here # because we want to be sure the actual typed password is valid, not some # password sitting in a cookie. if mlist.Authenticate( (mm_cfg.AuthCreator, mm_cfg.AuthListAdmin, mm_cfg.AuthSiteAdmin), password) == mm_cfg.UnAuthorized: request_deletion( doc, mlist, _('You are not authorized to delete this mailing list')) return # Do the MTA-specific list deletion tasks if mm_cfg.MTA: modname = 'Mailman.MTA.' + mm_cfg.MTA __import__(modname) sys.modules[modname].remove(mlist, cgi=1) REMOVABLES = ['lists/%s'] if delarchives: REMOVABLES.extend([ 'archives/private/%s', 'archives/private/%s.mbox', 'archives/public/%s', 'archives/public/%s.mbox', ]) problems = 0 listname = mlist.internal_name() for dirtmpl in REMOVABLES: dir = os.path.join(mm_cfg.VAR_PREFIX, dirtmpl % listname) if os.path.islink(dir): try: os.unlink(dir) except OSError as e: if e.errno not in (errno.EACCES, errno.EPERM): raise problems += 1 syslog('error', 'link %s not deleted due to permission problems', dir) elif os.path.isdir(dir): try: shutil.rmtree(dir) except OSError as e: if e.errno not in (errno.EACCES, errno.EPERM): raise problems += 1 syslog('error', 'directory %s not deleted due to permission problems', dir) title = _('Mailing list deletion results') doc.SetTitle(title) table = Table(border=0, width='100%') table.AddRow([Center(Bold(FontAttr(title, size='+1')))]) table.AddCellInfo(table.GetCurrentRowIndex(), 0, bgcolor=mm_cfg.WEB_HEADER_COLOR) if not problems: table.AddRow([ _('''You have successfully deleted the mailing list <b>%(listname)s</b>.''') ]) else: sitelist = Utils.get_site_email(mlist.host_name) table.AddRow([ _('''There were some problems deleting the mailing list <b>%(listname)s</b>. Contact your site administrator at %(sitelist)s for details.''') ]) doc.AddItem(table) doc.AddItem('<hr>') doc.AddItem( _('Return to the ') + Link(Utils.ScriptURL('listinfo'), _('general list overview')).Format()) doc.AddItem( _('<br>Return to the ') + Link(Utils.ScriptURL( 'admin'), _('administrative list overview')).Format()) doc.AddItem(MailmanLogo())