public function afterRemove()
{
$db = ezcDbInstance::get();
$stmt = $db->prepare("SELECT user_id FROM lh_userdep WHERE dep_group_id = :dep_group_id AND dep_id = :dep_id");
$stmt->bindValue(':dep_group_id', $this->dep_group_id);
$stmt->bindValue(':dep_id', $this->dep_id);
$stmt->execute();
$user_ids = array_unique($stmt->fetchAll(PDO::FETCH_COLUMN));
$stmt = $db->prepare('DELETE FROM lh_userdep WHERE dep_group_id = :dep_group_id AND dep_id = :dep_id');
$stmt->bindValue(':dep_group_id', $this->dep_group_id);
$stmt->bindValue(':dep_id', $this->dep_id);
$stmt->execute();
if (!empty($user_ids)) {
foreach ($user_ids as $userId) {
self::updateUserDepartmentsIds($userId);
}
}
}