diff options
author | Frédéric Guillot <contact@fredericguillot.com> | 2014-03-06 21:47:16 -0500 |
---|---|---|
committer | Frédéric Guillot <contact@fredericguillot.com> | 2014-03-06 21:47:16 -0500 |
commit | e0b67d773a6930ff92c828122f9fe541b3bd6deb (patch) | |
tree | a83c3e5a098ae170f50436937de0542be0d9fdaa /models | |
parent | 544f9924241f9b2caaf83ead203161ea41e5f1cf (diff) |
Assign existing tasks to nobody when a user is removed
Diffstat (limited to 'models')
-rw-r--r-- | models/user.php | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/models/user.php b/models/user.php index 2832a3fb..394cf742 100644 --- a/models/user.php +++ b/models/user.php @@ -63,7 +63,15 @@ class User extends Base public function remove($user_id) { - return $this->db->table(self::TABLE)->eq('id', $user_id)->remove(); + $this->db->startTransaction(); + + // All tasks assigned to this user will be unassigned + $this->db->table(Task::TABLE)->eq('owner_id', $user_id)->update(array('owner_id' => '')); + $this->db->table(self::TABLE)->eq('id', $user_id)->remove(); + + $this->db->closeTransaction(); + + return true; } public function updateSession(array $user = array()) |