Attachment 'UserList-1.8.1.py'

Download

   1 # -*- coding: iso-8859-1 -*-
   2 """
   3     MoinMoin - User account Listing
   4 
   5     (mostly copied from admin.do_user_browser)
   6     @copyright: 2001-2004 Juergen Hermann <jh@web.de>,
   7                 2003-2007 MoinMoin:ThomasWaldmann,
   8                 2007 MoinMoin:ReimarBauer,
   9     @license: GNU GPL, see COPYING for details.
  10     UserList-1.7.1
  11 """
  12 
  13 from MoinMoin import user, wikiutil
  14 from MoinMoin.util.dataset import TupleDataset, Column
  15 from MoinMoin.Page import Page
  16 
  17 
  18 def macro_UserList(macro):
  19     """ macro to list users. """
  20     request = macro.request
  21     _ = request.getText
  22 
  23     data = TupleDataset()
  24     data.columns = [
  25         Column('name', label=_('Username')),
  26         Column('email', label=_('Email')),
  27         Column('groups', label=_('Member of Groups')),
  28         Column('language', label=_('Language')),
  29     ]
  30 
  31     isgroup = request.cfg.cache.page_group_regexact.search
  32     groupnames = request.rootpage.getPageList(user='', filter=isgroup)
  33 
  34     # Iterate over users
  35     for uid in user.getUserList(request):
  36         account = user.User(request, uid)
  37         # don't offer groupnames to users which aren't allowed to read them
  38         grouppage_links = ', '.join([Page(request, groupname).link_to(request)
  39                                      for groupname in groupnames
  40                                      if request.dicts.has_member(groupname, account.name) and request.user.may.read(groupname)])
  41 
  42         userhomepage = Page(request, account.name)
  43         if userhomepage.exists():
  44             namelink = userhomepage.link_to(request)
  45         else:
  46             namelink = wikiutil.escape(account.name)
  47 
  48         if account.disabled:
  49             enable_disable_link = request.page.link_to(
  50                                     request, text=_('Enable user'),
  51                                     querystr={"action": "userprofile",
  52                                               "name": account.name,
  53                                               "key": "disabled",
  54                                               "val": "0",
  55                                              },
  56                                     rel='nofollow')
  57             namelink += " (%s)" % _("disabled")
  58         else:
  59             enable_disable_link = request.page.link_to(
  60                                     request, text=_('Disable user'),
  61                                     querystr={"action": "userprofile",
  62                                               "name": account.name,
  63                                               "key": "disabled",
  64                                               "val": "1",
  65                                              },
  66                                     rel='nofollow')
  67 
  68         if account.email:
  69             email_link = (request.formatter.url(1, 'mailto:' + account.email, css='mailto') +
  70                           request.formatter.text(account.email) +
  71                           request.formatter.url(0))
  72         else:
  73             email_link = ''
  74 
  75         # language defined in settings or default language
  76         language = account.language or request.cfg.language_default
  77 
  78         data.addRow((
  79             request.formatter.rawHTML(namelink),
  80             email_link,
  81             request.formatter.rawHTML(grouppage_links),
  82             language,
  83         ))
  84 
  85     if data:
  86         from MoinMoin.widget.browser import DataBrowserWidget
  87 
  88         browser = DataBrowserWidget(request)
  89         browser.setData(data)
  90         return browser.render(method="GET") #browser.toHTML() #change for for moin1.8.1
  91 
  92     # No data
  93     return ''

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2008-08-21 17:16:36, 3.4 KB) [[attachment:UserList-1.7.1.py]]
  • [get | view] (2009-01-21 09:26:07, 3.5 KB) [[attachment:UserList-1.8.1.py]]
  • [get | view] (2004-06-14 13:14:28, 4.2 KB) [[attachment:UserList.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.