changeset 2359:cc6dd879104c

Merge main again.
author Karol 'grzywacz' Nowak <grzywacz@sul.uni.lodz.pl>
date Wed, 11 Jul 2007 13:53:03 +0200
parents 148862d36d4a (current diff) 5cf429e40f18 (diff)
children dccb34282e18
files MoinMoin/config/multiconfig.py MoinMoin/userprefs/__init__.py
diffstat 4 files changed, 30 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/userprefs.py	Wed Jul 11 02:51:47 2007 +0200
+++ b/MoinMoin/action/userprefs.py	Wed Jul 11 13:53:03 2007 +0200
@@ -20,15 +20,20 @@
     """
     _ = request.getText
     sub = request.form.get('handler', [None])[0]
+
+    if sub in request.cfg.disabled_userprefs:
+        return None
+
     try:
         cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
     except wikiutil.PluginMissingError:
-        return _("No such preferences plugin")
+        # we never show this plugin to click on so no need to
+        # give a message here
+        return None
 
     obj = cls(request)
     if not obj.allowed():
-        # intentionally do not let the user know this exists
-        return _("No such preferences plugin")
+        return None
     return obj.handle_form()
 
 def _create_prefs_page(request, sel=None):
@@ -40,6 +45,8 @@
     items = html.UL()
     ret.append(items)
     for sub in plugins:
+        if sub in request.cfg.disabled_userprefs:
+            continue
         cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
         obj = cls(request)
         if not obj.allowed():
@@ -60,12 +67,19 @@
         msg = None
 
     sub = request.form.get('sub', [''])[0]
-    try:
-        cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
-    except wikiutil.PluginMissingError:
+    cls = None
+    if sub and not sub in request.cfg.disabled_userprefs:
+        try:
+            cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
+        except wikiutil.PluginMissingError:
+            # cls is already None
+            pass
+
+    obj = cls and cls(request)
+
+    if not obj or not obj.allowed():
         return _create_prefs_page(request), None, msg
 
-    obj = cls(request)
     return obj.create_form(), obj.title, msg
 
 
--- a/MoinMoin/config/multiconfig.py	Wed Jul 11 02:51:47 2007 +0200
+++ b/MoinMoin/config/multiconfig.py	Wed Jul 11 13:53:03 2007 +0200
@@ -516,6 +516,9 @@
 
     url_mappings = {}
 
+    # allow disabling certain userpreferences plugins
+    disabled_userprefs = []
+
     user_checkbox_fields = [
         ('mailto_author', lambda _: _('Publish my email (not my wiki homepage) in author info')),
         ('edit_on_doubleclick', lambda _: _('Open editor on double click')),
--- a/MoinMoin/userprefs/__init__.py	Wed Jul 11 02:51:47 2007 +0200
+++ b/MoinMoin/userprefs/__init__.py	Wed Jul 11 13:53:03 2007 +0200
@@ -62,4 +62,4 @@
             title should be listed or not and whether
             submissions are accepted.
         '''
-        return True
+        return self.request.user and self.request.user.valid
--- a/MoinMoin/userprefs/oid.py	Wed Jul 11 02:51:47 2007 +0200
+++ b/MoinMoin/userprefs/oid.py	Wed Jul 11 13:53:03 2007 +0200
@@ -29,7 +29,7 @@
     def allowed(self):
         for authm in self.request.cfg.auth:
             if isinstance(authm, OpenIDAuth):
-                return True
+                return UserPrefBase.allowed(self)
         return False
 
     def _handle_remove(self):
@@ -69,7 +69,8 @@
             qstr = wikiutil.makeQueryString({'action': 'userprefs',
                                              'handler': 'oid',
                                              'oid.return': '1'})
-            return_to = ''.join([request.getBaseURL(), '?', qstr])
+            return_to = '%s/%s' % (request.getBaseURL(),
+                                   request.page.url(request, qstr))
             trust_root = request.getBaseURL()
             if oidreq.shouldSendRedirect():
                 redirect_url = oidreq.redirectURL(trust_root, return_to)
@@ -92,7 +93,8 @@
         qstr = wikiutil.makeQueryString({'action': 'userprefs',
                                          'handler': 'oid',
                                          'oid.return': '1'})
-        return_to = ''.join([request.getBaseURL(), '?', qstr])
+        return_to = '%s/%s' % (request.getBaseURL(),
+                               request.page.url(request, qstr))
         info = oidconsumer.complete(query, return_to=return_to)
         if info.status == consumer.FAILURE:
             return _('OpenID error: %s.') % info.message