edit_profile.naml

<macro name="edit_profile" requires="servlet">
	<n.user_page.>
		<n.if.not.visitor.is_registered>
			<then>
				<n.login.><t>You must login to view this page.</t></n.login.>
			</then>
		</n.if.not.visitor.is_registered>

		<n.if.both condition1="[n.not.visitor.is_site_admin/]" condition2="[n.not.page_user.equals.visitor/]">
			<then>
				<n.login.><t>You must login to view this page.</t></n.login.>
			</then>
		</n.if.both>

		<n.if.is_submitted_form>
			<then>
				<n.catch_exception. id="save-profile">
					<n.edit_page_user.>
						<n.set_name name="[n.user_name_field.value/]"/>
						<n.set_password password1="[n.password_field.value/]" password2="[n.password2_field.value/]"/>
						<n.save_user/>
					</n.edit_page_user.>
					<n.if.page_user.equals.visitor>
						<then.profile_update_with_redirection_to.page_user.url/>
						<else.redirect_to.page_user.url/>
					</n.if.page_user.equals.visitor>
				</n.catch_exception.>
			</then>
			<else>
				<n.user_name_field.set_value value="[n.page_user.name/]" />
			</else>
		</n.if.is_submitted_form>

		<n.html>
			<head>
				<META NAME="robots" CONTENT="noindex,nofollow"/>
				<n.title.><t>Edit Profile</t></n.title.>
			</head>
			<body>
				<style>
					div.field-title {margin-top:0}
				</style>
				<h1><t>Edit Profile</t></h1>

				<div class="field-box light-border-color">
					<div class="second-font field-title">Email</div>
					<div class="weak-color">
						<n.page_user.user_email/>
						&#187; <a href="[n.page_user.change_email_path/]">Change Email</a>
					</div>
				</div>

				<n.form.>
					<div class="field-box light-border-color" id="username-field">
						<div class="second-font field-title">User Name</div>
						<div class="weak-color">
							Your user name must be unique in <n.root_node.subject/>
						</div>
						<div>
							<n.user_name_field.input size="25" maxlength="25"/>
						</div>
					</div>

					<div class="field-box light-border-color">
						<div class="second-font field-title">Change Password</div>
						<div class="weak-color">Nabble encrypts your password (<a href="[n.help.password/]">?</a>)</div>
						<table style="margin:.4em 0" class="shaded-bg-color">
							<tr valign="top">
								<td class="form-label" style="padding-top:.6em">Password:&nbsp;</td>
								<td><n.password_field.input type="password" size="25" maxlength="25"/></td>
							</tr>
							<tr>
								<td class="form-label">Confirm Password:&nbsp;</td>
								<td><n.password2_field.input type="password" size="25" maxlength="25"/></td>
							</tr>
						</table>
					</div>

					<input type="submit" class="toolbar action-button" value="[t]Save Changes[/t]"/>
					<t>or</t> <a href="[n.page_user.url/]"><t>Cancel</t></a>
				</n.form.>
			</body>
		</n.html>
	</n.user_page.>
</macro>

<macro name="show_edit_profile_error">
	<n.if.is_submitted_form>
		<then.if.has_exception for="save-profile">
			<then.format_error.handle_exception. for="save-profile">
				<n.exception. name="empty_user_name">
					<t>User name cannot be empty.</t>
				</n.exception.>
				<n.exception. name="passwords_dont_match">
					<t>The password fields don't match.</t>
				</n.exception.>
				<n.exception. name="user_name_already_in_use">
					<t>This user name is already in use.</t>
				</n.exception.>
			</then.format_error.handle_exception.>
		</then.if.has_exception>
	</n.if.is_submitted_form>
</macro>