<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:i18n="http://genshi.edgewall.org/i18n"
      i18n:domain="acct_mgr">
  <xi:include href="admin.html" />
  <head>
    <title>Account</title>
    <script type="text/javascript">
      jQuery(document).ready(function($) {
          $('#password').focus();
      });
    </script>
  </head>

  <body>
    <div id="account_details">
      <div>
        <h2>Manage User Account</h2>
        <p py:choose="">
          <py:when test="acctmgr.name">
            <i18n:msg params="name, user">for <b>${acctmgr.name}</b> (<em>$user</em>)</i18n:msg>
          </py:when>
          <py:otherwise>
            <i18n:msg params="user">for <b>$user</b></i18n:msg>
          </py:otherwise>
          <img py:if="not change_uid_enabled"
               src="${href.chrome('/acct_mgr/info.png')}" alt="${''}"
               title="User ID change requires additional components enabled"
               height="16" width="16" />
        </p>
      </div>

      <!--! Account property editor -->
      <form id="account-editor" class="addnew" method="post" py:choose="">
        <ul id="forms" py:if="len(forms) > 1">
          <li py:for="name, label in sorted(forms)"
              class="${'active' if name == active_form else None}"
              id="${('form_%s' % name) if name else None}">
            <a py:strip="name == active_form"
               href="${href.admin('accounts', 'users', user,
                                  action=name)}">${label}</a>
          </li>
        </ul>
        <div id="formcontent">
          <fieldset>
            <div py:when="active_form == 'uid'">
              <div class="field">
                <input type="hidden" name="action" value="uid" />
                <label>New Username:<br />
                  <input type="text" name="new_uid" id="new_uid"
                         class="textwidget"
                         title="Change user ID ('username')"
                         value="${acctmgr.new_uid}" /></label>
              </div>
              <div>
                <div class="field">
                  <label>
                    <input type="checkbox" name="uid_exists" value="true"
                           checked="${uid_exists and 'checked' or None}"
                           title="Skip creating account and password reset" />
                    Assume existing account
                  </label>
                </div>
                <div class="field">
                  <label>
                    <input type="checkbox" name="attr_addonly" value="true"
                           checked="${attr_addonly and 'checked' or None}"
                           title="Do not overwrite existing attributes" />
                    Copy only new account attributes
                  </label>
                </div>
                <div class="field">
                  <label>
                    <input type="checkbox" name="skip_delete" value="true"
                           checked="${skip_delete and 'checked' or None}"
                           title="Skip final account deletion" />
                    Leave old login data
                  </label>
                </div>
              </div>
            </div>
            <div py:otherwise="">
              <div>
                <div class="field">
                  <input type="hidden" name="action" value="edit" />
                  <label for="password">Password:<br />
                    <input type="password" id="password" name="password"
                           class="textwidget"
                           disabled="${not password_change_enabled and
                                       'disabled' or None}" />
                  </label>
                </div>
                <div class="field">
                  <label for="confirm">Confirm Password:<br />
                    <input type="password" id="confirm"
                           name="password_confirm" class="textwidget"
                           disabled="${not password_change_enabled and
                                       'disabled' or None}" />
                  </label>
                </div>
              </div>
              <div class="field">
                <label>Pre-/Surname (Nickname):<br />
                  <input type="text" name="name" class="textwidget"
                         value="${acctmgr.name}" />
                </label>
                <input type="image" name="delete_name" class="delete"
                       src="${href.chrome('/acct_mgr/delete.png')}"
                       alt="${dgettext('acct_mgr', 'Delete value')}"
                       py:if="acctmgr.name" />
              </div>
              <div class="field">
                <label>Email Address:<br />
                  <input type="text" name="email" class="textwidget"
                         value="${acctmgr.email}" />
                </label>
                <input type="image" name="delete_email" class="delete"
                       src="${href.chrome('/acct_mgr/delete.png')}"
                       alt="${dgettext('acct_mgr', 'Delete value')}"
                       py:if="acctmgr.email" />
                <br />
                <label py:if="verify_enabled">
                  <input type="checkbox" name="email_approved" value="true"
                         checked="${email_approved and 'checked' or None}" />
                  Skip new email verification
                </label>
              </div>
            </div>
            <div class="buttons">
              <input type="submit"
                     value="${dgettext('acct_mgr', 'Apply changes')}" />
            </div>
          </fieldset>
        </div>
      </form>

      <hr style="clear: right" py:strip="action_aside" />

      <form method="get" action="${url}">
        <fieldset>
          <legend><label>Account Status</label></legend>
          <div id="user_locked" py:if="approval or user_locked">
            <p>
              <span py:if="release_time and not approval">
                <img src="${href.chrome('/acct_mgr/time-locked.png')}" />
                <i18n:msg params="time">
                  This account has been locked until ${release_time}<br /><!--!
               -->and even valid login attempts are rejected meanwhile.
                </i18n:msg>
              </span>
              <span py:if="approval or not release_time">
                <img src="${href.chrome('/acct_mgr/locked.png')}" />
                This account has been locked permanently.
              </span>
              <span class="buttons">
                <input type="submit" name="release"
                       alt="Release account lock"
                       title="Release account lock"
                       value="${dgettext('acct_mgr', 'Unlock')}" />
              </span>
            </p>
          </div>

          <div id="restricted" py:if="lock_count" py:choose="">
            <div py:when="not lock_count == 0">
              <i18n:choose numeral="lock_count" params="count">
                <p i18n:singular="">Time lock condition has been met ${lock_count} time by now.</p>
                <p i18n:plural="">Time lock condition has been met ${lock_count} times by now.</p>
              </i18n:choose>
              <p py:if="not (approval or (user_locked and not release_time))">${
                dgettext("acct_mgr",
                         "Therefore after another failed login attempt "
                         "authentication for this account would be retarded "
                         "by %(time)s.", time=pretty_lock_time)
              }</p>
            </div>
            <div py:otherwise="">
              <p>Lock condition has not been met yet.</p>
            </div>
          </div>
          <div id="unrestricted" py:if="not (approval or lock_count)">
            <p>No constraints are set for this account.</p>
          </div>

          <hr py:if="user_locked or approval" />

          <div id="user_store" py:if="user_store">
            <p i18n:msg="order_num,store">
              Credentials for this user are stored in AuthStore number <!--!
           --><em>${store_order_num}</em> (${user_store}).
            </p>
            <p class="hint" py:if="ignore_auth_case" i18n:msg="">
              Username matching is set to <b>not case-sensitive</b>.
            </p>
            <p class="hint" py:if="not ignore_auth_case" i18n:msg="">
              Username matching is set to <em>case-sensitive</em>.
            </p>
          </div>
          <div id="no_user_store" py:if="not (approval or user_store)">
            <p i18n:msg="">
              No readable store provides credentials for this user, <!--!
           -->so the user may not get authenticated and access to this <!--!
           --><em>account might be effectively blocked</em>.
            </p>
          </div>
          <div py:if="acctmgr.email">
            <p i18n:msg="email">
              Current email address: &lt;${acctmgr.email}&gt;
            </p>
            <py:choose py:if="verification">
              <p py:when="email_verified">This address has been verified successfully.</p>
              <p py:when="not email_verified and email_verification_token" i18n:msg="token">
                Verification is pending <span class="hint">(token: ${email_verification_token})</span>
              </p>
              <p py:otherwise=""><!--! not email_verified -->
                This address has not been verified yet.
              </p>
            </py:choose>
          </div>
          <div py:if="not acctmgr.email">
            <p>No email address is registered for this account.</p>
          </div>
        </fieldset>

        <fieldset>
          <legend><label>Access History</label></legend>
          <p>${
            dgettext('acct_mgr', 'Last login: %(time)s', time=format_datetime(last_visit)) \
            if last_visit else \
            dgettext('acct_mgr', 'The user has not logged in before.')
          }</p>
          <div id="failed_attempts" py:if="attempts_count">
            <p i18n:msg="count">Total failed attempts: ${attempts_count}</p>
            <p class="tableheader">
              Table: Last failed login attempts log view</p>
            <table class="listing" id="login_attempts">
              <thead>
                <tr>
                  <th>IP address</th>
                  <th>Log time</th>
                </tr>
              </thead>
              <tbody>
                <tr py:for="attempt in attempts">
                  <td>${attempt.ipnr}</td>
                  <td>${format_datetime(attempt.time)}</td>
                </tr>
              </tbody>
            </table>
            <div class="buttons" py:if="not user_locked">
              <input type="submit" name="delete"
                     title="Delete login failure log"
                     value="${dgettext('acct_mgr', 'Delete Log')}" />
            </div>
          </div>
          <div id="no_failed_attempts" py:if="not attempts_count">
            <p>There is currently no failed login attempt logged.</p>
          </div>
        </fieldset>

        <div class="buttons">
          <input type="submit" name="update"
                 value="${dgettext('acct_mgr', 'Refresh')}" />
        </div>
      </form>
    </div>

  </body>
</html>
