From 0cb53efb957cbe0ff1026028ea24740aee63479f Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@enhancesoft.com> Date: Tue, 20 Mar 2018 12:22:34 +0000 Subject: [PATCH] Thread Action: New Task + Attachments Include attachments when creating a task from a thread entry --- include/class.thread.php | 4 ++++ include/class.thread_actions.php | 18 ++++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/include/class.thread.php b/include/class.thread.php index cb5912922..b06bd0432 100644 --- a/include/class.thread.php +++ b/include/class.thread.php @@ -2952,6 +2952,10 @@ abstract class ThreadEntryAction { return 'icon-' . $class::$icon; } + function getObJectId() { + return $this->entry->getThread()->getObjectId(); + } + function __construct(ThreadEntry $thread) { $this->entry = $thread; } diff --git a/include/class.thread_actions.php b/include/class.thread_actions.php index 497eb9219..3423b17c8 100644 --- a/include/class.thread_actions.php +++ b/include/class.thread_actions.php @@ -135,7 +135,8 @@ class TEA_EditThreadEntry extends ThreadEntryAction { && $T->getDept()->getManagerId() == $thisstaff->getId() ) || ($T instanceof Ticket - && $thisstaff->getRole($T->getDeptId())->hasPerm(ThreadEntry::PERM_EDIT) + && ($role = $thisstaff->getRole($T->getDeptId(), $T->isAssigned($thisstaff))) + && $role->hasPerm(ThreadEntry::PERM_EDIT) ) ); } @@ -469,14 +470,19 @@ JS private function trigger__get() { $vars = array( - 'description' => Format::htmlchars($this->entry->getBody()) - ); - return $this->getTicketsAPI()->addTask($this->entry->getThread()->getObjectId(), - $vars); + 'description' => Format::htmlchars($this->entry->getBody())); + if (($f= TaskForm::getInstance()->getField('description'))) { + $k = 'attach:'.$f->getId(); + foreach ($this->entry->getAttachments() as $a) + if (!$a->inline && $a->file) + $vars[$k][] = $a->file->getId(); + } + + return $this->getTicketsAPI()->addTask($this->getObjectId(), $vars); } private function trigger__post() { - return $this->getTicketsAPI()->addTask($this->entry->getThread()->getObjectId()); + return $this->getTicketsAPI()->addTask($this->getObjectId()); } } -- GitLab