Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

New Staff Reply Alert [MOD] 1.7RC5

I couldn't find a [MOD] to do what I needed so I created this one today.

When a staff member post a "external" reply to ticket, it alerts all the staff members involved with the ticket.

There is a email template for the reply, and you can enable/disable and choose recipients.

Only the admin can change the settings, would be simple to let the departments control it also, but I don't need that feature so I stopped here.

#### Changes to the database
Run SQL:
ALTER TABLE `ost_config` ADD `reply_alert_active` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `message_alert_dept_manager` ,
ADD `reply_alert_laststaff` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `reply_alert_active` ,
ADD `reply_alert_assigned` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `reply_alert_laststaff` ,
ADD `reply_alert_dept_manager` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `reply_alert_assigned`


Also run:
ALTER TABLE `ost_email_template` ADD `reply_alert_subj` VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `message_alert_body` ,
ADD `reply_alert_body` TEXT CHARACTER SET utf32 COLLATE utf32_general_ci NOT NULL AFTER `reply_alert_subj`


Optional Insert into reply_alert_subj :
New Staff Reply Alert

Optional Insert into reply_alert_body :
%{recipient},

%{staff} replied to %{ticket.name}'s ticket #%{ticket.number}.

----------------------------------

%{response}

----------------------------------

You are getting this alert because you have been involved in this ticket, a response from you may not be needed.
To view/respond to the ticket, please log-in to the support ticket system.

%{ticket.staff_link}

####Changes to include/staff/settings-alerts.inc.php
Add after:

[HTML]

> Department Manager (spammy)

[/HTML]

Around line 60:

[HTML]

New Staff Reply Alert: Alert sent out when a new reply, from staff, is appended to an existing ticket

Status:  
/>Enable
  
/>Disable




> Last Respondent




> Assigned Staff




> Department Manager (spammy)



[/HTML]


####Changes to class.config.php
Add after:

    function alertONNewMessage() {
return ($this->config['message_alert_active']);
}

function alertLastRespondentONNewMessage() {
return ($this->config['message_alert_laststaff']);
}

function alertAssignedONNewMessage() {
return ($this->config['message_alert_assigned']);
}

function alertDeptManagerONNewReply() {
return ($this->config['message_alert_dept_manager']);
}


Around line 395:

//  --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---	
function alertONNewReply() {
return ($this->config['reply_alert_active']);
}

function alertLastRespondentONNewReply() {
return ($this->config['reply_alert_laststaff']);
}

function alertAssignedONNewReply() {
return ($this->config['reply_alert_assigned']);
}

function alertDeptManagerONNewMessage() {
return ($this->config['reply_alert_dept_manager']);
}
// --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---



Add after:

        if($vars['message_alert_active']
&& (!isset($vars['message_alert_laststaff'])
&& !isset($vars['message_alert_assigned'])
&& !isset($vars['message_alert_dept_manager']))) {
$errors['message_alert_active']='Select recipient(s)';
}


Around line 815:

//  --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---	

if($vars['reply_alert_active']
&& (!isset($vars['reply_alert_laststaff'])
&& !isset($vars['reply_alert_assigned'])
&& !isset($vars['reply_alert_dept_manager']))) {
$errors['reply_alert_active']='Select recipient(s)';
}
// --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---



Add After:

$sql= 'UPDATE '.CONFIG_TABLE.' SET updated=NOW() '
.',ticket_alert_active='.db_input($vars['ticket_alert_active'])
.',ticket_alert_admin='.db_input(isset($vars['ticket_alert_admin'])?1:0)
.',ticket_alert_dept_manager='.db_input(isset($vars['ticket_alert_dept_manager'])?1:0)
.',ticket_alert_dept_members='.db_input(isset($vars['ticket_alert_dept_members'])?1:0)
.',message_alert_active='.db_input($vars['message_alert_active'])
.',message_alert_laststaff='.db_input(isset($vars['message_alert_laststaff'])?1:0)
.',message_alert_assigned='.db_input(isset($vars['message_alert_assigned'])?1:0)
.',message_alert_dept_manager='.db_input(isset($vars['message_alert_dept_manager'])?1:0)


Around line 864:

//  --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---				 
.',reply_alert_active='.db_input($vars['reply_alert_active'])
.',reply_alert_laststaff='.db_input(isset($vars['reply_alert_laststaff'])?1:0)
.',reply_alert_assigned='.db_input(isset($vars['reply_alert_assigned'])?1:0)
.',reply_alert_dept_manager='.db_input(isset($vars['reply_alert_dept_manager'])?1:0)
// --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---



