changeset 2306:5cf429e40f18

allow disabling certain userprefs plugins from config
author Johannes Berg <johannes AT sipsolutions DOT net>
date Wed, 11 Jul 2007 11:40:15 +0200
parents 5c75990712ca
children cc6dd879104c
files MoinMoin/action/userprefs.py MoinMoin/config/multiconfig.py
diffstat 2 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/action/userprefs.py	Wed Jul 11 11:39:59 2007 +0200
+++ b/MoinMoin/action/userprefs.py	Wed Jul 11 11:40:15 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():
@@ -61,7 +68,7 @@
 
     sub = request.form.get('sub', [''])[0]
     cls = None
-    if sub:
+    if sub and not sub in request.cfg.disabled_userprefs:
         try:
             cls = wikiutil.importPlugin(request.cfg, 'userprefs', sub, 'Settings')
         except wikiutil.PluginMissingError:
--- a/MoinMoin/config/multiconfig.py	Wed Jul 11 11:39:59 2007 +0200
+++ b/MoinMoin/config/multiconfig.py	Wed Jul 11 11:40:15 2007 +0200
@@ -514,6 +514,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')),