people.naml

<macro name="app_people" requires="servlet">
	<n.app_people_caching/>
	<n.node_page.>
		<n.html>
			<head>
				<n.people_head/>
			</head>
			<body>
				<n.people_header/>
				<n.people_tabbed_pane/>
			</body>
		</n.html>
	</n.node_page.>
</macro>

<macro name="app_people_caching">
	<n.if.not.is_online_users>
		<then.uncache_for.>
			<n.new_user/>
			<n.user_group_change/>
		</then.uncache_for.>
	</n.if.not.is_online_users>
</macro>

<macro name="people_head">
	<n.people_title/>
	<n.if.is_null.people_filter>
		<then>
			<META NAME="description" CONTENT="[t]People in [t.location.page_node.subject/][/t]"/>
			<META NAME="keywords" CONTENT="[n.page_node.subject/], users, posters, members, administrators, community"/>
		</then>
	</n.if.is_null.people_filter>
</macro>

<macro name="people_title">
	<n.title.>
		<t>People in <t.location.page_node.subject/></t>
		<n.if.not.is_null.people_filter>
			<then>(<n.people_filter/>)</then>
		</n.if.not.is_null.people_filter>
	</n.title.>
</macro>

<macro name="people_header">
	<h2 class="weak-color">
		<img src="/images/people.png" class="image24" alt="[t]People[/t]"/>
		<t>People in <t.location.page_node.subject/></t>
	</h2>
</macro>

<macro name="people_tabbed_pane">
	<div style="margin:.5em 0">
		<n.horizontal_tab_control.>
			<n.add_horizontal_tab
				url="[n.page_node.people_path/]"
				text="[t]Users & Groups[/t]"
				selected="[n.not.is_online_users/]"
				details="[n.visible_users_table.people_columns/]"
			/>
			<n.add_horizontal_tab
				url="[n.page_node.people_path filter='online-users'/]"
				text="[t]Online Users[/t]"
				selected="[n.is_online_users/]"
				details="[n.online_users_table.people_columns/]"
			/>
		</n.horizontal_tab_control.>
	</div>
</macro>

<macro name="people_columns">
	<n.set_visitor_online/>
	<n.user_column width="70%"/>
	<n.user_state_column/>
	<n.user_post_count_column/>
</macro>

<macro name="online_users_table" dot_parameter="columns" requires="node_page">
	<n.online_users. include_invisible_users="[n.visitor.is_site_admin/]">
		<n.filter_by.current_user.can_view.page_node/>
		<n.sort_by_node_count_desc/>
		<n.people_table.>
			<n.columns/>
		</n.people_table.>
	</n.online_users.>
	
	<div class="weak-color" style="margin-top:1em">
		<n.one_or_many.online_anonymous_users_count>
			<one_text><t>anonymous user</t></one_text>
			<many_text><t>anonymous users</t></many_text>
		</n.one_or_many.online_anonymous_users_count>
		<br/>
		<n.one_or_many.online_invisible_users_count>
			<one_text><t>invisible user</t></one_text>
			<many_text><t>invisible users</t></many_text>
		</n.one_or_many.online_invisible_users_count>
	</div>
</macro>

<macro name="visible_users_list" dot_parameter="do" requires="node_page">
	<n.if.is_null.people_filter>
		<then>
			<n.if.page_node.allows_showing_members_of.registered_group>
				<then>
					<n.site_users. start="0" length="99999" filter="[n.registered_filter/]">
						<n.filter_by.current_user.not.is_banned/>
						<n.do/>
					</n.site_users.>
				</then>
				<else>
					<!-- get the first group available -->
					<n.available_groups.>
						<n.if.next_element>
							<then>
								<n.users_in_group. group="[n.current_group/]">
									<n.filter_by.current_user.both condition1="[n.not.is_deactivated/]" condition2="[n.not.is_banned/]"/>
									<n.sort_by_node_count_desc/>
									<n.do/>
								</n.users_in_group.>
							</then>
							<else.empty_users_list.do/>
						</n.if.next_element>
					</n.available_groups.>
				</else>
			</n.if.page_node.allows_showing_members_of.registered_group>
		</then>
		<else>
			<!-- get the filtered group -->
			<n.if.page_node.allows_showing_members_of.people_filter>
				<then>
					<n.users_in_group. group="[n.people_filter/]">
						<n.filter_by.current_user.both condition1="[n.not.is_deactivated/]" condition2="[n.not.is_banned/]"/>
						<n.sort_by_node_count_desc/>
						<n.do/>
					</n.users_in_group.>
				</then>
				<else.empty_users_list.do/>
			</n.if.page_node.allows_showing_members_of.people_filter>
		</else>
	</n.if.is_null.people_filter>
</macro>

<macro name="visible_users_table" dot_parameter="columns" requires="node_page">
	<n.visible_users_list.>
		<n.show_people_filter total_rows="[n.element_count/]"/>
		<n.people_pagination total_rows="[n.element_count/]" />
		<n.sub_list. start="[n.people_page_index_record/]" length="[n.people_page_length/]">
			<n.people_table.>
				<n.columns/>
			</n.people_table.>
		</n.sub_list.>
	</n.visible_users_list.>
</macro>

