From 0c803634c97b07bd7298cef15f7c02e0954aab94 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Mon, 10 Aug 2015 08:43:22 -0500 Subject: [PATCH] dept: Correct ability to add duplicate name --- include/class.dept.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/class.dept.php b/include/class.dept.php index bcdfecf07..cc16d9578 100644 --- a/include/class.dept.php +++ b/include/class.dept.php @@ -420,11 +420,11 @@ implements TemplateVariable { } /*----Static functions-------*/ - static function getIdByName($name, $pid=0) { + static function getIdByName($name, $pid=null) { $row = static::objects() ->filter(array( 'name' => $name, - 'pid' => $pid ?: 0)) + 'pid' => $pid ?: null)) ->values_flat('id') ->first(); @@ -553,7 +553,7 @@ implements TemplateVariable { if (!$vars['name']) { $errors['name']=__('Name required'); } elseif (($did = static::getIdByName($vars['name'], $vars['pid'])) - && $did != $this->id) { + && $did != $id) { $errors['name']=__('Department already exists'); } @@ -576,7 +576,7 @@ implements TemplateVariable { if ($errors) return false; - $this->pid = $vars['pid'] ?: 0; + $this->pid = $vars['pid'] ?: null; $this->ispublic = isset($vars['ispublic'])?$vars['ispublic']:0; $this->email_id = isset($vars['email_id'])?$vars['email_id']:0; $this->tpl_id = isset($vars['tpl_id'])?$vars['tpl_id']:0; -- GitLab