From ab2453a35a12b4216cd1bce534f07cdec75ec0dc Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 7 Jul 2015 23:10:59 -0700 Subject: [PATCH] web: fix bug if request foundership of a team with no founder. Also, grant such a request immediately --- html/user/team_founder_transfer_action.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/html/user/team_founder_transfer_action.php b/html/user/team_founder_transfer_action.php index d8e2017448..c625ae9d89 100644 --- a/html/user/team_founder_transfer_action.php +++ b/html/user/team_founder_transfer_action.php @@ -38,8 +38,7 @@ if (!$user->teamid) { error_page(tra("You must be a member of a team to access this page.")); } -function send_founder_transfer_email($team, $user) { - $founder = BoincUser::lookup_id($team->userid); +function send_founder_transfer_email($team, $user, $founder) { // send founder a private message for good measure @@ -87,10 +86,19 @@ $action = post_str("action"); switch ($action) { case "initiate_transfer": $team = BoincTeam::lookup_id($user->teamid); + $founder = BoincUser::lookup_id($team->userid); + if (!$founder) { + // no founder - request is granted immediately + // + $team->update("userid=$user->id"); + page_head("Team founder request granted"); + echo "You are now the founder of $team->name

"; + break; + } $now = time(); if (new_transfer_request_ok($team, $now)) { page_head(tra("Requesting foundership of %1", $team->name)); - $success = send_founder_transfer_email($team, $user); + $success = send_founder_transfer_email($team, $user, $founder); // Go ahead with the transfer even if the email send fails. // Otherwise it would be impossible to rescue a team