Exemple #1
0
 def FormatUsers(self, digest, lang=None, list_hidden=False):
     if lang is None:
         lang = self.preferred_language
     conceal_sub = mm_cfg.ConcealSubscription
     people = []
     if digest:
         members = self.getDigestMemberKeys()
     else:
         members = self.getRegularMemberKeys()
     for m in members:
         if list_hidden or not self.getMemberOption(m, conceal_sub):
             people.append(m)
     num_concealed = len(members) - len(people)
     if num_concealed == 1:
         concealed = _('<em>(1 private member not shown)</em>')
     elif num_concealed > 1:
         concealed = _(
             '<em>(%(num_concealed)d private members not shown)</em>')
     else:
         concealed = ''
     items = []
     people.sort()
     obscure = self.obscure_addresses
     for person in people:
         id = Utils.ObscureEmail(person)
         url = self.GetOptionsURL(person, obscure=obscure)
         person = self.getMemberCPAddress(person)
         if obscure:
             showing = Utils.ObscureEmail(person, for_text=1)
         else:
             showing = person
         realname = Utils.uncanonstr(self.getMemberName(person), lang)
         if realname and mm_cfg.ROSTER_DISPLAY_REALNAME:
             showing += " (%s)" % Utils.websafe(realname)
         got = Link(url, showing)
         if self.getDeliveryStatus(person) <> MemberAdaptor.ENABLED:
             got = Italic('(', got, ')')
         items.append(got)
     # Just return the .Format() so this works until I finish
     # converting everything to htmlformat...
     return concealed + UnorderedList(*tuple(items)).Format()
 def AuthContextInfo(self, authcontext, user=None):
     # authcontext may be one of AuthUser, AuthListModerator,
     # AuthListAdmin, AuthSiteAdmin.  Not supported is the AuthCreator
     # context.
     #
     # user is ignored unless authcontext is AuthUser
     #
     # Return the authcontext's secret and cookie key.  If the authcontext
     # doesn't exist, return the tuple (None, None).  If authcontext is
     # AuthUser, but the user isn't a member of this mailing list, a
     # NotAMemberError will be raised.  If the user's secret is None, raise
     # a MMBadUserError.
     key = self.internal_name() + '+'
     if authcontext == mm_cfg.AuthUser:
         if user is None:
             # A bad system error
             raise TypeError('No user supplied for AuthUser context')
         secret = self.getMemberPassword(user)
         userdata = urllib.parse.quote(Utils.ObscureEmail(user), safe='')
         key += 'user+%s' % userdata
     elif authcontext == mm_cfg.AuthListPoster:
         secret = self.post_password
         key += 'poster'
     elif authcontext == mm_cfg.AuthListModerator:
         secret = self.mod_password
         key += 'moderator'
     elif authcontext == mm_cfg.AuthListAdmin:
         secret = self.password
         key += 'admin'
     # BAW: AuthCreator
     elif authcontext == mm_cfg.AuthSiteAdmin:
         sitepass = Utils.get_global_password()
         if mm_cfg.ALLOW_SITE_ADMIN_COOKIES and sitepass:
             secret = sitepass
             key = 'site'
         else:
             # BAW: this should probably hand out a site password based
             # cookie, but that makes me a bit nervous, so just treat site
             # admin as a list admin since there is currently no site
             # admin-only functionality.
             secret = self.password
             key += 'admin'
     else:
         return None, None
     return key, secret
Exemple #3
0
 def GetMailmanFooter(self):
     ownertext = Utils.ObscureEmail(self.GetOwnerEmail(), 1)
     # Remove the .Format() when htmlformat conversion is done.
     realname = self.real_name
     hostname = self.host_name
     listinfo_link = Link(self.GetScriptURL('listinfo'), realname).Format()
     owner_link = Link('mailto:' + self.GetOwnerEmail(), ownertext).Format()
     innertext = _('%(listinfo_link)s list run by %(owner_link)s')
     return Container(
         '<hr>',
         Address(
             Container(
                 innertext, '<br>',
                 Link(self.GetScriptURL('admin'),
                      _('%(realname)s administrative interface')),
                 _(' (requires authorization)'), '<br>',
                 Link(Utils.ScriptURL('listinfo'),
                      _('Overview of all %(hostname)s mailing lists')),
                 '<p>', MailmanLogo()))).Format()
