diff --git a/include/class.forms.php b/include/class.forms.php index 7f8a0f935100bc00143fa0bad871827e76f57bc6..3de1c82921a6ee01e9bccb26c84ca610b1dcac70 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -59,6 +59,7 @@ class Form { function getTitle() { return $this->title; } function getInstructions() { return $this->instructions; } function getSource() { return $this->_source; } + function setSource($source) { $this->_source = $source; } /** * Validate the form and indicate if there no errors. diff --git a/include/staff/ticket-view.inc.php b/include/staff/ticket-view.inc.php index 2b6bc0477cfb915c4b4426aa399d2174600a0bfb..442ca0882168d4dd8c3c1256ecd1af301d9d501c 100644 --- a/include/staff/ticket-view.inc.php +++ b/include/staff/ticket-view.inc.php @@ -591,7 +591,9 @@ $tcount+= $ticket->getNumNotes(); <div class="uploads"> </div> <div class="file_input"> - <input type="file" class="multifile" name="attachments[]" size="30" value="" /> +<?php +print $response_form->getField('attachments')->render(); +?> </div> </td> </tr> diff --git a/scp/tickets.php b/scp/tickets.php index 7de8a89fb49bc165f769a4e1a4575565c5e6edbb..8815c320993ce0d1c9f5dfc049fea277a1a29b7d 100644 --- a/scp/tickets.php +++ b/scp/tickets.php @@ -39,6 +39,11 @@ if($_REQUEST['id']) { if ($_REQUEST['uid']) $user = User::lookup($_REQUEST['uid']); +// Configure form for file uploads +$response_form = new Form(array( + 'attachments' => new FileUploadField(array('id'=>'attach')) +)); + //At this stage we know the access status. we can process the post. if($_POST && !$errors): @@ -65,8 +70,10 @@ if($_POST && !$errors): //If no error...do the do. $vars = $_POST; - if(!$errors && $_FILES['attachments']) - $vars['files'] = AttachmentFile::format($_FILES['attachments']); + $attachments = $response_form->getField('attachments')->getClean(); + if(!$errors && $attachments) + $vars['cannedattachments'] = array_merge( + $vars['cannedattachments'] ?: array(), $attachments); if(!$errors && ($response=$ticket->postReply($vars, $errors, $_POST['emailreply']))) { $msg = sprintf(__('%s: Reply posted successfully'), @@ -75,6 +82,10 @@ if($_POST && !$errors): $ticket->getId(), $ticket->getNumber())) ); + // Clear attachment list + $response_form->setSource(array()); + $response_form->getField('attachments')->reset(); + // Remove staff's locks TicketLock::removeStaffLocks($thisstaff->getId(), $ticket->getId()); @@ -465,4 +476,5 @@ if($ticket) { require_once(STAFFINC_DIR.'header.inc.php'); require_once(STAFFINC_DIR.$inc); +print $response_form->getMedia(); require_once(STAFFINC_DIR.'footer.inc.php');