2006-10-27 16:06:42 +00:00
< ? php
2008-08-05 22:43:14 +00:00
// This file is part of BOINC.
// http://boinc.berkeley.edu
// Copyright (C) 2008 University of California
//
// BOINC is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation,
// either version 3 of the License, or (at your option) any later version.
//
// BOINC is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
2006-10-27 16:06:42 +00:00
2010-02-16 01:06:03 +00:00
// action = 'initiate_transfer':
// handle a user's request to initiate a foundership transfer
// action = 'finalize_transfer':
// handle a user's request to finalize a foundership transfer
2007-11-07 23:59:08 +00:00
// action = 'decline':
// handle the current founder's declining of the request
2007-06-17 15:34:43 +00:00
2007-10-26 21:14:35 +00:00
require_once ( " ../inc/boinc_db.inc " );
2006-10-27 16:06:42 +00:00
require_once ( " ../inc/util.inc " );
require_once ( " ../inc/team.inc " );
require_once ( " ../inc/email.inc " );
2008-05-27 21:26:49 +00:00
require_once ( " ../inc/pm.inc " );
2006-10-27 16:06:42 +00:00
2011-02-09 22:11:34 +00:00
check_get_args ( array ());
2007-11-07 23:59:08 +00:00
$user = get_logged_in_user ();
2006-11-02 19:43:54 +00:00
if ( ! $user -> teamid ) {
2010-02-16 01:06:03 +00:00
error_page ( tra ( " You must be a member of a team to access this page. " ));
2006-11-02 19:43:54 +00:00
}
2006-10-27 16:06:42 +00:00
2007-07-23 20:30:30 +00:00
function send_founder_transfer_email ( $team , $user ) {
$founder = lookup_user_id ( $team -> userid );
2008-05-27 21:26:49 +00:00
// send founder a private message for good measure
2008-06-13 16:46:28 +00:00
$subject = " Team founder transfer request " ;
2008-06-13 16:40:51 +00:00
$body = " Team member " . $user -> name . " has asked that you
transfer foundership of $team -> name .
Please go [ url = " .URL_BASE. " team_change_founder_form . php ? teamid = $team -> id ] here [ / url ] to grant or decline the request .
If you do not respond within 60 days , " . $user->name . " will
be allowed to become the team founder .
" ;
2011-08-06 07:11:17 +00:00
pm_send ( $user , $founder , $subject , $body , false );
2008-06-13 16:46:28 +00:00
$subject = PROJECT . " team founder transfer " ;
$body = " Team member " . $user -> name . " has asked that you
transfer foundership of $team -> name in " .PROJECT. " .
Please visit
" .URL_BASE. " team_change_founder_form . php ? teamid = " . $team->id . "
to grant or decline the request .
If you do not respond within 60 days , " . $user->name . " will
be allowed to become the team founder .
Please do not respond to this email .
The mailbox is not monitored and the email
was sent using an automated system . " ;
2008-05-27 21:26:49 +00:00
return send_email ( $founder , $subject , $body );
2007-07-23 20:30:30 +00:00
}
function send_founder_transfer_decline_email ( $team , $user ) {
$body = " The founder of " . $team -> name . " has declined your request
2007-11-07 23:59:08 +00:00
to become the founder in " .PROJECT. " .
You can repeat the request at least 90 days after the initial request .
2007-07-23 20:30:30 +00:00
Please do not respond to this email .
The mailbox is not monitored and the email
was sent using an automated system . " ;
return send_email ( $user , PROJECT . " team founder transfer declined " , $body );
}
2006-10-27 16:06:42 +00:00
$action = post_str ( " action " );
2008-06-13 16:40:51 +00:00
switch ( $action ) {
case " initiate_transfer " :
2007-10-26 21:14:35 +00:00
$team = BoincTeam :: lookup_id ( $user -> teamid );
2006-10-27 16:06:42 +00:00
$now = time ();
2007-11-07 23:59:08 +00:00
if ( new_transfer_request_ok ( $team , $now )) {
2010-02-16 01:06:03 +00:00
page_head ( tra ( " Requesting foundership of %1 " , $team -> name ));
2007-11-07 23:59:08 +00:00
$success = send_founder_transfer_email ( $team , $user );
2008-05-27 21:26:49 +00:00
// Go ahead with the transfer even if the email send fails.
// Otherwise it would be impossible to rescue a team
// whose founder email is invalid
//
$team -> update ( " ping_user= $user->id , ping_time= $now " );
2010-02-16 01:06:03 +00:00
echo " <p> " . tra ( " The current founder has been notified of your request by email and private message.<br /><br />
If the founder does not respond within 60 days you will be allowed to become the founder . " )
. " </p> \n " ;
2006-10-27 16:06:42 +00:00
} else {
2010-02-16 01:06:03 +00:00
error_page ( tra ( " Foundership request not allowed now " ));
2008-06-13 16:40:51 +00:00
}
break ;
case " finalize_transfer " :
$team = BoincTeam :: lookup_id ( $user -> teamid );
$now = time ();
if ( $user -> id == $team -> ping_user && transfer_ok ( $team , $now )) {
2010-02-16 01:06:03 +00:00
page_head ( tra ( " Assumed foundership of %1 " , $team -> name ));
2008-06-13 16:40:51 +00:00
$team -> update ( " userid= $user->id , ping_user=0, ping_time=0 " );
2010-02-16 01:06:03 +00:00
echo tra ( " Congratulations, you are now the founder of team %1. Go to %2Your Account page%3 to find the Team Admin options. " , $team -> name , " <a href= \" " . URL_BASE . " home.php \" > " , " </a> " );
2008-06-13 16:40:51 +00:00
} else {
2010-02-16 01:06:03 +00:00
error_page ( tra ( " Foundership request not allowed now " ));
2006-10-27 16:06:42 +00:00
}
2008-06-13 16:40:51 +00:00
break ;
case " decline " :
2006-10-27 16:06:42 +00:00
$teamid = post_int ( " teamid " );
$team = lookup_team ( $teamid );
require_founder_login ( $user , $team );
2010-02-16 01:06:03 +00:00
page_head ( tra ( " Decline founder change request " ));
2006-10-27 16:06:42 +00:00
if ( $team -> ping_user ) {
2007-10-26 21:14:35 +00:00
$ping_user = BoincUser :: lookup_id ( $team -> ping_user );
2007-06-17 15:34:43 +00:00
2007-10-26 21:14:35 +00:00
$team -> update ( " ping_user=0 " );
2007-06-17 15:34:43 +00:00
send_founder_transfer_decline_email ( $team , $ping_user );
2010-02-16 01:06:03 +00:00
echo " <p> " . tra ( " The foundership request from %1 has been declined. " , user_links ( $ping_user ))
. " </p> " ;
2006-10-27 16:06:42 +00:00
} else {
2010-02-16 01:06:03 +00:00
echo " <p> " . tra ( " There were no foundership requests. " ) . " </p> " ;
2006-10-27 16:06:42 +00:00
}
2008-06-13 16:40:51 +00:00
break ;
default :
2010-02-16 01:06:03 +00:00
error_page ( tra ( " undefined action %1 " , $action ));
2006-10-27 16:06:42 +00:00
}
2010-02-16 01:06:03 +00:00
echo " <a href='team_display.php?teamid= $team->id '> " . tra ( " Return to team page " ) . " </a> " ;
2006-10-27 16:06:42 +00:00
page_tail ();
2007-11-07 23:59:08 +00:00
$cvs_version_tracker [] = " \$ Id $ " ; //Generated automatically - do not edit
2006-10-27 16:06:42 +00:00
?>