2002-08-07 18:56:55 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once("util.inc");
|
|
|
|
require_once("db.inc");
|
2003-02-24 21:25:16 +00:00
|
|
|
require_once("sanitize_html.inc");
|
2002-08-07 18:56:55 +00:00
|
|
|
|
|
|
|
function display_team_page($team) {
|
2002-11-08 17:21:45 +00:00
|
|
|
page_head("$team->name");
|
|
|
|
if ($team->name_html != null) {
|
|
|
|
echo "<p>";
|
|
|
|
echo "$team->name_html";
|
|
|
|
}
|
2003-03-17 22:37:49 +00:00
|
|
|
echo "<p>
|
|
|
|
[<a href=team_join_form.php?id=$team->id><b>Join</b></a>]
|
|
|
|
[<a href=team_quit_form.php?id=$team->id><b>Quit</b></a>]
|
|
|
|
[<a href=team_edit_form.php?id=$team->id><b>Edit*</b></a>]
|
|
|
|
[<a href=team_remove_inactive_form.php?id=$team->id><b>Remove Inactive Members*</b></a>]
|
|
|
|
[<a href=team_disband_form.php?id=$team->id><b>Disband Team*</b></a>]
|
|
|
|
[<a href=team_email_list.php?id=$team->id><b>View Team Emails*</b></a>]
|
|
|
|
<br><font size=2>* Team founder only</font>
|
|
|
|
<br>
|
|
|
|
<p>
|
|
|
|
";
|
|
|
|
start_table();
|
|
|
|
row1("Team info");
|
2002-11-08 17:21:45 +00:00
|
|
|
if (strlen($team->description)) {
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Description", sanitize_html($team->description));
|
2002-11-08 17:21:45 +00:00
|
|
|
}
|
|
|
|
if (strlen($team->url)) {;
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Web site", "<a href=http://$team->url>http://$team->url</a>");
|
2002-11-08 17:21:45 +00:00
|
|
|
}
|
2003-02-27 22:30:31 +00:00
|
|
|
row2("Members", $team->nusers);
|
2002-08-12 20:16:55 +00:00
|
|
|
|
2003-03-17 22:37:49 +00:00
|
|
|
$result = mysql_query("select * from user where teamid=$team->id");
|
2002-11-08 17:21:45 +00:00
|
|
|
$total_credit = 0;
|
|
|
|
for ($i = 0; $i < $team->nusers; $i++) {
|
|
|
|
$user = mysql_fetch_object($result);
|
|
|
|
$total_credit = $total_credit + $user->total_credit;
|
|
|
|
}
|
2002-08-07 18:56:55 +00:00
|
|
|
|
2003-03-17 22:37:49 +00:00
|
|
|
row2("Total credit", $total_credit);
|
|
|
|
$result = mysql_query("select * from user where id=$team->userid");
|
2002-08-07 18:56:55 +00:00
|
|
|
$user = mysql_fetch_object($result);
|
2003-03-17 22:37:49 +00:00
|
|
|
row2("Founder", "<a href=show_user.php?userid=$user->id>$user->name</a>");
|
|
|
|
row2("Country", $team->country);
|
2002-11-08 17:21:45 +00:00
|
|
|
echo "</table>";
|
|
|
|
echo "<p>";
|
2003-03-17 22:37:49 +00:00
|
|
|
start_table();
|
|
|
|
row1("Team members", 4);
|
|
|
|
echo "<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Total credit</th>
|
|
|
|
<th>Recent average credit</th>
|
|
|
|
<th>Country</th>
|
|
|
|
</tr>
|
|
|
|
";
|
2002-08-07 18:56:55 +00:00
|
|
|
|
2003-03-17 22:37:49 +00:00
|
|
|
$result = mysql_query("select * from user where teamid=$team->id order by expavg_credit desc");
|
2002-08-07 18:56:55 +00:00
|
|
|
|
2003-03-17 22:37:49 +00:00
|
|
|
$j = 1;
|
|
|
|
while (true) {
|
2002-11-08 17:21:45 +00:00
|
|
|
$user = mysql_fetch_object($result);
|
2003-03-17 22:37:49 +00:00
|
|
|
if (!$user) break;
|
|
|
|
echo "<tr>
|
|
|
|
<td align=left>$j) <a href=show_user.php?userid=$user->id>$user->name</a>
|
|
|
|
<td align=center>$user->total_credit</td>
|
|
|
|
<td align=center>$user->expavg_credit</td>
|
|
|
|
<td align=center>$user->country</td>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
$j++;
|
2002-11-08 17:21:45 +00:00
|
|
|
}
|
2003-03-17 22:37:49 +00:00
|
|
|
mysql_free_result($result);
|
2002-11-08 17:21:45 +00:00
|
|
|
echo "</table>";
|
|
|
|
page_tail();
|
2002-08-07 18:56:55 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 21:41:41 +00:00
|
|
|
// 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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-03-17 22:37:49 +00:00
|
|
|
function team_table_start() {
|
|
|
|
echo "<tr>
|
|
|
|
<th>Name</th>
|
|
|
|
<th>Members</th>
|
|
|
|
<th>Average credit</th>
|
|
|
|
<th>Total credit</th>
|
|
|
|
<th>Country</th>
|
|
|
|
</tr>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
function show_team_row($team, $i) {
|
|
|
|
echo "<tr>
|
|
|
|
<td>$i) <a href=team_display.php?id=$team->id>$team->name</a></td>
|
|
|
|
<td>$team->nusers</td>
|
|
|
|
<td>$team->expavg_credit</td>
|
|
|
|
<td>$team->total_credit</td>
|
|
|
|
<td>$team->country</td>
|
|
|
|
</tr>\n";
|
|
|
|
}
|
|
|
|
|
2002-08-07 18:56:55 +00:00
|
|
|
?>
|