PHP for the day

Well we use the h2_desk helpdesk at the moment that has the ability to receive emails and correctly file it under the ticket reference in teh subject line.

That’s great, but we realised sometimes when a customer emailed us directly, we would reply and copy in the ticket system. this meant the customer would get our email and a notification from the ticket system that there was an update.

The answer was to modify the code in email_parse.php to mark the email as a staff note, but only if the sender was a member of staff (in this case status = 2).
It took me around 30 mins to figure out the correct file location and to make the code edits and I’m proud it worked.

—ORIGINAL—

if( $exists ) // If it exists, add a post
{
$user_id = mysql_grab_col( “SELECT id FROM {$pre}user WHERE ( email = ‘$email’ )”, 0 );
$id = mysql_grab_col( “SELECT id FROM {$pre}ticket WHERE ( ticket = ‘$ticket’ )”, 0 );
create_post( $user_id, $id, $subject, $message, $date, $ip, false, false, $msgid );
}
else // Otherwise add a new ticket

—MODIFIED—

if( $exists ) // If it exists, add a post
{

$user_id = mysql_grab_col( “SELECT id FROM {$pre}user WHERE ( email = ‘$email’ )”, 0 );
$user_status = mysql_grab_col( “SELECT status FROM {$pre}user WHERE ( email = ‘$email’ )”, 0 ); //get the user status 1 = customer, 2 = staff
if ($user_status == 2) {//if they are a staff member

$id = mysql_grab_col( “SELECT id FROM {$pre}ticket WHERE ( ticket = ‘$ticket’ )”, 0 );
create_post( $user_id, $id, $subject, $message, $date, $ip, false, true, $msgid); //mark as staff note
}
else // if they are not a staff member
{
$id = mysql_grab_col( “SELECT id FROM {$pre}ticket WHERE ( ticket = ‘$ticket’ )”, 0 );
create_post( $user_id, $id, $subject, $message, $date, $ip, false, false, $msgid ); //do not mark staff note
}

}
else // Otherwise add a new ticket