From 8f9ad9b41977f7bb9a79f41adb9334027ea81938 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 1 Dec 2014 11:46:23 -0600
Subject: [PATCH] oops: Fix update of empty group dept access list

---
 include/class.group.php | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/include/class.group.php b/include/class.group.php
index 0a9dc94e1..635228974 100644
--- a/include/class.group.php
+++ b/include/class.group.php
@@ -97,7 +97,7 @@ class Group extends VerySimpleModel {
 
 
     function updateDeptAccess($dept_ids) {
-        if ($dept_ids && is_array($dept_ids)) {
+        if (is_array($dept_ids)) {
             $groups = GroupDeptAccess::objects()
                 ->filter(array('group_id' => $this->getId()));
             foreach ($groups as $group) {
@@ -111,9 +111,8 @@ class Group extends VerySimpleModel {
                     'group_id'=>$this->getId(), 'dept_id'=>$id
                 ))->save();
             }
-            return true;
         }
-        return false;
+        return true;
     }
 
     function delete() {
@@ -204,7 +203,7 @@ class Group extends VerySimpleModel {
         $this->notes=Format::sanitize($vars['notes']);
 
         if ($this->save())
-            return $this->updateDeptAccess($vars['depts']);
+            return $this->updateDeptAccess($vars['depts'] ?: array());
 
         if (isset($this->group_id)) {
             $errors['err']=sprintf(__('Unable to update %s.'), __('this group'))
-- 
GitLab