<macro name="show_people_filter" parameters="total_rows" requires="node_page">
	<n.put_in_head.>
		<script type="text/javascript">
			$(document).ready(function() {
				function applyFilter() {
					window.location = $('#filter').val();
				};
				$('#filter').change(applyFilter);
			});
		</script>
	</n.put_in_head.>
	<div class="nowrap float-left" style="margin-bottom:.3em">
		<b><t>Filter by group</t></b>
		<select id="filter">
			<n.if.page_node.allows_showing_members_of.registered_group>
				<then.select_option value="[n.page_node.people_path/]" text="[t]Registered Users[/t]"/>
			</n.if.page_node.allows_showing_members_of.registered_group>

			<n.available_groups.loop.>
				<n.select_option value="[n.page_node.people_path.current_group/]" selectedValue="[n.page_node.people_path.people_filter/]" text="[n.current_group/]"/>
			</n.available_groups.loop.>
		</select>

		<span class="bold" style="padding-left:1em">
			<n.one_or_many.total_rows>
				<one_text><t>user</t></one_text>
				<many_text><t>users</t></many_text>
			</n.one_or_many.total_rows>
		</span>
	</div>
</macro>

<macro name="available_groups" dot_parameter="do" requires="node_page">
	<n.page_node.groups_with_permission. permission="[n.show_group_members_permission/]">
		<n.remove.registered_group/>
		<n.sort/>
		<n.do/>
	</n.page_node.groups_with_permission.>
</macro>

<macro name="people_table" dot_parameter="columns" requires="user_list">
	<n.put_in_head.>
		<style type="text/css">
			table.people {
				width:100%;
				border-collapse:collapse;
				clear:both;
			}
			table.people td {
				padding:.1em .3em;
			}
			tr.header-row td {
				font-weight:bold;
				padding: .3em;
			}
		</style>
	</n.put_in_head.>
	<n.zebra_table_javascript table_selector="table.people"/>

	<table class="people">
		<n.table_header.>
			<tr class="header-row shaded-bg-color">
				<n.columns/>
			</tr>
		</n.table_header.>
		<n.loop.>
			<tr class="people-row">
				<n.columns/>
			</tr>
		</n.loop.>
	</table>
</macro>

<macro name="user_column" parameters="title,width" requires="user_list">
	<n.table_column>
		<head>
			<td style="[n.width_style.width/]">
				<n.default. to="[t]Name[/t]"><n.title/></n.default.>
			</td>
		</head>
		<body>
			<td class="weak-color">
				<table class="avatar-table">
					<tr>
						<td style="padding:0;vertical-align:top">
							<n.current_user.avatar size="small"/>
						</td>
						<td class="nowrap" style="width:100%;padding:0 .3em">
							<n.current_user.user_link/>
						</td>
					</tr>
				</table>
			</td>
		</body>
	</n.table_column>
</macro>

<macro name="user_state_column" parameters="title,width" requires="user_list">
	<n.table_column>
		<head>
			<td></td>
		</head>
		<body>
			<td class="weak-color">
				<n.if.current_user.is_anonymous>
					<then><t>Anonymous</t></then>
					<else>
						<n.if.current_user.is_registered>
							<then><t>Registered</t></then>
							<else>
								<n.if.current_user.is_deactivated>
									<then><t>Unregistered / Deactivated</t></then>
									<else><t>Unregistered</t></else>
								</n.if.current_user.is_deactivated>
							</else>
						</n.if.current_user.is_registered>
					</else>
				</n.if.current_user.is_anonymous>
			</td>
		</body>
	</n.table_column>
</macro>

<macro name="user_post_count_column" parameters="title,width" requires="user_list">
	<n.table_column>
		<head>
			<td class="nowrap" style="text-align:center;[n.width_style.width/]">
				<n.default. to="[t]Post Count[/t]"><n.title/></n.default.>
			</td>
		</head>
		<body>
			<td class="weak-color" style="text-align:center">
				<n.current_user.node_count/>
			</td>
		</body>
	</n.table_column>
</macro>

<macro name="people_pagination" parameters="total_rows" requires="node_page">
	<n.paging.
		total_rows="[n.total_rows/]"
		current_row="[n.people_page_index_record/]"
		rows_per_page="[n.people_page_length/]"
	>
		<n.generic_paging>
			<margin>.55em .2em</margin>
			<url><n.page_node.people_path filter="[n.people_filter/]" index_record="[n.page_row/]"/></url>
		</n.generic_paging>
	</n.paging.>
</macro>

<macro name="people_path" requires="node" dot_parameter="filter" parameters="index_record">
	<n.encode_url.remove_spaces.>
		/template/NamlServlet.jtp?macro=app_people&node=<n.id/>
		<n.add_to_path name="filter" value="[n.filter/]"/>
		<n.add_to_path name="i" value="[n.index_record/]" default_value="0"/>
	</n.encode_url.remove_spaces.>
</macro>

<macro name="people_filter" requires="servlet">
	<n.get_parameter name="filter"/>
</macro>

<macro name="people_page_index_record">
	<n.get_parameter name="i"/>	
</macro>

<macro name="people_page_length">
	20
</macro>

<macro name="is_online_users">
	<n.is_people_filter value='online-users' />
</macro>

<macro name="is_people_filter" parameters="value">
	<n.equal value1="[n.people_filter/]" value2="[n.value/]" />
</macro>

<macro name="empty_users_list" dot_parameter="do">
	<n.site_users. start="0" length="0">
		<n.do/>
	</n.site_users.>
</macro>