name", $user);
echo "
Team page for ";
if (strlen($team->name_html)) {
echo "$team->name_html";
} else {
echo $team->name;
}
echo "
";
if ($user->teamid == $team->id) {
echo "You currently belong to this team
";
} else {
echo "You don't currently belong to this team.
";
}
if ($user->id == $team->userid) {
echo "
You are the founder of this team.
";
}
start_table();
row1("Team info");
if (strlen($team->description)) {
row2("Description", sanitize_html($team->description));
}
if (strlen($team->url)) {;
row2("Web site", "url>http://$team->url");
}
row2("Members", $team->nusers);
$result = mysql_query("select * from user where teamid=$team->id");
$total_credit = 0;
for ($i = 0; $i < $team->nusers; $i++) {
$user = mysql_fetch_object($result);
$total_credit = $total_credit + $user->total_credit;
}
row2("Total credit", $total_credit);
$result = mysql_query("select * from user where id=$team->userid");
$user = mysql_fetch_object($result);
row2("Founder", "id>$user->name");
row2("Country", $team->country);
echo "";
echo "";
start_table();
row1("Team members", 4);
echo "
Name |
Total credit |
Recent average credit |
Country |
";
$result = mysql_query("select * from user where teamid=$team->id order by expavg_credit desc");
$j = 1;
while (true) {
$user = mysql_fetch_object($result);
if (!$user) break;
echo "
$j) id>$user->name
| $user->total_credit |
$user->expavg_credit |
$user->country |
";
$j++;
}
mysql_free_result($result);
echo "";
page_tail();
}
// requires that the team exist
function require_team($team) {
if (!$team) {
page_head("Error");
echo "Team does not exist.";
page_tail();
exit();
}
}
// requires that the user is logged in as the founder of
// the team trying to be edited
function require_founder_login($user, $team) {
require_team($team);
if ($user->id != $team->userid) {
page_head("Permission denied");
echo "Only a team's founder may edit a team.";
page_tail();
exit();
}
}
function team_table_start() {
echo "
Name |
Members |
Average credit |
Total credit |
Country |
";
}
function show_team_row($team, $i) {
echo "
$i) id>$team->name |
$team->nusers |
$team->expavg_credit |
$team->total_credit |
$team->country |
\n";
}
function team_edit_form($team, $label, $url) {
echo "\n";
}
?>