<tal:block tal:define="uf_obj here/getUserFolder;
					   user_tool here/getAuthenticationTool;
					   site_url here/absolute_url;
					   users_roles python:here.getUsersRoles(uf_obj);
					   skey python: request.get('skey', 'name');
					   rkey python: request.get('rkey', 1);">
<p i18n:translate="">
    This form displays the users defined in this source that have roles in the current portal.
    You can revoke a role prior assigned to a user by ticking in the appropiate check box
    and clicking the <em i18n:name="revoke-selected-roles" i18n:translate="">Revoke selected roles</em> button.
</p>
<div class="datatable">
	<table cellspacing="0" cellpadding="4"
			tal:attributes="class python:len(users_roles) and '' or 'empty'">
		<tr tal:condition="python:len(users_roles) != 0">
			<th width="15%" align="left" i18n:translate="">Username</th>
			<th i18n:translate="">Roles/Location</th>
			<th i18n:translate="">Revoke roles</th>
		</tr>
		<tr tal:repeat="user python: users_roles.keys()">
			<td tal:content="user">user</td>
			<td tal:define="user_roles python: users_roles[str(user)]">
				<div class="user-role"
					 tal:repeat="role python: user_roles">
					<tal:block condition="python: role[0]">
					<span class="roles-title" tal:content="python: ', '.join(role[0])"></span> in
					<a class="roles-location" tal:define="obj python: here.utGetObject(role[1])" tal:attributes="href obj/absolute_url" tal:content="obj/title_or_id"></a>
					</tal:block>
				</div>
				<tal:block condition="python: user_roles == [([], '')] ">-</tal:block>
			</td>
			<td tal:define="user_roles python: users_roles[str(user)]">
				<div class="user-role-revoke" tal:repeat="role python: user_roles">
					<tal:block condition="python: role[0]">
					<a class="revoke-role" i18n:attributes="title" title="Revoke role"
						tal:define="location python: role[1]"
						tal:attributes="href string:${site_url}/admin_revokerole?user=${user}&location=${location}">
						<img src="/misc_/Naaya/revoke_permission.png" alt="Revoke role" i18n:attributes="alt" />
					</a>
					</tal:block>
				</div>
			</td>
		</tr>
	</table>
</div>

<fieldset><legend i18n:translate="">Assign roles to users</legend>
<p i18n:translate="">
    Assign a new role to an existing user: select the username from the drop-down field,
    mark the intended role(s) you want to grant and choose the specific location you want to grant them to.
</p>

<tal:block define="redirect string:${here/absolute_url}; users uf_obj/getUserNames; action string:${here/absolute_url}/addUserRoles">
	<metal:block use-macro="python: here.getFormsTool().getForm('site_admin_assignroles').macros['content']">
		<metal:block fill-slot="usernames">
			<div class="field">
				<label for="name" i18n:translate="">User</label>
				<select name="name" id="name">
					<option tal:repeat="item uf_obj/getUserNames"
						tal:attributes="value item" tal:content="item">User</option>
				</select>
			</div>
		</metal:block>
		<metal:block fill-slot="notification">
			<div class="field-inline">
				<input type="checkbox" id="send_mail" name="send_mail" checked="checked" />
				<label class="form-label" for="send_mail" i18n:translate="">Send notification email to user</label>
			</div>
		</metal:block>
	</metal:block>
	</tal:block>
</tal:block>
