2007-11-07 17:32:04 +00:00
< ? php
2008-08-05 22:43:14 +00:00
// This file is part of BOINC.
// http://boinc.berkeley.edu
2014-04-18 06:31:51 +00:00
// Copyright (C) 2014 University of California
2008-08-05 22:43:14 +00:00
//
// 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/>.
2007-11-07 17:32:04 +00:00
require_once ( " ../inc/boinc_db.inc " );
require_once ( " ../inc/util.inc " );
require_once ( " ../inc/team.inc " );
2014-04-18 06:31:51 +00:00
if ( DISABLE_TEAMS ) error_page ( " Teams are disabled " );
2011-02-09 22:11:34 +00:00
check_get_args ( array ( " tnow " , " ttok " , " userid " , " email_addr " , " teamid " , " action " ));
2007-11-07 17:32:04 +00:00
function show_admin ( $user , $admin ) {
2007-11-07 17:54:27 +00:00
$admin_user = BoincUser :: lookup_id ( $admin -> userid );
2007-11-07 23:59:08 +00:00
$tokens = url_tokens ( $user -> authenticator );
2007-11-07 17:32:04 +00:00
$date = date_str ( $admin -> create_time );
echo " <tr>
2014-09-18 17:08:45 +00:00
< td > " .user_links( $admin_user , BADGE_HEIGHT_MEDIUM). " </ td >
2007-11-07 17:32:04 +00:00
< td > $date </ td >
< td >
" ;
2010-02-16 01:06:03 +00:00
show_button ( " team_admins.php?teamid= $admin->teamid &action=remove&userid= $admin_user->id " . $tokens , tra ( " Remove " ), tra ( " Remove Team Admin status from this member " ));
2007-11-07 17:32:04 +00:00
echo " </td></tr>
" ;
}
2007-11-07 17:54:27 +00:00
function show_admins ( $user , $teamid ) {
2010-02-16 01:06:03 +00:00
page_head ( tra ( " Add or remove Team Admins " ));
echo tra ( " You can select team members as 'Team Admins'. Team Admins can: " ) . "
2007-11-07 17:32:04 +00:00
< ul >
2010-02-16 01:06:03 +00:00
< li > " .tra( " Edit team information ( name , URL , description , country ) " ). "
< li > " .tra( " View the team ' s join / quit history " ). "
< li > " .tra( " Moderate the team forum , if any ( admins get email notification of moderation events and red X reports ) " ). "
2007-11-07 17:32:04 +00:00
</ ul >
2010-02-16 01:06:03 +00:00
" .tra( " Team Admins cannot : " ). "
2007-11-07 17:32:04 +00:00
< ul >
2010-02-16 01:06:03 +00:00
< li > " .tra( " Change the team founder " ). "
< li > " .tra( " Remove members " ). "
< li > " .tra( " Add or remove Team Admins " ). "
2007-11-07 17:32:04 +00:00
</ ul >
2010-02-16 01:06:03 +00:00
" .tra( " If a Team Admin quits the team , they cease to be a Team Admin . " ). "
< br />< br /> " .tra( " We recommend that you select only people you know and trust very well as Team Admins . " )
;
2007-11-07 17:32:04 +00:00
$admins = BoincTeamAdmin :: enum ( " teamid= $teamid " );
start_table ();
if ( count ( $admins ) == 0 ) {
2010-02-16 01:06:03 +00:00
row1 ( tra ( " There are currently no Team Admins " ));
2007-11-07 17:32:04 +00:00
} else {
2010-02-16 01:06:03 +00:00
row1 ( tra ( " Current Team Admins " ), 3 );
table_header ( tra ( " Name " ), tra ( " Became Team Admin on " ), " " );
2007-11-07 17:32:04 +00:00
foreach ( $admins as $admin ) {
show_admin ( $user , $admin );
}
}
end_table ();
echo "
< p >
< form action = team_admins . php >
< input type = hidden name = action value = add >
< input type = hidden name = teamid value = $teamid >
" ;
2007-11-07 23:59:08 +00:00
echo form_tokens ( $user -> authenticator );
2007-11-07 17:32:04 +00:00
start_table ();
2010-02-16 01:06:03 +00:00
row1 ( tra ( " Add Team Admin " ));
row2 ( tra ( " Email address of team member: " ), " <input name=email_addr> " );
2014-10-02 19:15:54 +00:00
row2 ( " " , " <input class= \" btn btn-default \" type=submit action value= \" " . tra ( " Add " ) . " \" > " );
2007-11-07 17:32:04 +00:00
end_table ();
echo " </form> " ;
page_tail ();
}
function remove_admin ( $team ) {
$userid = get_int ( 'userid' );
$ret = BoincTeamAdmin :: delete ( " teamid= $team->id and userid= $userid " );
if ( ! $ret ) {
2010-02-16 01:06:03 +00:00
error_page ( tra ( " failed to remove admin " ));
2007-11-07 17:32:04 +00:00
}
}
function add_admin ( $team ) {
$email_addr = get_str ( 'email_addr' );
2013-01-08 03:40:20 +00:00
$email_addr = BoincDb :: escape_string ( $email_addr );
2007-11-07 17:32:04 +00:00
$user = BoincUser :: lookup ( " email_addr=' $email_addr ' " );
2010-02-16 01:06:03 +00:00
if ( ! $user ) error_page ( tra ( " no such user " ));
if ( $user -> teamid != $team -> id ) error_page ( tra ( " User is not member of team " ));
2007-11-15 22:51:05 +00:00
if ( is_team_admin ( $user , $team )) {
2010-02-16 01:06:03 +00:00
error_page ( tra ( " %1 is already an admin of %2 " , $email_addr , $team -> name ));
2007-11-07 17:32:04 +00:00
}
$now = time ();
$ret = BoincTeamAdmin :: insert ( " (teamid, userid, create_time) values ( $team->id , $user->id , $now ) " );
2010-02-16 01:06:03 +00:00
if ( ! $ret ) error_page ( tra ( " Couldn't add admin " ));
2007-11-07 17:32:04 +00:00
}
$user = get_logged_in_user ();
$teamid = get_int ( 'teamid' );
$team = BoincTeam :: lookup_id ( $teamid );
2010-02-16 01:06:03 +00:00
if ( ! $team ) error_page ( tra ( " No such team " ));
2007-11-07 17:32:04 +00:00
require_founder_login ( $user , $team );
$action = get_str ( 'action' , true );
switch ( $action ) {
case 'remove' :
2007-11-07 23:59:08 +00:00
check_tokens ( $user -> authenticator );
2007-11-07 17:32:04 +00:00
remove_admin ( $team );
Header ( " Location: team_admins.php?teamid= $teamid " );
exit ();
case 'add' :
2007-11-07 23:59:08 +00:00
check_tokens ( $user -> authenticator );
2007-11-07 17:32:04 +00:00
add_admin ( $team );
Header ( " Location: team_admins.php?teamid= $teamid " );
exit ();
}
2007-11-07 17:54:27 +00:00
show_admins ( $user , $teamid );
2007-11-07 17:32:04 +00:00
?>