. require_once("../inc/boinc_db.inc"); require_once("../inc/util.inc"); require_once("../inc/team.inc"); if (DISABLE_TEAMS) error_page("Teams are disabled"); check_get_args(array("tnow", "ttok", "userid", "email_addr", "teamid", "action")); function show_admin($user, $admin) { $admin_user = BoincUser::lookup_id($admin->userid); $tokens = url_tokens($user->authenticator); $date = date_str($admin->create_time); echo "
"; page_tail(); } function remove_admin($team) { $userid = get_int('userid'); $ret = BoincTeamAdmin::delete("teamid=$team->id and userid=$userid"); if (!$ret) { error_page(tra("failed to remove admin")); } } function add_admin($team) { $email_addr = get_str('email_addr'); $email_addr = BoincDb::escape_string($email_addr); $user = BoincUser::lookup("email_addr='$email_addr'"); if (!$user) error_page(tra("no such user")); if ($user->teamid != $team->id) error_page(tra("User is not member of team")); if (is_team_admin($user, $team)) { error_page(tra("%1 is already an admin of %2", $email_addr, $team->name)); } $now = time(); $ret = BoincTeamAdmin::insert("(teamid, userid, create_time) values ($team->id, $user->id, $now)"); if (!$ret) error_page(tra("Couldn't add admin")); } $user = get_logged_in_user(); $teamid = get_int('teamid'); $team = BoincTeam::lookup_id($teamid); if (!$team) error_page(tra("No such team")); require_founder_login($user, $team); $action = get_str('action', true); switch($action) { case 'remove': check_tokens($user->authenticator); remove_admin($team); Header("Location: team_admins.php?teamid=$teamid"); exit(); case 'add': check_tokens($user->authenticator); add_admin($team); Header("Location: team_admins.php?teamid=$teamid"); exit(); } show_admins($user, $teamid); ?>