diff -r ca98a59c5902 MoinMoin/action/AttachFile.py --- a/MoinMoin/action/AttachFile.py Fri Oct 26 09:15:18 2007 +0200 +++ b/MoinMoin/action/AttachFile.py Tue Nov 20 18:46:08 2007 +0100 @@ -554,6 +554,48 @@ def upload_form(pagename, request, msg=' request.write('\n') # end content div wikiutil.send_footer(request, pagename) +def do_notify(pagename, request, msg): + if request.cfg.mail_enabled and request.cfg.mail_attachment_changes: + _ = request.getText + from MoinMoin.PageEditor import PageEditor + + page = PageEditor(request, pagename) + trivial = 0 + pagelink = request.getQualifiedURL(page.url(request)) + pagelink += "?action=AttachFile\n\n%s" % msg + + subscribers = page.getSubscribers(request, return_users=1, trivial=trivial) + if subscribers: + mailBody = _("Dear Wiki user,\n\n" + 'You have subscribed to a wiki page or wiki category on "%(sitename)s" for change notification.\n\n' + "The following page has been changed by %(editor)s:\n" + "%(pagelink)s\n\n" , formatted=False) % { + 'editor': user.getUserIdentification(request), + 'pagelink': pagelink, + 'sitename': request.cfg.sitename or request.getBaseURL(), + } + # send email to all subscribers + results = [_('Status of sending notification mails:')] + for lang in subscribers.keys(): + emails = map(lambda u: u.email, subscribers[lang]) + names = map(lambda u: u.name, subscribers[lang]) + + mailok, status = util.mail.sendmail(request, emails, + _('[%(sitename)s] Update of "%(pagename)s" by %(username)s ', formatted=False) % { + 'sitename': request.cfg.sitename or "Wiki", + 'pagename': pagename, + 'username': user.getUserIdentification(request), + }, mailBody, mail_from=request.cfg.mail_from) + recipients = ", ".join(names) + results.append(_('[%(lang)s] %(recipients)s: %(status)s') % { + 'lang': lang, 'recipients': recipients, 'status': status}) + + return '

\n%s\n

' % '
'.join(results) + + else: + return "" + else: + return "" def do_upload(pagename, request, overwrite): _ = request.getText @@ -628,6 +670,12 @@ def do_upload(pagename, request, overwri " with %(bytes)d bytes saved.") % { 'target': target, 'filename': filename, 'bytes': bytes} _addLogEntry(request, 'ATTNEW', pagename, target) + # send notification mails + result = "" + if request.cfg.mail_enabled: + result = do_notify(pagename, request, msg) + + msg = msg + result # return attachment list upload_form(pagename, request, msg) @@ -674,8 +722,10 @@ def del_file(pagename, request): # delete file os.remove(fpath) _addLogEntry(request, 'ATTDEL', pagename, filename) - - upload_form(pagename, request, msg=_("Attachment '%(filename)s' deleted.") % {'filename': filename}) + msg = _("Attachment '%(filename)s' deleted.") % {'filename': filename} + result = do_notify(pagename, request, msg) + msg = msg + result + upload_form(pagename, request, msg=msg) def move_file(request, pagename, new_pagename, attachment, new_attachment): _ = request.getText @@ -697,9 +747,15 @@ def move_file(request, pagename, new_pag filesys.rename(attachment_path, new_attachment_path) _addLogEntry(request, 'ATTDEL', pagename, attachment) _addLogEntry(request, 'ATTNEW', new_pagename, new_attachment) - upload_form(pagename, request, msg=_("Attachment '%(filename)s' moved to %(page)s.") % { - 'filename': new_attachment, - 'page': new_pagename}) + msg = _("Attachment '%(old_filename)s' moved from %(old_page)s to %(new_page)s as '%(new_filename)s'.") % { + 'old_filename': attachment, + 'new_filename': new_attachment, + 'old_page': pagename, + 'new_page': new_pagename} + + result = do_notify(pagename, request, msg) + msg = msg + result + upload_form(pagename, request, msg=msg) else: upload_form(pagename, request, msg=_("Nothing changed")) else: diff -r ca98a59c5902 MoinMoin/multiconfig.py --- a/MoinMoin/multiconfig.py Fri Oct 26 09:15:18 2007 +0200 +++ b/MoinMoin/multiconfig.py Tue Nov 20 16:17:43 2007 +0100 @@ -281,6 +281,7 @@ reStructuredText Quick Reference mail_sendmail = None # "/usr/sbin/sendmail -t -i" to not use SMTP, but sendmail mail_smarthost = None mail_from = None # u'Jürgen Wiki ' + mail_attachment_changes = False # some dangerous mimetypes (we don't use "content-disposition: inline" for them when a user # downloads such attachments, because the browser might execute e.g. Javascript contained