id);
row("founder", $team->userid);
row("name", $team->name);
row("url", $team->url);
row("type", $team->type);
row("name_html", $team->name_html);
row("description", $team->description);
}
function display_team_page($team) {
page_head("$team->name");
if ($team->name_html != null) {
echo "
";
echo "$team->name_html";
}
echo "
";
echo "[id>Join] ";
echo "[id>Quit] ";
echo "[id>Edit*] ";
echo "[id>Remove Inactive Members*] ";
echo "[id>Disband Team*] ";
echo "[id>View Team Emails*]";
echo "
* Team founder only";
echo "
";
echo "
";
echo "
";
echo "";
echo "Team Info: |
";
echo "";
if (strlen($team->description)) {
row("Description: ", $team->description);
}
if (strlen($team->url)) {;
row("Web site: ", "url>http://$team->url");
}
row("Members: ", $team->nusers);
$query = sprintf(
"select * from user where teamid = %d",
$team->id
);
$result = mysql_query($query);
$total_credit = 0;
for ($i = 0; $i < $team->nusers; $i++) {
$user = mysql_fetch_object($result);
$total_credit = $total_credit + $user->total_credit;
}
row("Total Credit: ", $total_credit);
$query = sprintf(
"select * from user where id = %d",
$team->userid
);
$result = mysql_query($query);
$user = mysql_fetch_object($result);
row("Founder: ", $user->name);
echo "
";
echo "";
echo "
";
echo "";
echo "Team Members: |
";
echo "";
echo "Name | ";
echo "Total credit | ";
echo "Recent average CPU time per work unit | ";
echo "Country | ";
echo "
";
$query = sprintf(
"select * from user where teamid = %d order by expavg_credit desc",
$team->id
);
$result = mysql_query($query);
for ($i = 0; $i < $team->nusers; $i++) {
$user = mysql_fetch_object($result);
$j = $i+1;
echo "$j) $user->name";
echo " | $user->total_credit | ";
echo "$user->expavg_credit | ";
echo "$user->country | ";
echo "
";
}
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_login($user);
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();
}
}
?>