# This is a patch for moin-1.2.3.orig to update it to moin-1.2.3
# 
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'patch' program with this file as input.
#
#### End of Preamble ####

#### Patch data follows ####
diff -u 'moin-1.2.3.orig/MoinMoin/Page.py' 'moin-1.2.3/MoinMoin/Page.py'
Index: ./MoinMoin/Page.py
--- ./MoinMoin/Page.py	Thu Oct 21 16:02:33 2004
+++ ./MoinMoin/Page.py	Thu Oct 21 16:03:20 2004
@@ -333,11 +333,13 @@
         @param request: the request object
         @keyword include_self: if 1, include current user (default: 0)
         @keyword return_users: if 1, return user instances (default: 0)
+        @keyword trivial: if 1, only include users who want trivial changes (default: 0)
         @rtype: dict
         @return: lists of subscribed email addresses in a dict by language key
         """
         include_self = kw.get('include_self', 0)
         return_users = kw.get('return_users', 0)
+        trivial = kw.get('trivial', 0)
 
         # extract categories of this page
         pageList = self.getCategories(request)
@@ -353,24 +355,31 @@
         # get email addresses of the all wiki user which have a profile stored;
         # add the address only if the user has subscribed to the page and
         # the user is not the current editor
+        # Also, if the change is trivial (send email isn't ticked) only send email to users
+        # who want_trivial changes (typically Admins on public sites)
         userlist = user.getUserList()
-        emails = {}
+        subscriber_list = {}
         for uid in userlist:
             if uid == request.user.id and not include_self: continue # no self notification
             subscriber = user.User(request, uid)
-            if not subscriber.email: continue # skip empty email address
+
+            # This is a bit wrong if return_users=1 (which implies that the caller will process
+            # user attributes and may, for example choose to send an SMS)
+            # So it _should_ be "not (subscriber.email and return_users)" but that breaks at the moment.
+            if not subscriber.email: continue # skip empty email addresses
+            if trivial and not subscriber.want_trivial: continue # skip uninterested subscribers
 
             if not UserPerms(subscriber).read(self.page_name): continue
 
-            if subscriber.isSubscribedTo(pageList):                
+            if subscriber.isSubscribedTo(pageList):
                 lang = subscriber.language or 'en'
-                if not emails.has_key(lang): emails[lang] = []
+                if not subscriber_list.has_key(lang): subscriber_list[lang] = []
                 if return_users:
-                    emails[lang].append(subscriber)
+                    subscriber_list[lang].append(subscriber)
                 else:
-                    emails[lang].append(subscriber.email) 
+                    subscriber_list[lang].append(subscriber.email)
 
-        return emails
+        return subscriber_list
 
 
     def send_page(self, request, msg=None, **keywords):
diff -u 'moin-1.2.3.orig/MoinMoin/PageEditor.py' 'moin-1.2.3/MoinMoin/PageEditor.py'
Index: ./MoinMoin/PageEditor.py
--- ./MoinMoin/PageEditor.py	Thu Oct 21 16:02:33 2004
+++ ./MoinMoin/PageEditor.py	Thu Oct 21 16:03:20 2004
@@ -463,13 +463,14 @@
         cache.remove()
 
 
-    def _sendNotification(self, comment, emails, email_lang, oldversions):
+    def _sendNotification(self, comment, emails, email_lang, oldversions, trivial):
         """
         Send notification email for a single language.
         @param comment: editor's comment given when saving the page
         @param emails: list of email addresses
         @param email_lang: language of emails
         @param oldversions: old versions of this page
+        @param trivial: the change is marked as trivial
         @rtype: int
         @return: sendmail result
         """
@@ -491,7 +492,8 @@
         # append a diff
         if not oldversions:
             mailBody = mailBody + \
-                _("No older revisions of the page stored, diff not available.")
+                _("New page:\n") + \
+                Page(self.page_name).get_raw_body()
         else:
             newpage = os.path.join(config.text_dir, wikiutil.quoteFilename(self.page_name))
             oldpage = os.path.join(config.backup_dir, oldversions[0])
@@ -507,7 +509,8 @@
                         _('The diff function returned with error code %(rc)s!') % {'rc': rc}
 
         return util.mail.sendmail(self.request, emails,
-            _('[%(sitename)s] Update of "%(pagename)s"') % {
+            _('[%(sitename)s]%(trivial)s Update of "%(pagename)s"') % {
+                'trivial' : (trivial or "") and " Trivial",
                 'sitename': config.sitename or "Wiki",
                 'pagename': self.page_name,
             },
@@ -515,16 +518,17 @@
             # was: self.request.user.email, but we don't want to disclose email
 
 
-    def _notifySubscribers(self, comment):
+    def _notifySubscribers(self, comment, trivial):
         """
         Send email to all subscribers of this page.
         
         @param comment: editor's comment given when saving the page
