From cb9e6377f6dd1d16d6c5d1aa98014941eef48814 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Thu, 30 Nov 2017 12:02:48 -0800 Subject: Disable private projects when disabling a user --- app/Model/UserModel.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/Model') diff --git a/app/Model/UserModel.php b/app/Model/UserModel.php index af49ce7d..c44fd3e7 100644 --- a/app/Model/UserModel.php +++ b/app/Model/UserModel.php @@ -286,7 +286,11 @@ class UserModel extends Base */ public function disable($user_id) { - return $this->db->table(self::TABLE)->eq('id', $user_id)->update(array('is_active' => 0)); + $this->db->startTransaction(); + $result1 = $this->db->table(self::TABLE)->eq('id', $user_id)->update(array('is_active' => 0)); + $result2 = $this->db->table(ProjectModel::TABLE)->eq('is_private', 1)->eq('owner_id', $user_id)->update(array('is_active' => 0)); + $this->db->closeTransaction(); + return $result1 && $result2; } /** -- cgit v1.2.3