<%--
  The contents of this file are subject to the Mozilla Public License Version 1.1
  (the "License"); you may not use this file except in compliance with the License.
  You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.

  Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
  WARRANTY OF ANY KIND, either express or implied. See the License for the specific
  language governing rights and limitations under the License.
  
  The Original Code is the Venice Web Communities System.
  
  The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
  for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
  Copyright (C) 2001-02 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.

  Contributor(s): 
--%>
<%@ page import = "java.util.Iterator" %>
<%@ page import = "java.util.List" %>
<%@ page import = "com.silverwrist.venice.core.*" %>
<%@ page import = "com.silverwrist.venice.security.Role" %>
<%@ page import = "com.silverwrist.venice.ui.conf.view.ConfMemberView" %>
<%@ taglib uri="/tlds/util" prefix="util" %>
<%@ taglib uri="/tlds/community" prefix="comm" %>
<%@ taglib uri="/tlds/conference" prefix="conf" %>
<%
  ConfMemberView view = ConfMemberView.get(request);
%>
<util:comment>Set membership view for conference <conf:name/></util:comment>
<util:header title="Set Conference Membership:">
  <util:subtitle><util:escape><conf:name/></util:escape></util:subtitle>
</util:header>

<util:font color="content.fg" size="content"><util:xlink>
  <util:href type="servlet">conf/membership.js.vs?cc=<comm:ID/>&conf=<conf:ID/></util:href>
  <util:text>Redisplay Member List</util:text>
</util:xlink>&nbsp;|&nbsp;<util:xlink>
  <util:href type="servlet">conf/manage_conf.js.vs?cc=<comm:ID/>&conf=<conf:ID/></util:href>
  <util:text>Return to Manage Conference Menu</util:text>
</util:xlink></util:font><P>

<util:font color="content.fg" size="subhead"><B>Find Members of Community "<comm:name/>":</B></util:font><P>
<util:form action="conf/membership.js.vs" type="servlet"><DIV CLASS="content">
  <INPUT TYPE="HIDDEN" NAME="cc" VALUE="<comm:ID/>">
  <INPUT TYPE="HIDDEN" NAME="conf" VALUE="<conf:ID/>">
  <INPUT TYPE="HIDDEN" NAME="sl" VALUE="0">
  <INPUT TYPE="HIDDEN" NAME="ofs" VALUE="0">
  <util:font color="content.fg" size="content">
    Display all community members whose&nbsp;&nbsp;
    <SELECT NAME="field" SIZE=1>
      <OPTION VALUE="<%= SearchMode.FIELD_USER_NAME %>"
      <% if (view.testField(SearchMode.FIELD_USER_NAME)) { %>SELECTED<% } %> >user name</OPTION>
      <OPTION VALUE="<%= SearchMode.FIELD_USER_DESCRIPTION %>"
      <% if (view.testField(SearchMode.FIELD_USER_DESCRIPTION)) { %>SELECTED<% } %> >description</OPTION>
      <OPTION VALUE="<%= SearchMode.FIELD_USER_GIVEN_NAME %>"
      <% if (view.testField(SearchMode.FIELD_USER_GIVEN_NAME)) { %>SELECTED<% } %> >first name</OPTION>
      <OPTION VALUE="<%= SearchMode.FIELD_USER_FAMILY_NAME %>"
      <% if (view.testField(SearchMode.FIELD_USER_FAMILY_NAME)) { %>SELECTED<% } %> >last name</OPTION>
    </SELECT><BR>

    <SELECT NAME="mode" SIZE=1>
      <OPTION VALUE="<%= SearchMode.SEARCH_PREFIX %>"
      <% if (view.testMode(SearchMode.SEARCH_PREFIX)) { %>SELECTED<% } %> >starts with the string</OPTION>
      <OPTION VALUE="<%= SearchMode.SEARCH_SUBSTRING %>"
      <% if (view.testMode(SearchMode.SEARCH_SUBSTRING)) { %>SELECTED<% } %> >contains the string</OPTION>
      <OPTION VALUE="<%= SearchMode.SEARCH_REGEXP %>"
      <% if (view.testMode(SearchMode.SEARCH_REGEXP)) { %>SELECTED<% } %> >matches the regular
      expression</OPTION>
    </SELECT>

    <SPAN CLASS="cinput"><INPUT TYPE=TEXT CLASS="cinput" NAME="term" SIZE=32 MAXLENGTH=255
                                VALUE="<%= view.getTerm() %>"></SPAN><BR>
    <util:button id="search" type="input"/>
  </util:font>
</DIV></util:form>

