changeset 1714:8f944671df08

merged main
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Sun, 07 Jan 2007 11:26:52 +0100
parents 1f18d08ec3ba (current diff) c0dd392bed62 (diff)
children 8d2035dfb153
files docs/CHANGES
diffstat 3 files changed, 68 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/macro/Login.py	Sun Jan 07 11:25:09 2007 +0100
+++ b/MoinMoin/macro/Login.py	Sun Jan 07 11:26:52 2007 +0100
@@ -1,19 +1,74 @@
 # -*- coding: iso-8859-1 -*-
 """
-    MoinMoin - login form
+    MoinMoin - login and sendmail form
 
     @copyright: 2005-2006 by Radomirs Cirskis <nad2000@gmail.com>
+    @copyright: 2007 Reimar Bauer, Oliver Siemoneit
     @license: GNU GPL, see COPYING for details.
 """
 from MoinMoin.widget import html
 from MoinMoin import userform
 
+def make_row(table, label, cell, **kw):
+    """ Create a row in the form table.
+    """
+    table.append(html.TR().extend([
+        html.TD(**kw).extend([html.B().append(label), '   ']),
+        html.TD().extend(cell),
+    ]))
+    return table
+
 def execute(macro, args):
     """ Show the login form (but only when not logged in) """
     request = macro.request
-    if request.user.valid:
-        data = u''
+    _ = request.getText
+    formatter = macro.formatter
+    if not args:
+        if request.user.valid:
+            data = u''
+        else:
+            data = userform.getLogin(request)
+        return data
+
+    elif args == "sendmail":
+        sn = request.getScriptname()
+        pi = request.getPathinfo()
+        action = u"%s%s" % (sn, pi)
+        form = html.FORM(action=action)
+        table = html.TABLE()
+
+        if not request.cfg.mail_enabled:
+            return _("This wiki is not enabled for mail processing.\nContact the owner of the wiki, who can enable email.")
+        else:
+            buttons = []
+            action = u"%s%s" % (sn, pi)
+            form = html.FORM(action=action)
+            table = html.TABLE(border="0")
+
+            # Add form fields
+            for key, label, type, length, textafter in request.cfg.user_form_fields:
+                if key == 'email':
+                    table = make_row(table, _(label),
+                                     [html.INPUT(type=type, size=length, name=key,
+                                     value=''), ' ', ])
+            # Add buttons
+            buttons.append(("account_sendmail", _('Mail me my account data')))
+            button_cell = []
+            for name, label in buttons:
+                if not name in request.cfg.user_form_remove:
+                    button_cell.extend([
+                        html.INPUT(type="submit", name=name, value=label),
+                        ' ',
+                    ])
+            make_row(table, '', button_cell)
+
+            # Use the user interface language and direction
+            lang_attr = request.theme.ui_lang_attr()
+            form.append(html.Raw('<div class="userpref"%s>' % lang_attr))
+            form.append(html.INPUT(type="hidden", name="action", value="userform"))
+            form.append(table)
+            form.append(html.Raw("</div>"))
+
+            return unicode(form)
     else:
-        data = userform.getLogin(request)
-    return data
-
+        return _("Check your argument %s" % (args))
--- a/MoinMoin/userform.py	Sun Jan 07 11:25:09 2007 +0100
+++ b/MoinMoin/userform.py	Sun Jan 07 11:26:52 2007 +0100
@@ -638,8 +638,10 @@
         pi = request.getPathinfo()
         action = u"%s%s" % (sn, pi)
         userprefslink = wikiutil.getSysPage(request, "UserPreferences").link_to(request, rel='nofollow')
-        hint = _("To create an account or recover a lost password, see the %(userprefslink)s page.") % {
-               'userprefslink': userprefslink}
+        sendmypasswordlink = wikiutil.getSysPage(request, "SendMyPassword").link_to(request, rel='nofollow')
+        hint = _("To create an account, see the %(userprefslink)s page. To recover a lost password, go to %(sendmypasswordlink)s.") % {
+                 'userprefslink': userprefslink,
+                 'sendmypasswordlink': sendmypasswordlink}
         self._form = html.FORM(action=action)
         self._table = html.TABLE(border="0")
 
--- a/docs/CHANGES	Sun Jan 07 11:25:09 2007 +0100
+++ b/docs/CHANGES	Sun Jan 07 11:26:52 2007 +0100
@@ -287,6 +287,9 @@
       * if a page does not exist any more (because it was deleted or renamed),
         we link the deleted icon to the diff showing what was deleted (for the
         delete action). For the rename action, we just show the deleted icon.
+    * the login page gives now the possibility to recover a lost password, thanks to 
+      Oliver Siemoneit. This is especially useful for wikis where access to user 
+      preferences is restricted by acl.
 
   Bugfixes:
     * on action "info" page, "revert" link will not be displayed for empty page