Comment feature: Toggle sending mail for replies (based on osTicket 1.6 RC5)
Here is the requested mod/add-on. Actually, the code as in osTicket 1.6 RC5 makes this very easy (once one knows how to do it)
1. Add HTML code checkbox to toggle sending mail
In file include/staff/viewticket.inc.php search for
Ticket Status: (should be around line 329). Before this line insert the following lines
Just comment (no mail)
Of course, text ("Just comment (no mail)") and formatting are a matter of taste. The rest is crucial, though.
2. Code in scp/tickets.php to handle the HTML checkbox
In file scp/tickets.php we evaluate the HTML checkbox and pass on the parameter. Look for the text (should be around line 83)
//If no error...do the do.
Before this text insert the following
// isComment hack by xrat
if(isset($_POST) && ($_POST == 1)) {
$isComment = TRUE; $mycanalert = false;
} else {
$isComment = FALSE; $mycanalert = true;
}
2 lines below osTicket calls postReponse() where we need to add our 2 variables. Change line
if(!$errors && ($respId=$ticket->postResponse($_POST,$_POST,$_POST,$_FILES))){
to
if(!$errors && ($respId=$ticket->postResponse($_POST,$_POST,$_POST,$_FILES,$mycanalert,$isComment))){
Eventually, 9 lines further below just before the
} else {
we need to insert these 2 lines
// Mark unanswered if it was just a comment -- isComment hack by xrat
if($isComment) $ticket->markUnAnswered();
3. Code to mark replies as comments
Finally, in file include/class.ticket.php go to (around line 685)
//Insert Staff Reply
function postResponse($msgid,$response,$signature='none',$attachment=false,$canalert=true){
global $thisuser,$cfg;
if(!$thisuser || !$thisuser->getId() || !$thisuser->isStaff()) //just incase
return 0;
and change this to (2 changes!)
//Insert Staff Reply
function postResponse($msgid,$response,$signature='none',$attachment=false,$canalert=true,$isComment=FALSE){
global $thisuser,$cfg;
if(!$thisuser || !$thisuser->getId() || !$thisuser->isStaff()) //just incase
return 0;
// isComment hack by xrat
if($isComment) $response = "\n\n$response";
Again, here the text "" can be changed as required. That's it.
Background story (for the technically inclined)
What makes this mod rather simple is the fact that function postResponse() evaluates a 5th parameter: It's internally named $canalert and toggles sending alert mails. Thus, the above presented mod could even be reduced to less: The introduced 6th parameter $isComment is not essential.
Thanks
This mod was requested, supported and pressed ahead by (gavbond). Say thanks to him. xrat only did the coding and barking. Also all mistakes are his.
Disclaimer
Comes without warranty. Use at your own risk. Might put cats on fire.