[% currentPage = 'newUser.html' %]
[% currentPageTitle = 'Create User' %]
[%
    execute  = modwheel.getParam('execute')
    username = modwheel.getParam('username')
    password = modwheel.getParam('password')
    realname = modwheel.getParam('realname')
    email    = modwheel.getParam('email')
    comment     = modwheel.getParam('comment')
    confirm  = modwheel.getParam('confirm')
%]
[% IF execute %]
    [% UNLESS confirm %]
        [% error = 'Please confirm your password' %]
    [% END %]
    [% UNLESS password %]
        [% error = 'Missing password' %]
    [% END %]
    [% UNLESS username %]
        [% error = 'Missing username' %]
    [% END  %]
    [% UNLESS error %]
        [% IF password == confirm %]
            [% newId = modwheel.createUser(username => username, password => password, real_name => realname, email => email, comments => comment) %]
            [% IF newId %]
                [% success = 'New user created!' %]
            [% ELSE %]
                [% error =' An error occured' %]
            [% END  %]
        [% ELSE  %]
            [% error = "Passwords doesn't match. Please try again." %]
        [% END  %]
    [% END  %]
[% END %]
[% INCLUDE header_start.html %]
[% IF newId %]
<script type="text/javascript">
window.location = "editUser.html?username=[% username %]";
</script>
[% END %]
[% INCLUDE header_end.html %]
<h1>Create new user</h1>
<form name="useredit" action="[% currentPage %]" method="post">
    <input type="hidden" name="execute" value="yes" />
    <p><b>Username*:</b><input type="text" name="username" value="[% username %]" /></p>
    <p><b>Password*:</b><input type="password" name="password" autocomplete="off" /></p>
    <p><b>Password Confirm*:</b><input type="password" name="confirm" autocomplete="off" /></p>
    <p><b>Real Name:</b><input type:"text" name="realname" value="[% realname %]" i/></p>
    <p><b>E-mail:</b><input type="text" name="email" value="[% email %]" /><p>
    <p><b>Comment:</b></p>
    <p><textarea rows="6" cols="50" name="comment">[% comment %]</textarea></p>
    <p><input type="submit" value="Create" /></p>
</form>

[% IF error %]
    <p class="error">[% error %]</p>
[% END %]
[% IF success %]
    <p class="success">[% success %]</p>
[% END %]

[% INCLUDE footer.html %]
