From 43a21e6efd202b8cca1da4bec2807e90814d21bb Mon Sep 17 00:00:00 2001
From: David Anderson Please note:
Please note before quitting a team:";
- echo "
Team is empty - deleting team.\n";
+ mysql_query("delete from team where id=$team->id");
+ }
+}
+
?>
diff --git a/html/inc/util.inc b/html/inc/util.inc
index 5ea470c381..613b1b5ec2 100644
--- a/html/inc/util.inc
+++ b/html/inc/util.inc
@@ -155,6 +155,13 @@ function profile_error_page($str) {
page_tail();
}
+function error_page($msg) {
+ page_head("Unable to handle request");
+ echo $msg;
+ page_tail();
+ exit();
+}
+
function date_str($x) {
if ($x == 0) return "---";
// return date("g:i A, l M j", $when);
diff --git a/html/user/team_create_action.php b/html/user/team_create_action.php
index ef7f8d19f4..99266ce5b8 100644
--- a/html/user/team_create_action.php
+++ b/html/user/team_create_action.php
@@ -32,7 +32,7 @@
$team_result = mysql_query("select * from team where id = $teamid");
$new_team = mysql_fetch_object($team_result);
mysql_free_result($team_result);
- user_join_team($new_team,$user);
+ user_join_team($new_team, $user);
Header("Location: team_display.php?teamid=$teamid");
} else {
page_head("Error");
diff --git a/html/user/team_edit_action.php b/html/user/team_edit_action.php
index 036a208d56..29f3d0c0ae 100644
--- a/html/user/team_edit_action.php
+++ b/html/user/team_edit_action.php
@@ -8,12 +8,7 @@
$user = get_logged_in_user();
$teamid = $_POST["teamid"];
- $query = "select * from team where id = $teamid";
- $result = mysql_query($query);
- if ($result) {
- $team = mysql_fetch_object($result);
- mysql_free_result($result);
- }
+ $team = lookup_team($teamid);
require_founder_login($user, $team);
$team_url = ereg_replace("\"", "'", $_POST["url"]);
diff --git a/html/user/team_edit_form.php b/html/user/team_edit_form.php
index ba7876ec74..c5f7012b18 100644
--- a/html/user/team_edit_form.php
+++ b/html/user/team_edit_form.php
@@ -8,14 +8,9 @@ require_once("../inc/team.inc");
$user = get_logged_in_user();
$teamid = $_GET["teamid"];
-
- $query = "select * from team where id = $teamid";
- $result = mysql_query($query);
- if ($result) {
- $team = mysql_fetch_object($result);
- mysql_free_result($result);
- }
+ $team = lookup_team($teamid);
require_founder_login($user, $team);
+
$team_name = ereg_replace("\"", "'", $team->name);
$team_name_html = ereg_replace("\"", "'", $team->name_html);
$team_url = ereg_replace("\"", "'", $team->url);
diff --git a/html/user/team_email_list.php b/html/user/team_email_list.php
index b7f40a7097..b5d61530b6 100644
--- a/html/user/team_email_list.php
+++ b/html/user/team_email_list.php
@@ -9,13 +9,7 @@ require_once("../inc/team.inc");
$user = get_logged_in_user();
$teamid = $_GET["teamid"];
-
- $result = mysql_query("select * from team where id=$teamid");
- if ($result) {
- $team = mysql_fetch_object($result);
- mysql_free_result($result);
- }
-
+ $team = lookup_team($teamid);
require_founder_login($user, $team);
page_head("$team->name Email List");
diff --git a/html/user/team_join_action.php b/html/user/team_join_action.php
index 5344f27285..9320324c2a 100644
--- a/html/user/team_join_action.php
+++ b/html/user/team_join_action.php
@@ -14,18 +14,17 @@
page_head("Unable to add $user->name");
echo "You are already a member of $team->name.";
} else {
- $success = user_join_team($team,$user);
+ $success = user_join_team($team, $user);
if ($success == true) {
page_head("Joined $team->name");
echo "You have joined
id>$team->name.
";
} else {
- page_head("Error");
- echo "Couldn't join team - please try later.\n";
+ error_page("Couldn't join team - please try later.");
}
}
-page_tail();
+ page_tail();
?>
diff --git a/html/user/team_join_form.php b/html/user/team_join_form.php
index f26e26b73a..3d972a8f71 100644
--- a/html/user/team_join_form.php
+++ b/html/user/team_join_form.php
@@ -4,18 +4,12 @@ require_once("../inc/db.inc");
require_once("../inc/util.inc");
require_once("../inc/team.inc");
-db_init();
-$user = get_logged_in_user();
-$id = $_GET["id"];
+ db_init();
+ $user = get_logged_in_user();
+ $teamid = $_GET["id"];
- $query = "select * from team where id = $id";
- $result = mysql_query($query);
- if ($result) {
- $team = mysql_fetch_object($result);
- mysql_free_result($result);
- }
+ $team = lookup_team($teamid);
$team_name = $team->name;
- $team_id = $team->id;
page_head("Join $team_name");
echo "
@@ -24,7 +18,7 @@ $id = $_GET["id"];
";
diff --git a/html/user/team_lookup.php b/html/user/team_lookup.php
index 337e25d75a..3be1697f64 100644
--- a/html/user/team_lookup.php
+++ b/html/user/team_lookup.php
@@ -32,9 +32,10 @@
}
echo "";
if ($too_many) {
- echo "This is only a partial list of the possible teams you ";
- echo "were searching for. You will need to narrow your search ";
- echo "criteria to get more accurate results.
";
+ echo "
+ More than 100 teams match your search.
+ The first 100 are shown.
+ ";
}
}
echo "End of results
";
diff --git a/html/user/team_manage.php b/html/user/team_manage.php
index b81a6e270c..59ccda0cb9 100644
--- a/html/user/team_manage.php
+++ b/html/user/team_manage.php
@@ -20,11 +20,11 @@ if ($team->userid != $user->id) {
}
echo "
-
+
";
page_tail();
diff --git a/html/user/team_quit_action.php b/html/user/team_quit_action.php
index 492f9e5c72..2778e08c65 100644
--- a/html/user/team_quit_action.php
+++ b/html/user/team_quit_action.php
@@ -6,25 +6,15 @@
db_init();
$user = get_logged_in_user();
$teamid = $_POST["id"];
-
$team = lookup_team($teamid);
if ($user->teamid == $team->id) {
- $query_user_table = "update user set teamid = 0 where id = $user->id";
- $result_user_table = mysql_query($query_user_table);
- $query_team_table = "update team set nusers=nusers-1 where id=$team->id";
- $result_team_table = mysql_query($query_team_table);
- if ($result_user_table && $result_team_table) {
- $team_name = $team->name;
- page_head("Quit $team_name");
- echo "Removed from team
";
- echo "You have been removed from id>$team_name";
- } else {
- page_head("Error");
- echo "Couldn't quit team - please try later.\n";
- }
+ mysql_query("update user set teamid=0 where id=$user->id");
+ team_update_nusers($team);
+ page_head("Quit $team->name");
+ echo "You have been removed from id>$team->name";
} else {
- page_head("Unable to remove $user->name");
- echo "$user->name is not a member of $team_name.\n";
+ page_head("Unable to quit team");
+ echo "Team doesn't exist, or you don't belong to it.\n";
}
page_tail();
diff --git a/html/user/team_quit_form.php b/html/user/team_quit_form.php
index 65d9a3219e..d560eac259 100644
--- a/html/user/team_quit_form.php
+++ b/html/user/team_quit_form.php
@@ -8,31 +8,28 @@ db_init();
$user = get_logged_in_user(true);
$id = $user->teamid;
- $result = mysql_query("select * from team where id=$id");
- if ($result) {
- $team = mysql_fetch_object($result);
- mysql_free_result($result);
- }
- $team_name = $team->name;
- $team_id = $team->id;
- page_head("Quit $team_name");
- echo "Quit $team_name
";
- echo "";
- echo "
";
- page_tail();
+$result = mysql_query("select * from team where id=$id");
+if ($result) {
+ $team = mysql_fetch_object($result);
+ mysql_free_result($result);
+}
+$team_name = $team->name;
+$team_id = $team->id;
+page_head("Quit $team_name");
+echo "
+ Please note before quitting a team:
+ ";
- echo " ";
- echo "
";
- echo "";
- echo "
";
- echo "";
- echo "
+
+
The team has been disbanded because there are no more members."; + if ($ndel) { + team_update_nusers($team); } - $result = mysql_query($query); page_tail(); diff --git a/html/user/team_remove_inactive_form.php b/html/user/team_remove_inactive_form.php index 2daaf510d8..6eb9a2c575 100644 --- a/html/user/team_remove_inactive_form.php +++ b/html/user/team_remove_inactive_form.php @@ -7,22 +7,14 @@ db_init(); $user = get_logged_in_user(); $teamid = $_GET["teamid"]; - - $result = mysql_query("select * from team where id = $teamid"); - if ($result) { - $team = mysql_fetch_object($result); - mysql_free_result($result); - } + $team = lookup_team($teamid); require_founder_login($user, $team); - $team_name = $team->name; - $team_id = $team->id; $nusers = $team->nusers; - page_head("Remove Members from $team_name"); + page_head("Remove Members from $team->name"); echo " -