Hello everyone,
First of all, I want to share the modification that I made. This MOD will avoid duplicate ticket-content saved ini database.
As we know, in existing condition, after client submit a new ticket and got "thank you" message from osTicket, sometimes client refresh/reload that "thank you" page... and this will cause the same ticket-content (of course with different Ticket-ID) will be saved in database.
This MOD will avoid that duplicate ticket-content saved in database, and client will get error message "Data already exists in database!", and the page will be back to the Open New Ticket form that filled-in with that duplicate data. This is useful for you, especially if you want to apply this rule to your osTicket, moreover this will avoid spam-ticket record in your database if client refresh/reload the "thank you" page via his/her browser. ;)
Okay. Let's getting started now!
In file \include\class.ticket.php
FIND:
//Any error above is fatal.
if($errors) { return 0; }
BEFORE, ADD:
// Added by Masino Sinaga, April 13, 2009
// This code to avoid duplicate ticket-content saved in database
//
// For example: In existing condition, If user refresh/reload
// the page that show thank you message after client
// open a new ticket, the new ticket would be created
// and that new record will be saved in database, even
// the new ticket has same content with the previous ticket.
// With this MOD, system will avoid the same ticket-content
// saved in database.
//
// In other words:
// Before: Duplicate ticket-content will be saved in database
// After : Avoid duplicate ticket-content in database
$sql1='SELECT email FROM '.TICKET_TABLE.'
WHERE email='.db_input($var).'
AND name='.db_input(Format:($var)).'
AND subject='.db_input(Format:($var)).'
AND phone='.db_input(Format:($var)).'
AND ip_address='.db_input($ipaddress).'
AND source='.db_input($source).'';
$sql2='SELECT ticket_id FROM '.TICKET_MESSAGE_TABLE.'
WHERE message='.db_input(Format:($var)).'';
$res1=db_query($sql1);
$res2=db_query($sql2);
if( ($res1 && db_num_rows($res1)) && ($res2 && db_num_rows($res2)) ) {
$errors="Data already exists in database!";
}
// Added by Masino Sinaga, April 13, 2009
That's all, everyone.
Hope this helpful for you.
Have a nice day! :)
Best regards,
Masino Sinaga