Limiting Tickets Sent by Same Email Within The Last N Days in osTicket
As Administrator in your osTicket System, you want to limit tickets sent by the same user/email within the last period of days, somehow. For example, you want to limit only 3 tickets a user (determined from the email address) can submit within the last one month. When this condition meet the criteria, osTicket System will display the message such as: “You are not allowed to send the ticket because you have already sent 3 tickets within the last 30 days!”, afterwards, the system will reject the ticket that user submitting immediately. So here is the solution that I made.
-
Open your \include\class.ticket.php file, and find this code:
1152 1153
//Any error above is fatal. if($errors) { return 0; }
before the first line of that code above, please insert the following code:
1151 1152 1153 1154 1155 1156 1157 1158
$sqllimit='SELECT email FROM '.TICKET_TABLE.' WHERE 30 >= TIMESTAMPDIFF(DAY,created,NOW()) AND email='.db_input($var['email']).''; $reslimit=db_query($sqllimit); // Limit only 3 tickets sent within the last 30 days if (db_num_rows($reslimit) >= 3) { $errors['err'] = 'You are not allowed to send the ticket because you have already sent 3 tickets within the last 30 days!'; }
If somehow you want to change the period of the day (for example you want to change become one week), then you may change it the code above in part of:
WHERE 30 >= TIMESTAMPDIFF(DAY,created,NOW())
become:
WHERE 7 >= TIMESTAMPDIFF(DAY,created,NOW())
And don’t forget to adjust the message above that will be displayed to your client.
Print This Post
Recent Comments