From 37283c798c5061dbd5a05073049f9718eb319e57 Mon Sep 17 00:00:00 2001 From: Jared Hancock <gravydish@gmail.com> Date: Mon, 18 Jun 2012 15:08:54 -0500 Subject: [PATCH] Delete and cleanup in proper order --- include/class.team.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/include/class.team.php b/include/class.team.php index 116fae389..48d7b5655 100644 --- a/include/class.team.php +++ b/include/class.team.php @@ -142,15 +142,22 @@ class Team { if(!$thisstaff || !($id=$this->getId())) return false; - # Remove members of this team - db_query('DELETE FROM '.TEAM_MEMBER_TABLE - .' WHERE team_id='.db_input($id)); - # Remove the team $res = db_query( 'DELETE FROM '.TEAM_TABLE.' WHERE team_id='.db_input($id) .' LIMIT 1'); - return (db_affected_rows($res) == 1); + if (db_affected_rows($res) != 1) + return false; + + # Remove members of this team + db_query('DELETE FROM '.TEAM_MEMBER_TABLE + .' WHERE team_id='.db_input($id)); + + # Reset ticket ownership for tickets owned by this team + db_query('UPDATE '.TICKET_TABLE.' SET team_id=0 WHERE team_id=' + .db_input($id)); + + return true; } /* ----------- Static function ------------------*/ -- GitLab