<mt:setvar name="edit_author" value="1">
<mt:setvar name="position_actions_bottom" value="1">

<mt:if name="new_object">
  <mt:setvar name="page_title" value="<__trans phrase="Create User">">
<mt:else>
  <mt:if name="nickname">
  <mt:setvarblock name="page_title_name"><mt:var name="nickname" escape="html"></mt:setvarblock>
  <mt:else>
  <mt:setvarblock name="page_title_name"><mt:var name="name" escape="html"></mt:setvarblock>
  </mt:if>    
  <mt:setvarblock name="page_title"><__trans phrase="Edit Profile"></mt:setvarblock>
</mt:if>

<mt:setvarblock name="related_content">
<mtapp:PageActions>
</mt:setvarblock>

<mt:setvarblock name="system_msg" id="system_msg">
<mt:if name="saved">
  <mtapp:statusmsg
     id="saved"
     class="success">
    <__trans phrase="This profile has been updated.">
  </mtapp:statusmsg>
</mt:if>
<mt:if name="recovered">
  <mtapp:statusmsg
     id="recovered"
     class="success">
    <__trans phrase="A new password has been generated and sent to the email address [_1]." params="<mt:var name="email" escape="html">">
  </mtapp:statusmsg>
</mt:if>
<mt:if name="unlocked">
  <mtapp:statusmsg
     id="unlocked"
     class="success">
    <__trans phrase="This profile has been unlocked.">
  </mtapp:statusmsg>
</mt:if>
<mt:if name="error">
  <mtapp:statusmsg
     id="generic-error"
     class="error"
     can_close="0">
    <mt:var name="error">
  </mtapp:statusmsg>
</mt:if>
<mt:if name="editing_other_profile">
  <mt:if name="status_pending">
    <mtapp:statusmsg
       id="user-pending"
       class="alert"
       can_close="0">
      <__trans phrase="This user was classified as pending.">
    </mtapp:statusmsg>
  <mt:else>
    <mt:unless name="status_enabled">
    <mtapp:statusmsg
       id="user-disabled"
       class="alert"
       can_close="0">
      <__trans phrase="This user was classified as disabled.">
    </mtapp:statusmsg>
    </mt:unless>
  </mt:if>
</mt:if>
<mt:if name="locked_out">
  <mtapp:statusmsg
     id="user-locked-out"
     class="alert"
     can_close="0">
    <__trans phrase="This user was locked out."><mt:if name="recover_lockout_link"> <__trans phrase="If you want to unlock this user click the 'Unlock' link. <a href="[_1]">Unlock</a>" params="<mt:var name="recover_lockout_link">"></mt:if>
  </mtapp:statusmsg>
</mt:if>
</mt:setvarblock>

<mt:setvarblock name="html_head" append="1">
<script type="text/javascript" src="<mt:var name="static_uri">js/tc/client.js"></script>
</mt:setvarblock>

<mt:setvarblock name="related_content">
<mt:unless name="new_object">
  <mtapp:widget
     id="user-properties"
     label="<__trans phrase="User properties">">
    <mt:include name="include/users_content_nav.tmpl">
  </mtapp:widget>
</mt:unless>
</mt:setvarblock>

<mt:include name="include/header.tmpl">

<script type="text/javascript">
/* <![CDATA[ */
function reveal_api_password() {
    var pw = getByID("api_password");
    alert("<__trans phrase="Your web services password is currently">: " + pw.value);
    return false;
}
function tagDelimChoice(sel) {
    if (sel.selectedIndex == 2) {
        show("tag_delim_input");
        var el = getByID("tag_delim_input");
        if (el) el.focus();
    } else {
        hide("tag_delim_input");
    }
}

