From eee26a0db451d4f4b7f2b3bad2004fb30a6aa506 Mon Sep 17 00:00:00 2001 From: Eric Heien Date: Tue, 20 May 2003 22:20:08 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=1224 --- checkin_notes | 9 ++++++++ html/user/team.inc | 35 ++++++++++++++++++++++++++++++ html/user/team_create_action.php | 6 +++++- html/user/team_join_action.php | 37 ++++---------------------------- todo | 2 -- 5 files changed, 53 insertions(+), 36 deletions(-) diff --git a/checkin_notes b/checkin_notes index d1ebae32aa..2f344cf6ba 100755 --- a/checkin_notes +++ b/checkin_notes @@ -4272,3 +4272,12 @@ Erik May 19 2003 sched/ handle_request.C server_types.C,h + +Eric May 20, 2003 + - When you create a team you automatically join it + + html_user/ + team.inc + team_create_action.php + team_join_action.php + diff --git a/html/user/team.inc b/html/user/team.inc index 4a2f85be09..3ebb6aff38 100644 --- a/html/user/team.inc +++ b/html/user/team.inc @@ -135,6 +135,41 @@ function show_team_row($team, $i) { $team->total_credit, $team->country ); } +function user_join_team($team, $user) { + if ($user->teamid != 0) { + $query_team_other = sprintf( + "select * from team where id = %d", + $user->teamid + ); + $result_team_other = mysql_query($query_team_other); + $first_team = mysql_fetch_object($result_team_other); + $first_nusers = $first_team->nusers; + $first_new_nusers = $first_nusers - 1; + $query_team_table_other = sprintf( + "update team set nusers = %d where id = %d", + $first_new_nusers, + $first_team->id + ); + $result_team_table_other = mysql_query($query_team_table_other); + } + $query_user_table = sprintf( + "update user set teamid = %d where id = %d", + $team->id, + $user->id + ); + $result_user_table = mysql_query($query_user_table); + $nusers = $team->nusers; + $new_nusers = $nusers + 1; + $query_team_table = sprintf( + "update team set nusers = %d where id = %d", + $new_nusers, + $team->id + ); + $result_team_table = mysql_query($query_team_table); + if ($result_user_table && $result_team_table) return true; + else return false; +} + function team_edit_form($team, $label, $url) { echo "
\n"; if ($team) { diff --git a/html/user/team_create_action.php b/html/user/team_create_action.php index c0154dc92e..b8e9253efa 100644 --- a/html/user/team_create_action.php +++ b/html/user/team_create_action.php @@ -23,12 +23,16 @@ $_POST["name_html"], $_POST["description"], $_POST["country"], - 1 + 0 ); $result = mysql_query($query); if ($result) { $teamid = mysql_insert_id(); + $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); Header("Location: team_display.php?teamid=$teamid"); } else { page_head("Error"); diff --git a/html/user/team_join_action.php b/html/user/team_join_action.php index 88bf7b413d..8181c47593 100644 --- a/html/user/team_join_action.php +++ b/html/user/team_join_action.php @@ -16,41 +16,12 @@ page_head("Unable to add $user->name"); echo "You are already a member of $team->name."; } else { - if ($user->teamid != 0) { - $query_team_other = sprintf( - "select * from team where id = %d", - $user->teamid - ); - $result_team_other = mysql_query($query_team_other); - $first_team = mysql_fetch_object($result_team_other); - $first_nusers = $first_team->nusers; - $first_new_nusers = $first_nusers - 1; - $query_team_table_other = sprintf( - "update team set nusers = %d where id = %d", - $first_new_nusers, - $first_team->id - ); - $result_team_table_other = mysql_query($query_team_table_other); - } - $query_user_table = sprintf( - "update user set teamid = %d where id = %d", - $team->id, - $user->id - ); - $result_user_table = mysql_query($query_user_table); - $nusers = $team->nusers; - $new_nusers = $nusers + 1; - $query_team_table = sprintf( - "update team set nusers = %d where id = %d", - $new_nusers, - $team->id - ); - $result_team_table = mysql_query($query_team_table); - if ($result_user_table && $result_team_table) { - page_head("Joined $team_name"); + $success = user_join_team($team,$user); + if ($success == true) { + page_head("Joined $team->name"); echo "

Joined team

"; echo "You have joined - id>$team_name. + id>$team->name. "; } else { page_head("Error"); diff --git a/todo b/todo index 2ebd0d9300..70ad328c96 100755 --- a/todo +++ b/todo @@ -107,8 +107,6 @@ implement a "fetch prefs" command (regular RPC w/o work request) all RPCs should return a "user-specific project URL" to be used in GUI (might refer to user page) -when you create a team you should join that team - in GUI, project name should hyperlink to a project-specified URL (typically user page for that project)