From bc129629da47b30b6b8edfb266832830c1d2b6a5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?C=C3=B4me=20Chilliet?= <come.bernigaud@opensides.be>
Date: Thu, 17 Mar 2016 10:41:22 +0100
Subject: [PATCH] Fixes #4529 Fixed fatal error in departement

---
 plugins/admin/departments/class_department.inc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/plugins/admin/departments/class_department.inc b/plugins/admin/departments/class_department.inc
index a4d781cef..4467fcaaa 100644
--- a/plugins/admin/departments/class_department.inc
+++ b/plugins/admin/departments/class_department.inc
@@ -147,11 +147,13 @@ class department extends simplePlugin
     $categoriesList = $this->config->get_cfg_value('DepartmentCategories', array());
 
     /* Insert current value to possibilities */
-    $businessCategory = $this->attributesAccess['businessCategory']->getValue();
-    if (($businessCategory != "") && !in_array($businessCategory, $categoriesList)) {
-      $categoriesList[] = $businessCategory;
+    if (isset($this->attributesAccess['businessCategory'])) {
+      $businessCategory = $this->attributesAccess['businessCategory']->getValue();
+      if (($businessCategory != "") && !in_array($businessCategory, $categoriesList)) {
+        $categoriesList[] = $businessCategory;
+      }
+      $this->attributesAccess['businessCategory']->setChoices($categoriesList);
     }
-    $this->attributesAccess['businessCategory']->setChoices($categoriesList);
 
     $this->attributesAccess[$this->getNamingAttr()]->setUnique(TRUE);
   }
-- 
GitLab