function passwordResetConfirm() {
    var username = '<mt:var name="name" escape="js">';
    var email = '<mt:var name="email" escape="js">';
    if (confirm('<__trans phrase="_WARNING_PASSWORD_RESET_SINGLE" params="'+username+'%%'+email+'">')) {
        document.forms['recover'].submit();
    }
}
function toggleDisabled( state ){
    if (state == 1) {
        state = false;
    } else if (state == 2) {
        state = true;
    }
    var elements = TC.getElementsByClassName('state_change');
    for (var i=0; i < elements.length; i++) {
        elements[i].disabled = state;
    }
}
function togglePerms(c, a) {
    if (a == '') {
        return;
    }

    if (c.checked) {
        jQuery(a).each(function(){
            this.checked = true;
            this.disabled = true;
        });
    } else {
        jQuery(a).each(function(){
            this.checked = false;
            this.disabled = false;
        });
    }
}

function removeUserpic() {
    var param = '__mode=remove_userpic'
        + '&user_id=<mt:var name="id" escape="url">'
        + '&magic_token=<mt:var name="magic_token">';
    var params = { uri: '<mt:var name="script_url">', method: 'POST', arguments: param, load: removedUserpic };
    TC.Client.call(params);
}

function removedUserpic(c) {
    var res = c.responseText;
    if (res != 'success') {
        message = '<__trans phrase="Error occurred while removing userpic." escape="js">';
        showMsg(message, 'ajax-message', 'error');
    }

    getByID('userpic_asset_id').value = '0';
    if (!DOM.hasClassName('userpic-preview', 'hidden'))
       toggleHidden('userpic-preview');
    if (!DOM.hasClassName('remove-userpic', 'hidden'))
       toggleHidden('remove-userpic');
    return false
}

function init() {
    var c = document.forms['profile'].elements['can_administer'];
    if (c.checked)
        document.forms['profile'].elements['can_administer'].onclick();
}

TC.attachLoadEvent(init);
<mt:if name="auth_mode_mt">
<$mt:PasswordValidation form="profile" password="pass" username="name"$>
</mt:if>
/* ]]> */
</script>

<form name="profile" id="profile" method="post" action="<mt:var name="script_url">">
  <input type="hidden" name="__mode" value="save" />
  <input type="hidden" name="_type" value="author" />
  <input type="hidden" name="return_args" value="<mt:var name="return_args" escape="html">" />
  <input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />
<mt:if name="editing_other_profile">
  <input type="hidden" name="_type" value="author" />
</mt:if>
<mt:if name="id">
  <input type="hidden" name="id" value="<mt:var name="id" escape="html">" />
</mt:if>
<mt:if name="new_object">
  <input type="hidden" id="status" name="status" value="1" />
