summaryrefslogtreecommitdiff
path: root/cgi/handle_opts
diff options
context:
space:
mode:
authorviega1998-06-14 01:00:28 +0000
committerviega1998-06-14 01:00:28 +0000
commit73e488770ae493feeaf08ac9d21bd14eccdb2da2 (patch)
tree950823c4949a13fcf3b3dcb82df1310bbe6be6ba /cgi/handle_opts
parent8dfd4643c7d8216cfbf6e180ed7b868715b9e775 (diff)
downloadmailman-73e488770ae493feeaf08ac9d21bd14eccdb2da2.tar.gz
mailman-73e488770ae493feeaf08ac9d21bd14eccdb2da2.tar.zst
mailman-73e488770ae493feeaf08ac9d21bd14eccdb2da2.zip
Replaced with Mailman.runcgi-wrapped code that runs Mailman.Cgi.<script>
Diffstat (limited to 'cgi/handle_opts')
-rwxr-xr-xcgi/handle_opts199
1 files changed, 5 insertions, 194 deletions
diff --git a/cgi/handle_opts b/cgi/handle_opts
index 45a98858c..f43fb99ef 100755
--- a/cgi/handle_opts
+++ b/cgi/handle_opts
@@ -16,199 +16,10 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-"""Process input to user options form."""
+import paths
-import sys
-import os, cgi, string
-import paths # path hacking
-import mm_utils, maillist, mm_err, mm_cfg, htmlformat
+def handle_opts():
+ import Mailman.Cgi.handle_opts
-try:
- sys.stderr = mm_utils.StampedLogger("error", label = 'handle_opts',
- 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(bgcolor="#ffffff")
- 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)
-
-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)
-
-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)
-
-
-def PrintResults(results):
- replacements = list.GetStandardReplacements()
- replacements['<mm-results>'] = results
- replacements['<mm-operation>'] = operation
- output = list.ParseTags('handle_opts.html', replacements)
-
- doc.AddItem(output)
- print doc.Format(bgcolor="#ffffff")
- list.Unlock()
- sys.exit(0)
-
-form = cgi.FieldStorage()
-
-error = 0
-operation = ""
-
-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 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))
-
- 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>
-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.")
-
-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 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))
-
-
- 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.Unlock() \ No newline at end of file
+from Mailman.runcgi import *
+wrap_func(handle_opts)