From ad1537d0ae4318ceee561c87c7907b38e9dbe272 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Thu, 21 Aug 2014 09:52:34 -0500
Subject: [PATCH] forms: Add attachment configuration to the thread entry

---
 include/class.forms.php | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/include/class.forms.php b/include/class.forms.php
index 00588ddb6..c7dedaeb1 100644
--- a/include/class.forms.php
+++ b/include/class.forms.php
@@ -987,10 +987,21 @@ class ThreadEntryField extends FormField {
     function isPresentationOnly() {
         return true;
     }
-    function renderExtras($mode=null) {
-        if ($mode == 'client')
-            // TODO: Pass errors arrar into showAttachments
-            $this->getWidget()->showAttachments();
+
+    function getConfigurationOptions() {
+        global $cfg;
+
+        $attachments = new FileUploadField();
+        return array(
+            'attachments' => new BooleanField(array(
+                'label'=>__('Enable Attachments'),
+                'default'=>$cfg->allowOnlineAttachments(),
+                'configuration'=>array(
+                    'desc'=>__('Enables attachments submitted with the issue details'),
+                ),
+            )),
+        )
+        + $attachments->getConfigurationOptions();
     }
 }
 
@@ -1681,12 +1692,12 @@ class ThreadEntryWidget extends Widget {
             cols="21" rows="8" style="width:80%;"><?php echo
             Format::htmlchars($this->value); ?></textarea>
     <?php
-    }
-
-    function showAttachments($errors=array()) {
-        global $cfg, $thisclient;
+        $config = $this->field->getConfiguration();
+        if (!$config['attachments'])
+            return;
 
-        $attachments = new FileUploadField(array('id'=>'attach'));
+        $attachments = new FileUploadField(array('id'=>'attach',
+            'configuration'=>$config));
         print $attachments->render($client);
         foreach ($attachments->getMedia() as $type=>$urls) {
             foreach ($urls as $url)
-- 
GitLab