From ecf693120f4a4f4ba712de9daaf7faa6f63f7920 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Sun, 27 Sep 2015 22:02:42 -0500 Subject: [PATCH] staff: Cleanup staff-dept records on staff deletion --- include/class.staff.php | 5 +++++ include/staff/department.inc.php | 2 ++ 2 files changed, 7 insertions(+) diff --git a/include/class.staff.php b/include/class.staff.php index 539160259..f0173d360 100644 --- a/include/class.staff.php +++ b/include/class.staff.php @@ -692,6 +692,11 @@ implements AuthenticatedUser, EmailContact, TemplateVariable { ->filter(array('staff_id'=>$this->getId())) ->delete(); + // Cleanup staff dept access + StaffDeptAccess::objects() + ->filter(array('staff_id'=>$this->getId())) + ->delete(); + return true; } diff --git a/include/staff/department.inc.php b/include/staff/department.inc.php index 7b6efb32e..4fa72ef7c 100644 --- a/include/staff/department.inc.php +++ b/include/staff/department.inc.php @@ -419,6 +419,8 @@ $('#add_extended_access').find('button').on('click', function() { if ($dept) { $members = $dept->members->all(); foreach ($dept->extended as $x) { + if (!$x->staff) + continue; $members[] = new AnnotatedModel($x->staff, array( 'alerts' => $x->isAlertsEnabled(), 'role_id' => $x->role_id, -- GitLab