2007-11-07 17:32:04 +00:00
< ? php
require_once ( " ../inc/boinc_db.inc " );
require_once ( " ../inc/util.inc " );
require_once ( " ../inc/team.inc " );
function show_admin ( $user , $admin ) {
2007-11-07 17:54:27 +00:00
$admin_user = BoincUser :: lookup_id ( $admin -> userid );
$tokens = url_tokens ( $user -> auth );
2007-11-07 17:32:04 +00:00
$date = date_str ( $admin -> create_time );
echo " <tr>
2007-11-07 17:54:27 +00:00
< td > " .user_links( $admin_user ). " </ td >
2007-11-07 17:32:04 +00:00
< td > $date </ td >
< td >
" ;
2007-11-07 17:54:27 +00:00
show_button ( " team_admins.php?teamid= $admin->teamid &action=remove&userid= $admin_user->id " . $tokens , " Remove " , " 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 ) {
2007-11-07 17:32:04 +00:00
page_head ( " Add or remove Team Admins " );
echo "
You can select team members as 'Team Admins' .
Team Admins can :
< ul >
< li > Edit team information ( name , URL , description , country ) .
< li > Remove members .
< li > View the member list ( including email addresses ) .
< li > View the team ' s join / quit history .
</ ul >
Team Admins cannot :
< ul >
< li > Change the team founder .
< li > Add or remove Team Admins .
</ ul >
If a Team Admin quits the team , they cease to be a Team Admin .
< p >
We recommend that you select only people
you know and trust very well as Team Admins .
" ;
$admins = BoincTeamAdmin :: enum ( " teamid= $teamid " );
start_table ();
if ( count ( $admins ) == 0 ) {
2007-11-07 17:54:27 +00:00
row1 ( " There are currently no Team Admins " );
2007-11-07 17:32:04 +00:00
} else {
row1 ( " Current Team Admins " , 3 );
table_header ( " Name " , " Became Team Admin on " , " " );
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 17:54:27 +00:00
echo form_tokens ( $user -> auth );
2007-11-07 17:32:04 +00:00
start_table ();
row1 ( " Add Team Admin " );
row2 ( " Email address of team member: " , " <input name=email_addr> " );
row2 ( " " , " <input type=submit action value= \" Add \" > " );
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 ) {
error_page ( " failed to remove admin " );
}
}
function add_admin ( $team ) {
$email_addr = get_str ( 'email_addr' );
$user = BoincUser :: lookup ( " email_addr=' $email_addr ' " );
if ( ! $user ) error_page ( " no such user " );
if ( $user -> teamid != $team -> id ) error_page ( " User is not member of team " );
if ( is_admin ( $user , $team )) {
error_page ( " $email_addr is already an admin of $team->name " );
}
$now = time ();
$ret = BoincTeamAdmin :: insert ( " (teamid, userid, create_time) values ( $team->id , $user->id , $now ) " );
if ( ! $ret ) error_page ( " Couldn't add admin " );
}
$user = get_logged_in_user ();
$teamid = get_int ( 'teamid' );
$team = BoincTeam :: lookup_id ( $teamid );
if ( ! $team ) error_page ( " No such team " );
require_founder_login ( $user , $team );
$action = get_str ( 'action' , true );
switch ( $action ) {
case 'remove' :
2007-11-07 17:54:27 +00:00
check_tokens ( $user -> auth );
2007-11-07 17:32:04 +00:00
remove_admin ( $team );
Header ( " Location: team_admins.php?teamid= $teamid " );
exit ();
case 'add' :
2007-11-07 17:54:27 +00:00
check_tokens ( $user -> auth );
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
?>