From 8ed92f3df06c62f67944489b23d6fd9f9778716a Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 13 Oct 2015 07:32:27 -0500
Subject: [PATCH] queue: Shore up the installer

---
 bootstrap.php                       | 2 +-
 include/ajax.search.php             | 1 -
 include/class.config.php            | 1 -
 include/class.i18n.php              | 1 +
 include/class.queue.php             | 6 ++++++
 include/i18n/en_US/config.yaml      | 1 +
 include/staff/queues-ticket.inc.php | 3 ---
 scp/queues.php                      | 2 --
 scp/tickets.php                     | 1 -
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/bootstrap.php b/bootstrap.php
index c00e425c3..df723ae7a 100644
--- a/bootstrap.php
+++ b/bootstrap.php
@@ -207,7 +207,7 @@ class Bootstrap {
         require(INCLUDE_DIR.'class.mailer.php');
         require_once INCLUDE_DIR.'mysqli.php';
         require_once INCLUDE_DIR.'class.i18n.php';
-        require_once INCLUDE_DIR.'class.search.php';
+        require_once INCLUDE_DIR.'class.queue.php';
     }
 
     function i18n_prep() {
diff --git a/include/ajax.search.php b/include/ajax.search.php
index 55dd5aa01..db9fab815 100644
--- a/include/ajax.search.php
+++ b/include/ajax.search.php
@@ -19,7 +19,6 @@ if(!defined('INCLUDE_DIR')) die('403');
 
 include_once(INCLUDE_DIR.'class.ticket.php');
 require_once(INCLUDE_DIR.'class.ajax.php');
-require_once(INCLUDE_DIR.'class.queue.php');
 
 class SearchAjaxAPI extends AjaxController {
 
diff --git a/include/class.config.php b/include/class.config.php
index 20c09e1dd..1a37d3e0b 100644
--- a/include/class.config.php
+++ b/include/class.config.php
@@ -1241,7 +1241,6 @@ class OsticketConfig extends Config {
         if (!preg_match('`(?!<\\\)#`', $vars['ticket_number_format']))
             $errors['ticket_number_format'] = 'Ticket number format requires at least one hash character (#)';
 
-        require_once INCLUDE_DIR . 'class.queue.php';
         if (!isset($vars['default_ticket_queue']))
             $errors['default_ticket_queue'] = __("Select a default ticket queue");
         elseif (!CustomQueue::lookup($vars['default_ticket_queue']))
diff --git a/include/class.i18n.php b/include/class.i18n.php
index 69814a0a3..d7aaa71ed 100644
--- a/include/class.i18n.php
+++ b/include/class.i18n.php
@@ -66,6 +66,7 @@ class Internationalization {
             'role.yaml' =>          'Role::__create',
             'file.yaml' =>          'AttachmentFile::__create',
             'sequence.yaml' =>      'Sequence::__create',
+            'queue.yaml' =>         'CustomQueue::__create',
         );
 
         $errors = array();
diff --git a/include/class.queue.php b/include/class.queue.php
index 7690a9023..51bc6ff66 100644
--- a/include/class.queue.php
+++ b/include/class.queue.php
@@ -290,6 +290,12 @@ class CustomQueue extends SavedSearch {
 
         return $queue;
     }
+
+    static function __create($vars) {
+        $q = static::create($vars);
+        $q->save();
+        return $q;
+    }
 }
 
 abstract class QueueColumnAnnotation {
diff --git a/include/i18n/en_US/config.yaml b/include/i18n/en_US/config.yaml
index c849302f4..32783896b 100644
--- a/include/i18n/en_US/config.yaml
+++ b/include/i18n/en_US/config.yaml
@@ -80,3 +80,4 @@ core:
     log_level: 2
     log_graceperiod: 12
     client_registration: 'public'
+    default_ticket_queue: 1
diff --git a/include/staff/queues-ticket.inc.php b/include/staff/queues-ticket.inc.php
index 6ddb5c598..f051d5b7c 100644
--- a/include/staff/queues-ticket.inc.php
+++ b/include/staff/queues-ticket.inc.php
@@ -1,6 +1,3 @@
-<?php
-require_once INCLUDE_DIR . 'class.queue.php';
-?>
 <div>
 <table class="form_table settings_table" width="940" border="0" cellspacing="0" cellpadding="2">
     <thead>
diff --git a/scp/queues.php b/scp/queues.php
index a227238ad..90e8e9bd8 100644
--- a/scp/queues.php
+++ b/scp/queues.php
@@ -17,8 +17,6 @@
 
 require('admin.inc.php');
 
-require_once INCLUDE_DIR . 'class.queue.php';
-
 $nav->setTabActive('settings', 'settings.php?t='.urlencode($_GET['t']));
 $errors = array();
 
diff --git a/scp/tickets.php b/scp/tickets.php
index 1587110b0..f381c3059 100644
--- a/scp/tickets.php
+++ b/scp/tickets.php
@@ -58,7 +58,6 @@ if (!$ticket) {
         $_GET['status'] = $_REQUEST['status'] = $queue_name;
 }
 
-require_once INCLUDE_DIR . 'class.queue.php';
 $queue_id = @$_REQUEST['queue'] ?: $cfg->getDefaultTicketQueueId();
 if ((int) $queue_id) {
     $queue = CustomQueue::lookup($queue_id);
-- 
GitLab