change_user_groups.naml

<macro name="change_user_groups" requires="servlet">
	<n.user_page.>
		<n.if.not.visitor.can_manage_users_and_groups>
			<then>
				<n.login.><t>Only authorized users can proceed in this area.</t></n.login.>
			</then>
		</n.if.not.visitor.can_manage_users_and_groups>
		<n.if.is_submitted_form>
			<then>
				<n.catch_exception. id="save-block">
					<n.edit_page_user.>
						<n.user_group_list.loop.group_field. group="[n.current_group/]">
							<n.if.is_checked>
								 <then><n.add_to_group.current_group/></then>
								 <else><n.remove_from_group.current_group/></else>
							</n.if.is_checked>
						</n.user_group_list.loop.group_field.>
						<n.get_parameter_values. name="newgroup">
							<n.loop.>
								<n.if.not.is_empty.current_parameter_value>
								 	<then><n.add_to_group.current_parameter_value/></then>
								</n.if.not.is_empty.current_parameter_value>
							</n.loop.>
						</n.get_parameter_values.>
					</n.edit_page_user.>
					<n.redirect_to.page_user.path/>
				</n.catch_exception.>
			</then>
		</n.if.is_submitted_form>
		<n.html>
			<head>
				<META NAME="robots" CONTENT="noindex,nofollow"/>
				<n.title.><t>Change User Groups</t></n.title.>
				<style type="text/css">
					.title-row {
						padding:.2em;
						border-bottom-width:2px;
						border-bottom-style:solid;
						font-weight:bold;
					}
				</style>
			</head>
			<body>
				<n.page_user.profile_header/>

				<div class="title-row light-border-color" style="margin-top:.5em">
					<t>Groups of this user</t>
				</div>
				<n.form.>
					<table>
						<n.if.page_user.is_registered>
							<then><n.fixed_group_row name="Anyone" tip="[t]Users that completed the registration process[/t]"/></then>
						</n.if.page_user.is_registered>

						<n.if.page_user.is_authenticated>
							<then>
								<n.user_group_list.loop.>
									<n.group_row>
										<group><n.current_group/></group>
										<checked><n.page_user.is_in_group.current_group/></checked>
									</n.group_row>
								</n.user_group_list.loop.>

								<n.empty_group_controls/>
							</then>
						</n.if.page_user.is_authenticated>
					</table>

					<n.if.page_user.is_authenticated>
						<then>
							<div style="margin-top:1.4em">
								<input type="submit" value="[t]Save Changes[/t]" />
								<t>or</t> <a href="[n.page_user.url/]"><t>Cancel</t></a>
							</div>
						</then>
					</n.if.page_user.is_authenticated>
				</n.form.>
			</body>
		</n.html>
	</n.user_page.>
</macro>

<macro name="fixed_group_row" parameters="name,tip">
	<tr>
		<td>&nbsp;</td>
		<td style="padding:.2em 0">
			<n.name/>
		</td>
		<td class="weak-color">
			<n.hide_null.tip/>
		</td>
	</tr>
</macro>

<macro name="group_row" parameters="group,checked">
	<n.group_field. group="[n.group/]">
		<n.set_value.checked/>
		<tr>
			<td>
				<n.checkbox/>
			</td>
			<td><label for="[n.name/]"><n.group/></label></td>
			<td></td>
		</tr>
	</n.group_field.>
</macro>

<macro name="group_field" parameters="group" dot_parameter="do">
	<n.field. name="group-[n.remove_spaces.group/]"><n.do/></n.field.>
</macro>

<macro name="empty_group_controls">
	<n.put_in_head.>
		<script type="text/javascript">
			function addNewGroup() {
				var r = '<tr>';
				r += '<td></td>';
				r += '<td><input type="text" name="newgroup"/> <a href="javascript:void(0)" onclick="$(this).parent().parent().remove()"><t>remove</t></a></td>';
				r += '</tr>';
				$('#last-row').before(r);
				$('input[type="text"]:last').focus();
				Nabble.resizeFrames();
			};
		</script>
	</n.put_in_head.>
	<tr id="last-row">
		<td>&nbsp;</td>
		<td><a href="javascript:void(0)" onclick="addNewGroup()"><t>Add a new group</t></a></td>
		<td></td>
	</tr>
</macro>

<macro name="user_group_list" dot_parameter="do">
	<n.user_groups.>
		<n.add.members_group/>
		<n.add.administrators_group/>
		<n.sort/>
		<n.do/>
	</n.user_groups.>
</macro>