From dcbe4e357d9358c11c09183b8f6f33b25334ed48 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 27 Aug 2015 15:18:18 -0500
Subject: [PATCH] forms: Forbid adding deleted forms to topics, form management

---
 include/staff/helptopic.inc.php              | 5 ++++-
 include/staff/templates/form-manage.tmpl.php | 7 ++++---
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/staff/helptopic.inc.php b/include/staff/helptopic.inc.php
index 2dd9db0dd..28b01152f 100644
--- a/include/staff/helptopic.inc.php
+++ b/include/staff/helptopic.inc.php
@@ -387,7 +387,10 @@ foreach ($forms as $F) {
    <strong><?php echo __('Add Custom Form'); ?></strong>:
    <select name="form_id" id="newform">
     <option value=""><?php echo '— '.__('Add a custom form') . ' —'; ?></option>
-    <?php foreach (DynamicForm::objects()->filter(array('type'=>'G')) as $F) { ?>
+    <?php foreach (DynamicForm::objects()
+        ->filter(array('type'=>'G'))
+        ->exclude(array('flags__hasbit' => DynamicForm::FLAG_DELETED))
+    as $F) { ?>
         <option value="<?php echo $F->get('id'); ?>"
            <?php if (in_array($F->id, $current_forms))
                echo 'disabled="disabled"'; ?>
diff --git a/include/staff/templates/form-manage.tmpl.php b/include/staff/templates/form-manage.tmpl.php
index 217265da7..9794bdbdd 100644
--- a/include/staff/templates/form-manage.tmpl.php
+++ b/include/staff/templates/form-manage.tmpl.php
@@ -29,9 +29,10 @@ foreach ($forms as $e) { ?>
     $(this).parent().find('button').trigger('click');">
 <option selected="selected" disabled="disabled"><?php
     echo __('Add a form'); ?></option>
-<?php foreach (DynamicForm::objects()->filter(array(
-    'type'=>'G')) as $f
-) {
+<?php foreach (DynamicForm::objects()
+    ->filter(array('type'=>'G'))
+    ->exclude(array('flags__hasbit' => DynamicForm::FLAG_DELETED))
+    as $f) {
     if (in_array($f->get('id'), $current_list))
         continue;
     ?><option value="<?php echo $f->get('id'); ?>"><?php
-- 
GitLab