diff src/nabble/view/naml/manage_users_and_groups.naml @ 0:7ecd1a4ef557

add content
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 Mar 2019 19:15:52 -0600
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/nabble/view/naml/manage_users_and_groups.naml	Thu Mar 21 19:15:52 2019 -0600
@@ -0,0 +1,243 @@
+<macro name="manage_users_and_groups" requires="servlet">
+	<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.save_users_and_group/>
+	</n.if.is_submitted_form>
+
+	<n.html>
+		<head>
+			<META NAME="robots" CONTENT="noindex,nofollow"/>
+			<n.title.><t>Manage Users & Groups</t></n.title.>
+			<n.if.is_submitted_form>
+				<then>
+					<script type="text/javascript">
+						$(document).ready(function() {
+							notice('<t>Data successfully saved</t>', 2000, 1000);
+						});
+					</script>
+				</then>
+			</n.if.is_submitted_form>
+		</head>
+		<body>
+			<n.edit_header first_text="[t]Manage Users & Groups[/t]" second_text="[n.root_node.subject/]" />
+
+			<div class="weak-color" style="margin-top:1em">
+				<t>Below you can manage groups and users. You can copy and paste users in order
+				to move them from one group to another.</t>
+			</div>
+
+			<div class="weak-color" style="margin:.5em 0 1em">
+				<t>You can also <n.root_node.change_permissions_link.>change the permissions</n.root_node.change_permissions_link.> of the groups below.</t>
+			</div>
+
+			<n.user_groups.>
+				<n.add.members_group/>
+				<n.add.administrators_group/>
+				<n.sort/>
+				<n.vertical_tab_control.>
+					<n.add_new_group_vertical_tab/>
+					<n.add_all_users_vertical_tab/>
+					<n.add_registered_vertical_tab/>
+					<n.loop.>
+						<n.add_group_vertical_tab group="[n.current_group/]"/>
+					</n.loop.>
+					<n.reset_list_index/>
+				</n.vertical_tab_control.>
+			</n.user_groups.>
+		</body>
+	</n.html>
+</macro>
+
+<macro name="add_new_group_vertical_tab">
+	<n.add_vertical_tab>
+		<icon><img src="/images/add.png" width="12" height="12" style="vertical-align:-10%"/></icon>
+		<text><t>Add New Group</t></text>
+		<url><n.manage_users_and_groups_path/></url>
+		<selected><n.is_null.selected_group/></selected>
+		<details><n.new_group_panel/></details>
+	</n.add_vertical_tab>
+</macro>
+
+<macro name="add_all_users_vertical_tab">
+	<n.add_vertical_tab>
+		<text><t>All Users</t></text>
+		<style>padding-left:20px</style>
+		<url><n.manage_users_and_groups_path group="All_Users"/></url>
+		<selected><n.equal value1="[n.selected_group/]" value2="All_Users"/></selected>
+		<details><n.all_users_panel/></details>
+	</n.add_vertical_tab>
+</macro>
+
+<macro name="add_registered_vertical_tab">
+	<n.add_vertical_tab>
+		<text><t>Registered Users</t></text>
+		<style>padding-left:20px</style>
+		<url><n.manage_users_and_groups_path group="Registered"/></url>
+		<selected><n.equal value1="[n.selected_group/]" value2="Registered"/></selected>
+		<details><n.registered_users_panel/></details>
+	</n.add_vertical_tab>
+</macro>
+
+<macro name="add_group_vertical_tab" parameters="group">
+	<n.add_vertical_tab>
+		<text><n.group/></text>
+		<style>padding-left:20px</style>
+		<url><n.manage_users_and_groups_path group="[n.group/]"/></url>
+		<selected><n.equal value1="[n.selected_group/]" value2="[n.group/]"/></selected>
+		<details><n.group_editor_panel group="[n.group/]"/></details>
+	</n.add_vertical_tab>
+</macro>
+
+<macro name="save_users_and_group">
+	<n.string_list. values="[n.users_field.value/]" separator="\n">
+		<n.filter_by.not.is_empty.current_string/>
+		<n.remove_group group="[n.selected_group/]"/>
+		<n.loop.>
+			<n.set_var. name='email'>
+				<n.get_email_address_from.current_string/>
+			</n.set_var.>
+			<n.if.not.is_empty.var name='email'>
+				<then>
+					<n.get_or_create_user. email="[n.var name='email'/]">
+						<n.as_user_page.edit_page_user.>
+							<n.add_to_group.selected_group/>
+						</n.as_user_page.edit_page_user.>
+					</n.get_or_create_user.>
+				</then>
+			</n.if.not.is_empty.var>
+		</n.loop.>
+
+		<n.if.list_is_empty>
+			<then.redirect_to.manage_users_and_groups_path/>
+		</n.if.list_is_empty>
+	</n.string_list.>
+</macro>
+
+<macro name="manage_users_and_groups_path" parameters="group">
+	<n.encode_url.remove_spaces.>
+		/template/NamlServlet.jtp?macro=manage_users_and_groups
+		<n.add_to_path name="group" value="[n.group/]"/>
+	</n.encode_url.remove_spaces.>
+</macro>
+
+<macro name="selected_group">
+	<n.get_parameter name='group'/>
+</macro>
+
+<macro name="group_editor_panel" parameters="group">
+	<div class="second-font field-title nowrap" style="margin-top:0">
+		<n.group/>
+	</div>
+	<n.short_description/>
+	<n.users_field.set_value.>
+		<n.users_in_group. group="[n.group/]">
+			<n.loop.>
+				<n.current_user.name/> <n.lt/><n.current_user.user_email/><n.gt/><n.crlf/>
+			</n.loop.>
+		</n.users_in_group.>
+	</n.users_field.set_value.>
+	<n.form.>
+		<input type="hidden" name="group" value="[n.selected_group/]"/>
+		<n.users_field.textarea wrap="SOFT" style="width:100%;height:25em;margin:.3em 0" />
+		<input type="submit" value="[t]Save Changes[/t]"/>
+	</n.form.>
+</macro>
+
+<macro name="short_description">
+	<div class="weak-color nowrap">
+		<t>Enter one user per row</t> (<a href="javascript: void(0)" onclick="$('#help').slideToggle()"><t>more help</t></a>)
+		<div id="help" style="display:none">
+			<b><t>Examples:</t></b>
+			<div style="margin-left:1em">
+				john_smith@example.com<br/>
+				John Smith &lt;john_smith@example.com&gt;
+			</div>
+			<div>
+				<t>To remove a group, empty the text area below and save the changes.</t>
+			</div>
+		</div>
+	</div>
+</macro>
+
+<macro name="all_users_panel">
+	<div class="second-font field-title nowrap" style="margin:0"><t>All Users</t></div>
+	<div class="weak-color" style="margin-bottom:.8em">
+		<t>Read-only list with all users with an email under <t.location.root_node.subject/>.</t>
+		<t>This list shows registered, unregistered and banned users. Anonymous users are not listed because they don't have an email and thus cannot be part of a group.</t>
+	</div>
+
+	<div style="height:25em;overflow:auto">
+		<n.site_users. length="99999">
+			<n.loop.>
+				<n.current_user.name/> &lt;<n.current_user.user_email/>&gt;<br/>
+			</n.loop.>
+		</n.site_users.>
+	</div>
+</macro>
+
+<macro name="registered_users_panel">
+	<div class="second-font field-title nowrap" style="margin:0"><t>Registered Users</t></div>
+	<div class="weak-color" style="margin-bottom:.8em">
+		<t>All users that have registered to <t.location.root_node.subject/>.
+		These users have confirmed their email addresses and are able to login to the system.</t>
+	</div>
+
+	<div style="height:25em;overflow:auto">
+		<n.site_users. length="99999">
+		<n.filter_by.both condition1="[n.current_user.is_registered/]" condition2="[n.current_user.not.is_banned/]"/>
+			<n.loop.>
+				<n.current_user.name/> &lt;<n.current_user.user_email/>&gt;<br/>
+			</n.loop.>
+		</n.site_users.>
+	</div>
+</macro>
+
+<macro name="new_group_panel">
+	<n.put_in_head.>
+		<script type="text/javascript">
+			function checkGroupName() {
+				var name = $('#group-name').val();
+				var isValidName = name && Nabble.trim(name).length > 0 && name != 'Authors' && name != 'authors';
+				if (!isValidName) {
+					alert('<t>The name of the group is not valid.</t>');
+					return false;
+				}
+				return true;
+			}
+		</script>
+	</n.put_in_head.>
+	<n.form. onsubmit="return checkGroupName()">
+		<div class="second-font field-title nowrap" style="margin:0">
+			<t>Group Name:</t>
+			<input id="group-name" type="text" name="group"/>
+		</div>
+		<n.short_description/>
+		<input type="hidden" name="group" value="[n.selected_group/]"/>
+		<n.users_field.textarea wrap="SOFT" style="width:100%;height:25em;margin:.3em 0" />
+		<input type="submit" value="[t]Save Changes[/t]"/>
+	</n.form.>
+</macro>
+
+<macro name="users_field" dot_parameter="do">
+	<n.field. name="users"><n.do/></n.field.>
+</macro>
+
+<macro name="get_email_address_from" dot_parameter="text">
+	<n.if.not.is_null.extract_email_address_from.text>
+		<then.extract_email_address_from.text/>
+		<else>
+			<n.if.has_authenticated_user_with_name name="[n.text/]">
+				<then>
+					<n.get_authenticated_user_with_name. name="[n.text/]">
+						<n.user_email/>
+					</n.get_authenticated_user_with_name.>
+				</then>
+			</n.if.has_authenticated_user_with_name>
+		</else>
+	</n.if.not.is_null.extract_email_address_from.text>
+</macro>
\ No newline at end of file