</mt:if>
  <h2><__trans phrase="Profile"></h2>
  <fieldset id="author-profile-settings">
  <mt:if name="editing_other_profile">

    <mtapp:setting
       id="status"
       label="<__trans phrase="_USER_STATUS_CAPTION">"
       label_class="left-label <mt:var name="user_status">"
       hint="<__trans phrase="Status of user in the system. Disabling a user prevents that person from using the system but preserves their content and history.">">
      <select name="status" id="status" class="half-width" onchange="toggleDisabled(this.value);">
        <option <mt:if name="status_enabled">selected="selected"</mt:if> value="1"><__trans phrase="_USER_ENABLED"></option>
      <mt:if name="status_pending">
        <option selected="selected" value="3"><__trans phrase="_USER_PENDING"></option>
      </mt:if>
        <option <mt:unless name="status_enabled"><mt:unless name="status_pending">selected="selected"</mt:unless></mt:unless> value="2"><__trans phrase="_USER_DISABLED"></option>
      </select>
    </mtapp:setting>
  </mt:if>

    <mtapp:setting
       id="name"
       required="1"
       label="<__trans phrase="Username">"
       hint="<__trans phrase="The username used to login.">">
      <input type="text" name="name" id="name" class="text" value="<mt:var name="name" escape="html">" <mt:unless name="auth_mode_mt"><mt:unless name="new_user_external_auth">disabled="disabled"</mt:unless></mt:unless> /><mt:unless name="auth_mode_mt"><mt:unless name="new_user_external_auth"><input name="name" type="hidden" value="<mt:var name="name" escape="html">" /></mt:unless></mt:unless>
    </mtapp:setting>

  <mt:if name="external_id">
    <mt:if name="show_external_id">
    <mtapp:setting
       id="external_id"
       label="<__trans phrase="External user ID">">
      <mt:var name="external_id" escape="html">
    </mtapp:setting>
    </mt:if>
  </mt:if>

  <mt:unless name="new_user_external_auth">
    <mtapp:setting
       id="nickname"
       required="1"
       label="<__trans phrase="Display Name">"
       show_hint="1"
       hint="<__trans phrase="The name displayed when content from this user is published.">">
      <input type="text" name="nickname" id="nickname" class="text" value="<mt:var name="nickname" escape="html">" />
    </mtapp:setting>

    <mtapp:setting
       id="email"
       required="$auth_mode_mt"
       label="<__trans phrase="Email Address">"
       hint="<__trans phrase="The email address associated with this user.">">
        <input type="text" name="email" id="email" class="text" value="<mt:var name="email" escape="html">" />
    </mtapp:setting>

    <mtapp:setting
       id="url"
       label="<__trans phrase="Website URL">"
       show_hint="1"
       hint="<__trans phrase="This User's website (e.g. http://www.movabletype.com/).  If the Website URL and Display Name fields are both populated, Movable Type will by default publish entries and comments with bylines linked to this URL.">">
      <input type="text" name="url" id="url" class="text" value="<mt:var name="url" escape="html">" />
    </mtapp:setting>

    <mt:if name="id">
      <mt:if name="can_use_userpic">
    <mtapp:setting
       id="userpic_asset_id"
       label="<__trans phrase="Userpic">"
       hint="<__trans phrase="The image associated with this user.">">
      <input type="hidden" name="userpic_asset_id" id="userpic_asset_id" value="<mt:var name="userpic_asset_id" default="0" escape="html">" />
      <div id="userpic-preview"<mt:unless name="userpic"> class="hidden"</mt:unless>>
        <span id="userpic-preview-userpic"><mt:var name="userpic"></span>
      </div>
      <a href="<mt:var name="script_url">?__mode=dialog_list_asset&amp;edit_field=userpic_asset_id&amp;blog_id=0&amp;filter=userpic&amp;filter_val=<mt:var name="id" escape="url">&amp;next_mode=asset_userpic&amp;upload_mode=upload_userpic" class="mt-open-dialog"><__trans phrase="Select Userpic"></a>
      <span id="remove-userpic"<mt:unless name="userpic"> class="hidden"</mt:unless>>
        <a href="javascript:void(0)" onclick="removeUserpic()"><__trans phrase="Remove Userpic"></a>
        <span id="ajax-message"></span>
      </span>
    </mtapp:setting>
      </mt:if>
    </mt:if>

    <mt:if name="can_modify_password">
      <mt:unless name="new_object">
    <mtapp:setting
       id="show_password"
       label="<__trans phrase="Password">">
      <a href="#" id="change-password-link" class="toggle-link"><__trans phrase="Change Password"></a>
    </mtapp:setting>
      </mt:unless>
    <div id="password-fields"<mt:unless name="new_object"> style="display: none;"</mt:unless>>
      <mt:unless name="new_object">
        <mt:if name="is_me">
      <mtapp:setting
         id="old_pass"
         label="<__trans phrase="Current Password">"
         hint="<__trans phrase="Existing password required to create a new password.">">
        <input type="password" name="old_pass" id="old_pass" class="text password" value="" />
      </mtapp:setting>
        </mt:if>
      </mt:unless>

      <mt:if name="new_object">
        <mt:setvar name="password_required" value="1">
        <mt:setvar name="password_prompt" value="<__trans phrase="Initial Password">">
        <mt:setvar name="password_hint" value="<__trans phrase="Enter preferred password."> (<$mt:PasswordValidationRule$>)">
      <mt:else>
        <mt:setvar name="password_required" value="0">
        <mt:setvar name="password_prompt" value="<__trans phrase="New Password">">
        <mt:setvar name="password_hint" value="<__trans phrase="Enter the new password."> (<$mt:PasswordValidationRule$>)">
      </mt:if>

      <mtapp:setting
         id="pass"
         label="$password_prompt"
         required="$password_required"
         hint="$password_hint"
         show_hint="1">
        <input type="password" name="pass" id="pass" class="text password" value="" />
      </mtapp:setting>

      <mtapp:setting
         id="pass_verify"
         label="<__trans phrase="Confirm Password">"
         required="$password_required"
         hint="<__trans phrase="Repeat the password for confirmation.">">
        <input type="password" name="pass_verify" id="pass_verify" class="text password" value="" />
      </mtapp:setting>

      <mt:unless name="new_object">
        <mt:if name="hint">
      <mtapp:setting
         id="hint"
         required="0"
         label="<__trans phrase="Password recovery word/phrase">"
         hint="<__trans phrase="This word or phrase is not used in the password recovery.">">
        <input name="hint" id="hint" value="<mt:var name="hint" escape="html">" />
      </mtapp:setting>
        </mt:if>
      </mt:unless>
    </div>
    </mt:if>
  </fieldset>

  <h2><__trans phrase="Preferences"></h2>
  <fieldset id="author-preferences-settings">
    <mtapp:setting
       id="preferred_language"
       label="<__trans phrase="Language">"
       show_hint="1"
       hint="<__trans phrase="Display language for the Movable Type interface.">">
      <select name="preferred_language" id="preferred_language">
      <mt:loop name="languages">
        <option value="<mt:var name="l_tag">"<mt:if name="l_selected"> selected="selected"</mt:if>><mt:var name="l_name"></option>
      </mt:loop>
      </select>
    </mtapp:setting>

    <mtapp:setting
       id="text_format"
       label="<__trans phrase="Text Format">"
       show_hint="1"
       hint="<__trans phrase="Default text formatting filter when creating new entries and new pages.">">
      <select name="text_format" id="text_format" class="se">
      <mt:loop name="text_filters">
        <option value="<mt:var name="key">"<mt:if name="selected"> selected="selected"</mt:if>><mt:if name="key" eq="0"><__trans phrase="(Use Website/Blog Default)"><mt:else><mt:var name="label" escape="html"></mt:if></option>
      </mt:loop>
      </select>
    </mtapp:setting>

    <mtapp:setting
       id="date_format"
       label="<__trans phrase="Date Format">"
       show_hint="1"
       hint="<__trans phrase="Default date formatting in the Movable Type interface.">">
      <select name="date_format" id="date_format">
        <option value="relative"<mt:if name="date_format" eq="relative"> selected="selected"</mt:if>><__trans phrase="Relative"></option>
        <option value="full"<mt:if name="date_format" eq="full"> selected="selected"</mt:if>><__trans phrase="Full"></option>
      </select>
    </mtapp:setting>

    <mtapp:setting
       id="tag_delim"
       label="<__trans phrase="Tag Delimiter">"
       show_hint="1"
       hint="<__trans phrase="Preferred method of separating tags.">">
      <select name="tag_delim" id="tag_delim" class="se">
        <option value="comma"<mt:if name="auth_pref_tag_delim_comma"> selected="selected"</mt:if>><__trans phrase="Comma"></option>
        <option value="space"<mt:if name="auth_pref_tag_delim_space"> selected="selected"</mt:if>><__trans phrase="Space"></option>
      </select>
    </mtapp:setting>
  </mt:unless>

  <mt:if name="is_me">
    <mtapp:setting
       id="api_password"
       label="<__trans phrase="Web Services Password">"
       hint="<__trans phrase="For use by Activity feeds and with XML-RPC and Atom-enabled clients.">">
      <input type="password" name="api_password" id="api_password" class="text password" value="<mt:var name="api_password" escape="html">" />
      <a href="javascript:void(0)" onclick="return reveal_api_password()"><__trans phrase="Reveal"></a>
    </mtapp:setting>
  </mt:if>
  </fieldset>

  <h2><__trans phrase="System Permissions"></h2>
  <fieldset id="author-permission-settings">
    <mtapp:setting
       id="system_permissions"
       label="<__trans phrase="Permissions">">
      <ul class="inline-list">
      <mt:loop name="loaded_permissions">
        <li><input name="<mt:var name="id">" id="<mt:var name="id">" type="checkbox" value="1"<mt:if name="can_do"> checked="checked"</mt:if> <mt:unless name="new_object"><mt:unless name="editing_other_profile">disabled="disabled"</mt:unless></mt:unless> onclick="togglePerms(this, '<mt:var name="children">')" /> <label for="<mt:var name="id">"><mt:var name="label"></label></li>
      </mt:loop>
      </ul>
    </mtapp:setting>
  </fieldset>

