From a7cc49fe2e5951bdb517cda1fd5581c744162bf0 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 13 Aug 2015 15:25:19 -0500
Subject: [PATCH] topic: Sort manually if configured

---
 include/class.config.php | 4 ++--
 include/class.topic.php  | 5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/include/class.config.php b/include/class.config.php
index 5a169199d..9fbddc5ac 100644
--- a/include/class.config.php
+++ b/include/class.config.php
@@ -530,8 +530,8 @@ class OsticketConfig extends Config {
 
     static function allTopicSortModes() {
         return array(
-            'a' => __('Alphabetically'),
-            'm' => __('Manually'),
+            Topic::SORT_ALPHA   => __('Alphabetically'),
+            Topic::SORT_MANUAL  => __('Manually'),
         );
     }
 
diff --git a/include/class.topic.php b/include/class.topic.php
index 140be9215..6b8f814e1 100644
--- a/include/class.topic.php
+++ b/include/class.topic.php
@@ -69,6 +69,9 @@ implements TemplateVariable {
 
     const FLAG_CUSTOM_NUMBERS = 0x0001;
 
+    const SORT_ALPHA = 'a';
+    const SORT_MANUAL = 'm';
+
     function asVar() {
         return $this->getName();
     }
@@ -353,7 +356,7 @@ implements TemplateVariable {
         // primary, the list may need to be sorted. Caching is ok here,
         // because the locale is not going to be changed within a single
         // request.
-        if ($localize)
+        if ($localize && $cfg->getTopicSortMode() == self::SORT_ALPHA)
             return Internationalization::sortKeyedList($requested_names);
 
         return $requested_names;
-- 
GitLab