From 7b241891f39c72a83da648e5030820cb7503c504 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Tue, 3 Jun 2014 13:23:21 -0500
Subject: [PATCH] topics: Restrict delete and disable on default topic

---
 include/class.topic.php | 4 ++++
 scp/helptopics.php      | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/include/class.topic.php b/include/class.topic.php
index af160c303..700072c13 100644
--- a/include/class.topic.php
+++ b/include/class.topic.php
@@ -198,6 +198,10 @@ class Topic {
     }
 
     function delete() {
+        global $cfg;
+
+        if ($this->getId() == $cfg->getDefaultTopicId())
+            return false;
 
         $sql='DELETE FROM '.TOPIC_TABLE.' WHERE topic_id='.db_input($this->getId()).' LIMIT 1';
         if(db_query($sql) && ($num=db_affected_rows())) {
diff --git a/scp/helptopics.php b/scp/helptopics.php
index 9262444a5..b33cad9a5 100644
--- a/scp/helptopics.php
+++ b/scp/helptopics.php
@@ -68,7 +68,8 @@ if($_POST){
                         break;
                     case 'disable':
                         $sql='UPDATE '.TOPIC_TABLE.' SET isactive=0 '
-                            .' WHERE topic_id IN ('.implode(',', db_input($_POST['ids'])).')';
+                            .' WHERE topic_id IN ('.implode(',', db_input($_POST['ids'])).')'
+                            .' AND topic_id <> '.db_input($cfg->getDefaultTopicId());
                         if(db_query($sql) && ($num=db_affected_rows())) {
                             if($num==$count)
                                 $msg = 'Selected help topics disabled';
-- 
GitLab