From 77283f76db11263ea0ac75a8be4cd0138e936185 Mon Sep 17 00:00:00 2001
From: aydreeihn <adriane@enhancesoft.com>
Date: Mon, 11 Sep 2017 16:52:13 -0500
Subject: [PATCH] if topic has inactive dept saved, change it to system default
 dept

---
 include/staff/helptopics.inc.php | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/staff/helptopics.inc.php b/include/staff/helptopics.inc.php
index 8978b97e3..731bee7c9 100644
--- a/include/staff/helptopics.inc.php
+++ b/include/staff/helptopics.inc.php
@@ -123,6 +123,13 @@ $order_by = 'sort';
                 if ($topic->dept_id) {
                     $deptId = $topic->dept_id;
                     $dept = (string) $topic->dept;
+                    $department = Dept::lookup($deptId);
+                    if (!$department->isActive()) {
+                      $deptId = $defaultDept->getId();
+                      $dept = (string) $defaultDept;
+                      $topic->dept_id = $deptId;
+                      $topic->save();
+                    }
                 } elseif ($defaultDept) {
                     $deptId = $defaultDept->getId();
                     $dept = (string) $defaultDept;
-- 
GitLab