- user web: add "team search" page, which does a multi-criteria

search (keywords, country, type).
    Have the new-user scenario route the user through this page.
    Also, link to it rather than team.php for existing users.
- user web: use cookies rather than URLs to identify new users,
    and show "Welcome to X" when they reach their user page.
- user web: don't show user intermediate page for join/quit team.
    Just take them to their user page.

svn path=/trunk/boinc/; revision=13731
This commit is contained in:
David Anderson 2007-10-02 03:19:03 +00:00
parent bd858b38fd
commit 2272891035
15 changed files with 335 additions and 28 deletions

View File

@ -8952,3 +8952,33 @@ Rytis 29 Sep 2007
forum_edit.php
forum_post.php
forum_reply.php
David 1 Oct 2007
- user web: add "team search" page, which does a multi-criteria
search (keywords, country, type).
Have the new-user scenario route the user through this page.
Also, link to it rather than team.php for existing users.
- user web: use cookies rather than URLs to identify new users,
and show "Welcome to X" when they reach their user page.
- user web: don't show user intermediate page for join/quit team.
Just take them to their user page.
DB update required; see ops/db_update.php
html/
inc/
team.inc
team_types.inc
user.inc
ops/
db_update.php
user/
account_finish_action.php
create_account_action.php
home.php
team.php
team_join.php
team_search.php
team_quit_action.php
validate_email_addr.php
white.css

View File

