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