1<?php 2// This file is part of BOINC. 3// http://boinc.berkeley.edu 4// Copyright (C) 2008 University of California 5// 6// BOINC is free software; you can redistribute it and/or modify it 7// under the terms of the GNU Lesser General Public License 8// as published by the Free Software Foundation, 9// either version 3 of the License, or (at your option) any later version. 10// 11// BOINC is distributed in the hope that it will be useful, 12// but WITHOUT ANY WARRANTY; without even the implied warranty of 13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14// See the GNU Lesser General Public License for more details. 15// 16// You should have received a copy of the GNU Lesser General Public License 17// along with BOINC. If not, see <http://www.gnu.org/licenses/>. 18 19require_once("../inc/boinc_db.inc"); 20require_once("../inc/util.inc"); 21require_once("../inc/user.inc"); 22 23function show_user($user) { 24 echo " 25 <tr> 26 <td>", user_links($user, BADGE_HEIGHT_MEDIUM), " (ID $user->id)</td> 27 "; 28 if ($user->teamid) { 29 $team = BoincTeam::lookup_id($user->teamid); 30 echo " 31 <td> <a href=team_display.php?teamid=$team->id>$team->name</a> </td> 32 "; 33 } else { 34 echo "<td><br></td>"; 35 } 36 echo " 37 <td align=right>", format_credit($user->expavg_credit), "</td> 38 <td align=right>", format_credit_large($user->total_credit), "</td> 39 <td>", $user->country, "</td> 40 <td>", time_str($user->create_time),"</td> 41 </tr> 42 "; 43} 44 45function user_search_form() { 46 page_head("User search"); 47 echo "<form name=f method=get action=user_search.php> 48 <input type=hidden name=action value=search> 49 "; 50 start_table(); 51 row1(tra("Filters"), 2, "heading"); 52 row2( 53 tra("User name starts with"), 54 '<input class="form-control" type="text" name="search_string">' 55 ); 56 row2_init(tra("Country"), "<select class=\"form-control\" name=\"country\"><option value=\"any\" selected>".tra("Any")."</option>"); 57 echo country_select_options("asdf"); 58 echo "</select></td></tr>"; 59 row2(tra("With profile?"), 60 "<input type=radio name=profile value=either checked=1> ".tra("Either")." 61 <input type=radio name=profile value=no> ".tra("No")." 62 <input type=radio name=profile value=yes> ".tra("Yes")." 63 "); 64 row2(tra("On a team?"), 65 "<input type=radio name=team value=either checked=1> ".tra("Either")." 66 <input type=radio name=team value=no> ".tra("No")." 67 <input type=radio name=team value=yes> ".tra("Yes")." 68 "); 69 row1(tra("Ordering"), 2, "heading"); 70 row2(tra("Decreasing sign-up time"), "<input type=radio name=search_type value=\"date\" checked>"); 71 row2(tra("Decreasing average credit"), "<input type=radio name=search_type value=\"rac\">"); 72 row2(tra("Decreasing total credit"), "<input type=radio name=search_type value=\"total\">"); 73 row2("", "<input class=\"btn btn-success\" type=submit name=action value=".tra("Search").">"); 74 end_table(); 75 echo " 76 <script>document.f.search_string.focus()</script> 77 "; 78 79 page_tail(); 80} 81 82function search_action() { 83 $where = "true"; 84 $search_string = get_str('search_string'); 85 if (strlen($search_string)) { 86 if (strlen($search_string)<3) { 87 error_page(tra("search string must be at least 3 characters")); 88 } 89 $s = BoincDb::escape_string($search_string); 90 $s = escape_pattern($s); 91 $where .= " and name like '$s%'"; 92 } 93 $country = get_str('country'); 94 if ($country != 'any') { 95 $s = BoincDb::escape_string($country); 96 $where .= " and country='$s'"; 97 } 98 $t = get_str('team'); 99 if ($t == 'yes') { 100 $where .= " and teamid<>0"; 101 } else if ($t == 'no') { 102 $where .= " and teamid=0"; 103 } 104 $t = get_str('profile'); 105 if ($t == 'yes') { 106 $where .= " and has_profile<>0"; 107 } else if ($t == 'no') { 108 $where .= " and has_profile=0"; 109 } 110 111 $search_type = get_str('search_type', true); 112 $order_clause = "id desc"; 113 if ($search_type == 'rac') { 114 $order_clause ="expavg_credit desc"; 115 } else if ($search_type == 'total') { 116 $order_clause ="total_credit desc"; 117 } 118 119 $fields = "id, create_time, name, country, total_credit, expavg_credit, teamid, url, has_profile, donated"; 120 $users = BoincUser::enum_fields($fields, $where, "order by $order_clause limit 100"); 121 page_head(tra("User search results")); 122 $n=0; 123 foreach ($users as $user) { 124 if ($n==0) { 125 start_table('table-striped'); 126 row_heading_array( 127 array( 128 tra("Name"), 129 tra("Team"), 130 tra("Average credit"), 131 tra("Total credit"), 132 tra("Country"), 133 tra("Joined") 134 ), 135 array(null, null, ALIGN_RIGHT, ALIGN_RIGHT, null, null) 136 ); 137 } 138 show_user($user); 139 $n++; 140 } 141 end_table(); 142 if (!$n) { 143 echo tra("No users match your search criteria."); 144 } 145 page_tail(); 146} 147 148$action = get_str('action', true); 149if ($action) { 150 search_action(); 151} else { 152 user_search_form(); 153} 154 155$cvs_version_tracker[]="\$Id: user_search.php 13586 2007-09-13 09:46:36Z Rytis $"; //Generated automatically - do not edit 156?> 157