Admin gets Email on Topic Move

Everything related to Hesk - helpdesk software

Moderator: mkoch227

Post Reply
azWRX06
Posts: 9
Joined: Tue Dec 23, 2008 2:28 pm

Admin gets Email on Topic Move

Post by azWRX06 »

/*************************************
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

Then I simply added the email blocks from one of the other files into the original, accounting for my additional field.

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>&nbsp;</p>
<h3 align="center"><?php echo $hesklang['moved'] ?></h3>

<p>&nbsp;</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>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>

<!-- HR -->
<p>&nbsp;</p>

<?php
require_once('inc/footer.inc.php');
exit();

?>

Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Thanks for sharing all the modifications!
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
azWRX06
Posts: 9
Joined: Tue Dec 23, 2008 2:28 pm

Post by azWRX06 »

No problem, the shell code was so good to begin with, that it was just simple changes.
hollandsedrop
Posts: 90
Joined: Tue Dec 30, 2008 11:29 am

Post by hollandsedrop »

azWRX06 wrote:No problem, the shell code was so good to begin with, that it was just simple changes.
Hi. what i can do it version 2.0?
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

It's included by default in 2.0
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
hollandsedrop
Posts: 90
Joined: Tue Dec 30, 2008 11:29 am

Post by hollandsedrop »

Klemen wrote:It's included by default in 2.0
Are you test this? Because not working, not send category moved mail.
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

It won't send category moved mail to YOU if you are the one who moved it (because you already know it is moved and there is no need for an e-mail), but it will send to any other staff members who have access to the new category and have their profile set to receive notifications.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
hollandsedrop
Posts: 90
Joined: Tue Dec 30, 2008 11:29 am

Post by hollandsedrop »

Klemen wrote:It won't send category moved mail to YOU if you are the one who moved it (because you already know it is moved and there is no need for an e-mail), but it will send to any other staff members who have access to the new category and have their profile set to receive notifications.
I tested administrator account and that not receive move ticket mail. But other staff receive it. Do Administrator receive all moved ticket?
hollandsedrop
Posts: 90
Joined: Tue Dec 30, 2008 11:29 am

Post by hollandsedrop »

And old version mail included %%CATEGORY%% area.

how can i do that version?

thanks for help.
Klemen
Site Admin
Posts: 10136
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

hollandsedrop wrote:I tested administrator account and that not receive move ticket mail. But other staff receive it. Do Administrator receive all moved ticket?
That's exactly what I am telling you - the person who moves the ticket doesn't receive an e-mail (because he/she know the ticket was moved!), all the others do.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
hollandsedrop
Posts: 90
Joined: Tue Dec 30, 2008 11:29 am

Post by hollandsedrop »

And old version mail included %%CATEGORY%% area.

how can i do that version?

thanks for help.
Post Reply