<% List results = view.getResults(); %>
<% if (results!=null) { %>
  <HR>
  <%
    int dcount = results.size();
    // Determine the number of results to display and whether to display a "next" button
    boolean go_next = false;
    if (dcount>view.getMaxResults())
    { // there's a "next"
      dcount = view.getMaxResults();
      go_next = true;

    } // end if
  %>
  <TABLE WIDTH="100%" BORDER=0 ALIGN=CENTER><TR VALIGN=MIDDLE>
    <TD WIDTH="50%" ALIGN=LEFT CLASS="content"><util:font color="content.fg" size="content">
      <%-- The conference members/search results header --%>
      <FONT SIZE=+1><B>
        <% if (view.getSimple()) { %>Conference Members:<% } else { %>Search Results:<% } %>
      </B></FONT>
      (Displaying <%= view.getOffset() + 1 %>-<%= view.getOffset() + dcount %> of
      <%= view.getFindCount() %>)
    </util:font></TD>

    <TD WIDTH="50%" ALIGN=RIGHT CLASS="content">
      <% if (go_next || (view.getOffset()>0)) { %>
        <%-- The navigational form that allows us to page through the results --%>
        <util:comment>Navigational Form</util:comment>
        <util:form action="conf/membership.js.vs" type="servlet"><DIV CLASS="content">
          <INPUT TYPE=HIDDEN NAME="cc" VALUE="<comm:ID/>">
          <INPUT TYPE=HIDDEN NAME="conf" VALUE="<conf:ID/>">
          <INPUT TYPE=HIDDEN NAME="sl" VALUE="<%= view.getSimple() ? 1 : 0 %>">
          <INPUT TYPE=HIDDEN NAME="ofs" VALUE="<%= view.getOffset() %>">
          <INPUT TYPE=HIDDEN NAME="field" VALUE="<%= view.getField() %>">
          <INPUT TYPE=HIDDEN NAME="mode" VALUE="<%= view.getMode() %>">
          <INPUT TYPE=HIDDEN NAME="term" VALUE="<%= view.getTerm() %>">
          <INPUT TYPE=HIDDEN NAME="fcount" VALUE="<%= view.getFindCount() %>">
          <% if (view.getOffset()>0) { %>
            <util:button id="previous" type="input"/>
          <% } else { %>
            <util:button id="_null_"/>
          <% } // end if %>
          &nbsp;
          <% if (go_next) { %>
            <util:button id="next" type="input"/>
          <% } else { %>
            <util:button id="_null_"/>
          <% } // end if %>
        </DIV></util:form>
      <% } else { %>&nbsp;<% } %>
    </TD>
  </TR></TABLE><BR>

  <%-- Display the results of the search --%>
  <% if (results.size()>0) { %>
    <util:comment>Update Form</util:comment>
    <util:form action="conf/membership.js.vs" type="servlet"><DIV CLASS="content">
      <INPUT TYPE=HIDDEN NAME="cc" VALUE="<comm:ID/>">
      <INPUT TYPE=HIDDEN NAME="conf" VALUE="<conf:ID/>">
      <INPUT TYPE=HIDDEN NAME="sl" VALUE="<%= view.getSimple() ? 1 : 0 %>">
      <INPUT TYPE=HIDDEN NAME="ofs" VALUE="<%= view.getOffset() %>">
      <INPUT TYPE=HIDDEN NAME="field" VALUE="<%= view.getField() %>">
      <INPUT TYPE=HIDDEN NAME="mode" VALUE="<%= view.getMode() %>">
      <INPUT TYPE=HIDDEN NAME="term" VALUE="<%= view.getTerm() %>">
      <INPUT TYPE=HIDDEN NAME="fcount" VALUE="<%= view.getFindCount() %>">
      <% StringBuffer buf = new StringBuffer(":"); %>
      <TABLE BORDER=0 ALIGN=LEFT CELLPADDING=0 CELLSPACING=4>
        <% for (int i=0; i<dcount; i++) { %>
          <TR VALIGN=TOP>
            <% UserFound uf = (UserFound)(results.get(i)); %>
            <% buf.append(uf.getUID()).append(":"); %>
            <TD ALIGN=CENTER WIDTH=14><util:stdbullet/></TD>
            <TD ALIGN=LEFT CLASS="content"><util:font color="content.fg" size="content">
              <util:xlink>
                <util:href type="servlet">user/<%= uf.getName() %></util:href>
                <util:text><%= uf.getName() %></util:text>
              </util:xlink>
            </util:font></TD>
            <TD>&nbsp;&nbsp;</TD>
            <TD ALIGN=LEFT CLASS="content">
              <INPUT TYPE=HIDDEN NAME="zxcur_<%= uf.getUID() %>" VALUE="<%= uf.getLevel() %>">
              <SELECT NAME="zxnew_<%= uf.getUID() %>" SIZE=1>
                <% Iterator it = view.getRoleList().iterator(); %>
                <% while (it.hasNext()) { %>
                  <% Role r = (Role)(it.next()); %>
                  <OPTION VALUE="<%= r.getLevel() %>" <% if (r.getLevel()==uf.getLevel()) { %>SELECTED<% } %> ><util:escape><%= r.getName() %></util:escape></OPTION>
                <% } // end while %>
              </SELECT>
            </TD>
          </TR>
        <% } // end for %>
      </TABLE><BR CLEAR=LEFT>
      <INPUT TYPE=HIDDEN NAME="listuids" VALUE="<%= buf.toString() %>">
      <util:button id="update" type="input"/>
    </DIV></util:form>
  <% } // end if %>
<% } // end if %>
