ban_user.naml

<macro name="ban_user" requires="servlet">
	<n.user_page.>
		<n.if.not.visitor.can_manage_banned_users>
			<then>
				<n.login.><t>Only authorized users can proceed in this area.</t></n.login.>
			</then>
		</n.if.not.visitor.can_manage_banned_users>
		<n.if.is_submitted_form>
			<then>
				<n.if.ban_user_field.is_checked>
					<then><n.page_user.ban/></then>
				</n.if.ban_user_field.is_checked>

				<n.if.delete_posts_field.is_checked>
					<then><n.page_user.delete_user_nodes/></then>
				</n.if.delete_posts_field.is_checked>
			</then>
		</n.if.is_submitted_form>
		<n.html>
			<head>
				<META NAME="robots" CONTENT="noindex,nofollow"/>
				<n.title.><t>Ban User</t></n.title.>
				<script type="text/javascript">
					$(document).ready(function() {
						function enableButton() {
							var $submit = $('input[type="submit"]');
							var disabled = !$('#ban_this_user').is(':checked') && !$('#delete_posts').is(':checked');
							if (disabled)
								$submit.attr('disabled','true');
							else
								$submit.removeAttr('disabled');
						}
						$('input[type="checkbox"]').click(enableButton);
						enableButton();
					});
				</script>
				<n.bold_label_style/>
			</head>
			<body>
				<n.edit_header first_text="[t]Ban User[/t]" second_text="[n.page_user.name/]" />

				<n.form.>
					<table style="margin-bottom: .5em">
						<tr valign="top">
							<td><n.page_user.avatar size="big"/></td>
							<td>
								<div style="padding:.3em .5em">
								<t>Select below the actions you want to take:</t>
								</div>
								<n.ban_user_control/>
								<n.delete_posts_control/>
							</td>
						</tr>
					</table>

					<n.if.not.is_submitted_form>
						<then>
							<div style="margin-top:1.4em">
								<input type="submit" value="[t]Take Action[/t]" disabled="true"/>
								<t>or</t> <a href="[n.page_user.url/]"><t>Cancel</t></a>
							</div>
						</then>
					</n.if.not.is_submitted_form>
				</n.form.>

				<p><t>You can also <n.manage_banned_users_link.>manage banned users</n.manage_banned_users_link.> in <t.location.root_node.subject/>.</t></p>
			</body>
		</n.html>
	</n.user_page.>
</macro>

<macro name="ban_user_control">
	<n.if.page_user.is_authenticated>
		<then>
			<table style="margin-bottom:1em">
				<tr valign="top">
					<n.ban_user_field.>
						<n.if.not.is_submitted_form>
							<then>
								<td><n.checkbox/></td>
								<td>
									<label for="[n.name/]"><t>Ban this user</t></label>
									<div class="weak-color" style="margin-top:.3em">
										<t>If you ban this user, he/she won't be able to do anything in <t.location.root_node.subject/>.</t>
										<t>Remember that the banning action isn't efficient because the user can always come back with a different account.</t>
									</div>
								</td>
							</then>
							<else>
								<n.if.is_checked>
									<then>
										<td><img src="/images/success.png" class="image16"/></td>
										<td><t><t.author><b><n.page_user.name/></b></t.author> has been successfully banned.</t></td>
									</then>
								</n.if.is_checked>
							</else>
						</n.if.not.is_submitted_form>
					</n.ban_user_field.>
				</tr>
			</table>
		</then>
	</n.if.page_user.is_authenticated>
</macro>

<macro name="delete_posts_control">
	<table style="margin-bottom:1em">
		<tr valign="top">
			<n.delete_posts_field.>
				<n.if.not.is_submitted_form>
					<then>
						<td><n.checkbox/></td>
						<td>
							<label for="[n.name/]"><t>Delete all posts from this user</t></label>
							<div class="weak-color" style="margin-top:.3em">
								<t>The user will receive a copy of all delete posts by email, so that he/she can have a chance to save them.</t>
							</div>
						</td>
					</then>
					<else>
						<n.if.is_checked>
							<then>
								<td><img src="/images/success.png" class="image16"/></td>
								<td><t>All posts from <t.author><b><n.page_user.name/></b></t.author> have been successfully removed.</t></td>
							</then>
						</n.if.is_checked>
					</else>
				</n.if.not.is_submitted_form>
			</n.delete_posts_field.>
		</tr>
	</table>
</macro>

<macro name="ban_user_field" dot_parameter="do">
	<n.field. name="ban_this_user"><n.do/></n.field.>
</macro>

<macro name="delete_posts_field" dot_parameter="do">
	<n.field. name="delete_posts"><n.do/></n.field.>
</macro>