From 606f45baba7b6f61bba4052e3ebc53e0ed75e385 Mon Sep 17 00:00:00 2001
From: JediKev <kevin@enhancesoft.com>
Date: Thu, 12 Jul 2018 14:55:50 -0500
Subject: [PATCH] issue: Ticket Lock On Disable

This addresses an issue where disabling Ticket Locks but setting a time
for the Lock Timeout will always throw a "lock required" error. This adds
a check to see if locks are enabled AND there is a time set. If locks are
disabled it will not throw the error.
---
 include/class.config.php | 5 +++++
 scp/tickets.php          | 4 ++--
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/class.config.php b/include/class.config.php
index 8f10d777a..ef616e0fb 100644
--- a/include/class.config.php
+++ b/include/class.config.php
@@ -419,6 +419,11 @@ class OsticketConfig extends Config {
         return $this->get('enable_avatars');
     }
 
+    function isTicketLockEnabled() {
+        return (($this->getTicketLockMode() != Lock::MODE_DISABLED)
+                && $this->getLockTime());
+    }
+
     function getClientTimeout() {
         return $this->getClientSessionTimeout();
     }
diff --git a/scp/tickets.php b/scp/tickets.php
index 25e21dfd4..aa0c90339 100644
--- a/scp/tickets.php
+++ b/scp/tickets.php
@@ -90,7 +90,7 @@ if($_POST && !$errors):
                 if(!$vars['response'])
                     $errors['response']=__('Response required');
 
-                if ($cfg->getLockTime()) {
+                if ($cfg->isTicketLockEnabled()) {
                     if (!$lock) {
                         $errors['err'] = sprintf('%s %s', __('This action requires a lock.'), __('Please try again!'));
                     }
@@ -147,7 +147,7 @@ if($_POST && !$errors):
                 $vars['cannedattachments'] ?: array(), $attachments);
             $vars['note'] = ThreadEntryBody::clean($vars['note']);
 
-            if ($cfg->getLockTime()) {
+            if ($cfg->isTicketLockEnabled()) {
                 if (!$lock) {
                     $errors['err'] = sprintf('%s %s', __('This action requires a lock.'), __('Please try again!'));
                 }
-- 
GitLab