From db9c2fa85001714a0188899c09c5a35adf04af27 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 5 May 2011 16:05:23 +0000 Subject: [PATCH] - web RPC: add RPC for getting teams by country svn path=/trunk/boinc/; revision=23507 --- checkin_notes | 6 ++++ html/user/team_search.php | 67 +++++++++++++++++++++++++-------------- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/checkin_notes b/checkin_notes index 144ab2c1d5..a5e08d5a69 100644 --- a/checkin_notes +++ b/checkin_notes @@ -2800,3 +2800,9 @@ David 5 May 2011 validator.cpp html/user/ friend.php + +David 5 May 2011 + - web RPC: add RPC for getting teams by country + + html/user/ + team_search.php diff --git a/html/user/team_search.php b/html/user/team_search.php index ca712e3e64..683fba4e77 100644 --- a/html/user/team_search.php +++ b/html/user/team_search.php @@ -20,8 +20,9 @@ include_once("../inc/boinc_db.inc"); include_once("../inc/util.inc"); include_once("../inc/team.inc"); include_once("../inc/team_types.inc"); +include_once("../inc/xml.inc"); -check_get_args(array("keywords", "active", "country", "type", "submit")); +check_get_args(array("keywords", "active", "country", "type", "submit", "xml")); // Merge list1 into list2. // list entries are of the form id => team, @@ -87,6 +88,38 @@ function show_list($list) { echo ""; } +function show_teams_html($list) { + page_head(tra("Team search results")); + if (sizeof($list) == 0) { + echo tra("No teams were found matching your criteria. Try another search.") + ."

" + .tra("Or you can %1create a new team%2.", "", "") + ."

\n"; + team_search_form($params); + } else { + echo tra("The following teams match one or more of your search criteria. + To join a team, click its name to go to the team page, + then click %1Join this team%2.", "", "") + ."

+ "; + sort_list($list); + show_list($list); + echo "

".tra("Change your search")."

"; + team_search_form($params); + } + page_tail(); +} + +function show_teams_xml($list) { + xml_header(); + echo "\n"; + sort_list($list); + foreach($list as $team) { + show_team_xml($team); + } + echo "\n"; +} + function search($params) { $list = array(); $tried = false; @@ -120,40 +153,28 @@ function search($params) { merge_lists($list2, $list, 2); $tried = true; } - if (!$tried) { $list = get_teams("id>0", $params->active); } - if (sizeof($list) == 0) { - echo tra("No teams were found matching your criteria. Try another search.") - ."

" - .tra("Or you can %1create a new team%2.", "", "") - ."

\n"; - team_search_form($params); - } else { - echo tra("The following teams match one or more of your search criteria. - To join a team, click its name to go to the team page, - then click %1Join this team%2.", "", "") - ."

- "; - sort_list($list); - show_list($list); - echo "

".tra("Change your search")."

"; - team_search_form($params); - } + return $list; } $user = get_logged_in_user(false); $submit = get_str("submit", true); -if ($submit) { +$xml = get_str("xml", true); +if ($submit || $xml) { $params = null; $params->keywords = get_str('keywords', true); $params->country = get_str("country", true); $params->type = get_str("type", true); $params->active = get_str('active', true); - page_head(tra("Team search results")); - search($params); + $list = search($params); + if ($xml) { + show_teams_xml($list); + } else { + show_teams_html($list); + } } else { page_head(tra("Find a team"), 'document.form.keywords.focus()'); echo tra("You can team up with other people with similar interests, or from the same country, company, or school.") @@ -165,7 +186,7 @@ if ($submit) { echo "

".tra("%1I'm not interested%2 in joining a team right now.", "", ""); } + page_tail(); } -page_tail(); ?>