<mt:if name="new_object">
  <h2><__trans phrase="Options"></h2>
  <mtapp:settinggroup id="author-optional-settings">
    <mtapp:setting
       id="create_user_blog"
       label="<__trans phrase="Options">"
       hint="<__trans phrase="Create personal blog for user">"
       show_hint="0">
      <label for="create_personal_weblog">
        <input type="checkbox" id="create_personal_weblog" name="create_personal_weblog" <mt:if name="create_personal_weblog">checked="checked"<mt:else>disabled="disabled"</mt:if> />
        <__trans phrase="Create personal blog for user">
      </label>
    </mtapp:setting>
  </mtapp:settinggroup>
</mt:if>

  <mt:setvarblock name="action_buttons">
  <mt:if name="new_object">
    <button
       type="submit"
       accesskey="s"
       title="<__trans phrase="Create User (s)">"
       class="create action primary button">
      <__trans phrase="Create User">
    </button>
  <mt:else>
    <button
       type="submit"
       accesskey="s"
       title="<__trans phrase="Save changes to this author (s)">"
       class="save action primary button">
      <__trans phrase="Save Changes">
    </button>
  </mt:if>
  </mt:setvarblock>
  <mt:include name="include/actions_bar.tmpl" bar_position="bottom" hide_pager="1" settings_bar="1">
