[Mailman-Users] Showing list of user's subscriptions

Paul H Byerly paul at thcwd.com
Thu Sep 25 03:16:31 CEST 2003


Rob LeVine  wrote:
>Hi,
>Here's my deal:  I run a social site that has the need for very low 
>security mailing lists.  I am currently using MailMan 2.1.2 and I've read, 
>yet not implemented, FAQ 1.5 that discusses turing off the password 
>requirement.  Assuming I can successully complete that, what are the 
>chances that when a user site logs in to my site (not into Mailman), 
>meaning I know what his email address is I can show him what lists he's 
>subscribed to without having him having to go to the MailMan user options page?
>
>Example: User logs into my site and with his email address I fetch a list 
>of subscribed mailing lists and show that list to the user.
<!--

      I've done something like this, and it also gives the number of 
members on the list, and links to the list info page, and archives page of 
each list.  I've done it by adding the following to Mailman/Cgi/options.py

-----
     if cgidata.has_key('mylists'):

         # 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=4,
                           bgcolor=mm_cfg.WEB_HEADER_COLOR)

         listnames = Utils.list_names()
         listnames.sort()

         greeting = FontAttr(_('Welcome!'), size='+2')

         welcome = [greeting]
         mailmanlink = Link(mm_cfg.MAILMAN_URL, _('Mailman')).Format()
         welcome.append(
             _('''<p>Below is a listing of all the public mailing lists on
             %(hostname)s.  Click on a list name under "List Information"
             to get more information about the list, to subscribe, or 
unsubscribe.
             Members of a list may click on the "Archives" link to access 
the list's posts.'''))

         # set up some local variables
         siteowner = Utils.get_site_email()
         welcome.extend(
             (_(''' Some text here  '''),
              Link(Utils.ScriptURL('admin'),
                   _('the list admin overview page')),
              _(''' to find the management interface for your list.
              <p>Send questions or comments to '''),
              Link('mailto:' + siteowner, siteowner),
          '.<p>'))

         table.AddRow([apply(Container, welcome)])
         table.AddCellInfo(max(table.GetCurrentRowIndex(), 0), 0, colspan=4)

         table.AddRow(['&nbsp;', '&nbsp;', '&nbsp;', '&nbsp;'])
         table.AddRow([Bold(FontAttr(_('List Information'), size='+2')),
                       Center(Bold(FontAttr(_('Members'), size='+2'))),
                       Center(Bold(FontAttr(_('List Archive'), size='+2'))),
                       Bold(FontAttr(_('Description'), size='+2'))
                       ])
         highlight = 1
         onlists = []
         for gmlist in lists_of_member(mlist, user) + [mlist]:
             table.AddRow(
                 [Link(gmlist.GetScriptURL('listinfo'), 
Bold(gmlist.real_name)),
                  Center(len(gmlist.members) + len(gmlist.digest_members)),
                  Center(Link(gmlist.GetBaseArchiveURL(), Bold('Archives'))),
                  gmlist.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()
         return

     if cgidata.has_key('mylistsbu'):
         hostname = mlist.host_name
         title = _('List subscriptions for %(safeuser)s on %(hostname)s')
         doc.SetTitle(title)
         doc.AddItem(Header(2, title))
         doc.AddItem(_('''Click on a link to visit your options page for the
         requested mailing list.'''))

         # Troll through all the mailing lists that match host_name and see if
         # the user is a member.  If so, add it to the list.
         onlists = []
         for gmlist in lists_of_member(mlist, user) + [mlist]:
             url = gmlist.GetBaseArchiveURL()
             link = Link(url, gmlist.real_name)
             onlists.append((gmlist.real_name, link))
         onlists.sort()
         items = OrderedList(*[link for name, link in onlists])
         doc.AddItem(items)
         print doc.Format()
         return
-----

      I'm calling it from archtoc.html with:
---
<SCRIPT LANGUAGE=JAVASCRIPT>
mylistsurl = 'http://svr01.thcwd.com/mailman/options/mm-p-f-a/' + userName 
+ '?mylists=1'
</SCRIPT>

<a href="#" onclick="window.location = mylistsurl ;">My Lists</a>&nbsp; &nbsp;
---
      where userName contains the users e-mail address.  It should work 
from any web page, as long as you can pass the proper information, but only 
works if the person has logged in their password, so that puts in in 
mailman.  You could also do a button from the users options page with 
something like:
---
<center><INPUT type="Submit" name="mylists" value="My Lists - links to 
archives"></center>
---
      right under:

<center><MM-Other-Subscriptions-Submit></center>


      Either way, this method uses Mailman's to do the heavy lifting.  Back 
everything up, watch the leading spaces, restart the gunners afterwards, 
and have fun.  Al the usual "it works for me, it's not my fault if it blows 
up your server" stuff applies.

-->

<>< Paul, who only understands half of that code 





More information about the Mailman-Users mailing list