forked from science-ation/science-ation
Disabled deleting teams if they're registered for events
This commit is contained in:
parent
dc63df156c
commit
24c80b1654
@ -146,6 +146,10 @@ function user_row($uid, $username, $firstName, $lastName, $email){
|
|||||||
|
|
||||||
// delete the record for the specified user id. Returns true on succes, error message on failure
|
// delete the record for the specified user id. Returns true on succes, error message on failure
|
||||||
function delete_record($uid){
|
function delete_record($uid){
|
||||||
|
// delete schedule registrations
|
||||||
|
mysql_query("DELETE FROM schedule_registrations_users_link WHERE users_uid = $uid");
|
||||||
|
|
||||||
|
// now delete the user
|
||||||
$user = user_load_by_uid($uid);
|
$user = user_load_by_uid($uid);
|
||||||
user_delete($user);
|
user_delete($user);
|
||||||
$user = user_load_by_uid($uid);
|
$user = user_load_by_uid($uid);
|
||||||
@ -153,6 +157,7 @@ function delete_record($uid){
|
|||||||
if($user['deleted'] != 'yes'){
|
if($user['deleted'] != 'yes'){
|
||||||
return "Failed to delete user";
|
return "Failed to delete user";
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,19 @@ function draw_page(){
|
|||||||
echo i18n('name') . ': <input type="text" name="teamname" value="' . $team['name'] . '"></input>';
|
echo i18n('name') . ': <input type="text" name="teamname" value="' . $team['name'] . '"></input>';
|
||||||
echo '<div style="height:1em;"></div>';
|
echo '<div style="height:1em;"></div>';
|
||||||
echo "<button onclick=\"saveData('" . $team['id'] . "');\">" . i18n('Save') . '</button>';
|
echo "<button onclick=\"saveData('" . $team['id'] . "');\">" . i18n('Save') . '</button>';
|
||||||
echo "<button onclick=\"delete_team('" . $team['id'] . "');\">" . i18n('Delete') . '</button>';
|
$record = mysql_fetch_array(mysql_query("SELECT count(*) AS regCount FROM schedule_registrations WHERE so_teams_id = " . $team['id']));
|
||||||
|
if($record['regCount'] == 0){
|
||||||
|
echo "<button onclick=\"delete_team('" . $team['id'] . "');\">" . i18n('Delete') . '</button>';
|
||||||
|
}else{
|
||||||
|
echo '<div style="font-size: 80%">';
|
||||||
|
echo '<a href="schoolschedule.php" style="color:#666">';
|
||||||
|
if($record['regCount'] > 1){
|
||||||
|
echo i18n("This team is currently registered for %1 events and can not be deleted.", array($record['regCount']));
|
||||||
|
}else{
|
||||||
|
echo i18n("This team is currently registered for an event and can not be deleted.");
|
||||||
|
}
|
||||||
|
echo '</a></div>';
|
||||||
|
}
|
||||||
echo "<input type=\"hidden\" name=\"teamId\" value=\"" . $team['id'] . "\"></input>";
|
echo "<input type=\"hidden\" name=\"teamId\" value=\"" . $team['id'] . "\"></input>";
|
||||||
echo '</form>';
|
echo '</form>';
|
||||||
echo "</div>";
|
echo "</div>";
|
||||||
|
Loading…
Reference in New Issue
Block a user