summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcgi/admindb204
1 files changed, 204 insertions, 0 deletions
diff --git a/cgi/admindb b/cgi/admindb
new file mode 100755
index 000000000..287575956
--- /dev/null
+++ b/cgi/admindb
@@ -0,0 +1,204 @@
+#!/usr/local/bin/python
+
+import sys, os, cgi, string, crypt, types
+
+f = open('/tmp/fboggle', 'a+')
+sys.stderr = sys.stdout
+sys.path.append('/home/mailman/mailman/modules')
+import mm_utils, maillist, mm_err, htmlformat
+
+doc = htmlformat.Document()
+
+path = os.environ['PATH_INFO']
+list_info = mm_utils.GetPathPieces(path)
+
+if len(list_info) < 1:
+ doc.AddItem(htmlformat.Header(2, "Invalid options to CGI script."))
+ print doc.Format()
+ sys.exit(0)
+
+list_name = list_info[0]
+
+try:
+ list = maillist.MailList(list_name)
+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)
+
+# 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.
+
+def SubscribeAll():
+ for i in range(len(list.requests['add_member'])):
+ comment_key = 'comment-%d' % list.requests['add_member'][0][0]
+ if form.has_key(comment_key):
+ list.HandleRequest(('add_member', 0), 1, form[comment_key].value)
+ else:
+ list.HandleRequest(('add_member', 0), 1)
+
+def SubscribeNone():
+ for i in range(len(list.requests['add_member'])):
+ comment_key = 'comment-%d' % list.requests['add_member'][0][0]
+ if form.has_key(comment_key):
+ list.HandleRequest(('add_member', 0), 0, form[comment_key].value)
+ else:
+ list.HandleRequest(('add_member', 0), 0)
+
+def PrintHeader(str):
+ doc.AddItem(htmlformat.Header(3, htmlformat.Italic(str)))
+ doc.AddItem('<hr>')
+
+def HandleRequests(doc):
+ if not form.has_key('adminpw'):
+ PrintHeader('You need to supply the admin password to answer requests.')
+ return
+ try:
+ list.ConfirmAdminPassword(form['adminpw'].value)
+ except:
+ PrintHeader('Incorrect admin password.')
+ return
+ ignore_subscribes = 0
+ if form.has_key('subscribe_all'):
+ ignore_subscribes = 1
+ SubscribeAll()
+ elif form.has_key('subscribe_none'):
+ ignore_subscribes = 1
+ SubscribeNone()
+ for k in form.keys():
+ try:
+ v = eval(form[k].value)
+ request_id = eval(k)
+ except: # For stuff like adminpw
+ continue
+ if type(request_id) <> types.IntType:
+ continue
+ try:
+ request = list.GetRequest(request_id)
+ except mm_err.MMBadRequestId:
+ continue # You've already changed the database. No biggie.
+ if ignore_subscribes and request[0] == 'add_member':
+ # We already handled this request.
+ continue
+ comment_key = 'comment-%d' % request_id
+ if form.has_key(comment_key):
+ list.HandleRequest(request, v, form[comment_key].value)
+ else:
+ list.HandleRequest(request, v)
+ list.Save()
+ PrintHeader('Database Updated...')
+
+
+def PrintAddMemberRequest(val, table):
+ table.AddRow([
+ val[3],
+ htmlformat.RadioButtonArray(val[0], ("Refuse", "Subscribe")),
+ htmlformat.TextBox("comment-%d" % val[0], size=50)
+ ])
+
+def PrintPostRequest(val, form):
+ t = htmlformat.Table(cellspacing=10)
+ t.AddRow([
+ htmlformat.FontSize("+1",
+ htmlformat.Bold('Post held because: ')),
+ val[3]])
+ t.AddRow([
+ htmlformat.FontSize("+1",
+ htmlformat.Bold('Action to take on this post:')),
+ htmlformat.RadioButtonArray(val[0], ("Reject", "Approve")),
+ htmlformat.SubmitButton('submit', 'Submit All Data')
+ ])
+ t.AddRow([
+ htmlformat.FontSize("+1",
+ htmlformat.Bold('If you reject this post, '
+ 'why you chose to reject it '
+ '(optional):')),
+ htmlformat.TextBox("comment-%d" % val[0], size=60)])
+
+ cur_row = t.GetCurrentRowIndex()
+ cur_col = t.GetCurrentCellIndex()
+ t.AddCellInfo(cur_row, cur_col, colspan=3)
+
+ t.AddRow([
+ htmlformat.FontSize("+1",
+ htmlformat.Bold('Contents:'))])
+ form.AddItem(t)
+ form.AddItem(htmlformat.Preformatted(val[2][1]))
+ form.AddItem('<p>')
+
+
+def PrintRequests(doc):
+ # 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
+ # the code).
+
+ doc.AddItem(htmlformat.Header(2, "Administrative requests for "
+ "'%s' mailing list" % list.real_name))
+ doc.AddItem(htmlformat.FontSize("+1", htmlformat.Link(
+ list.GetScriptURL('admin'), htmlformat.Italic(
+ 'View or edit the list configuration information'))))
+ doc.AddItem('<p><hr>')
+ if not list.RequestsPending():
+ doc.AddItem(htmlformat.Header(3,'There are no pending requests.'))
+ doc.AddItem(list.GetMailmanFooter())
+ return
+ form = htmlformat.Form(list.GetScriptURL('admindb'))
+ doc.AddItem(form)
+ form.AddItem('Admin password: ')
+ form.AddItem(htmlformat.PasswordBox('adminpw'))
+ form.AddItem('<p>')
+ if list.requests.has_key('add_member'):
+## form.AddItem('<hr>')
+## t = htmlformat.Table(cellspacing=10)
+## t.AddRow([
+## htmlformat.SubmitButton('submit', 'Submit All Data'),
+## htmlformat.SubmitButton('subscribe_all', 'Subscribe Everybody'),
+## htmlformat.SubmitButton('subscribe_none', 'Refuse Everybody')
+## ])
+## form.AddItem(t)
+ form.AddItem('<hr>')
+ form.AddItem(htmlformat.Center(
+ htmlformat.Header(2, 'Subscription Requests')))
+ t = htmlformat.Table(border=2)
+ t.AddRow([
+ htmlformat.Bold('Email'),
+ htmlformat.Bold('Descision'),
+ htmlformat.Bold('Reasoning if you refuse subscription (optional)')])
+ for request in list.requests['add_member']:
+ PrintAddMemberRequest(request, t)
+
+ form.AddItem(t)
+ form.AddItem('<hr>')
+ t = htmlformat.Table(cellspacing=10)
+ t.AddRow([
+ htmlformat.SubmitButton('submit', 'Submit All Data'),
+ htmlformat.SubmitButton('subscribe_all', 'Subscribe Everybody'),
+ htmlformat.SubmitButton('subscribe_none', 'Refuse Everybody')
+ ])
+ form.AddItem(t)
+
+ # Print submitit buttons...
+ if list.requests.has_key('post'):
+ for request in list.requests['post']:
+ form.AddItem('<hr>')
+ form.AddItem(htmlformat.Center(htmlformat.Header(2, "Held Message")))
+ PrintPostRequest(request, form)
+ doc.AddItem(list.GetMailmanFooter())
+
+try:
+ form = cgi.FieldStorage()
+ if len(form.keys()):
+ HandleRequests(doc)
+ PrintRequests(doc)
+ text = doc.Format()
+ print text
+ sys.stdout.flush()
+finally:
+ list.Unlock()