From 10a30228b31a7d71b7ddb765936221d80884ab2a Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Mon, 20 Jul 2015 15:49:19 -0500
Subject: [PATCH] client: Drop open new ticket links if web tickets disabled

---
 include/client/accesslink.inc.php         | 10 +++++++---
 include/client/login.inc.php              |  4 +++-
 include/client/templates/sidebar.tmpl.php |  6 ++++--
 open.php                                  |  5 ++++-
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/include/client/accesslink.inc.php b/include/client/accesslink.inc.php
index 9143186b8..46413f42b 100644
--- a/include/client/accesslink.inc.php
+++ b/include/client/accesslink.inc.php
@@ -50,7 +50,11 @@ else
 </form>
 <br>
 <p>
-<?php echo sprintf(
-__("If this is your first time contacting us or you've lost the ticket number, please %s open a new ticket %s"),
-    '<a href="open.php">','</a>'); ?>
+<?php
+if ($cfg->getClientRegistrationMode() != 'disabled'
+    || !$cfg->isClientLoginRequired()) {
+    echo sprintf(
+    __("If this is your first time contacting us or you've lost the ticket number, please %s open a new ticket %s"),
+        '<a href="open.php">','</a>');
+} ?>
 </p>
diff --git a/include/client/login.inc.php b/include/client/login.inc.php
index 5c6413f9b..ac0746270 100644
--- a/include/client/login.inc.php
+++ b/include/client/login.inc.php
@@ -63,7 +63,9 @@ if ($cfg && $cfg->isClientRegistrationEnabled()) {
 </form>
 <br>
 <p>
-<?php if ($cfg && !$cfg->isClientLoginRequired()) {
+<?php
+if ($cfg->getClientRegistrationMode() != 'disabled'
+    || !$cfg->isClientLoginRequired()) {
     echo sprintf(__('If this is your first time contacting us or you\'ve lost the ticket number, please %s open a new ticket %s'),
         '<a href="open.php">', '</a>');
 } ?>
diff --git a/include/client/templates/sidebar.tmpl.php b/include/client/templates/sidebar.tmpl.php
index e3f15419e..88fb0bb24 100644
--- a/include/client/templates/sidebar.tmpl.php
+++ b/include/client/templates/sidebar.tmpl.php
@@ -5,15 +5,17 @@ $BUTTONS = isset($BUTTONS) ? $BUTTONS : true;
 <?php if ($BUTTONS) { ?>
         <div class="front-page-button flush-right">
 <p>
+<?php
+    if ($cfg->getClientRegistrationMode() != 'disabled'
+        || !$cfg->isClientLoginRequired()) { ?>
             <a href="open.php" style="display:block" class="blue button"><?php
                 echo __('Open a New Ticket');?></a>
 </p>
-<?php   if ($cfg && !$cfg->isKnowledgebaseEnabled()) { ?>
+<?php } ?>
 <p>
             <a href="view.php" style="display:block" class="green button"><?php
                 echo __('Check Ticket Status');?></a>
 </p>
-<?php   } ?>
         </div>
 <?php } ?>
         <div class="content"><?php
diff --git a/open.php b/open.php
index 90bce8173..a081c29c9 100644
--- a/open.php
+++ b/open.php
@@ -57,7 +57,10 @@ if ($_POST) {
 //page
 $nav->setActiveNav('new');
 if ($cfg->isClientLoginRequired()) {
-    if (!$thisclient) {
+    if ($cfg->getClientRegistrationMode() == 'disabled') {
+        Http::redirect('view.php');
+    }
+    elseif (!$thisclient) {
         require_once 'secure.inc.php';
     }
     elseif ($thisclient->isGuest()) {
-- 
GitLab