def loginpage(mlist, doc, user, lang):
    realname = mlist.real_name
    actionurl = mlist.GetScriptURL('options')
    if user is None:
        title = _('%(realname)s list: member options login page')
        extra = _('email address and ')
    else:
        safeuser = Utils.websafe(user)
        title = _('%(realname)s list: member options for user %(safeuser)s')
        obuser = Utils.ObscureEmail(user)
        extra = ''
    # Set up the title
    doc.SetTitle(title)
    # We use a subtable here so we can put a language selection box in
    table = Table(width='100%', border=0, cellspacing=4, cellpadding=5)
    # If only one language is enabled for this mailing list, omit the choice
    # buttons.
    table.AddRow([Center(Header(2, title))])
    table.AddCellInfo(table.GetCurrentRowIndex(),
                      0,
                      bgcolor=mm_cfg.WEB_HEADER_COLOR)
    if len(mlist.GetAvailableLanguages()) > 1:
        langform = Form(actionurl)
        langform.AddItem(
            SubmitButton('displang-button', _('View this page in')))
        langform.AddItem(mlist.GetLangSelectBox(lang))
        if user:
            langform.AddItem(Hidden('email', user))
        table.AddRow([Center(langform)])
    doc.AddItem(table)
    # Preamble
    # Set up the login page
    form = Form(actionurl)
    form.AddItem(Hidden('language', lang))
    table = Table(width='100%', border=0, cellspacing=4, cellpadding=5)
    table.AddRow([
        _("""In order to change your membership option, you must
    first log in by giving your %(extra)smembership password in the section
    below.  If you don't remember your membership password, you can have it
    emailed to you by clicking on the button below.  If you just want to
    unsubscribe from this list, click on the <em>Unsubscribe</em> button and a
    confirmation message will be sent to you.

    <p><strong><em>Important:</em></strong> From this point on, you must have
    cookies enabled in your browser, otherwise none of your changes will take
    effect.
    """)
    ])
    # Password and login button
    ptable = Table(width='50%', border=0, cellspacing=4, cellpadding=5)
    if user is None:
        ptable.AddRow([Label(_('Email address:')), TextBox('email', size=20)])
    else:
        ptable.AddRow([Hidden('email', user)])
    ptable.AddRow([Label(_('Password:'******'password', size=20)])
    ptable.AddRow([Center(SubmitButton('login', _('Log in')))])
    ptable.AddCellInfo(ptable.GetCurrentRowIndex(), 0, colspan=2)
    table.AddRow([Center(ptable)])
    # Unsubscribe section
    table.AddRow([Center(Header(2, _('Unsubscribe')))])
    table.AddCellInfo(table.GetCurrentRowIndex(),
                      0,
                      bgcolor=mm_cfg.WEB_HEADER_COLOR)

    table.AddRow([
        _("""By clicking on the <em>Unsubscribe</em> button, a
    confirmation message will be emailed to you.  This message will have a
    link that you should click on to complete the removal process (you can
    also confirm by email; see the instructions in the confirmation
    message).""")
    ])

    table.AddRow([Center(SubmitButton('login-unsub', _('Unsubscribe')))])
    # Password reminder section
    table.AddRow([Center(Header(2, _('Password reminder')))])
    table.AddCellInfo(table.GetCurrentRowIndex(),
                      0,
                      bgcolor=mm_cfg.WEB_HEADER_COLOR)

    table.AddRow([
        _("""By clicking on the <em>Remind</em> button, your
    password will be emailed to you.""")
    ])

    table.AddRow([Center(SubmitButton('login-remind', _('Remind')))])
    # Finish up glomming together the login page
    form.AddItem(table)
    doc.AddItem(form)
    doc.AddItem(mlist.GetMailmanFooter())
def options_page(mlist, doc, user, cpuser, userlang, message=''):
    # The bulk of the document will come from the options.html template, which
    # includes it's own html armor (head tags, etc.).  Suppress the head that
    # Document() derived pages get automatically.
    doc.suppress_head = 1

    if mlist.obscure_addresses:
        presentable_user = Utils.ObscureEmail(user, for_text=1)
        if cpuser is not None:
            cpuser = Utils.ObscureEmail(cpuser, for_text=1)
    else:
        presentable_user = user

    fullname = Utils.uncanonstr(mlist.getMemberName(user), userlang)
    if fullname:
        presentable_user += ', %s' % Utils.websafe(fullname)

    # Do replacements
    replacements = mlist.GetStandardReplacements(userlang)
    replacements['<mm-results>'] = Bold(FontSize('+1', message)).Format()
    replacements['<mm-digest-radio-button>'] = mlist.FormatOptionButton(
        mm_cfg.Digests, 1, user)
    replacements['<mm-undigest-radio-button>'] = mlist.FormatOptionButton(
        mm_cfg.Digests, 0, user)
    replacements['<mm-plain-digests-button>'] = mlist.FormatOptionButton(
        mm_cfg.DisableMime, 1, user)
    replacements['<mm-mime-digests-button>'] = mlist.FormatOptionButton(
        mm_cfg.DisableMime, 0, user)
    replacements['<mm-global-mime-button>'] = (CheckBox('mime-globally',
                                                        1,
                                                        checked=0).Format())
    replacements['<mm-delivery-enable-button>'] = mlist.FormatOptionButton(
        mm_cfg.DisableDelivery, 0, user)
    replacements['<mm-delivery-disable-button>'] = mlist.FormatOptionButton(
        mm_cfg.DisableDelivery, 1, user)
    replacements['<mm-disabled-notice>'] = mlist.FormatDisabledNotice(user)
    replacements['<mm-dont-ack-posts-button>'] = mlist.FormatOptionButton(
        mm_cfg.AcknowledgePosts, 0, user)
    replacements['<mm-ack-posts-button>'] = mlist.FormatOptionButton(
        mm_cfg.AcknowledgePosts, 1, user)
    replacements['<mm-receive-own-mail-button>'] = mlist.FormatOptionButton(
        mm_cfg.DontReceiveOwnPosts, 0, user)
    replacements['<mm-dont-receive-own-mail-button>'] = (
        mlist.FormatOptionButton(mm_cfg.DontReceiveOwnPosts, 1, user))
    replacements['<mm-dont-get-password-reminder-button>'] = (
        mlist.FormatOptionButton(mm_cfg.SuppressPasswordReminder, 1, user))
    replacements['<mm-get-password-reminder-button>'] = (
        mlist.FormatOptionButton(mm_cfg.SuppressPasswordReminder, 0, user))
    replacements['<mm-public-subscription-button>'] = (
        mlist.FormatOptionButton(mm_cfg.ConcealSubscription, 0, user))
    replacements['<mm-hide-subscription-button>'] = mlist.FormatOptionButton(
        mm_cfg.ConcealSubscription, 1, user)
    replacements['<mm-dont-receive-duplicates-button>'] = (
        mlist.FormatOptionButton(mm_cfg.DontReceiveDuplicates, 1, user))
    replacements['<mm-receive-duplicates-button>'] = (mlist.FormatOptionButton(
        mm_cfg.DontReceiveDuplicates, 0, user))
    replacements['<mm-unsubscribe-button>'] = (
        mlist.FormatButton('unsub', _('Unsubscribe')) + '<br>' +
        CheckBox('unsubconfirm', 1, checked=0).Format() +
        _('<em>Yes, I really want to unsubscribe</em>'))
    replacements['<mm-new-pass-box>'] = mlist.FormatSecureBox('newpw')
    replacements['<mm-confirm-pass-box>'] = mlist.FormatSecureBox('confpw')
    replacements['<mm-change-pass-button>'] = (mlist.FormatButton(
        'changepw', _("Change My Password")))
    replacements['<mm-other-subscriptions-submit>'] = (mlist.FormatButton(
        'othersubs', _('List my other subscriptions')))
    replacements['<mm-form-start>'] = (mlist.FormatFormStart(
        'options', user, mlist=mlist, contexts=AUTH_CONTEXTS, user=user))
    replacements['<mm-user>'] = user
    replacements['<mm-presentable-user>'] = presentable_user
    replacements['<mm-email-my-pw>'] = mlist.FormatButton(
        'emailpw', (_('Email My Password To Me')))
    replacements['<mm-umbrella-notice>'] = (mlist.FormatUmbrellaNotice(
        user, _("password")))
    replacements['<mm-logout-button>'] = (mlist.FormatButton(
        'logout', _('Log out')))
    replacements['<mm-options-submit-button>'] = mlist.FormatButton(
        'options-submit', _('Submit My Changes'))
    replacements['<mm-global-pw-changes-button>'] = (CheckBox(
        'pw-globally', 1, checked=0).Format())
    replacements['<mm-global-deliver-button>'] = (CheckBox('deliver-globally',
                                                           1,
                                                           checked=0).Format())
    replacements['<mm-global-remind-button>'] = (CheckBox('remind-globally',
                                                          1,
                                                          checked=0).Format())
    replacements['<mm-global-nodupes-button>'] = (CheckBox('nodupes-globally',
                                                           1,
                                                           checked=0).Format())

    days = int(mm_cfg.PENDING_REQUEST_LIFE / mm_cfg.days(1))
    if days > 1:
        units = _('days')
    else:
        units = _('day')
    replacements['<mm-pending-days>'] = _('%(days)d %(units)s')

    replacements['<mm-new-address-box>'] = mlist.FormatBox('new-address')
    replacements['<mm-confirm-address-box>'] = mlist.FormatBox(
        'confirm-address')
    replacements['<mm-change-address-button>'] = mlist.FormatButton(
        'change-of-address', _('Change My Address and Name'))
    replacements['<mm-global-change-of-address>'] = CheckBox(
        'changeaddr-globally', 1, checked=0).Format()
    replacements['<mm-fullname-box>'] = mlist.FormatBox('fullname',
                                                        value=fullname)

    # Create the topics radios.  BAW: what if the list admin deletes a topic,
    # but the user still wants to get that topic message?
    usertopics = mlist.getMemberTopics(user)
    if mlist.topics:
        table = Table(border="0")
        for name, pattern, description, emptyflag in mlist.topics:
            if emptyflag:
                continue
            quotedname = urllib.parse.quote_plus(name)
            details = Link(
                mlist.GetScriptURL('options') + '/%s/?VARHELP=%s' %
                (user, quotedname), ' (Details)')
            if name in usertopics:
                checked = 1
            else:
                checked = 0
            table.AddRow([
                CheckBox('usertopic', quotedname, checked=checked),
                name + details.Format()
            ])
        topicsfield = table.Format()
    else:
        topicsfield = _('<em>No topics defined</em>')
    replacements['<mm-topics>'] = topicsfield
    replacements['<mm-suppress-nonmatching-topics>'] = (
        mlist.FormatOptionButton(mm_cfg.ReceiveNonmatchingTopics, 0, user))
    replacements['<mm-receive-nonmatching-topics>'] = (
        mlist.FormatOptionButton(mm_cfg.ReceiveNonmatchingTopics, 1, user))

    if cpuser is not None:
        replacements['<mm-case-preserved-user>'] = _('''
You are subscribed to this list with the case-preserved address
<em>%(cpuser)s</em>.''')
    else:
        replacements['<mm-case-preserved-user>'] = ''

    page_text = mlist.ParseTags('options.html', replacements, userlang)
    if not (mlist.digestable or mlist.getMemberOption(user, mm_cfg.Digests)):
        page_text = DIGRE.sub('', page_text)
    doc.AddItem(page_text)