@ -161,7 +161,7 @@ echo "
language("Belgium (Dutch/French/English)", array(
site("http://www.boinc.be", "www.boinc.be"),
seti("http://icewolves.plid.be", "IceWolves"),
site("http://icewolves.plid.be", "IceWolves"),
));
language("Catalan", array(
site("http://www.boinc.cat", "BOINC.cat"),

View File

@ -58,7 +58,11 @@ function display_team_page($team, $offset, $sort_by) {
row2("Country", $team->country);
row2("Type", team_type_name($team->type));
if ($user->teamid != $team->id) {
row2("Join this team", "<a href='team_join_form.php?id=$team->id'>Join</a>");
$tokens = url_tokens($user->authenticator);
row2("",
"<a href='team_join.php?$tokens&teamid=$team->id'>Join this team</a>
<br><span class=note>Note: joining a team gives its founder access to your email address.</span>"
);
}
if (($user->teamid == $team->id) && ($user->id != $founder->id)) {
row2("Request team founder transfer", "<a href=\"team_founder_transfer_form.php\">Initiate transfer</a>");

View File

@ -35,7 +35,7 @@ function team_type_num($name) {
return 0;
}
function team_type_select($team){
function team_type_select($team, $allow_none=false){
global $team_types;
if (!empty($team)) {
@ -43,8 +43,12 @@ function team_type_select($team){
} else {
$type = 1;
}
return select_from_array('type', $team_types, $type);
$types = $team_types;
if ($allow_none) {
$types[0] = '---';
$type = 0;
}
return select_from_array('type', $types, $type);
}
?>

View File

@ -211,7 +211,7 @@ function show_user_info_private($user) {
}
row2("Team", $x);
} else {
row2("Team", "None (<a href=team.php>find a team</a>)");
row2("Team", "None (<a href=team_search.php>find a team</a>)");
}
$team_founder = lookup_team_founder($user->id);

View File

@ -445,6 +445,12 @@ function update_9_26_2007() {
do_query("ALTER TABLE team CHANGE ping_user ping_user integer NOT NULL DEFAULT 0");
}
function update_9_28_2007() {
do_query("alter table team engine=myisam");
do_query("alter table team change description description text");
do_query("alter table team add fulltext index team_name_desc(name, description)");
}
// modify the following to call the function you want.
// Make sure you do all needed functions, in order.
// (Look at your DB structure using "explain" queries to see

View File

@ -26,11 +26,8 @@ if ($new_name != strip_tags($new_name)) {
}
$country = post_str("country");
if ($country == "") {
$country = "International";
}
if (!is_valid_country($country)) {
show_error( "bad country");
show_error( "invalid country");
}
$postal_code = strip_tags(process_user_text(post_str("postal_code", true)));
@ -43,7 +40,8 @@ if (!$retval) {
session_start();
$_SESSION["authenticator"] = $auth;
Header("Location: home.php?new_acct=1");
Header("Location: team_search.php");
setcookie('auth', $auth, time()+3600*24*365);
setcookie('init', "1", time()+3600*24*365);
?>

View File

@ -125,7 +125,10 @@ if(defined('INVITE_CODES')) {
session_start();
$_SESSION["authenticator"] = $user->authenticator;
Header("Location: home.php?new_acct=1&via_web=1");
Header("Location: home.php");
setcookie('auth', $user->authenticator, time()+3600*24*365);
setcookie('init', "1", time()+3600*24*365);
setcookie('via_web', "1", time()+3600*24*365);
?>

View File

@ -11,22 +11,28 @@ db_init();
$user = get_logged_in_user();
$user = getForumPreferences($user);
$user = get_other_projects($user);
page_head("Your account");
if (get_str("new_acct", true)) {
$init = isset($_COOKIE['init']);
$via_web = isset($_COOKIE['via_web']);
if ($init) {
setcookie('init', '', time()-3600);
page_head("Welcome to ".PROJECT);
echo "
<p>
Welcome to ".PROJECT.".
View and edit your account preferences using the links below.
";
if ($via_web) {
setcookie('via_web', '', time()-3600);
echo "
<p> If you have not already done so,
<a href=http://boinc.berkeley.edu/download.php>download BOINC client software</a>.
";
}
} else {
page_head("Your account");
}
if (get_str("via_web", true)) {
echo "
<p>
If you have not already done so,
<a href=http://boinc.berkeley.edu/download.php>download BOINC client software</a>.
";
}
echo "<p>\n";
show_user_page_private($user);

View File

@ -22,16 +22,18 @@ echo "<p>".PROJECT." participants may form <b>teams</b>.
<li> disband a team if it has no members
</ul>
<p>
To join a team, visit its team page and click Join.
To join a team, visit its team page and click <b>Join this team</b>.
<hr>
<ul>
<li> <a href=team_search.php>Find a team</a> based on your interests and country
<li> <a href=team_create_form.php>Create a team</a>
<li> <form method=get action=team_lookup.php>
Search for teams whose name contains:
Show teams whose names contains:
<input name=team_name>
<input type=submit name=search value=Search>
</form>
<li> <a href=team_create_form.php>Create a team</a>
</ul>
<hr>
Show top teams:
<ul>
<li> <a href=top_teams.php>All teams</a>

28
html/user/team_join.php Normal file
View File

@ -0,0 +1,28 @@
<?php
require_once("../inc/db.inc");
require_once("../inc/util.inc");
require_once("../inc/team.inc");
db_init();
$user = get_logged_in_user(true);
check_tokens($user->authenticator);
$teamid = get_int("teamid");
$team = lookup_team($teamid);
require_team($team);
if ($user->teamid == $team->id) {
page_head("Unable to add $user->name");
echo "You are already a member of $team->name.";
} else {
$success = user_join_team($team, $user);
if ($success) {
Header("Location: home.php");
} else {
error_page("Couldn't join team - please try later.");
}
}
page_tail();
?>

View File

@ -12,8 +12,7 @@ $teamid = post_int("id");
$team = lookup_team($teamid);
if ($user->teamid == $team->id) {
user_quit_team($user);
page_head("Quit $team->name");
echo "You have been removed from <a href=\"team_display.php?teamid=$team->id\">$team->name</a>";
Header("Location: home.php");
} else {
page_head("Unable to quit team");
echo "Team doesn't exist, or you don't belong to it.\n";

164
html/user/team_search.php Normal file
View File

@ -0,0 +1,164 @@
<?php
include_once("../inc/db.inc");
include_once("../inc/util.inc");
include_once("../inc/team.inc");
include_once("../inc/team_types.inc");
db_init();
function print_form() {
$user = get_logged_in_user(false);
echo "
<form action=team_search.php>
";
start_table();
row2("Key words<br><span class=note>Find teams with these words in their names or descriptions</span>", "<input name=keywords>");
row2_init("Country");
echo "<select name=country><option value=\"\" selected>---</option>";
$country = $user->country;
if (!$country || $country == 'None') $country = "XXX";
print_country_select($country);
echo "</select></td></tr>\n";
row2("Type of team", team_type_select(0, true));
row2("Show only active teams", "<input type=checkbox name=active checked>");
row2("", "<input type=submit name=submit value=Search>");
end_table();
echo "
</form>
";
}
// Merge list1 into list2.
// list entries are of the form id => team,
// where team includes a field "refcnt".
//
function merge_lists($list1, &$list2) {
foreach($list1 as $id=>$team) {
if (array_key_exists($id, $list2)) {
$list2[$id]->refcnt++;
} else {
$list2[$id] = $team;
$list2[$id]->refcnt = 0;
}
}
}
function compare($t1, $t2) {
if ($t1->refcnt > $t2->refcnt) return -1;
if ($t1->refcnt < $t2->refcnt) return 1;
if ($t1->expavg_credit > $t2->expavg_credit) return -1;
if ($t1->expavg_credit < $t2->expavg_credit) return 1;
return 0;
}
// Sort list by decreasing refcnt
//
function sort_list(&$list) {
usort($list, compare);
}
function get_teams($clause, $active) {
if ($active) $c2 = "and expavg_credit>0";
$query = "select * from team where $clause $c2 limit 20";
$result = mysql_query($query);
$list = array();
while ($team = mysql_fetch_object($result)) {
$list[$team->id] = $team;
}
return $list;
}
function show_list($list) {
start_table();
echo "
<tr>
<th>Team name</th>
<th>Description</th>
<th>Average credit</th>
<th>Type</th>
<th>Country</th>
</tr>
";
foreach ($list as $team) {
$type = team_type_name($team->type);
echo "<tr class=bordered>
<td class=shaded valign=top><a href=team_display.php?teamid=$team->id>$team->name</a></td>
<td class=shaded valign=top><span class=note>".sanitize_html($team->description)."</span></td>
<td class=shaded valign=top>$team->expavg_credit</td>
<td class=shaded valign=top>$type</td>
<td class=shaded valign=top>$team->country</td>
</tr>
";
}
echo "</table>";
}
function search() {
$keywords = $_GET['keywords'];
$country = $_GET['country'];
$type = $_GET['type'];
$active = $_GET['active'];
$list = array();
if (strlen($keywords)) {
$list2 = get_teams("match(name, description) against ('$keywords')", $active);
//echo "<br>keyword matches: ",sizeof($list2);
merge_lists($list2, $list);
}
if (strlen($country) && $country!='None') {
$list2 = get_teams("country = '$country'", $active);
//echo "<br>country matches: ",sizeof($list2);
merge_lists($list2, $list);
}
if ($type and $type>1) {
$list2 = get_teams("type=$type", $active);
//echo "<br>type matches: ",sizeof($list2);
merge_lists($list2, $list);
}
if (sizeof($list) == 0) {
echo "
No teams were found matching your criteria.
Try another search.
<p>
Or you can <a href=team_create_form.php>create a new team</a>.
<p>
";
print_form();
} else {
echo "
The following teams match your search criteria.
To join a team, click its name to go to the team page,
then click <b>Join this team</b>.
<p>
";
sort_list($list);
show_list($list);
}
}
if ($_GET['submit']) {
page_head("Team search results");
search();
} else {
page_head("Find a team");
echo "
You can team up with other people with similar interests,
or from the same country, company, or school.
<p>
Use this form to find teams that might be right for you.
<p>
";
print_form();
if (isset($_COOKIE['init'])) {
echo "
<p>
<a href=home.php>Click here</a>
if you're not interested in joining a team right now.
";
}
}
page_tail();
?>

View File

@ -0,0 +1,59 @@
<?php
require_once("../inc/db.inc");
require_once("../inc/util.inc");
require_once("../inc/email.inc");
db_init();
function send_validate_email() {
global $master_url;
$user = get_logged_in_user();
$x2 = md5($user->email_addr.$user->authenticator);
send_email(
$user,
"Validate BOINC email address",
"Please visit the following link to validate the email address\n"
."of your ".PROJECT." account:\n"
.$master_url."validate_email_addr.php?validate=1&u=$user->id&x=$x2"
);
page_head("Validate email sent");
echo "
An email has been sent to $user->email_addr.
Visit the link it contains to validate your email address.
";
page_tail();
}
function validate() {
$x = process_user_text(get_str("x"));
$u = process_user_text(get_int("u"));
$user = lookup_user_id($u);
if (!$user) {
error_page("No such user.\n");
}
$x2 = md5($user->email_addr.$user->authenticator);
if ($x2 != $x) {
error_page("Error in URL data - can't validate email address");
}
$result = mysql_query("update user set email_validated=1 where id=$user->id");
if (!$result) {
error_page("Database update failed - please try again later.");
}
page_head("Validate email address");
echo "
The email address of your account has been validated.
";
page_tail();
}
if ($_GET['validate']) {
validate();
} else {
send_validate_email();
}
?>

View File

@ -34,6 +34,10 @@ td.bordered {
border: 1px solid gray;
}
td.shaded {
background-color: #f0f0f0;
}
td.indent {
border-left: 4px solid white;
}
@ -305,4 +309,4 @@ span.news_date {
font-weight: bold;
font-size: 1.3em;
border-bottom: 1px solid #cccccc;
}
}