Last active
August 15, 2022 01:18
-
-
Save clonemeagain/8089055 to your computer and use it in GitHub Desktop.
Adds onClose notification template functionality to osTicket 1.8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I've just trawled the code (including latest dev), and no, there is no part of it which will do that.. | |
Shouldn't be too hard to implement though, just a few modifications, and a single db entry! | |
First, Run this query to create the template: | |
<?php | |
INSERT INTO `tickets`.`ost_email_template` (`id`, `tpl_id`, `code_name`, `subject`, `body`, `created`, `updated`) VALUES (NULL, 1, 'ticket.close', '[#%{ticket.number}] %{ticket.subject}', '%{ticket.name}, | |
Our customer care team has closed the ticket, #%{ticket.number} on your behalf. | |
If you wish to provide additional comments or information regarding this issue, please don''t open a new ticket. You can update or view this ticket''s progress online here: %{ticket.client_link}. | |
%{signature}', NOW(), NOW()); | |
?> | |
Add the following code: (also below as patches) | |
/include/class.ticket.php | |
(doesn't matter where really, between two functions will do: | |
<?php | |
function onClose() | |
{ | |
global $thisstaff, $cfg; | |
$dept = $this->getDept (); | |
if ($thisstaff && $vars ['signature'] == 'mine') | |
$signature = $thisstaff->getSignature (); | |
elseif ($vars ['signature'] == 'dept' && $dept && $dept->isPublic ()) | |
$signature = $dept->getSignature (); | |
else | |
$signature = ''; | |
$variables = array ('signature' => $signature,'staff' => $thisstaff,'poster' => $thisstaff ); | |
if (($email = $dept->getEmail ()) && ($tpl = $dept->getTemplate ()) && ($msg = $tpl->getCloseMsgTemplate ())) { | |
$msg = $this->replaceVars ( $msg->asArray (), $variables ); | |
if ($cfg->stripQuotedReply () && ($tag = $cfg->getReplySeparator ())) | |
$msg ['body'] = "<p style=\"display:none\">$tag<p>" . $msg ['body']; | |
$email->send ( $this->getEmail (), $msg ['subj'], $msg ['body'] ); | |
} | |
} | |
?> | |
/include/class.template.php | |
Find: | |
<?php | |
'staff.pwreset' => array( | |
'name' => 'Staff Password Reset', | |
'desc' => 'Notice sent to staff with the password reset link.', | |
'default' => 'templates/staff.pwreset.txt'), | |
?> | |
Add after: | |
<?php | |
'ticket.close' => array( | |
'name' => 'Ticket Closed Notification', | |
'desc' => 'Notice sent to client on the closure of a ticket.' | |
) | |
?> | |
Just before the final ); | |
Then find | |
<?php | |
function getReplyMsgTemplate() { | |
return $this->getMsgTemplate('ticket.reply'); | |
} | |
?> | |
Add after: | |
<?php | |
function getCloseMsgTemplate() { | |
return $this->getMsgTemplate('ticket.close'); | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/include/class.template.php b/include/class.template.php | |
index e135034..d5f3a59 100644 | |
--- a/include/class.template.php | |
+++ b/include/class.template.php | |
@@ -65,6 +65,10 @@ | |
'name' => 'Staff Password Reset', | |
'desc' => 'Notice sent to staff with the password reset link.', | |
'default' => 'templates/staff.pwreset.txt'), | |
+ 'ticket.close' => array( | |
+ 'name' => 'Ticket Closed Notification', | |
+ 'desc' => 'Notice sent to client on the closure of a ticket.' | |
+ ) | |
); | |
function EmailTemplateGroup($id){ | |
@@ -207,6 +211,9 @@ | |
function getReplyMsgTemplate() { | |
return $this->getMsgTemplate('ticket.reply'); | |
+ } | |
+ function getCloseMsgTemplate() { | |
+ return $this->getMsgTemplate('ticket.close'); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/include/class.ticket.php b/include/class.ticket.php | |
index 273d8e2..f730133 100644 | |
--- a/include/class.ticket.php | |
+++ b/include/class.ticket.php | |
@@ -793,6 +793,8 @@ | |
$this->reload(); | |
$this->logEvent('closed'); | |
$this->deleteDrafts(); | |
+ | |
+ $this->onClose(); | |
return true; | |
} | |
@@ -1634,6 +1636,31 @@ | |
return $response; | |
} | |
+ | |
+ function onClose() | |
+ { | |
+ global $thisstaff, $cfg; | |
+ | |
+ $dept = $this->getDept (); | |
+ | |
+ if ($thisstaff && $vars ['signature'] == 'mine') | |
+ $signature = $thisstaff->getSignature (); | |
+ elseif ($vars ['signature'] == 'dept' && $dept && $dept->isPublic ()) | |
+ $signature = $dept->getSignature (); | |
+ else | |
+ $signature = ''; | |
+ | |
+ $variables = array ('signature' => $signature,'staff' => $thisstaff,'poster' => $thisstaff ); | |
+ | |
+ if (($email = $dept->getEmail ()) && ($tpl = $dept->getTemplate ()) && ($msg = $tpl->getCloseMsgTemplate ())) { | |
+ | |
+ $msg = $this->replaceVars ( $msg->asArray (), $variables ); | |
+ | |
+ if ($cfg->stripQuotedReply () && ($tag = $cfg->getReplySeparator ())) | |
+ $msg ['body'] = "<p style=\"display:none\">$tag<p>" . $msg ['body']; | |
+ $email->send ( $this->getEmail (), $msg ['subj'], $msg ['body'] ); | |
+ } | |
+ } | |
//Activity log - saved as internal notes WHEN enabled!! | |
function logActivity($title, $note) { |
I would like to know how to setup this please
For me doesn´t work :(
@clonemeagain, please if you can help me
Hi Dsaamorim, this was written in 2016.. osTicket has changed a lot since then. So, it will not work in any current version. Probably better asking them to add it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yesterday I have installed the latest version but it's giving the same issue.Pls help me