[Zope-CVS] CVS: Products/WikiForNow - SubscriberList.py:1.2

Ken Manheimer klm@zope.com
Sun, 24 Nov 2002 00:39:20 -0500


Update of /cvs-repository/Products/WikiForNow
In directory cvs.zope.org:/tmp/cvs-serv20447

Modified Files:
	SubscriberList.py 
Log Message:
Enable managers to remove subscribers.

New methods .unsubscribeSelected() and .wikiUnsubscribeSelected(),
plus adjustments to .subscribe() and .unsubscribe() so they can be
articulated by these new collective drivers.


=== Products/WikiForNow/SubscriberList.py 1.1.1.1 => 1.2 ===
--- Products/WikiForNow/SubscriberList.py:1.1.1.1	Mon Jun 17 18:45:55 2002
+++ Products/WikiForNow/SubscriberList.py	Sun Nov 24 00:39:19 2002
@@ -154,6 +154,7 @@
             REQUEST.RESPONSE.redirect(REQUEST['URL1'] + '/subscribeform')
 
     def unsubscribe(self, userid=None, container=0, _propagating=0,
+                    dont_reindex=0,
                     REQUEST=None):
         """
         Remove a userid from this page's mail subscriber list.
@@ -177,12 +178,28 @@
                     subp.unsubscribe(REQUEST=REQUEST, container=0,
                                      _propagating=1)
 
-        self.reindex_subscribers()
+        if not dont_reindex:
+            self.reindex_subscribers()
 
         # redirect browser if needed
         if REQUEST:
             REQUEST.RESPONSE.redirect(REQUEST['URL1'] + '/subscribeform')
 
+    def unsubscribeSelected(self, page_unsubscribers=None, REQUEST=None):
+        """For managers: Remove selected users from wiki-wide subscription."""
+        # XXX This (and all the methods!) should be protected by
+        #     suitable security declarations.
+
+        if page_unsubscribers:
+            for userid in page_unsubscribers.keys():
+                self.unsubscribe(userid=userid, dont_reindex=1,
+                                 REQUEST=REQUEST)
+
+            self.reindex_subscribers()
+
+        if REQUEST:
+            REQUEST.RESPONSE.redirect(REQUEST['URL1'] + '/subscribeform')
+
     def reindex_subscribers(self, unindex_only=0):
         """Apply the subscribers index if we can acquare a catalog for it."""
         if self.dont_catalog or not hasattr(self, 'REQUEST'):
@@ -218,6 +235,21 @@
     def wikiUnsubscribe(self, REQUEST=None):
         """Whole-wiki version of unsubscribe."""
         return self.unsubscribe(container=1, REQUEST=REQUEST)
+
+    def wikiUnsubscribeSelected(self, wiki_unsubscribers=None, REQUEST=None):
+        """For managers: Remove selected users from wiki-wide subscription."""
+        # XXX This (and all the methods!) should be protected by
+        #     suitable security declarations.
+
+        if wiki_unsubscribers:
+            for userid in wiki_unsubscribers.keys():
+                self.unsubscribe(userid=userid, container=1, dont_reindex=1,
+                                 REQUEST=REQUEST)
+
+            self.reindex_subscribers()
+
+        if REQUEST:
+            REQUEST.RESPONSE.redirect(REQUEST['URL1'] + '/subscribeform')
 
     ######################################################################
     # METHOD CATEGORY: misc