comparison MoinMoin/userform/admin.py @ 4053:31617ef6a68b

bug fix for MoinMoinBugs/SystemAdminMailAccountData by using POST and forms for recoverpass and enable/disable useraccount (ported from 1.7)
author Reimar Bauer <rb.proj AT googlemail DOT com>
date Sun, 31 Aug 2008 20:51:57 +0200
parents 1008dd34b71c
children b5dfb48bad1c
comparison
equal deleted inserted replaced
4052:0cdc180a2932 4053:31617ef6a68b
2 """ 2 """
3 MoinMoin - User account administration 3 MoinMoin - User account administration
4 4
5 @copyright: 2001-2004 Juergen Hermann <jh@web.de>, 5 @copyright: 2001-2004 Juergen Hermann <jh@web.de>,
6 2003-2007 MoinMoin:ThomasWaldmann 6 2003-2007 MoinMoin:ThomasWaldmann
7 2007 MoinMoin:ReimarBauer 7 2007-2008 MoinMoin:ReimarBauer
8 @license: GNU GPL, see COPYING for details. 8 @license: GNU GPL, see COPYING for details.
9 """ 9 """
10 from MoinMoin import user, wikiutil 10 from MoinMoin import user, wikiutil
11 from MoinMoin.util.dataset import TupleDataset, Column 11 from MoinMoin.util.dataset import TupleDataset, Column
12 from MoinMoin.Page import Page 12 from MoinMoin.Page import Page
13 13 from MoinMoin.widget import html
14 14
15 def do_user_browser(request): 15 def do_user_browser(request):
16 """ Browser for SystemAdmin macro. """ 16 """ Browser for SystemAdmin macro. """
17 _ = request.getText 17 _ = request.getText
18 18
40 if userhomepage.exists(): 40 if userhomepage.exists():
41 namelink = userhomepage.link_to(request) 41 namelink = userhomepage.link_to(request)
42 else: 42 else:
43 namelink = wikiutil.escape(account.name) 43 namelink = wikiutil.escape(account.name)
44 44
45 # creates the POST data for account disable/enable
46 val = "1"
47 text=_('Disable user')
45 if account.disabled: 48 if account.disabled:
46 enable_disable_link = request.page.link_to( 49 text=_('Enable user')
47 request, text=_('Enable user'), 50 val = "0"
48 querystr={"action": "userprofile",
49 "name": account.name,
50 "key": "disabled",
51 "val": "0",
52 },
53 rel='nofollow')
54 namelink += " (%s)" % _("disabled") 51 namelink += " (%s)" % _("disabled")
55 else:
56 enable_disable_link = request.page.link_to(
57 request, text=_('Disable user'),
58 querystr={"action": "userprofile",
59 "name": account.name,
60 "key": "disabled",
61 "val": "1",
62 },
63 rel='nofollow')
64 52
65 recoverpass_link = request.page.link_to( 53 url = request.page.url(request)
66 request, text=_('Mail account data'), 54 ret = html.FORM(action=url)
67 querystr={"action": "recoverpass", 55 ret.append(html.INPUT(type='hidden', name='action', value='userprofile'))
68 "email": account.email, 56 ret.append(html.INPUT(type='hidden', name='name', value=account.name))
69 "account_sendmail": "1", 57 ret.append(html.INPUT(type='hidden', name='key', value="disabled"))
70 "sysadm": "users", }, 58 ret.append(html.INPUT(type='hidden', name='val', value=val))
71 rel='nofollow') 59 ret.append(html.INPUT(type='submit', name='userprofile', value=text))
60 enable_disable_link = unicode(unicode(ret))
61
62 # creates the POST data for recoverpass
63 url = request.page.url(request)
64 ret = html.FORM(action=url)
65 ret.append(html.INPUT(type='hidden', name='action', value='recoverpass'))
66 ret.append(html.INPUT(type='hidden', name='email', value=account.email))
67 ret.append(html.INPUT(type='hidden', name='account_sendmail', value="1"))
68 ret.append(html.INPUT(type='hidden', name='sysadm', value="users"))
69 ret.append(html.INPUT(type='submit', name='recoverpass', value=_('Mail account data')))
70 recoverpass_link = unicode(unicode(ret))
72 71
73 if account.email: 72 if account.email:
74 email_link = (request.formatter.url(1, 'mailto:' + account.email, css='mailto') + 73 email_link = (request.formatter.url(1, 'mailto:' + account.email, css='mailto') +
75 request.formatter.text(account.email) + 74 request.formatter.text(account.email) +
76 request.formatter.url(0)) 75 request.formatter.url(0))
87 data.addRow(( 86 data.addRow((
88 request.formatter.rawHTML(namelink), 87 request.formatter.rawHTML(namelink),
89 request.formatter.rawHTML(grouppage_links), 88 request.formatter.rawHTML(grouppage_links),
90 email_link, 89 email_link,
91 jabber_link, 90 jabber_link,
92 recoverpass_link + " - " + enable_disable_link 91 recoverpass_link + enable_disable_link
93 )) 92 ))
94 93
95 if data: 94 if data:
96 from MoinMoin.widget.browser import DataBrowserWidget 95 from MoinMoin.widget.browser import DataBrowserWidget
97 96
98 browser = DataBrowserWidget(request) 97 browser = DataBrowserWidget(request)
99 browser.setData(data) 98 browser.setData(data)
100 return browser.render() 99 return browser.render(method="POST")
101 100
102 # No data 101 # No data
103 return '' 102 return ''
104 103