#!/usr/local/bin/python """Produce user options form, from list options.html template. Takes listname/userid in PATH_INFO, expecting an "obscured" userid. (Depending on the mm_utils.{O,Uno}bscureEmail utilities tolerance, will work fine with an unobscured ids as well.)""" __version__ = "$Revision: 388 $" # We don't need to lock in this script, because we're never going to change # data. import sys sys.path.append('/home/mailman/mailman/modules') import os, string import mm_utils, maillist, htmlformat, mm_cfg try: sys.stderr = mm_utils.StampedLogger("error", label = 'options', manual_reprime=1, nofail=0) except IOError: pass # Oh well - SOL on redirect, errors show thru. doc = htmlformat.Document() path = os.environ['PATH_INFO'] list_info = mm_utils.GetPathPieces(path) if len(list_info) < 2: doc.AddItem(htmlformat.Header(2, "Error")) doc.AddItem(htmlformat.Bold("Invalid options to CGI script.")) print doc.Format() sys.exit(0) list_name = string.lower(list_info[0]) user = mm_utils.UnobscureEmail(list_info[1]) try: list = maillist.MailList(list_name) except: doc.AddItem(htmlformat.Header(2, "Error")) doc.AddItem(htmlformat.Bold("%s: No such list." % list_name )) print doc.Format() sys.exit(0) if not list._ready: doc.AddItem(htmlformat.Header(2, "Error")) doc.AddItem(htmlformat.Bold("%s: No such list." % list_name )) print doc.Format() sys.exit(0) if string.lower(user) not in list.members + list.digest_members: doc.AddItem(htmlformat.Header(2, "Error")) doc.AddItem(htmlformat.Bold("%s: No such member %s." % (list_name, `user`))) doc.AddItem(list.GetMailmanFooter()) print doc.Format() sys.exit(0) # Re-obscure the user's address for the page banner if obscure_addresses set. if list.obscure_addresses: presentable_user = mm_utils.ObscureEmail(user, for_text=1) else: presentable_user = user replacements = list.GetStandardReplacements() replacements[''] = list.FormatOptionButton( mm_cfg.Digests, 1, user) replacements[''] = list.FormatOptionButton( mm_cfg.Digests, 0, user) replacements[''] = list.FormatOptionButton( mm_cfg.DisableMime, 1, user) replacements[''] = list.FormatOptionButton( mm_cfg.DisableMime, 0, user) replacements[''] = list.FormatOptionButton( mm_cfg.DisableDelivery, 0, user) replacements[''] = list.FormatOptionButton( mm_cfg.DisableDelivery, 1, user) replacements[''] = list.FormatOptionButton( mm_cfg.AcknowlegePosts, 0, user) replacements[''] = list.FormatOptionButton( mm_cfg.AcknowlegePosts, 1, user) replacements[''] = list.FormatOptionButton( mm_cfg.DontReceiveOwnPosts, 0, user) replacements[''] = list.FormatOptionButton( mm_cfg.DontReceiveOwnPosts, 1, user) replacements[''] = list.FormatOptionButton( mm_cfg.ConcealSubscription, 0, user) replacements[''] = list.FormatOptionButton( mm_cfg.ConcealSubscription, 1, user) replacements[''] = list.FormatButton('setdigest', 'Submit My Changes') replacements[''] = list.FormatButton('unsub', 'Unsubscribe') replacements[''] = list.FormatSecureBox('digpw') replacements[''] = list.FormatSecureBox('upw') replacements[''] = list.FormatSecureBox('opw') replacements[''] = list.FormatSecureBox('newpw') replacements[''] = list.FormatSecureBox('confpw') replacements[''] = list.FormatButton('changepw', "Change My Password") replacements[''] = list.FormatFormStart('handle_opts', user) replacements[''] = user replacements[''] = presentable_user replacements[''] = list.FormatButton('emailpw', 'Email My Password To Me') doc.AddItem(list.ParseTags('options.html', replacements)) print doc.Format()