<!DOCTYPE html >
<html lang="en">
<head>
  <title><%cat_full_name%>: Member Directory<%if this_do eq 'user_search'%> Search Results<%endif%></title>
  <%include include_common_head.html%>
</head>
<%~if this_do eq user_search%>
<%~set url_header = GForum::SEO::url(params => "do=user_list")%>
<%~set content_header_breadcrumb = "<a href=$url_header>Member Directory</a>"%>
<%~set content_header_title = 'Search Results'%>
<%~else%>
<%~set content_header_title = 'Member Directory'%>
<%~endif%>

<%~set hidden_sort = ''%><%set hidden_page = ''%>
<%~if in.sb%><%set hidden_sort .= ";sb=$sb"%><%endif%>
<%~if in.so%><%set hidden_sort .= ";so=$so"%><%endif%>
<%~if in.mh%><%set hidden_page .= ";mh=$mh"%><%endif%>
<%~set mh = $in.mh%>
<%~set mh ||= $current.user_default_mh_user%>
<%~set mh ||= $config.default_mh_user%>

<body class="page-<%page_id%>">
  <div class="container-b">
    <%include include_header.html%>

    <div class="main">
      <div class="contentwrapper clearfix">
        <div class="sidebar">
            <%include include_sidebar.html%>
        </div>

        <%~init array breadcrumbs%><%init hash breadcrumbs.0%>
        <%~set breadcrumbs.0.name = $content_header_title%>

        <%include include_breadcrumb.html%>

        <div class="content"><%-- start content--%>
          <%include include_content_header.html%>

          <p class="tab-description">
          <%~if this_do eq user_search%>
            Your search returned <%num_page_items%> result<%if num_page_items != 1%>s<%endif%>.
          <%~elsif this_do eq user_list and first%>
            <%num_page_items%> user<%if num_page_items != 1%>s<%endif%> found starting with <%if first eq NUM%>0 - 9<%elsif first eq OTHER%>Other<%else%>'<%first%>'<%endif%>.
          <%~else%>
            There are <%registered_users%> registered users.
          <%~endif%>
          </p>

          <form action="<%GForum::SEO::url()%>" class="member-search">
            <input type="hidden" name="do" value="user_search" />
          <%~-- search_bool, when set to 'or', makes multiple field searches return any
               records with any matches, rather than those will all fields matched --%>
            <input type="hidden" name="search_bool" value="or" />
            <%hidden_form%>Search

            <input type="text" name="search_field" value="<%search_field || ''%>" class="txt shotext" placeholder="Search keyword..." />
            <select name="search_column">
            <%~-- Search usernames: --%>
              <option value="user_username"<%if search_column eq 'user_username'%> selected="selected"<%endif%>>Username</option>
            <%~-- Search e-mail addresses (but only the display addresses): --%>
              <option value="user_disp_email"<%if search_column eq 'user_disp_email'%> selected="selected"<%endif%>>E-Mail Address</option>
            <%~-- Search real names: --%>
              <option value="user_real_name"<%if search_column eq 'user_real_name'%> selected="selected"<%endif%>>Real Name</option>
            <%~-- Search minimum number of posts: --%>
              <option value="user_posts-ge"<%if search_column eq 'user_posts-ge'%> selected="selected"<%endif%>>Number of Posts</option>
            <%~-- The following are other options you might want to add.  To add an option,
                 simply remove the '<%--' at the beginning of the line, and '--%>' at the
                 end of the line --%>

            <%~-- Search usernames, e-mail addresses, and real names: --%>
            <%~--
              <option value="user_username,user_disp_email,user_real_name"<%if search_column eq 'user_username,user_disp_email,user_real_name'%> selected="selected"<%endif%>>Username, E-mail, or Name</option>
            --~%>

            <%~-- Search for users with fewer than this many posts: --%>
            <%~--
              <option value="user_posts-lt"<%if search_column eq 'user_posts-lt'%> selected="selected"<%endif%>>Fewer than posts</option>
            --~%>
            </select>

            <input type="submit" value="Search Users" class="btn" />
          </form>

          <%~if this_do eq user_list%>
          <%~set base_url = GForum::SEO::url(params => "do=user_list;sb=user_username;so=")%>
          <%~if so%>
            <%~set base_url .= $so%>
          <%~else%>
            <%~set base_url .= 'ASC'%>
          <%~endif%>
          <div class="row">
            <div class="alphabet-list">
              <%if first eq NUM%><b>0-9</b><%elsif has_num%><a href="<%base_url%>;first=NUM<%hidden_page%><%hidden_url%>">0-9</a><%else%>0-9<%endif%>
              <%if first eq A%><b>A</b><%elsif has_a%><a href="<%base_url%>;first=A<%hidden_page%><%hidden_url%>">A</a><%else%>A<%endif%>
              <%if first eq B%><b>B</b><%elsif has_b%><a href="<%base_url%>;first=B<%hidden_page%><%hidden_url%>">B</a><%else%>B<%endif%>
              <%if first eq C%><b>C</b><%elsif has_c%><a href="<%base_url%>;first=C<%hidden_page%><%hidden_url%>">C</a><%else%>C<%endif%>
              <%if first eq D%><b>D</b><%elsif has_d%><a href="<%base_url%>;first=D<%hidden_page%><%hidden_url%>">D</a><%else%>D<%endif%>
              <%if first eq E%><b>E</b><%elsif has_e%><a href="<%base_url%>;first=E<%hidden_page%><%hidden_url%>">E</a><%else%>E<%endif%>
              <%if first eq F%><b>F</b><%elsif has_f%><a href="<%base_url%>;first=F<%hidden_page%><%hidden_url%>">F</a><%else%>F<%endif%>
              <%if first eq G%><b>G</b><%elsif has_g%><a href="<%base_url%>;first=G<%hidden_page%><%hidden_url%>">G</a><%else%>G<%endif%>
              <%if first eq H%><b>H</b><%elsif has_h%><a href="<%base_url%>;first=H<%hidden_page%><%hidden_url%>">H</a><%else%>H<%endif%>
              <%if first eq I%><b>I</b><%elsif has_i%><a href="<%base_url%>;first=I<%hidden_page%><%hidden_url%>">I</a><%else%>I<%endif%>
              <%if first eq J%><b>J</b><%elsif has_j%><a href="<%base_url%>;first=J<%hidden_page%><%hidden_url%>">J</a><%else%>J<%endif%>
              <%if first eq K%><b>K</b><%elsif has_k%><a href="<%base_url%>;first=K<%hidden_page%><%hidden_url%>">K</a><%else%>K<%endif%>
              <%if first eq L%><b>L</b><%elsif has_l%><a href="<%base_url%>;first=L<%hidden_page%><%hidden_url%>">L</a><%else%>L<%endif%>
              <%if first eq M%><b>M</b><%elsif has_m%><a href="<%base_url%>;first=M<%hidden_page%><%hidden_url%>">M</a><%else%>M<%endif%>
              <%if first eq N%><b>N</b><%elsif has_n%><a href="<%base_url%>;first=N<%hidden_page%><%hidden_url%>">N</a><%else%>N<%endif%>
              <%if first eq O%><b>O</b><%elsif has_o%><a href="<%base_url%>;first=O<%hidden_page%><%hidden_url%>">O</a><%else%>O<%endif%>
              <%if first eq P%><b>P</b><%elsif has_p%><a href="<%base_url%>;first=P<%hidden_page%><%hidden_url%>">P</a><%else%>P<%endif%>
              <%if first eq Q%><b>Q</b><%elsif has_q%><a href="<%base_url%>;first=Q<%hidden_page%><%hidden_url%>">Q</a><%else%>Q<%endif%>
              <%if first eq R%><b>R</b><%elsif has_r%><a href="<%base_url%>;first=R<%hidden_page%><%hidden_url%>">R</a><%else%>R<%endif%>
              <%if first eq S%><b>S</b><%elsif has_s%><a href="<%base_url%>;first=S<%hidden_page%><%hidden_url%>">S</a><%else%>S<%endif%>
              <%if first eq T%><b>T</b><%elsif has_t%><a href="<%base_url%>;first=T<%hidden_page%><%hidden_url%>">T</a><%else%>T<%endif%>
              <%if first eq U%><b>U</b><%elsif has_u%><a href="<%base_url%>;first=U<%hidden_page%><%hidden_url%>">U</a><%else%>U<%endif%>
              <%if first eq V%><b>V</b><%elsif has_v%><a href="<%base_url%>;first=V<%hidden_page%><%hidden_url%>">V</a><%else%>V<%endif%>
              <%if first eq W%><b>W</b><%elsif has_w%><a href="<%base_url%>;first=W<%hidden_page%><%hidden_url%>">W</a><%else%>W<%endif%>
              <%if first eq X%><b>X</b><%elsif has_x%><a href="<%base_url%>;first=X<%hidden_page%><%hidden_url%>">X</a><%else%>X<%endif%>
              <%if first eq Y%><b>Y</b><%elsif has_y%><a href="<%base_url%>;first=Y<%hidden_page%><%hidden_url%>">Y</a><%else%>Y<%endif%>
              <%if first eq Z%><b>Z</b><%elsif has_z%><a href="<%base_url%>;first=Z<%hidden_page%><%hidden_url%>">Z</a><%else%>Z<%endif%>
              <%if first eq OTHER%><b>Other</b><%elsif has_other%><a href="<%base_url%>;first=OTHER<%hidden_page%><%hidden_url%>">Other</a><%endif%>
              <%if not first%><b>All</b><%else%><a href='<%GForum::SEO::url(params => "do=user_list$hidden_page")%>'>All</a><%endif%>
            </div>
          </div>
          <%endif%>

          <div class="dtable">
            <div class="dhead">
              <div class="drow">
                <div class="dcell username">
                  <%~if sb eq user_username and so ieq asc%><%set url_so = 'desc'%><%else%><%set url_so = 'asc'%><%endif%>
                  <%~if first%><%set first = escape_url first%><%set first = ";first=$first"%><%else%><%set first = ""%><%endif%>
                  <a href='<%GForum::SEO::url(params => "do=$this_do;sb=user_username;so=$url_so$hidden_page")%>' title="Sort by Username">
                    Username
                    <%~if sb eq user_username%> <span class="<%if so ieq asc%>ascending<%else%>descending<%endif%>"></span><%endif~%>
                  </a>
                </div>
                <div class="dcell online">Online</div>
                <div class="dcell nickname">Title</div>
                <div class="dcell posts">
                  <%~if sb eq user_posts and so ieq asc%><%set url_so = 'desc'%><%else%><%set url_so = 'asc'%><%endif%>
                  <%~if first%><%set first = escape_url first%><%set first = ";first=$first"%><%else%><%set first = ""%><%endif%>
                  <a href='<%GForum::SEO::url(params => "do=$this_do;sb=user_posts;so=$url_so$hidden_page")%>' title="Sort by Post count"><%~%>
                    Posts
                    <%~if sb eq user_posts%> <span class="<%if so ieq asc%>ascending<%else%>descending<%endif%>"></span><%endif~%>
                  </a>
                </div>
                <div class="dcell date">
                  <%~if sb eq user_last_seen and so ieq asc%><%set url_so = 'desc'%><%else%><%set url_so = 'asc'%><%endif%>
                  <%~if first%><%set first = escape_url first%><%set first = ";first=$first"%><%else%><%set first = ""%><%endif%>
                  <a href='<%GForum::SEO::url(params => "do=$this_do;sb=user_last_seen;so=$url_so$hidden_page")%>' title="Sort by Post count"><%~%>
                    Last seen
                    <%~if sb eq user_last_seen%> <span class="<%if so ieq asc%>ascending<%else%>descending<%endif%>"></span><%endif~%>
                  </a>
                </div>
              </div>
            </div>
            <div class="dbody">
              <%~loop users%>
              <div class="drow">
                <div class="dcell username">
                  <%~if current.user_status == $ADMINISTRATOR%>
                    <%include include_username.html%>  
                    <%if user_status == $ADMINISTRATOR%><%-- Admin users cannot disable/enable other admin users --~%>
                     &mdash; Disable
                    <%elsif user_enabled~%>
                     &mdash; <a href='<%GForum::SEO::url(params => "do=disable_user;redo=$this_do;user_id=$user_id")%>' title="Disable this user account" rel="post-only">Disable</a>
                    <%else~%>
                     &mdash; <a href='<%GForum::SEO::url(params => "do=enable_user;redo=$this_do;user_id=$user_id")%>' title="User account is currently disabled" rel="post-only">Enable</a>
                    <%endif%>
                  <%~else%>
                    <%include include_username.html%>
                  <%~endif%>
                  &mdash; <a href="<%GForum::SEO::url(params => "do=message;user_username=$user_username")%>">Message</a>
                </div>
                <div class="dcell online">
                  <%~if user_invisible and current.user_status < $ADMINISTRATOR%>No
                  <%~elsif user_online%>Yes
                  <%~else%>No
                  <%~endif~%>
                </div>
                <div class="dcell nickname"><%user_title%></div>
                <%~set url_user_username = escape_url unescape_html $user_username%>
                <div class="dcell posts"><%if user_posts%><a href='<%GForum::SEO::url(params => "do=search_results;search_forum=all;search_user_username=$url_user_username")%>' title="Show <%user_username%>'s posts"><%user_posts%></a><%else%>0<%endif%></div>
                <div class="dcell date">
                  <%~if user_invisible and current.user_status < $ADMINISTRATOR~%>
                  <span class="invisible">(Invisible)</span>
                  <%~else~%>
                  <%if user_invisible%><span class="invisible" title="User is invisible"><%endif~%>
                    <%user_last_seen_date%>
                    <%~if user_last_seen and user_tz_differs%>
                    <%~set date_user_time = GForum::date_user_time($loop_value, $user_last_seen)%>
                    <%~-- Check that the date_user_time is actually different -- user_tz_differs will be true for America/Vancouver vs. America/Los_Angeles,
                    even though the time in those zones is (generally) the same --%>
                    <%~unless user_last_seen_date ends " $date_user_time"~%>
                    <span class="localtime" title="User's local time"> (<%date_user_time%>)</span>
                    <%~endunless%>
                    <%~endif%>
                    <%~if user_invisible%></span><%endif~%>
                  <%~endif~%>
                </div>
              </div>
              <%~endloop%>
            </div>
          </div>

          <%if num_page_items > $mh%>
          <div class="toolbar clear">
            <hr class="line" />
            <div class="paging">
              <%include include_paging.html%>
            </div>
          </div>
          <%~endif%>

        </div><%-- end content --%>
      </div>
    </div>
    <%include include_footer.html%>
  </div>

</body>
<%~include include_global_js.html%>
<%~if current.user_status == $ADMINISTRATOR%>
  <script type="text/javascript">
    $(document).ready(function () {
      GForum.init_post_only();
    });
  </script>
<%~endif%>
</html>
