changeset 563:de89a01a1bc2

action.mailto: shows the superuser all email addresses of wikiusers in mailto format
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Fri, 08 Apr 2011 09:34:23 +0200
parents 0a13d4186fa0
children 6aefd777e2dd
files data/plugin/action/mailto.py
diffstat 1 files changed, 52 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/data/plugin/action/mailto.py	Fri Apr 08 09:34:23 2011 +0200
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+"""
+    MoinMoin - mailto
+
+    shows the superuser all email addresses of wikiusers in mailto format
+    for sending a mail to everyone
+    
+    @copyright: 2011 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()