<metal:block extend-macro="python:here.getFormsTool().getForm('site_admin_template').macros['page']" define-macro="page">
<metal:block metal:fill-slot="title">
	<h1>
		<metal:block define-slot="title"><span tal:omit-tag="" i18n:translate="">User management</span></metal:block>
		<tal:block tal:condition="python: 'admin_users_html' not in request.PATH_INFO">-</tal:block>
		<metal:block define-slot="second-title"></metal:block>
	</h1>
</metal:block>
<tal:block metal:fill-slot="section"
    tal:define="site_url here/getSitePath;
                user_tool here/getAuthenticationTool;
                skey python: request.get('skey', 'name');
                rkey python: int(request.get('rkey', 0));
				query python: request.get('query', '');
				page python: int(request.get('page', 0));
				per_page python: int(request.get('per_page', 50));
				filter_role python: request.get('role', '');
				filter_location python: request.get('location', '_all_');
				user_sources python: here.getAuthenticationTool().getSources();
				path_info python: request.PATH_INFO">
	<script type="text/javascript"
		tal:attributes="src string:${user_tool/absolute_url}/admin_js"></script>
<metal:block define-slot="buttons">
	<tal:block tal:condition="python: 'admin_users_html' in path_info">
		<metal:block use-macro="python: here.getFormsTool().getForm('site_admin_local_users').macros['buttons']"></metal:block>
	</tal:block>
</metal:block>

<div class="floated-buttons">
	&nbsp;
</div>

<metal:block define-slot="tabs"><metal:block define-macro="tabs">
<div class="tabbedmenu" tal:define="toggle_all_users python:len(user_sources)>0">
    <ul>
        <li tal:condition='user_sources'
			tal:attributes="class python: (
								('admin_all_users_html' in path_info) or
								('admin_users_html' in path_info) or
								('admin_edituser_html' in path_info and request.get('from', '')  == 'all')
							) and 'currenttab' or ''">
			<a tal:attributes="href string:${site_url}/admin_all_users_html" i18n:translate="">All users</a>
		</li>
        <li tal:repeat="item user_sources"
			tal:attributes="class python: ('admin_sources_html' in path_info and request.get('id', '') == item.id) and 'currenttab' or ''">
            <a tal:attributes="href string:${site_url}/admin_sources_html?id=${item/id}" tal:content="string:${item/title_or_id} users">source</a>
        </li>
		<li tal:attributes="class python: (
								('admin_local_users_html' in path_info) or
								('admin_assignroles_html' in path_info) or
								('admin_adduser_html' in path_info) or
								('admin_users_html' in path_info and not len(user_sources)) or
								('admin_edituser_html' in path_info and request.get('from', '')  == 'local')
							) and 'currenttab' or ''">
			<a tal:attributes="href string:${site_url}/admin_local_users_html" i18n:translate="">Local users</a>
		</li>
		<li tal:condition="python: here.checkPermission('Change permissions')"
		    tal:attributes="class python: (
								('admin_roles_html' in path_info) or
								('admin_editrole_html' in path_info)
							) and 'currenttab' or ''">
			<a tal:attributes="href string:${site_url}/admin_roles_html" i18n:translate="">Roles</a>
		</li>
    </ul>
</div>
</metal:block></metal:block>

<metal:block define-slot='second-tabs'>
	<tal:block tal:condition="python: 'admin_users_html' in path_info and len(user_sources) == 0">
		<metal:block use-macro="python: here.getFormsTool().getForm('site_admin_local_users').macros['second-tabs']"></metal:block>
	</tal:block>
</metal:block>

<metal:block define-slot="description-text">
	<div class="cleaner">&nbsp;</div>
	<div class="description-text">
		<p i18n:translate="" tal:condition="user_sources">
			This page lists all local users defined in this portal (with or without roles), together with the LDAP users and LDAP groups that have roles in this portal.
        </p>
		<p i18n:translate="" tal:condition="not:user_sources">
			This page lists the users defined in this portal along with their credentials.
			Click on a username to modify the corresponding information.
        </p>
	</div>
</metal:block>

<metal:block define-slot="section-title">
<tal:block condition="user_sources">
	<h3 i18n:translate="">
		Users list
	</h3>
</tal:block>
</metal:block>

<metal:block define-slot="content">
	<tal:block condition="user_sources"><metal:block use-macro="python: here.getFormsTool().getForm('site_admin_all_users').macros['content']"></metal:block></tal:block>
	<tal:block condition="not: user_sources"><metal:block use-macro="python: here.getFormsTool().getForm('site_admin_local_users').macros['content']"></metal:block></tal:block>
</metal:block>
</tal:block>
</metal:block>
