diff options
| author | bwarsaw | 1998-06-19 19:57:31 +0000 |
|---|---|---|
| committer | bwarsaw | 1998-06-19 19:57:31 +0000 |
| commit | aff327f7d375d3ccf5aa6a165f93d8d9454ce0ea (patch) | |
| tree | 47ee88da43726e203f453c6cc80d386e11ed537e | |
| parent | 002f566bfd5619df6c215bfe5597aeace7a59499 (diff) | |
| download | mailman-aff327f7d375d3ccf5aa6a165f93d8d9454ce0ea.tar.gz mailman-aff327f7d375d3ccf5aa6a165f93d8d9454ce0ea.tar.zst mailman-aff327f7d375d3ccf5aa6a165f93d8d9454ce0ea.zip | |
| -rw-r--r-- | Mailman/Cgi/admindb.py | 88 | ||||
| -rw-r--r-- | Mailman/Cgi/edithtml.py | 195 | ||||
| -rw-r--r-- | Mailman/Cgi/handle_opts.py | 328 | ||||
| -rw-r--r-- | Mailman/Cgi/options.py | 167 | ||||
| -rw-r--r-- | Mailman/Cgi/subscribe.py | 289 |
5 files changed, 559 insertions, 508 deletions
diff --git a/Mailman/Cgi/admindb.py b/Mailman/Cgi/admindb.py index 415184d3b..3ac0d455f 100644 --- a/Mailman/Cgi/admindb.py +++ b/Mailman/Cgi/admindb.py @@ -19,38 +19,57 @@ """Produce and process the pending-approval items for a list.""" import sys -import os, cgi, string, crypt, types -import mm_utils, maillist, mm_err, htmlformat +import os, cgi, string, types +from Mailman import Utils, MailList, Errors, htmlformat -doc = htmlformat.Document() +def main(): + global list -path = os.environ['PATH_INFO'] -list_info = mm_utils.GetPathPieces(path) + doc = htmlformat.Document() + path = os.environ['PATH_INFO'] + list_info = Utils.GetPathPieces(path) -if len(list_info) < 1: - doc.SetTitle("Admindb Error") - doc.AddItem(htmlformat.Header(2, "Invalid options to CGI script.")) - print doc.Format(bgcolor="#ffffff") - sys.exit(0) -list_name = string.lower(list_info[0]) -try: - list = maillist.MailList(list_name) -except: - msg = "%s: No such list." % list_name - doc.SetTitle("Admindb Error - %s" % msg) - doc.AddItem(htmlformat.Header(2, msg)) - print doc.Format(bgcolor="#ffffff") - sys.exit(0) + if len(list_info) < 1: + doc.SetTitle("Admindb Error") + doc.AddItem(htmlformat.Header(2, "Invalid options to CGI script.")) + print doc.Format(bgcolor="#ffffff") + sys.exit(0) + list_name = string.lower(list_info[0]) + + try: + list = MailList.MailList(list_name) + except: + msg = "%s: No such list." % list_name + doc.SetTitle("Admindb Error - %s" % msg) + doc.AddItem(htmlformat.Header(2, msg)) + print doc.Format(bgcolor="#ffffff") + sys.exit(0) + + if not list._ready: + msg = "%s: No such list." % list_name + doc.SetTitle("Admindb Error - %s" % msg) + doc.AddItem(htmlformat.Header(2, msg)) + print doc.Format(bgcolor="#ffffff") + sys.exit(0) + + try: + form = cgi.FieldStorage() + if len(form.keys()): + doc.SetTitle("%s Admindb Results" % list.real_name) + HandleRequests(doc) + else: + doc.SetTitle("%s Admindb" % list.real_name) + PrintRequests(doc) + text = doc.Format(bgcolor="#ffffff") + print text + sys.stdout.flush() + finally: + list.Unlock() -if not list._ready: - msg = "%s: No such list." % list_name - doc.SetTitle("Admindb Error - %s" % msg) - doc.AddItem(htmlformat.Header(2, msg)) - print doc.Format(bgcolor="#ffffff") - sys.exit(0) + # Note, these 2 functions use i only to count the number of times to # go around. We always operate on the first element of the list # because we're going to delete the element after we operate on it. @@ -107,7 +126,7 @@ def HandleRequests(doc): continue try: request = list.GetRequest(request_id) - except mm_err.MMBadRequestId: + except Errors.MMBadRequestId: continue # You've already changed the database. No biggie. if ignore_subscribes and request[0] == 'add_member': # We already handled this request. @@ -159,7 +178,11 @@ def PrintPostRequest(val, form): form.AddItem('<p>') + def PrintRequests(doc): + # XXX: blech, yuk, ick + global list + # The only types of requests we know about are add_member and post. # Anything else that might have gotten in here somehow we'll just # ignore (This should never happen unless someone is hacking at @@ -217,16 +240,3 @@ def PrintRequests(doc): PrintPostRequest(request, form) doc.AddItem(list.GetMailmanFooter()) -try: - form = cgi.FieldStorage() - if len(form.keys()): - doc.SetTitle("%s Admindb Results" % list.real_name) - HandleRequests(doc) - else: - doc.SetTitle("%s Admindb" % list.real_name) - PrintRequests(doc) - text = doc.Format(bgcolor="#ffffff") - print text - sys.stdout.flush() -finally: - list.Unlock() diff --git a/Mailman/Cgi/edithtml.py b/Mailman/Cgi/edithtml.py index faf35e715..795ae2bcb 100644 --- a/Mailman/Cgi/edithtml.py +++ b/Mailman/Cgi/edithtml.py @@ -19,80 +19,128 @@ """Script which implements admin editing of the list's html templates.""" import sys -import os, cgi, string, crypt, types -import mm_utils, maillist, mm_cfg -import htmlformat +import os, cgi, string, types +from Mailman import Utils, MailList +from Mailman import htmlformat + #Editable templates. We should also be able to edit the archive index, which #currently isn't a working template, but will be soon. -template_data = (('listinfo.html', 'General list information page'), - ('subscribe.html', 'Subscribe results page'), - ('options.html', 'User specific options page'), - ('handle_opts.html', 'Changing user options results page'), - ('archives.html', 'Archives index page') - ) +def main(): + # XXX: blech, yuck, ick + global doc + global list + global template_info + global template_name + template_data = (('listinfo.html', 'General list information page'), + ('subscribe.html', 'Subscribe results page'), + ('options.html', 'User specific options page'), + ('handle_opts.html', 'Changing user options results page'), + ('archives.html', 'Archives index page') + ) -def InitDocument(): - return htmlformat.HeadlessDocument() -doc = InitDocument() + doc = InitDocument() -path = os.environ['PATH_INFO'] -list_info = mm_utils.GetPathPieces(path) + path = os.environ['PATH_INFO'] + list_info = Utils.GetPathPieces(path) -if len(list_info) < 1: - doc.AddItem(htmlformat.Header(2, "Invalid options to CGI script.")) - print doc.Format() - sys.exit(0) + if len(list_info) < 1: + doc.AddItem(htmlformat.Header(2, "Invalid options to CGI script.")) + print doc.Format() + sys.exit(0) -list_name = string.lower(list_info[0]) + list_name = string.lower(list_info[0]) -try: - list = maillist.MailList(list_name, lock=0) -except: - doc.AddItem(htmlformat.Header(2, "%s : No such list" % list_name)) - print doc.Format() - sys.exit(0) + try: + list = MailList.MailList(list_name, lock=0) + except: + doc.AddItem(htmlformat.Header(2, "%s : No such list" % list_name)) + print doc.Format() + sys.exit(0) -if not list._ready: - doc.AddItem(htmlformat.Header(2, "%s : No such list" % list_name)) - print doc.Format() - sys.exit(0) + if not list._ready: + doc.AddItem(htmlformat.Header(2, "%s : No such list" % list_name)) + print doc.Format() + sys.exit(0) -if len(list_info) > 1: - template_name = list_info[1] - for (template, info) in template_data: - if template == template_name: - template_info = info - doc.SetTitle('%s -- Edit html for %s' % - (list.real_name, template_info)) - break + if len(list_info) > 1: + template_name = list_info[1] + for (template, info) in template_data: + if template == template_name: + template_info = info + doc.SetTitle('%s -- Edit html for %s' % + (list.real_name, template_info)) + break + else: + doc.SetTitle('Edit HTML : Error') + doc.AddItem(htmlformat.Header(2, "%s: Invalid template" % template_name)) + doc.AddItem(list.GetMailmanFooter()) + print doc.Format() + sys.exit(0) else: - doc.SetTitle('Edit HTML : Error') - doc.AddItem(htmlformat.Header(2, "%s: Invalid template" % template_name)) - doc.AddItem(list.GetMailmanFooter()) - print doc.Format() - sys.exit(0) -else: - doc.SetTitle('%s -- HTML Page Editing' % list.real_name) - doc.AddItem(htmlformat.Header(1, '%s -- HTML Page Editing' % list.real_name)) - doc.AddItem(htmlformat.Header(2, 'Select page to edit:')) - template_list = htmlformat.UnorderedList() - for (template, info) in template_data: - l = htmlformat.Link(os.path.join(list.GetRelativeScriptURL('edithtml'), - template), info) - - template_list.AddItem(l) - doc.AddItem(htmlformat.FontSize("+2", template_list)) - doc.AddItem(list.GetMailmanFooter()) - print doc.Format() - sys.exit(0) + doc.SetTitle('%s -- HTML Page Editing' % list.real_name) + doc.AddItem(htmlformat.Header(1, '%s -- HTML Page Editing' % list.real_name)) + doc.AddItem(htmlformat.Header(2, 'Select page to edit:')) + template_list = htmlformat.UnorderedList() + for (template, info) in template_data: + l = htmlformat.Link(os.path.join(list.GetRelativeScriptURL('edithtml'), + template), info) + + template_list.AddItem(l) + doc.AddItem(htmlformat.FontSize("+2", template_list)) + doc.AddItem(list.GetMailmanFooter()) + print doc.Format() + sys.exit(0) + + try: + cgi_data = cgi.FieldStorage() + if len(cgi_data.keys()): + if not cgi_data.has_key('adminpw'): + m = 'Error: You must supply the admin password to edit html.' + doc.AddItem(htmlformat.Header(3, + htmlformat.Italic( + htmlformat.FontAttr( + m, color="ff5060")))) + doc.AddItem('<hr>') + else: + try: + list.ConfirmAdminPassword(cgi_data['adminpw'].value) + ChangeHTML(list, cgi_data, template_name, doc) + except: + m = 'Error: Incorrect admin password.' + doc.AddItem(htmlformat.Header(3, + htmlformat.Italic( + htmlformat.FontAttr( + m, color="ff5060")))) + doc.AddItem('<hr>') + + + + FormatHTML(doc) + + finally: + try: + doc.AddItem(list.GetMailmanFooter()) + print doc.Format() + except: + pass + + + +def InitDocument(): + return htmlformat.HeadlessDocument() def FormatHTML(doc): + # XXX: blech, yuck, ick + global list + global template_info + global template_name + doc.AddItem(htmlformat.Header(1,'%s:' % list.real_name)) doc.AddItem(htmlformat.Header(1, template_info)) @@ -117,9 +165,10 @@ def FormatHTML(doc): form.AddItem(password_table) - text = mm_utils.QuoteHyperChars(list.SnarfHTMLTemplate(template_name)) + text = Utils.QuoteHyperChars(list.SnarfHTMLTemplate(template_name)) form.AddItem(htmlformat.TextArea('html_code', text, rows=40, cols=75)) + def ChangeHTML(list, cgi_info, template_name, doc): if not cgi_info.has_key('html_code'): doc.AddItem(htmlformat.Header(3,"Can't have empty html page.")) @@ -133,35 +182,3 @@ def ChangeHTML(list, cgi_info, template_name, doc): doc.AddItem(htmlformat.Header(3, 'HTML successfully updated.')) doc.AddItem('<hr>') -try: - cgi_data = cgi.FieldStorage() - if len(cgi_data.keys()): - if not cgi_data.has_key('adminpw'): - m = 'Error: You must supply the admin password to edit html.' - doc.AddItem(htmlformat.Header(3, - htmlformat.Italic( - htmlformat.FontAttr( - m, color="ff5060")))) - doc.AddItem('<hr>') - else: - try: - list.ConfirmAdminPassword(cgi_data['adminpw'].value) - ChangeHTML(list, cgi_data, template_name, doc) - except: - m = 'Error: Incorrect admin password.' - doc.AddItem(htmlformat.Header(3, - htmlformat.Italic( - htmlformat.FontAttr( - m, color="ff5060")))) - doc.AddItem('<hr>') - - - - FormatHTML(doc) - -finally: - try: - doc.AddItem(list.GetMailmanFooter()) - print doc.Format() - except: - pass diff --git a/Mailman/Cgi/handle_opts.py b/Mailman/Cgi/handle_opts.py index 7b5747f4f..0c64716f5 100644 --- a/Mailman/Cgi/handle_opts.py +++ b/Mailman/Cgi/handle_opts.py @@ -20,188 +20,202 @@ import sys import os, cgi, string -import mm_utils, maillist, mm_err, mm_cfg, htmlformat +from Mailman import Utils, MailList, Errors, htmlformat +from Mailman import mm_cfg -doc = htmlformat.Document() + +def PrintResults(results): + # XXX: blech, yuk, ick + global list + global operation + global doc -path = os.environ['PATH_INFO'] -list_info = mm_utils.GetPathPieces(path) + replacements = list.GetStandardReplacements() + replacements['<mm-results>'] = results + replacements['<mm-operation>'] = operation + output = list.ParseTags('handle_opts.html', replacements) -if len(list_info) < 2: - doc.AddItem(htmlformat.Header(2, "Error")) - doc.AddItem(htmlformat.Bold("Invalid options to CGI script.")) + doc.AddItem(output) print doc.Format(bgcolor="#ffffff") + list.Unlock() sys.exit(0) -list_name = string.lower(list_info[0]) -user = list_info[1] -if len(list_info) < 2: - doc.AddItem(htmlformat.Header(2, "Error")) - doc.AddItem(htmlformat.Bold("Invalid options to CGI script.")) - print doc.Format(bgcolor="#ffffff") - sys.exit(0) + +def main(): + # XXX: blech, yuk, ick + global list + global operation + global doc -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(bgcolor="#ffffff") - sys.exit(0) + doc = htmlformat.Document() -if not list._ready: - doc.AddItem(htmlformat.Header(2, "Error")) - doc.AddItem(htmlformat.Bold("%s: No such list." % list_name)) - print doc.Format(bgcolor="#ffffff") - list.Unlock() - sys.exit(0) + path = os.environ['PATH_INFO'] + list_info = 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(bgcolor="#ffffff") + sys.exit(0) -def PrintResults(results): - replacements = list.GetStandardReplacements() - replacements['<mm-results>'] = results - replacements['<mm-operation>'] = operation - output = list.ParseTags('handle_opts.html', replacements) + list_name = string.lower(list_info[0]) + user = list_info[1] - doc.AddItem(output) - print doc.Format(bgcolor="#ffffff") - list.Unlock() - sys.exit(0) + if len(list_info) < 2: + doc.AddItem(htmlformat.Header(2, "Error")) + doc.AddItem(htmlformat.Bold("Invalid options to CGI script.")) + print doc.Format(bgcolor="#ffffff") + sys.exit(0) + + 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(bgcolor="#ffffff") + sys.exit(0) -form = cgi.FieldStorage() + if not list._ready: + doc.AddItem(htmlformat.Header(2, "Error")) + doc.AddItem(htmlformat.Bold("%s: No such list." % list_name)) + print doc.Format(bgcolor="#ffffff") + list.Unlock() + sys.exit(0) -error = 0 -operation = "" + form = cgi.FieldStorage() -if string.lower(user) not in list.members + list.digest_members: - PrintResults("%s not a member!<p>" % user) + error = 0 + operation = "" -if form.has_key("unsub"): - operation = "Unsubscribe" - if not form.has_key("upw"): - PrintResults("You must give your password to unsubscribe.<p>") - else: - try: - pw = form["upw"].value - if list.ConfirmUserPassword(user, pw): - list.DeleteMember(user, "web cmd") - except mm_err.MMListNotReady: - PrintResults("List is not functional.") - except mm_err.MMNoSuchUserError: - PrintResults("You seem to already be not a member.<p>") - except mm_err.MMBadUserError: - PrintResults("Your account has gone awry - " - "please contact the list administrator!<p>") - except mm_err.MMBadPasswordError: - PrintResults("That password was incorrect.<p>") -# except: -# PrintResults('''An unknown error occured. <p> -#Please send mail to <a href=%s>%s</a> explaining -#exactly what you did to get this error.<p>''' % (mm_cfg.MAILMAN_OWNER, -# mm_cfg.MAILMAN_OWNER)) + if string.lower(user) not in list.members + list.digest_members: + PrintResults("%s not a member!<p>" % user) + + if form.has_key("unsub"): + operation = "Unsubscribe" + if not form.has_key("upw"): + PrintResults("You must give your password to unsubscribe.<p>") + else: + try: + pw = form["upw"].value + if list.ConfirmUserPassword(user, pw): + list.DeleteMember(user, "web cmd") + except Errors.MMListNotReady: + PrintResults("List is not functional.") + except Errors.MMNoSuchUserError: + PrintResults("You seem to already be not a member.<p>") + except Errors.MMBadUserError: + PrintResults("Your account has gone awry - " + "please contact the list administrator!<p>") + except Errors.MMBadPasswordError: + PrintResults("That password was incorrect.<p>") + # except: + # PrintResults('''An unknown error occured. <p> + #Please send mail to <a href=%s>%s</a> explaining + #exactly what you did to get this error.<p>''' % (mm_cfg.MAILMAN_OWNER, + # mm_cfg.MAILMAN_OWNER)) - PrintResults("You have been unsubscribed.<p>") -elif form.has_key("emailpw"): - try: - list.MailUserPassword(user) - PrintResults("A reminder of your password " - "has been emailed to you.<p>") - except mm_err.MMBadUserError: - PrintResults("Your password entry has not been found. The list " - "manager is being notified.<p>") - -elif form.has_key("changepw"): - if (form.has_key('opw') - and form.has_key('newpw') - and form.has_key('confpw')): - try: - list.ConfirmUserPassword(user, form['opw'].value) - list.ChangeUserPassword(user, - form['newpw'].value, form['confpw'].value) - except mm_err.MMListNotReady: - PrintResults("The list is currently not funcitonal.") - except mm_err.MMNotAMemberError: - PrintResults("You seem to no longer be a list member.") - except mm_err.MMBadPasswordError: - PrintResults("The old password you supplied was incorrect.") - except mm_err.MMPasswordsMustMatch: - PrintResults("Passwords must match.") - except: - PrintResults('''An unknown error occured. <p> + PrintResults("You have been unsubscribed.<p>") + elif form.has_key("emailpw"): + try: + list.MailUserPassword(user) + PrintResults("A reminder of your password " + "has been emailed to you.<p>") + except Errors.MMBadUserError: + PrintResults("Your password entry has not been found. The list " + "manager is being notified.<p>") + + elif form.has_key("changepw"): + if (form.has_key('opw') + and form.has_key('newpw') + and form.has_key('confpw')): + try: + list.ConfirmUserPassword(user, form['opw'].value) + list.ChangeUserPassword(user, + form['newpw'].value, form['confpw'].value) + except Errors.MMListNotReady: + PrintResults("The list is currently not funcitonal.") + except Errors.MMNotAMemberError: + PrintResults("You seem to no longer be a list member.") + except Errors.MMBadPasswordError: + PrintResults("The old password you supplied was incorrect.") + except Errors.MMPasswordsMustMatch: + PrintResults("Passwords must match.") + except: + PrintResults('''An unknown error occured. <p> Please send mail to <a href=%s>%s</a> explaining exactly what you did to get this error.<p>''' % (mm_cfg.MAILMAN_OWNER, mm_cfg.MAILMAN_OWNER)) - PrintResults("Your password has been changed.") - else: - PrintResults("You must supply your old password," - " and your new password twice.") + PrintResults("Your password has been changed.") + else: + PrintResults("You must supply your old password," + " and your new password twice.") -else: - # If keys don't exist, set them to whatever they were. (essentially a noop) - if form.has_key("digest"): - digest_value = eval(form["digest"].value) else: - digest_value = list.GetUserOption(user, mm_cfg.Digests) - if form.has_key("mime"): - mime = eval(form["mime"].value) - else: - mime = list.GetUserOption(user, mm_cfg.DisableMime) - if form.has_key("dontreceive"): - dont_receive = eval(form["dontreceive"].value) - else: - dont_receive = list.GetUserOption(user, mm_cfg.DontReceiveOwnPosts) - if form.has_key("ackposts"): - ack_posts = eval(form["ackposts"].value) - else: - ack_posts = list.GetUserOption(user, mm_cfg.AcknowlegePosts) - if form.has_key("disablemail"): - disable_mail = eval(form["disablemail"].value) - else: - disable_mail = list.GetUserOption(user, mm_cfg.DisableDelivery) - if form.has_key("conceal"): - conceal = eval(form["conceal"].value) - else: - conceal = list.GetUserOption(user, mm_cfg.ConcealSubscription) + # If keys don't exist, set them to whatever they were. (essentially a noop) + if form.has_key("digest"): + digest_value = eval(form["digest"].value) + else: + digest_value = list.GetUserOption(user, mm_cfg.Digests) + if form.has_key("mime"): + mime = eval(form["mime"].value) + else: + mime = list.GetUserOption(user, mm_cfg.DisableMime) + if form.has_key("dontreceive"): + dont_receive = eval(form["dontreceive"].value) + else: + dont_receive = list.GetUserOption(user, mm_cfg.DontReceiveOwnPosts) + if form.has_key("ackposts"): + ack_posts = eval(form["ackposts"].value) + else: + ack_posts = list.GetUserOption(user, mm_cfg.AcknowlegePosts) + if form.has_key("disablemail"): + disable_mail = eval(form["disablemail"].value) + else: + disable_mail = list.GetUserOption(user, mm_cfg.DisableDelivery) + if form.has_key("conceal"): + conceal = eval(form["conceal"].value) + else: + conceal = list.GetUserOption(user, mm_cfg.ConcealSubscription) - if not form.has_key("digpw"): - PrintResults("You must supply a password to change options.") - try: - list.ConfirmUserPassword(user, form['digpw'].value) - except mm_err.MMAlreadyDigested: - pass - except mm_err.MMAlreadyUndigested: - pass - except mm_err.MMMustDigestError: - PrintResults("List only accepts digest members.") - except mm_err.MMCantDigestError: - PrintResults("List doesn't accept digest members.") - except mm_err.MMNotAMemberError: - PrintResults("%s isn't subscribed to this list." % mail.GetSender()) - except mm_err.MMListNotReady: - PrintResults("List is not functional.") - except mm_err.MMNoSuchUserError: - PrintResults("%s is not subscribed to this list." %mail.GetSender()) - except mm_err.MMBadPasswordError: - PrintResults("You gave the wrong password.") - except: - PrintResults('''An unknown error occured. <p> -Please send mail to <a href=%s>%s</a> explaining -exactly what you did to get this error.<p>''' % (mm_cfg.MAILMAN_OWNER)) - + if not form.has_key("digpw"): + PrintResults("You must supply a password to change options.") + try: + list.ConfirmUserPassword(user, form['digpw'].value) + except Errors.MMAlreadyDigested: + pass + except Errors.MMAlreadyUndigested: + pass + except Errors.MMMustDigestError: + PrintResults("List only accepts digest members.") + except Errors.MMCantDigestError: + PrintResults("List doesn't accept digest members.") + except Errors.MMNotAMemberError: + PrintResults("%s isn't subscribed to this list." % mail.GetSender()) + except Errors.MMListNotReady: + PrintResults("List is not functional.") + except Errors.MMNoSuchUserError: + PrintResults("%s is not subscribed to this list." %mail.GetSender()) + except Errors.MMBadPasswordError: + PrintResults("You gave the wrong password.") + except: + PrintResults('''An unknown error occured. <p> + Please send mail to <a href=%s>%s</a> explaining + exactly what you did to get this error.<p>''' % (mm_cfg.MAILMAN_OWNER)) - list.SetUserOption(user, mm_cfg.DisableDelivery, disable_mail) - list.SetUserOption(user, mm_cfg.DontReceiveOwnPosts, dont_receive) - list.SetUserOption(user, mm_cfg.AcknowlegePosts, ack_posts) - list.SetUserOption(user, mm_cfg.DisableMime, mime) - try: - list.SetUserDigest(user, digest_value) - except (mm_err.MMAlreadyDigested, mm_err.MMAlreadyUndigested): - pass - list.SetUserOption(user, mm_cfg.ConcealSubscription, conceal) - PrintResults("You have successfully set your options.") + list.SetUserOption(user, mm_cfg.DisableDelivery, disable_mail) + list.SetUserOption(user, mm_cfg.DontReceiveOwnPosts, dont_receive) + list.SetUserOption(user, mm_cfg.AcknowlegePosts, ack_posts) + list.SetUserOption(user, mm_cfg.DisableMime, mime) + try: + list.SetUserDigest(user, digest_value) + except (Errors.MMAlreadyDigested, Errors.MMAlreadyUndigested): + pass + list.SetUserOption(user, mm_cfg.ConcealSubscription, conceal) + PrintResults("You have successfully set your options.") -list.Unlock()
\ No newline at end of file + + list.Unlock() diff --git a/Mailman/Cgi/options.py b/Mailman/Cgi/options.py index 07664bbb3..79575a87f 100644 --- a/Mailman/Cgi/options.py +++ b/Mailman/Cgi/options.py @@ -19,7 +19,7 @@ """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 +on the Utils.{O,Uno}bscureEmail utilities tolerance, will work fine with an unobscured ids as well. """ @@ -29,97 +29,98 @@ unobscured ids as well. import sys import os, string -import mm_utils, maillist, htmlformat, mm_cfg +from Mailman import Utils, MailList, htmlformat +from Mailman import mm_cfg -doc = htmlformat.HeadlessDocument() +def main(): + doc = htmlformat.HeadlessDocument() -try: - path = os.environ['PATH_INFO'] -except KeyError: - path = "" -list_info = mm_utils.GetPathPieces(path) + try: + path = os.environ['PATH_INFO'] + except KeyError: + path = "" + list_info = 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) + 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]) + list_name = string.lower(list_info[0]) + user = Utils.UnobscureEmail(list_info[1]) -try: - list = maillist.MailList(list_name, lock=0) -except: - doc.AddItem(htmlformat.Header(2, "Error")) - doc.AddItem(htmlformat.Bold("%s: No such list." % list_name )) - print doc.Format() - sys.exit(0) + try: + list = MailList.MailList(list_name, lock=0) + 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 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) + 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 + # Re-obscure the user's address for the page banner if obscure_addresses set. + if list.obscure_addresses: + presentable_user = Utils.ObscureEmail(user, for_text=1) + else: + presentable_user = user -replacements = list.GetStandardReplacements() -replacements['<mm-digest-radio-button>'] = list.FormatOptionButton( - mm_cfg.Digests, 1, user) -replacements['<mm-undigest-radio-button>'] = list.FormatOptionButton( - mm_cfg.Digests, 0, user) -replacements['<mm-plain-digests-button>'] = list.FormatOptionButton( - mm_cfg.DisableMime, 1, user) -replacements['<mm-mime-digests-button>'] = list.FormatOptionButton( - mm_cfg.DisableMime, 0, user) -replacements['<mm-delivery-enable-button>'] = list.FormatOptionButton( - mm_cfg.DisableDelivery, 0, user) -replacements['<mm-delivery-disable-button>'] = list.FormatOptionButton( - mm_cfg.DisableDelivery, 1, user) -replacements['<mm-disabled-notice>'] = list.FormatDisabledNotice(user) -replacements['<mm-dont-ack-posts-button>'] = list.FormatOptionButton( - mm_cfg.AcknowlegePosts, 0, user) -replacements['<mm-ack-posts-button>'] = list.FormatOptionButton( - mm_cfg.AcknowlegePosts, 1, user) -replacements['<mm-receive-own-mail-button>'] = list.FormatOptionButton( - mm_cfg.DontReceiveOwnPosts, 0, user) -replacements['<mm-dont-receive-own-mail-button>'] = list.FormatOptionButton( - mm_cfg.DontReceiveOwnPosts, 1, user) -replacements['<mm-public-subscription-button>'] = list.FormatOptionButton( - mm_cfg.ConcealSubscription, 0, user) -replacements['<mm-hide-subscription-button>'] = list.FormatOptionButton( - mm_cfg.ConcealSubscription, 1, user) + replacements = list.GetStandardReplacements() + replacements['<mm-digest-radio-button>'] = list.FormatOptionButton( + mm_cfg.Digests, 1, user) + replacements['<mm-undigest-radio-button>'] = list.FormatOptionButton( + mm_cfg.Digests, 0, user) + replacements['<mm-plain-digests-button>'] = list.FormatOptionButton( + mm_cfg.DisableMime, 1, user) + replacements['<mm-mime-digests-button>'] = list.FormatOptionButton( + mm_cfg.DisableMime, 0, user) + replacements['<mm-delivery-enable-button>'] = list.FormatOptionButton( + mm_cfg.DisableDelivery, 0, user) + replacements['<mm-delivery-disable-button>'] = list.FormatOptionButton( + mm_cfg.DisableDelivery, 1, user) + replacements['<mm-disabled-notice>'] = list.FormatDisabledNotice(user) + replacements['<mm-dont-ack-posts-button>'] = list.FormatOptionButton( + mm_cfg.AcknowlegePosts, 0, user) + replacements['<mm-ack-posts-button>'] = list.FormatOptionButton( + mm_cfg.AcknowlegePosts, 1, user) + replacements['<mm-receive-own-mail-button>'] = list.FormatOptionButton( + mm_cfg.DontReceiveOwnPosts, 0, user) + replacements['<mm-dont-receive-own-mail-button>'] = list.FormatOptionButton( + mm_cfg.DontReceiveOwnPosts, 1, user) + replacements['<mm-public-subscription-button>'] = list.FormatOptionButton( + mm_cfg.ConcealSubscription, 0, user) + replacements['<mm-hide-subscription-button>'] = list.FormatOptionButton( + mm_cfg.ConcealSubscription, 1, user) -replacements['<mm-digest-submit>'] = list.FormatButton('setdigest', - 'Submit My Changes') -replacements['<mm-unsubscribe-button>'] = list.FormatButton('unsub', 'Unsubscribe') -replacements['<mm-digest-pw-box>'] = list.FormatSecureBox('digpw') -replacements['<mm-unsub-pw-box>'] = list.FormatSecureBox('upw') -replacements['<mm-old-pw-box>'] = list.FormatSecureBox('opw') -replacements['<mm-new-pass-box>'] = list.FormatSecureBox('newpw') -replacements['<mm-confirm-pass-box>'] = list.FormatSecureBox('confpw') -replacements['<mm-change-pass-button>'] = list.FormatButton('changepw', - "Change My Password") -replacements['<mm-form-start>'] = list.FormatFormStart('handle_opts', user) -replacements['<mm-user>'] = user -replacements['<mm-presentable-user>'] = presentable_user -replacements['<mm-email-my-pw>'] = list.FormatButton('emailpw', - 'Email My Password To Me') + replacements['<mm-digest-submit>'] = list.FormatButton('setdigest', + 'Submit My Changes') + replacements['<mm-unsubscribe-button>'] = list.FormatButton('unsub', 'Unsubscribe') + replacements['<mm-digest-pw-box>'] = list.FormatSecureBox('digpw') + replacements['<mm-unsub-pw-box>'] = list.FormatSecureBox('upw') + replacements['<mm-old-pw-box>'] = list.FormatSecureBox('opw') + replacements['<mm-new-pass-box>'] = list.FormatSecureBox('newpw') + replacements['<mm-confirm-pass-box>'] = list.FormatSecureBox('confpw') + replacements['<mm-change-pass-button>'] = list.FormatButton('changepw', + "Change My Password") + replacements['<mm-form-start>'] = list.FormatFormStart('handle_opts', user) + replacements['<mm-user>'] = user + replacements['<mm-presentable-user>'] = presentable_user + replacements['<mm-email-my-pw>'] = list.FormatButton('emailpw', + 'Email My Password To Me') -doc.AddItem(list.ParseTags('options.html', replacements)) -print doc.Format() - + doc.AddItem(list.ParseTags('options.html', replacements)) + print doc.Format() diff --git a/Mailman/Cgi/subscribe.py b/Mailman/Cgi/subscribe.py index aa69b959f..96e85c602 100644 --- a/Mailman/Cgi/subscribe.py +++ b/Mailman/Cgi/subscribe.py @@ -21,99 +21,171 @@ import sys import os, cgi, string from regsub import gsub -import mm_utils, maillist, mm_err, mm_message, mm_cfg, mm_pending, htmlformat +from Mailman import Utils, MailList, Errors, Pending, htmlformat +from Mailman import mm_cfg -doc = htmlformat.Document() +def main(): + doc = htmlformat.Document() -path = os.environ['PATH_INFO'] -list_info = mm_utils.GetPathPieces(path) -list_name = string.lower(list_info[0]) + path = os.environ['PATH_INFO'] + list_info = Utils.GetPathPieces(path) + list_name = string.lower(list_info[0]) -if len(list_info) < 1: - doc.AddItem(htmlformat.Header(2, "Error")) - doc.AddItem(htmlformat.Bold("Invalid options to CGI script.")) - print doc.Format() - sys.exit(0) + if len(list_info) < 1: + doc.AddItem(htmlformat.Header(2, "Error")) + doc.AddItem(htmlformat.Bold("Invalid options to CGI script.")) + print doc.Format() + sys.exit(0) -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) + 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() - list.Unlock() - 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() + list.Unlock() + sys.exit(0) -form = cgi.FieldStorage() + form = cgi.FieldStorage() -error = 0 -results = '' + error = 0 + results = '' -def call_script(which, pathinfo): - "A little bit of a hack to call one of the scripts..." - os.environ['PATH_INFO'] = string.join(pathinfo, '/') - file = os.path.join(mm_cfg.SCRIPTS_DIR, which) - list.Unlock() - execfile(file) - sys.exit(0) + def call_script(which, pathinfo): + "A little bit of a hack to call one of the scripts..." + os.environ['PATH_INFO'] = string.join(pathinfo, '/') + file = os.path.join(mm_cfg.SCRIPTS_DIR, which) + list.Unlock() + execfile(file) + sys.exit(0) -####### -# Preliminaries done, actual processing of the form input below. + ####### + # Preliminaries done, actual processing of the form input below. -if (form.has_key("UserOptions") - or (form.has_key("info") and not form.has_key("email"))): - # Go to user options section. - if not form.has_key("info"): - doc.AddItem(htmlformat.Header(2, "Error")) - doc.AddItem(htmlformat.Bold("You must supply your email address.")) - doc.AddItem(list.GetMailmanFooter()) - print doc.Format() - list.Unlock() - sys.exit(0) - addr = form['info'].value - member = list.FindUser(addr) - if not list.FindUser(addr): - doc.AddItem(htmlformat.Header(2, "Error")) - doc.AddItem(htmlformat.Bold("%s has no subscribed addr <i>%s</i>." - % (list.real_name, addr))) - doc.AddItem(list.GetMailmanFooter()) - print doc.Format() - list.Unlock() - sys.exit(0) - call_script('options', [list._internal_name, member]) -if not form.has_key("email"): - error = 1 - results = results + "You must supply a valid email address.<br>" -else: - email = form["email"].value -if not form.has_key("pw") or not form.has_key("pw-conf"): - error = 1 - results = results + "You must supply a valid password, and confirm it.<br>" -else: - pw = form["pw"].value - pwc = form["pw-conf"].value + if (form.has_key("UserOptions") + or (form.has_key("info") and not form.has_key("email"))): + # Go to user options section. + if not form.has_key("info"): + doc.AddItem(htmlformat.Header(2, "Error")) + doc.AddItem(htmlformat.Bold("You must supply your email address.")) + doc.AddItem(list.GetMailmanFooter()) + print doc.Format() + list.Unlock() + sys.exit(0) + addr = form['info'].value + member = list.FindUser(addr) + if not list.FindUser(addr): + doc.AddItem(htmlformat.Header(2, "Error")) + doc.AddItem(htmlformat.Bold("%s has no subscribed addr <i>%s</i>." + % (list.real_name, addr))) + doc.AddItem(list.GetMailmanFooter()) + print doc.Format() + list.Unlock() + sys.exit(0) + call_script('options', [list._internal_name, member]) + if not form.has_key("email"): + error = 1 + results = results + "You must supply a valid email address.<br>" + else: + email = form["email"].value + if not form.has_key("pw") or not form.has_key("pw-conf"): + error = 1 + results = results + "You must supply a valid password, and confirm it.<br>" + else: + pw = form["pw"].value + pwc = form["pw-conf"].value -if not error and (pw <> pwc): - error = 1 - results = results + "Your passwords did not match.<br>" + if not error and (pw <> pwc): + error = 1 + results = results + "Your passwords did not match.<br>" -if form.has_key("digest"): - digest = eval(form["digest"].value) + if form.has_key("digest"): + digest = eval(form["digest"].value) -if not list.digestable: - digest = 0 -elif not list.nondigestable: - digest = 1 + if not list.digestable: + digest = 0 + elif not list.nondigestable: + digest = 1 -def PrintResults(): + if error: + PrintResults(list, results, doc) + + else: + try: + results = results + ("Confirmation from your email address is " + "required, to prevent anyone from covertly " + "subscribing you. Instructions are being " + "sent to you at %s." % email) + if os.environ.has_key('REMOTE_HOST'): + remote = os.environ['REMOTE_HOST'] + elif os.environ.has_key('REMOTE_ADDR'): + remote = os.environ['REMOTE_ADDR'] + else: + remote = "." + if digest: + digesting = " digest" + else: + digesting = "" + cookie = Pending.gencookie() + Pending.add2pending(email, pw, digest, cookie) + text = Utils.maketext( + 'verify.txt', + {"email" : email, + "listaddr" : list.GetListEmail(), + "listname" : list.real_name, + "cookie" : cookie, + "hostname" : remote, + "requestaddr": list.GetRequestEmail(), + }) + list.SendTextToUser( + subject="%s -- confirmation of subscription -- request %d" % \ + (list.real_name, cookie), + recipient = email, + sender = list.GetRequestEmail(), + text = text, + add_headers = ["Reply-to: %s" + % list.GetRequestEmail(), + "Errors-To: %s" + % list.GetAdminEmail()]) + except Errors.MMBadEmailError: + results = results + ("Mailman won't accept the given email " + "address as a valid address. (Does it " + "have an @ in it???)<p>") + except Errors.MMListNotReady: + results = results + ("The list is not fully functional, and " + "can not accept subscription requests.<p>") + # + # deprecating this, it might be useful if we decide to + # allow approved based subscriptions without confirmation + # + ## except Errors.MMNeedApproval, x: + ## results = results + ("Subscription was <em>deferred</em> " + ## "because:<br> %s<p>Your request must " + ## "be approved by the list admin. " + ## "You will receive email informing you " + ## "of the moderator's descision when they " + ## "get to your request.<p>" % x) + except Errors.MMHostileAddress: + results = results + ("Your subscription is not allowed because " + "the email address you gave is insecure.<p>") + except Errors.MMAlreadyAMember: + results = results + "You are already subscribed!<p>" + + + PrintResults(list, results, doc) + list.Unlock() + + + +def PrintResults(list, results, doc): replacements = list.GetStandardReplacements() replacements['<mm-results>'] = results output = list.ParseTags('subscribe.html', replacements) @@ -123,66 +195,3 @@ def PrintResults(): list.Unlock() sys.exit(0) -if error: - PrintResults() - -else: - try: - results = results + ("Confirmation from your email address is " - "required, to prevent anyone from covertly " - "subscribing you. Instructions are being " - "sent to you at %s." % email) - if os.environ.has_key('REMOTE_HOST'): - remote = os.environ['REMOTE_HOST'] - elif os.environ.has_key('REMOTE_ADDR'): - remote = os.environ['REMOTE_ADDR'] - else: - remote = "." - if digest: - digesting = " digest" - else: - digesting = "" - cookie = mm_pending.gencookie() - mm_pending.add2pending(email, pw, digest, cookie) - list.SendTextToUser(subject = "%s -- confirmation of subscription -- request %d" % \ - (list.real_name, cookie), - recipient = email, - sender = list.GetRequestEmail(), - text = mm_pending.VERIFY_FMT % ({"email": email, - "listaddress": list.GetListEmail(), - "listname": list.real_name, - "cookie": cookie, - "requestor": remote, - "request_addr": list.GetRequestEmail()}), - - add_headers = ["Reply-to: %s" - % list.GetRequestEmail(), - "Errors-To: %s" - % list.GetAdminEmail()]) - except mm_err.MMBadEmailError: - results = results + ("Mailman won't accept the given email " - "address as a valid address. (Does it " - "have an @ in it???)<p>") - except mm_err.MMListNotReady: - results = results + ("The list is not fully functional, and " - "can not accept subscription requests.<p>") -# -# deprecating this, it might be useful if we decide to -# allow approved based subscriptions without confirmation -# -## except mm_err.MMNeedApproval, x: -## results = results + ("Subscription was <em>deferred</em> " -## "because:<br> %s<p>Your request must " -## "be approved by the list admin. " -## "You will receive email informing you " -## "of the moderator's descision when they " -## "get to your request.<p>" % x) - except mm_err.MMHostileAddress: - results = results + ("Your subscription is not allowed because " - "the email address you gave is insecure.<p>") - except mm_err.MMAlreadyAMember: - results = results + "You are already subscribed!<p>" - - -PrintResults() -list.Unlock()
\ No newline at end of file |