</form>

<mt:if name="auth_mode_mt">
  <mt:unless name="can_modify_password">
    <mt:unless name="new_object">
<form name="recover" method="post" action="<mt:var name="script_url">">
  <input type="hidden" name="__mode" value="recover_profile_password" />
  <input type="hidden" name="author_id" value="<mt:var name="id" escape="html">" />
  <input type="hidden" name="return_args" value="<mt:var name="return_args" escape="html">" />
  <input type="hidden" name="magic_token" value="<mt:var name="magic_token">" />
  <h2><__trans phrase="Password Recovery"></h2>
  <mtapp:settinggroup id="password-recovery">
    <p><__trans phrase="_USAGE_PASSWORD_RESET" params="<mt:var name="email" escape="html">"></p>
    <div style="text-align: center">
      <input class="state_change" onclick="passwordResetConfirm()" type="button" value="<__trans phrase="Initiate Password Recovery">" <mt:unless name="status_enabled">disabled</mt:unless> />
    </div>
  </mtapp:settinggroup>
</form>
    </mt:unless>
  </mt:unless>
</mt:if>

<mt:setvarblock name="jq_js_include" append="1">
<mt:unless name="new_object">
    jQuery('#change-password-link').click(function(event) {
        jQuery(this).parents('#show_password-field').next('#password-fields').show().focus();
        jQuery(this).parents('#show_password-field').hide();
        event.preventDefault();
    });
</mt:unless>
</mt:setvarblock>

<mt:include name="include/footer.tmpl">
