# -*- coding: iso-8859-1 -*-
"""
    MoinMoin - Make Invitation Macro

    This macro helps admins in creating accounts for new users
    and send out invitation with the login data to to join the
    wiki community.
    You have to be superuser to be able to call this macro,

    To get this macro work, patching user.py and userform.py
    is required. See http://moinmoin.wikiwikiweb.de

    There you can also find some page template for a new underlay
    page "MakeInvitation". Please set the acl accordingly so that
    only superuser are able to read this page.

    For full multilang support, translation for the phrase
    "User account created." must be provided as well as translations
    of the new underlay page MakeInvitation. Also translations for
    the new email text in userform.py is needed.
    
    @copyright: 2006 by Oliver Siemoneit
    @license: GNU GPL, see COPYING for details.
"""


from MoinMoin.widget import html
from MoinMoin import userform


def execute(macro, args):
    request = macro.request
    _ = request.getText
    formatter = macro.formatter

    # Check if user is superuser. If not: return with error msg
    if not request.user.isSuperUser():
        err = _('You are not allowed to perform this action.')
        return "%s%s%s" % (formatter.sysmsg(1), formatter.text(err), formatter.sysmsg(0))

    data = userform.getUserForm(request, True)
    return data

