Admin gets Email on Topic Move
Posted: Tue Dec 23, 2008 6:12 pm
/*************************************
Title: Admin gets Email on Topic Move
Version: 1.0
Author: Aaron Lee
Demo: NA
Download: NA
Website: NA
Short description: I needed a way to notify
admins if a ticket was moved into their
category.
*************************************/
You'll note, I also added the category into the email message.
I did this else where in the other email messages so that rules and filters could be created.
This is the code for the email message that goes into /hesk/emails
moved_to_category.txt
Then I simply added the email blocks from one of the other files into the original, accounting for my additional field.
Title: Admin gets Email on Topic Move
Version: 1.0
Author: Aaron Lee
Demo: NA
Download: NA
Website: NA
Short description: I needed a way to notify
admins if a ticket was moved into their
category.
*************************************/
You'll note, I also added the category into the email message.
I did this else where in the other email messages so that rules and filters could be created.
This is the code for the email message that goes into /hesk/emails
moved_to_category.txt
Code: Select all
Hello,
An administrator has just moved the ticket "%%SUBJECT%%" into your category.
Category: %%CATEGORY%%
You can view the ticket here:
%%TRACK_URL%%
*DO NOT REPLY TO THIS E-MAIL*
This is an automated e-mail message sent from the support system. Do not reply to this e-mail as the customer won't receive your reply!
To change your e-mail notification preferences login to the control panel and go to "Your profile".
Regards,
Hesk support system
Code: Select all
<?php
/*******************************************************************************
* Title: Helpdesk software Hesk
* Version: 0.94.1 @ October 25, 2007
* Author: Klemen Stirn
* Website: http://www.phpjunkyard.com
********************************************************************************
* COPYRIGHT NOTICE
* Copyright 2005-2007 Klemen Stirn. All Rights Reserved.
*
* This script may be used and modified free of charge by anyone
* AS LONG AS COPYRIGHT NOTICES AND ALL THE COMMENTS REMAIN INTACT.
* By using this code you agree to indemnify Klemen Stirn from any
* liability that might arise from it's use.
*
* Selling the code for this program, in part or full, without prior
* written consent is expressly forbidden.
*
* Obtain permission before redistributing this software over the Internet
* or in any other medium. In all cases copyright and header must remain
* intact. This Copyright is in full effect in any country that has
* International Trade Agreements with the United States of America or
* with the European Union.
*
* Removing any of the copyright notices without purchasing a license
* is illegal! To remove PHPJunkyard copyright notice you must purchase a
* license for this script. For more information on how to obtain a license
* please visit the site below:
* http://www.phpjunkyard.com/copyright-removal.php
*******************************************************************************/
define('IN_SCRIPT',1);
/* Get all the required files and functions */
require_once('hesk_settings.inc.php');
require_once('language/'.$hesk_settings['language'].'.inc.php');
require_once('inc/common.inc.php');
hesk_session_start();
hesk_isLoggedIn();
/* Print header */
require_once('inc/header.inc.php');
$trackingID=strtoupper(hesk_input($_POST['track'],"$hesklang[int_error]: $hesklang[no_trackID]."));
$category=hesk_input($_POST['category'],$hesklang['sel_app_cat']);
/* Connect to database */
require_once('inc/database.inc.php');
hesk_dbConnect() or hesk_error("$hesklang[cant_connect_db] $hesklang[contact_webmsater] $hesk_settings[webmaster_mail]!");
$sql = "UPDATE `hesk_tickets` SET `category`='$category' WHERE `trackid`='$trackingID' LIMIT 1";
$result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
if (hesk_dbAffectedRows() != 1) {hesk_error("$hesklang[int_error]: $hesklang[trackID_not_found].");}
$admin_trackingURL=$hesk_settings['hesk_url'].'/admin_ticket.php?track='.$trackingID.'&Refresh='.rand(10000,99999);
$sql = "SELECT `subject`,`category` FROM `hesk_tickets` WHERE `trackid`='$trackingID' LIMIT 1";
$result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
$ticket = hesk_dbFetchAssoc($result);
$category=$ticket['category'];
$sql2 = "SELECT `name` FROM `hesk_categories` WHERE `id`=$category LIMIT 1";
$result2 = hesk_dbQuery($sql2) or hesk_error("$hesklang[cant_sql]: $sql2</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
$ticket2 = hesk_dbFetchAssoc($result2);
/* Need to notify any admins? */
$admins=array();
$sql = "SELECT `email`,`isadmin`,`categories` FROM `hesk_users` WHERE `notify`='1'";
$result = hesk_dbQuery($sql) or hesk_error("$hesklang[cant_sql]: $sql</p><p>$hesklang[mysql_said]:<br>".mysql_error()."</p><p>$hesklang[contact_webmsater] $hesk_settings[webmaster_mail]");
while ($myuser=hesk_dbFetchAssoc($result))
{
/* Is this an administrator? */
if ($myuser['isadmin']) {$admins[]=$myuser['email']; continue;}
/* Not admin, is he allowed this category? */
$cat=substr($myuser['categories'], 0, -1);
$myuser['categories']=explode(",",$cat);
if (in_array($category,$myuser['categories']))
{
$admins[]=$myuser['email']; continue;
}
}
if (count($admins)>0)
{
$trackingURL_admin=$hesk_settings['hesk_url'].'/admin_ticket.php?track='.$trackingID;
/* Get e-mail message for customer */
$fp=fopen('emails/moved_to_category.txt','r');
$message=fread($fp,filesize('emails/moved_to_category.txt'));
fclose($fp);
$message=str_replace('%%NAME%%',$orig_name,$message);
$message=str_replace('%%SUBJECT%%',$ticket['subject'],$message);
$message=str_replace('%%CATEGORY%%',$ticket2['name'],$message);
$message=str_replace('%%TRACK_ID%%',$trackingID,$message);
$message=str_replace('%%TRACK_URL%%',$trackingURL_admin,$message);
$message=str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'] ,$message);
$message=str_replace('%%SITE_URL%%',$hesk_settings['site_url'] ,$message);
/* Send e-mail to staff */
$email=implode(',',$admins);
$headers="From: $hesk_settings[noreply_mail]\n";
$headers.="Reply-to: $hesk_settings[noreply_mail]\n";
@mail($email,"Ticket has been moved into your category",$message,$headers);
} // End if
/* Print admin navigation */
require_once('inc/show_admin_nav.inc.php');
?>
</td>
</tr>
<tr>
<td>
<p> </p>
<h3 align="center"><?php echo $hesklang['moved'] ?></h3>
<p> </p>
<p align="center"> <?php echo $hesklang['moved_to']; ?>!</p>
<p align="center"><a href="<?php echo $admin_trackingURL; ?>"><?php echo $hesklang['view_ticket']; ?></a> |
<a href="admin_main.php"><?php echo $hesklang['main_page']; ?></a></p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<!-- HR -->
<p> </p>
<?php
require_once('inc/footer.inc.php');
exit();
?>