Reply Patch 4.1
Have added an incremental update to Patch 4 as mentioned above based on requests.
- Staff can now email attachments that will be added to the ticket
- #actions can be included in either the subject, body, or a combination of the two in one email
- Added #internal as an action that marks the reply and in internal note and is not sent to the requester.
Presently emailed attachments are not forwarded via email to either staff or the requester. I don't see much of a need for staff need to get an email with attachments sent from the requester (will just clog up mail servers), BUT I think it would be useful for the requester to receive any attachments forwarded from staff. Have looked into this but the structure of the existing functions will make this very difficult. Something for another day.
As always, any bugs or suggestions please let me know.
Have attached zip and README, and also have diffs listed below.
include/class.mailfetch.php
diff class.mailfetch.php class.mailfetch.orig
400c400
< if(!($ticket=Ticket:($tid)))
---
> if(!($ticket=Ticket:($tid, $vars)))
406,423c406,408
< $staffsql = 'SELECT staff_id, firstname, lastname, email FROM '.STAFF_TABLE.' WHERE email='.db_input($vars).' LIMIT 1';
< $vars = $vars;
< if(($staffres=db_query($staffsql)) && (db_num_rows($staffres) == 0)){
< if(!($message=$ticket->postMessage($vars, 'Email')))
< return false;
< } else {
< $staffvars=db_fetch_row(db_query($staffsql));
< $replyvars=Array(
< "msgId" => $ticket,
< "response" => $vars,
< "poster" => $staffvars.' '.$staffvars,
< "staffId" => $staffvars,
< "subject" => $vars,
< );
< $errors=array();
< if(!($message=$ticket->postReply($replyvars, $errors)))
< return false;
< }
---
> if(!($message=$ticket->postMessage($vars, 'Email')))
> return false;
>
include/class.ticket.php
diff class.ticket.php class.ticket.orig
1315,1317d1314
< if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator()))
< $msg ="\n$tag\n\n".$msg;
<
1406,1421c1403,1404
<
< //Strip quoted reply...on emailed replies
< if($cfg->stripQuotedReply() && ($tag=$cfg->getReplySeparator()) && strpos($vars, $tag))
< if(list($msg) = split($tag, $vars))
< $vars = $msg;
<
< //Check if tagged as internal and post as a note instead.
< if(($vars && preg_match ("/#internal/", $vars, $action)) OR ($vars && preg_match ("/#internal/", $vars, $action))) {
< $vars = $vars;
< if(!($response=$this->getThread()->addNote($vars, $errors)))
< return null;
<
< } else {
< if(!($response = $this->getThread()->addResponse($vars, $errors)))
< return null;
< }
---
> if(!($response = $this->getThread()->addResponse($vars, $errors)))
> return null;
1459,1516c1442
< if(($vars && preg_match ("/#internal/", $vars, $action)) OR ($vars && preg_match ("/#internal/", $vars, $action))) {
< //Do not email requester if marked #internal
< } else {
< $email->send($this->getEmail(), $msg, $msg, $attachments);
< }
<
< }
<
< //Check for actions in the subject
< if($vars){
< $errors=array();
< $intvars = array(
< "title" => "Emailed Action",
< "note" => "",
< );
< }
<
< if(($vars && preg_match ("/#claim/", $vars, $action)) OR ($vars && preg_match ("/#claim/", $vars, $action))){
< $this->setStaffId($vars);
< $intvars = "Ticket has been claimed via email.";
< $this->postNote($intvars, $errors, $vars, $alert='true');
< }
<
< //Check for ticket assignment in subject
< if($vars && preg_match ("/#assign:/", $vars, $action)){
< $match = preg_split("/#assign:/", $vars);
< }
< //Check for ticket assignment in subject
< if($vars && preg_match ("/#assign:/", $vars, $action)) {
< $match = preg_split("/#assign:/", $vars);
< }
< //Assign the ticket if a match is found above
< if(isset($match)){
< $assignee = preg_split("/ |\r|\n|\r\n/", $match);
< $chksql = 'SELECT staff_id FROM '.STAFF_TABLE.' WHERE username='.db_input($assignee).' LIMIT 1';
< if($astaff_id = db_result(db_query($chksql))){
< $this->setStaffId($astaff_id);
< $intvars = "Ticket has been assigned to {$assignee} via email.";
< $this->postNote($intvars, $errors, $vars, $alert='true');
< }
< }
<
< if(($vars && preg_match ("/#unassign/", $vars, $action)) OR ($vars && preg_match ("/#unassign/", $vars, $action))) {
< $this->setStaffId('0');
< $intvars = "Ticket has been unassigned via email.";
< $this->postNote($intvars, $errors, $vars, $alert='true');
< }
<
< if(($vars && preg_match ("/#reopen/", $vars, $action)) OR ($vars && preg_match ("/#reopen/", $vars, $action))){
< if($this->isClosed()) $this->reopen();
< $intvars = "Ticket has been reopened via email.";
< $this->postNote($intvars, $errors, $vars, $alert='true');
< }
<
< if(($vars && preg_match ("/#close/", $vars, $action)) OR ($vars && preg_match ("/#close/", $vars, $action))){
< $this->close();
< $intvars = "Ticket has been closed via email.";
< $this->postNote($intvars, $errors, $vars, $alert='true');
---
> $email->send($this->getEmail(), $msg, $msg, $attachments);
[README.txt](https://forum.osticket.com/assets/files/migrated/4/550e4ea483f203223465dfc181492f0.txt)
[ReplyPatch4.1.zip](https://forum.osticket.com/assets/files/migrated/f/c6d2ad8fc5914469b7b82620bcb2f1d.zip)