@@ -226,11 +226,12 @@ function (Filter\Condition $condition) {
226
226
$ db ->update ('contact ' , [
227
227
'full_name ' => $ data ['full_name ' ],
228
228
'username ' => $ data ['username ' ] ?? null ,
229
- 'default_channel_id ' => $ this ->getChannelId ($ data ['default_channel ' ])
229
+ 'default_channel_id ' => $ this ->getChannelId ($ data ['default_channel ' ]),
230
230
], ['id = ? ' => $ contactId ]);
231
231
232
- $ db ->delete ('contact_address ' , ['contact_id = ? ' => $ contactId ]);
233
- $ db ->delete ('contactgroup_member ' , ['contact_id = ? ' => $ contactId ]);
232
+ $ markAsDeleted = ['deleted ' => 'y ' ];
233
+ $ db ->update ('contact_address ' , $ markAsDeleted , ['contact_id = ? ' => $ contactId , 'deleted = ? ' => 'n ' ]);
234
+ $ db ->update ('contactgroup_member ' , $ markAsDeleted , ['contact_id = ? ' => $ contactId , 'deleted = ? ' => 'n ' ]);
234
235
235
236
if (! empty ($ data ['addresses ' ])) {
236
237
$ this ->addAddresses ($ contactId , $ data ['addresses ' ]);
@@ -497,9 +498,26 @@ private function addAddresses(int $contactId, array $addresses): void
497
498
*/
498
499
private function removeContact (int $ id ): void
499
500
{
500
- Database::get ()->delete ('contactgroup_member ' , ['contact_id = ? ' => $ id ]);
501
- Database::get ()->delete ('contact_address ' , ['contact_id = ? ' => $ id ]);
502
- Database::get ()->delete ('contact ' , ['id = ? ' => $ id ]);
501
+ $ db = Database::get ();
502
+ $ markAsDeleted = ['deleted ' => 'y ' ];
503
+
504
+ $ db ->update (
505
+ 'rotation_member ' ,
506
+ $ markAsDeleted + ['position ' => null ],
507
+ ['contact_id = ? ' => $ id , 'deleted = ? ' => 'n ' ]
508
+ );
509
+
510
+ $ db ->update (
511
+ 'rule_escalation_recipient ' ,
512
+ $ markAsDeleted ,
513
+ ['contact_id = ? ' => $ id , 'deleted = ? ' => 'n ' ]
514
+ );
515
+
516
+ $ db ->update ('contactgroup_member ' , $ markAsDeleted , ['contact_id = ? ' => $ id , 'deleted = ? ' => 'n ' ]);
517
+ $ db ->update ('contact_address ' , $ markAsDeleted , ['contact_id = ? ' => $ id , 'deleted = ? ' => 'n ' ]);
518
+ $ db ->update ('contact ' , $ markAsDeleted , ['id = ? ' => $ id ]);
519
+
520
+ //TODO: properly remove rotations|escalations with no members as in form
503
521
}
504
522
505
523
/**
0 commit comments