From f591cafe95034f9802226d992627672f9f0c855b Mon Sep 17 00:00:00 2001
From: JediKev <kevin@enhancesoft.com>
Date: Mon, 4 Mar 2019 13:23:24 -0600
Subject: [PATCH] issue: FAQ Return Errors
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This addresses an issue reported on the Forum where creating a new FAQ and
not filling out required information returns the correct error but returns
the incorrect template (FAQ View Template). This is due to the check for an
FAQ when determining the template to return. This adds a check for the FAQ
ID to determine if it’s an actual FAQ or just a model instance.
---
 include/staff/faq.inc.php | 2 +-
 scp/faq.php               | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/staff/faq.inc.php b/include/staff/faq.inc.php
index 4579deb8d..a31d813a0 100644
--- a/include/staff/faq.inc.php
+++ b/include/staff/faq.inc.php
@@ -4,7 +4,7 @@ if (!defined('OSTSCPINC') || !$thisstaff
     die('Access Denied');
 
 $info = $qs = array();
-if($faq){
+if($faq && $faq->getId()){
     $title=__('Update FAQ').': '.$faq->getQuestion();
     $action='update';
     $submit_text=__('Save Changes');
diff --git a/scp/faq.php b/scp/faq.php
index 8b948c142..164de2393 100644
--- a/scp/faq.php
+++ b/scp/faq.php
@@ -143,7 +143,7 @@ if ($_POST) {
 }
 
 $inc='faq-categories.inc.php'; //FAQs landing page.
-if($faq) {
+if($faq && $faq->getId()) {
     $inc='faq-view.inc.php';
     if ($_REQUEST['a']=='edit'
             && $thisstaff->hasPerm(FAQ::PERM_MANAGE))
-- 
GitLab