view data/plugin/action/mailto.py @ 653:127da830be6c

updated copyright
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Tue, 19 Apr 2016 16:29:54 +0200
parents de89a01a1bc2
children
line wrap: on
line source
# -*- coding: utf-8 -*-
"""
    MoinMoin - mailto

    shows the superuser all email addresses of wikiusers in mailto format
    for sending a mail to everyone
    
    @copyright: 2011-2016 by MoinMoin:ReimarBauer
    @license: GNU GPL, see COPYING for details.
"""
from MoinMoin import user
from MoinMoin.Page import Page

def execute(pagename, request):
    _ = request.getText
    if not request.user.isSuperUser():
        msg = "You don't have priviledges to call this action"
        msgtype = "error"
        request.theme.add_msg(msg, msgtype)
        return Page(request, pagename).send_page()

    formatter = request.formatter
    uids = user.getUserList(request)
    members = [user.User(request, uid).name for uid in uids]
    emails = []
    for name in members:
        uid = user.getUserId(request, name)
        account = user.User(request, uid)
        if account.email:
            emails.append(account.email)
    msgtype = "info"
    msg = "please click on the mailto list"
    title = "All mailaddresses of this wiki for sending by TO entry"
    sendmailsto = ','.join(emails)

    mails_to = (formatter.url(1, 'mailto:' + sendmailsto, css='mailto') +
               formatter.text(sendmailsto) +
               formatter.url(0))
    text_to = (formatter.heading(1, 2) + title +
              formatter.heading(0, 2))

    copypaste = (formatter.paragraph(1) + "(If you need BCC, just copy paste the line into your mail client and change TO into BCC)" + 
                 formatter.paragraph(0))
    request.theme.add_msg(msg, msgtype)
    request.theme.send_title(title, page=request.page, pagename=pagename)
    request.write(request.formatter.startContent("content"))
    request.write(text_to)
    request.write(mails_to)
    request.write(copypaste)
    request.write(request.formatter.endContent())
    request.theme.send_footer(pagename)
    request.theme.send_closing_html()