diff --git a/include/class.thread_actions.php b/include/class.thread_actions.php index 3423b17c8a3e1ac62ef266ed0560f88b2e27021c..8cc2d785d2f2c29ab1274e4e349a9c3936e40784 100644 --- a/include/class.thread_actions.php +++ b/include/class.thread_actions.php @@ -136,7 +136,7 @@ class TEA_EditThreadEntry extends ThreadEntryAction { ) || ($T instanceof Ticket && ($role = $thisstaff->getRole($T->getDeptId(), $T->isAssigned($thisstaff))) - && $role->hasPerm(ThreadEntry::PERM_EDIT) + && $role->hasPerm(ThreadEntry::PERM_EDIT) ) ); } @@ -431,6 +431,45 @@ class TEA_ResendThreadEntry extends TEA_EditAndResendThreadEntry { } ThreadEntry::registerAction(/* trans */ 'Manage', 'TEA_ResendThreadEntry'); +/* Create a new ticket from thread entry as description */ +class TEA_CreateTicket extends ThreadEntryAction { + static $id = 'create_ticket'; + static $name = /* trans */ 'Create Ticket'; + static $icon = 'plus'; + + function isVisible() { + global $thisstaff; + + return $thisstaff && $thisstaff->hasPerm(Ticket::PERM_CREATE, false); + } + + function getJsStub() { + return sprintf(<<<JS + window.location.href = '%s'; +JS + , $this->getCreateTicketUrl() + ); + } + + function trigger() { + switch ($_SERVER['REQUEST_METHOD']) { + case 'GET': + return $this->trigger__get(); + } + } + + private function trigger__get() { + Http::redirect($this->getCreateTicketUrl()); + } + + private function getCreateTicketUrl() { + return sprintf('tickets.php?a=open&tid=%d', $this->entry->getId()); + } +} + +ThreadEntry::registerAction(/* trans */ 'Manage', 'TEA_CreateTicket'); + + class TEA_CreateTask extends ThreadEntryAction { static $id = 'create_task'; static $name = /* trans */ 'Create Task'; diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index aa396305a70f7b99c0a12e4bad6ed4cbe04e6257..d19138676399500753db5d7ff641711999031295 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -6,6 +6,22 @@ if (!defined('OSTSCPINC') || !$thisstaff $info=array(); $info=Format::htmlchars(($errors && $_POST)?$_POST:$info); + +// Use thread entry to seed the ticket +if (!$user && $_GET['tid'] && ($entry = ThreadEntry::lookup($_GET['tid']))) { + if ($entry->user_id) + $user = User::lookup($entry->user_id); + else + + $_SESSION[':form-data']['message'] = Format::htmlchars($entry->getBody()); + if (($m= TicketForm::getInstance()->getField('message'))) { + $k = 'attach:'.$m->getId(); + foreach ($entry->getAttachments() as $a) + if (!$a->inline && $a->file) + $_SESSION[':form-data'][$k][] = $a->file->getId(); + } +} + if (!$info['topicId']) $info['topicId'] = $cfg->getDefaultTopicId();