Back to index

moin  1.9.0~rc2
SystemAdmin.py
Go to the documentation of this file.
00001 # -*- coding: iso-8859-1 -*-
00002 """
00003     MoinMoin - System Administration
00004 
00005     Web interface to do MoinMoin system administration tasks.
00006 
00007     @copyright: 2001-2003 Juergen Hermann <jh@web.de>
00008     @license: GNU GPL, see COPYING for details.
00009 """
00010 
00011 from MoinMoin.userform import do_user_browser
00012 from MoinMoin.action.AttachFile import do_admin_browser
00013 
00014 Dependencies = ["time"]
00015 
00016 def macro_SystemAdmin(macro):
00017     _ = macro.request.getText
00018     request = macro.request
00019 
00020     # do not show system admin to users not in superuser list
00021     if not request.user.isSuperUser():
00022         return ''
00023 
00024     _MENU = {
00025         'attachments': (_("File attachment browser"), do_admin_browser),
00026         'users': (_("User account browser"), do_user_browser),
00027     }
00028     choice = request.values.get('sysadm')
00029 
00030     # create menu
00031     menuitems = [(label, fnid) for fnid, (label, handler) in _MENU.items()]
00032     menuitems.sort()
00033     result = []
00034     f = macro.formatter
00035     for label, fnid in menuitems:
00036         if fnid == choice:
00037             result.append(f.strong(1))
00038             result.append(f.text(label))
00039             result.append(f.strong(0))
00040         else:
00041             #result.append(wikiutil.link_tag(request, "%s?sysadm=%s" % (macro.formatter.page.page_name, id), label))
00042             result.append(f.page.link_to(request, label, querystr={'sysadm': fnid}))
00043         result.append(f.linebreak())
00044     result.append(f.linebreak())
00045 
00046     # add chosen content
00047     if choice in _MENU:
00048         result.append(f.rawHTML(_MENU[choice][1](request)))
00049 
00050     return ''.join(result)
00051