Skip to content
Snippets Groups Projects
Commit 415a672a authored by Peter Rotich's avatar Peter Rotich
Browse files

Thread Entry Action: New Ticket

Add thread entry action to create a new ticket. The entry is used to seed
ticket data like user, message (issue details) and attachments
parent 0cb53efb
Branches
Tags
No related merge requests found
......@@ -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';
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment