diff --git a/include/class.staff.php b/include/class.staff.php index 539160259bf730795b28ddc59de4efee0632efcb..f0173d360ca462241cdaee69e3716f686a14ecdb 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 7b6efb32ef9a64b1b0822fd9e34354de5bbb3b31..4fa72ef7c412f1732eca323faf1c53af97664c60 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,