####Changes to class.ticket.php
Add after:

        $this->onResponse(); //do house cleaning..
$this->reload();


Around 1628:

// --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---

// If alerts are not enabled then return a success.
if($alert || $cfg->alertONNewReply()) {

$dept = $this->getDept();

if(!($tpl = $dept->getTemplate()))
$tpl= $cfg->getDefaultTemplate();

if(!($email=$cfg->getAlertEmail()))
$email =$cfg->getDefaultEmail();


if($tpl && ($msg=$tpl->getNewReplyAlertMsgTemplate()) && $email) {

$msg = $this->replaceVars($msg,
array('response' => $vars['response'], 'staff' => $thisstaff));

// Alert recipients
$recipients=array();

//Last respondent.
if($cfg->alertLastRespondentONNewReply())
$recipients[]=$this->getLastRespondent();

//Assigned staff if any...could be the last respondent
if($cfg->alertAssignedONNewReply() && $this->isAssigned() && $this->getStaffId())
$recipients[]=$this->getStaff();

//Dept manager
if($cfg->alertDeptManagerONNewReply() && $dept && $dept->getManagerId())
$recipients[]=$dept->getManager();

// TODO: Add send attachments optional to settings page
$attachments =($cfg->emailAttachments() && $attachments)?$this->getAttachments($respId,'R'):array();
$sentlist=array();
foreach( $recipients as $k=>$staff) {
if(!$staff || !is_object($staff) || !$staff->getEmail() || !$staff->isAvailable()) continue;
if(in_array($staff->getEmail(),$sentlist) || ($staffId && $staffId==$staff->getId())) continue;
$alert = str_replace('%{recipient}',$staff->getFirstName(), $msg['body']);
$email->sendAlert($staff->getEmail(), $msg['subj'], $alert, $attachments);
$sentlist[] = $staff->getEmail();
}
}
}
// --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---

Comments

  • rest of the code...

    ####Changes to class.template.php
    Add after:

                case 'msg_alert':
    $tpl=array('subj'=>$this->ht['message_alert_subj'],'body'=>$this->ht['message_alert_body']);
    break;


    Around line 124:

    // --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---
    case 'reply_alert':
    $tpl=array('subj'=>$this->ht['reply_alert_subj'],'body'=>$this->ht['reply_alert_body']);
    break;
    // --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---


    Add After:

        function getOverlimitMsgTemplate() {
    return $this->getMsgTemplate('overlimit_notice');
    }


    Around line 183:

    // --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---
    function getNewReplyAlertMsgTemplate() {
    return $this->getMsgTemplate('reply_alert');
    }
    // --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---


    Add After:

                case 'msg_alert':
    $sql.=',message_alert_subj='.db_input($vars['subj']).',message_alert_body='.db_input($vars['body']);
    break;


    Around line 248:

    //  --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---
    case 'reply_alert':
    $sql.=',reply_alert_subj='.db_input($vars['subj']).',reply_alert_body='.db_input($vars['body']);
    break;
    // --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---


    Add After:

                            'msg_alert'=>array('name'=>'New Message Alert',
    'desc'=>'Alert sent to staff, if enabled, when user replies to an existing ticket.'),


    Around line 334:

    //  --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---
    'reply_alert'=>array('name'=>'New Staff Reply Alert',
    'desc'=>'Alert sent to staff, if enabled, when staff replies to an existing ticket.'),
    // --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---


    Add After:

                    .' ,message_autoresp_subj='.db_input($info['message_autoresp_subj'])
    .' ,message_autoresp_body='.db_input($info['message_autoresp_body'])
    .' ,message_alert_subj='.db_input($info['message_alert_subj'])
    .' ,message_alert_body='.db_input($info['message_alert_body'])


    Around line 418:

    //  --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---
    .' ,reply_alert_subj='.db_input($info['reply_alert_subj'])
    .' ,reply_alert_body='.db_input($info['reply_alert_body'])
    // --- MOD: New Reply Alert, for 1.7RC5. by Tristan Novak, tbjnovak@gmail.com, 3-6-13 ---
  • Would this MOD work on v1.9.3 release? 
    a MOD like this should be in the main features of OS ticket.

Sign In or Register to comment.