<%@ page import="com.atlassian.jira.ManagerFactory,
                 com.atlassian.jira.config.properties.APKeys"%>
<%@ taglib uri="webwork" prefix="webwork" %>
<%@ taglib uri="webwork" prefix="ui" %>
<%@ taglib uri="sitemesh-page" prefix="page" %>
<html>
<head>
	<title><webwork:text name="'admin.menu.usersandgroups.user.browser'"/></title>
</head>
<body>
<page:applyDecorator name="jiraform">
    <page:param name="title"><webwork:text name="'admin.menu.usersandgroups.user.browser'"/></page:param>
    <page:param name="instructions">

        <p>
        <webwork:text name="'admin.userbrowser.description'"/>
        </p>

        <% if (!ManagerFactory.getApplicationProperties().getOption(APKeys.JIRA_OPTION_USER_EXTERNALMGT)) { %>
        <p>
            <img src="<%= request.getContextPath() %>/images/icons/bullet_creme.gif" height=8 width=8 border=0 align=absmiddle>
            <b><a id="add_user" href="<%= request.getContextPath() %>/secure/admin/user/AddUser!default.jspa"><webwork:text name="'admin.userbrowser.add.user'"/></a></b>
        </p>
        <% } %>

        <p>
        <webwork:text name="'admin.userbrowser.displaying.users'">
            <webwork:param name="'value0'"><b><webwork:property value="niceStart" /></b></webwork:param>
            <webwork:param name="'value1'"><b><webwork:property value="niceEnd" /></b></webwork:param>
            <webwork:param name="'value2'"><b><webwork:property value="users/size" /></b></webwork:param>
        </webwork:text>

        <font size=1>
        (<a href="UserBrowser.jspa?emailFilter=&group=&max=<webwork:property value="filter/max"/>"><webwork:text name="'admin.userbrowser.reset.filter'"/></a>)
        </font>
    </page:param>
    <page:param name="width">100%</page:param>
    <page:param name="action">UserBrowser.jspa</page:param>
    <page:param name="columns">7</page:param>
    <page:param name="autoSelectFirst">false</page:param>

    <webwork:property value="filter">
    <tr bgcolor="#ffffff">
        <td bgcolor="#fffff0" align="right"><b><webwork:text name="'admin.userbrowser.users.per.page'"/>:</b></td>
        <ui:select label="text('admin.userbrowser.users.per.page')" name="'max'" theme="'single'"
            list="/maxValues" listKey="'.'" listValue="'.'" >
            <ui:param name="'headerrow'" value="text('common.words.all')" />
            <ui:param name="'headervalue'" value="'1000000'" />
        </ui:select>

        <td bgcolor="#fffff0" align="right"><b><webwork:text name="'admin.userbrowser.email.contains'"/>:</b></td>
        <ui:textfield label="text('admin.userbrowser.email.contains')" name="'emailFilter'" size="15" theme="'single'" />

        <td bgcolor="#fffff0" align="right"><b><webwork:text name="'admin.userbrowser.in.group'"/>:</b></td>
        <ui:select label="text('admin.userbrowser.in.group')" name="'group'" theme="'single'"
            list="/groups" listKey="'name'" listValue="'name'">
            <ui:param name="'headerrow'" value="text('common.filters.any')" />
            <ui:param name="'headervalue'" value="''" />
        </ui:select>

        <td>
            <input type="submit" value="<webwork:text name="'navigator.tabs.filter'"/>">
        </td>
    </tr>
    </webwork:property>
</page:applyDecorator>
<br>
<center>
<table  class="grid" width="100%" id="user_browser_table">
    <tr>
        <th>
            <webwork:text name="'common.words.username'"/>
        </th>
        <th>
            <webwork:text name="'common.words.email'"/>
        </th>
        <th>
            <webwork:text name="'common.words.fullname'"/>
        </th>
        <th>
            <webwork:text name="'common.words.groups'"/>
        </th>
    <% if (!ManagerFactory.getApplicationProperties().getOption(APKeys.JIRA_OPTION_USER_EXTERNALMGT)) { %>
        <th class="minNoWrap">
            <webwork:text name="'common.words.operations'"/>
        </th>
    <%  }   %>
    </tr>

    <webwork:iterator value="currentPage" status="'status'">
    <tr <webwork:if test="@status/modulus(2) == 0">bgcolor="#fffff0"</webwork:if>
            <webwork:else>bgcolor="#ffffff"</webwork:else>>
        <td ><a id="<webwork:property value="name"/>" href="<webwork:url page="ViewUser.jspa"><webwork:param name="'name'" value="name"/></webwork:url>"><webwork:property value="name"/></a></td>
        <td ><a href="<webwork:url page="ViewUser.jspa"><webwork:param name="'name'" value="name"/></webwork:url>"><webwork:property value="email"/></a></td>
        <td ><webwork:property value="fullName"/></td>
        <td  nowrap>
            <webwork:iterator value="groups">
                <webwork:property value="."/><br>
            </webwork:iterator>
        </td>

    <% if (!ManagerFactory.getApplicationProperties().getOption(APKeys.JIRA_OPTION_USER_EXTERNALMGT)) { %>
        <td class="minNoWrap">
    <a class="editgroups_link" id="editgroups_<webwork:property value="name"/>" href="<webwork:url page="EditUserGroups!default.jspa"><webwork:param name="'name'" value="name" /><webwork:param name="'returnUrl'" value="'UserBrowser.jspa'" /></webwork:url>"><webwork:text name="'common.words.groups'"/></a>
    | <a id="projectroles_link" href="<webwork:url page="ViewUserProjectRoles!default.jspa"><webwork:param name="'name'" value="name" /><webwork:param name="'returnUrl'" value="'UserBrowser.jspa'" /></webwork:url>"><webwork:text name="'common.words.project.roles'"/></a>        
    | <a href="<webwork:url page="EditUser!default.jspa"><webwork:param name="'editName'" value="name" /><webwork:param name="'returnUrl'" value="'UserBrowser.jspa'" /></webwork:url>"><webwork:text name="'common.words.edit'"/></a>
    | <a id="deleteuser_link_<webwork:property value="name"/>" href="<webwork:url page="DeleteUser!default.jspa"><webwork:param name="'name'" value="name" /><webwork:param name="'returnUrl'" value="'UserBrowser.jspa'" /></webwork:url>"><webwork:text name="'common.words.delete'"/></a>
        </td>
    <%  }   %>
    </tr>
    </webwork:iterator>
</table>

<p align="center">
    <webwork:if test="filter/start > 0">
		<a href="UserBrowser.jspa?start=<webwork:url value="filter/previousStart" />">&lt&lt; <webwork:text name="'common.forms.previous'"/></a>
	</webwork:if>

    <webwork:property value = "pager/pages(/browsableItems)">
        <webwork:if test="size > 1">
            <webwork:iterator value="." status="'pagerStatus'">
                <webwork:if test="currentPage == true"><b><webwork:property value="pageNumber" /></b></webwork:if>
                <webwork:else>
                    <a href="UserBrowser.jspa?start=<webwork:url value="start" />"><webwork:property value="pageNumber" /></a>
                </webwork:else>
                <webwork:if test="@pagerStatus/last == false"> | </webwork:if>
            </webwork:iterator>
        </webwork:if>
    </webwork:property>

	<webwork:if test="filter/end < users/size">
		<a href="UserBrowser.jspa?start=<webwork:url value="filter/nextStart" />"><webwork:text name="'common.forms.next'"/> &gt;&gt;</a>
	</webwork:if>
</p>
</center>

</body>
</html>