From aa036256b328b5b0bf3465754d21b2cda05891ff Mon Sep 17 00:00:00 2001
From: Peter Rotich <peter@osticket.com>
Date: Thu, 13 Aug 2015 18:23:36 +0000
Subject: [PATCH] bug: __create

Department/Topic create now considers the possibility of preset id (primary key)
Default help topic routing to floating system's default department
---
 include/class.dept.php             | 2 +-
 include/class.i18n.php             | 2 --
 include/class.topic.php            | 4 +++-
 include/i18n/en_US/help_topic.yaml | 5 +----
 4 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/include/class.dept.php b/include/class.dept.php
index cc16d9578..d33b1bb12 100644
--- a/include/class.dept.php
+++ b/include/class.dept.php
@@ -530,7 +530,7 @@ implements TemplateVariable {
     }
 
     static function __create($vars, &$errors) {
-        $dept = self::create();
+        $dept = self::create($vars);
         $dept->update($vars, $errors);
 
         return isset($dept->id) ? $dept : null;
diff --git a/include/class.i18n.php b/include/class.i18n.php
index 3c0da2b24..9163f6cf0 100644
--- a/include/class.i18n.php
+++ b/include/class.i18n.php
@@ -64,8 +64,6 @@ class Internationalization {
             'ticket_status.yaml' => 'TicketStatus::__create',
             // Role
             'role.yaml' =>          'Role::__create',
-            // Note that group requires department
-            'group.yaml' =>         'Group::__create',
             'file.yaml' =>          'AttachmentFile::__create',
             'sequence.yaml' =>      'Sequence::__create',
         );
diff --git a/include/class.topic.php b/include/class.topic.php
index b97513636..140be9215 100644
--- a/include/class.topic.php
+++ b/include/class.topic.php
@@ -281,7 +281,9 @@ implements TemplateVariable {
     }
 
     static function __create($vars, &$errors) {
-        $topic = self::create();
+        $topic = self::create($vars);
+        if (!isset($vars['dept_id']))
+            $vars['dept_id'] = 0;
         $topic->update($vars, $errors);
         return $topic;
     }
diff --git a/include/i18n/en_US/help_topic.yaml b/include/i18n/en_US/help_topic.yaml
index ab9c195eb..76faba0c0 100644
--- a/include/i18n/en_US/help_topic.yaml
+++ b/include/i18n/en_US/help_topic.yaml
@@ -21,7 +21,6 @@
 - topic_id: 1
   isactive: 1
   ispublic: 1
-  dept_id: 1
   priority_id: 2
   forms: [2]
   topic: General Inquiry
@@ -30,7 +29,6 @@
 
 - isactive: 1
   ispublic: 1
-  dept_id: 1
   priority_id: 1
   forms: [2]
   topic: Feedback
@@ -40,7 +38,7 @@
 - topic_id: 10
   isactive: 1
   ispublic: 1
-  dept_id: 1
+  dept_id: 3
   priority_id: 2
   forms: [2]
   topic: Report a Problem
@@ -50,7 +48,6 @@
 - topic_pid: 10
   isactive: 1
   ispublic: 1
-  dept_id: 1
   sla_id: 1
   priority_id: 3
   forms: [2]
-- 
GitLab