MOD: Staff CC ticket responses for osTicket 1.7ST

This mod is a partial update of the old 1.6ST Send reply to alternate/additional email address(es) by Scottro it has been updated for osTicket version 1.7ST. It adds a new text "CC" field to the Staff view ticket page. Here are instructions on what the steps are and how to do so:

\include\class.email.php

circa line 143, locate:

    function send($to, $subject, $message, $attachments=null, $options=null) {

        $mailer = new Mailer($this);
        if($attachments)
            $mailer->addAttachments($attachments);

        return $mailer->send($to, $subject, $message, $options);
    }

replace with:

    function send($to, $subject, $message, $attachments=null, $options=null,$cc=null) {

       $mailer = new Mailer($this);
       if($attachments)
         $mailer->addAttachments($attachments);

       return $mailer->send($to, $subject, $message, $options, $cc);
     }

\include\class.mailer.php

circa line 87, locate:

function send($to, $subject, $message, $options=null) {

replace with:

function send($to, $subject, $message, $options=null, $cc=null) {

circa line 95, locate:

$to = preg_replace("/(\r\n|\r|\n)/s",'', trim($to));

on the next line add:

$cc = preg_replace("/(\r\n|\r|\n)/s",'', trim($_POST['cc_to']));

circa line 112, locate:

        $headers = array (
                'From' => $this->getFromAddress(),
                'To' => $to,
                'Subject' => $subject,
                'Date'=> date('D, d M Y H:i:s O'),
                'Message-ID' => $messageId,
                'X-Mailer' =>'osTicket Mailer'
               );

replace with:

        $headers = array ();
        $headers['From'] = $this->getFromAddress();
        $headers['To'] = $to;
        $headers['Subject'] = $subject;
        if ($cc != null) {
            $headers['cc'] = $cc;
        }
        $headers['Date'] = date('D, d M Y H:i:s O');
        $headers['Message-ID'] = $messageId;
        $headers['X-Mailer'] = 'osTicket Mailer';

\include\class.ticket.php

circa line 1400-1401 locate:

        if(!$vars['staffId'] && $thisstaff)
            $vars['staffId'] = $thisstaff->getId();

After it add:

		if($_POST['cc_to']){
		  $cc = $_POST['cc_to'];
		  $ccmsg = "[ Message was CCed to: $cc. ]\n\r\n\r";
		  $vars['response'] = "$ccmsg".$vars['response'];
		}

circa line 1442, locate:

$email->send($this->getEmail(), $msg['subj'], $msg['body'], $attachments);

replace with:

$email->send($this->getEmail(), $msg['subj'], $msg['body'], $attachments,$cc='');

\include\staff\ticket-view.inc.php

circa line 413, locate:

</tr>

replace with:

</tr>
<tr>
  <td>CC:</td>
  <td><input size=80 type="text" name="cc_to" ></td>
</tr>

Notes: Unlike the old version this one does not allow you to edit the To or BCC fields. It's simply for CCing. This version updates the email sent and the note added o the ticket to indicate that the update was CCed to someone and to whom. Multiple CC recipients may be specified by separating emails with commas.

The original version of this mod is still available at Scottro's web site located at: http://sudobash.net and is for osTicket version 1.6ST.