+        @param trivial: editor's suggestion that the change is trivial (Subscribers may ignore this)
         @rtype: string
         @return: message, indicating success or errors.
         """
         _ = self._
-        subscribers = self.getSubscribers(self.request, return_users=1)
+        subscribers = self.getSubscribers(self.request, return_users=1, trivial=trivial)
 
         wiki_is_smarter_than_its_users = _("You will not be notified of your own changes!") + '<br>'
 
@@ -537,11 +541,18 @@
             for lang in subscribers.keys():
                 emails = map(lambda u: u.email, subscribers[lang])
                 names  = map(lambda u: u.name,  subscribers[lang])
-                mailok, status = self._sendNotification(comment, emails, lang, oldversions)
+                mailok, status = self._sendNotification(comment, emails, lang, oldversions, trivial)
                 recipients = ", ".join(names)
                 results.append(_('[%(lang)s] %(recipients)s: %(status)s') % {
                     'lang': lang, 'recipients': recipients, 'status': status})
 
+            if trivial:
+                # lie about not sending email (so abusers think their actions are hidden)
+                # This is a bit inconsistent with having this as a user option - maybe reconsider u.want_trivia
+                # to be memberOfGroup(WantTrivia)
+                # FIXME also maybe make this a wiki configurable?
+                return _('')
+
             return wiki_is_smarter_than_its_users + '<br>'.join(results)
 
         return wiki_is_smarter_than_its_users + _('Nobody subscribed to this page, no mail sent.')
@@ -792,8 +803,8 @@
                                     {'pagename': self.page_name})
 
             # send notification mails
-            if config.mail_smarthost and kw.get('notify', 0):
-                msg = msg + self._notifySubscribers(kw.get('comment', ''))
+            if config.mail_smarthost:
+                msg = msg + self._notifySubscribers(kw.get('comment', ''), not kw.get('notify', 0))
 
         # remove lock (forcibly if we were allowed to break it by the UI)
         # !!! this is a little fishy, since the lock owner might not notice
diff -u 'moin-1.2.3.orig/MoinMoin/user.py' 'moin-1.2.3/MoinMoin/user.py'
Index: ./MoinMoin/user.py
--- ./MoinMoin/user.py	Wed Jul 21 21:02:16 2004
+++ ./MoinMoin/user.py	Thu Oct 21 16:03:20 2004
@@ -110,6 +110,7 @@
          ('show_fancy_diff', lambda _: _('Show fancy diffs')),
          ('wikiname_add_spaces', lambda _: _('Add spaces to displayed wiki names')),
          ('remember_me', lambda _: _('Remember login information forever')),
+         ('want_trivial', lambda _: _('Subscribe to trivial changes')),
          ('disabled', lambda _: _('Disable this account forever')),
     ]
     _transient_fields =  ['id', 'valid', 'may', 'auth_username', 'trusted']
@@ -173,6 +174,7 @@
         self.show_toolbar = 1
         self.show_nonexist_qm = config.nonexist_qm
         self.show_fancy_diff = 1
+        self.want_trivial = 0
         self.remember_me = 1
 
         if not self.id and not self.auth_username:
#### End of Patch data ####

#### ApplyPatch data follows ####
# Data version        : 1.0
# Date generated      : Thu Oct 21 16:04:05 2004
# Generated by        : makepatch 2.00_07*
# Recurse directories : Yes
# Excluded files      : (\A|/).*\~\Z
#                       (\A|/).*\.a\Z
#                       (\A|/).*\.bak\Z
#                       (\A|/).*\.BAK\Z
#                       (\A|/).*\.elc\Z
#                       (\A|/).*\.exe\Z
#                       (\A|/).*\.gz\Z
#                       (\A|/).*\.ln\Z
#                       (\A|/).*\.o\Z
#                       (\A|/).*\.obj\Z
#                       (\A|/).*\.olb\Z
#                       (\A|/).*\.old\Z
#                       (\A|/).*\.orig\Z
#                       (\A|/).*\.rej\Z
#                       (\A|/).*\.so\Z
#                       (\A|/).*\.Z\Z
#                       (\A|/)\.del\-.*\Z
#                       (\A|/)\.make\.state\Z
#                       (\A|/)\.nse_depinfo\Z
#                       (\A|/)core\Z
#                       (\A|/)tags\Z
#                       (\A|/)TAGS\Z
#                       (\A|/)\.\#.*\Z
#                       (\A|/)\#.*\Z
#                       (\A|/)_\$.*\Z
#                       (\A|/).*\$\Z
#                       (\A|/)CVS\Z
#                       (\A|/)CVS\.adm\Z
#                       (\A|/)cvslog\..*\Z
#                       (\A|/)\,.*\Z
#                       (\A|/).*\,v\Z
#                       (\A|/)RCS\Z
#                       (\A|/)RCSLOG\Z
#                       (\A|/)p\..*\Z
#                       (\A|/)s\..*\Z
#                       (\A|/)SCCS\Z
# p 'MoinMoin/Page.py' 33174 1098371000 0100644
# p 'MoinMoin/PageEditor.py' 38314 1098371000 0100644
# p 'MoinMoin/user.py' 20137 1098371000 0100644
#### End of ApplyPatch data ####

#### End of Patch kit [created: Thu Oct 21 16:04:05 2004] ####
#### Patch checksum: 218 10007 2187 ####
#### Checksum: 236 10694 58896 ####
