Skip to content
Snippets Groups Projects
Commit 91ef1bfd authored by aydreeihn's avatar aydreeihn
Browse files

Issues Creating Task/Ticket from Thread

- In class.forms.php, $this->field->getClean() was null so $new was not populated and attachments were not being carried over, so we must get the fileIds directly from the form-data array
- We need to unset the form-data for attachment fields (on tasks and tickets) so that the array is empty each time we try to create a task or ticket from a thread
- We need to add files attached to threads where we are creating a task or ticket to the list of allowed files otherwise they will not carry over to new tasks/tickets (only files uploaded by this user in this session were allowed previously)
parent cf8f7578
No related branches found
No related tags found
No related merge requests found
...@@ -4366,6 +4366,12 @@ class FileUploadWidget extends Widget { ...@@ -4366,6 +4366,12 @@ class FileUploadWidget extends Widget {
$maxfilesize = ($config['size'] ?: 1048576) / 1048576; $maxfilesize = ($config['size'] ?: 1048576) / 1048576;
$files = $F = array(); $files = $F = array();
$new = array_fill_keys($this->field->getClean(), 1); $new = array_fill_keys($this->field->getClean(), 1);
//get file ids stored in session when creating tickets/tasks from thread
if (!$new && is_array($_SESSION[':form-data'])
&& array_key_exists($this->field->get('name'), $_SESSION[':form-data']))
$new = array_fill_keys($_SESSION[':form-data'][$this->field->get('name')], 1);
foreach ($attachments as $a) { foreach ($attachments as $a) {
$F[] = $a->file; $F[] = $a->file;
unset($new[$a->file_id]); unset($new[$a->file_id]);
...@@ -4449,6 +4455,12 @@ class FileUploadWidget extends Widget { ...@@ -4449,6 +4455,12 @@ class FileUploadWidget extends Widget {
if (isset($_SESSION[':uploadedFiles'])) if (isset($_SESSION[':uploadedFiles']))
$allowed += $_SESSION[':uploadedFiles']; $allowed += $_SESSION[':uploadedFiles'];
// Files attached to threads where we are creating tasks/tickets are allowed
if (isset($_SESSION[':form-data'][$this->field->get('name')])) {
foreach ($_SESSION[':form-data'][$this->field->get('name')] as $key => $value)
$allowed[$value] = 1;
}
// Canned attachments initiated by this session // Canned attachments initiated by this session
if (isset($_SESSION[':cannedFiles'])) if (isset($_SESSION[':cannedFiles']))
$allowed += $_SESSION[':cannedFiles']; $allowed += $_SESSION[':cannedFiles'];
......
...@@ -512,9 +512,11 @@ JS ...@@ -512,9 +512,11 @@ JS
'description' => Format::htmlchars($this->entry->getBody())); 'description' => Format::htmlchars($this->entry->getBody()));
if (($f= TaskForm::getInstance()->getField('description'))) { if (($f= TaskForm::getInstance()->getField('description'))) {
$k = 'attach:'.$f->getId(); $k = 'attach:'.$f->getId();
unset($_SESSION[':form-data'][$k]);
foreach ($this->entry->getAttachments() as $a) foreach ($this->entry->getAttachments() as $a)
if (!$a->inline && $a->file) if (!$a->inline && $a->file) {
$vars[$k][] = $a->file->getId(); $_SESSION[':form-data'][$k][] = $a->file->getId();
}
} }
return $this->getTicketsAPI()->addTask($this->getObjectId(), $vars); return $this->getTicketsAPI()->addTask($this->getObjectId(), $vars);
......
...@@ -15,9 +15,12 @@ if (!$user && $_GET['tid'] && ($entry = ThreadEntry::lookup($_GET['tid']))) { ...@@ -15,9 +15,12 @@ if (!$user && $_GET['tid'] && ($entry = ThreadEntry::lookup($_GET['tid']))) {
if (($m= TicketForm::getInstance()->getField('message'))) { if (($m= TicketForm::getInstance()->getField('message'))) {
$k = 'attach:'.$m->getId(); $k = 'attach:'.$m->getId();
foreach ($entry->getAttachments() as $a) unset($_SESSION[':form-data'][$k]);
if (!$a->inline && $a->file) foreach ($entry->getAttachments() as $a) {
$_SESSION[':form-data'][$k][] = $a->file->getId(); if (!$a->inline && $a->file) {
$_SESSION[':form-data'][$k][] = $a->file->getId();
}
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment