Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

osTicket v1.10 (stable) and Maintenance Release v1.9.15 are now available! Go get it now

[MOD] Add "Ban and Delete" button to drop-down

Makes it quicker to get rid of spam messages.

Frankly, I'm just too lazy to click so many times and scroll around banning emails and deleting posts.. so having a single button that does both just makes sense!


Anyway, to "install"

Open /scp/tickets.php:

search for:
        case 'process':

Add directly beneath:
            	case 'bandemail' : 
if(!$thisstaff->canBanEmails() or !$thisstaff->canDeleteTickets()) {
$errors['err']='Perm. Denied. You are not allowed to ban & delete emails';
} elseif(BanList::includes($ticket->getEmail())) {
$errors['err']='Email already in banlist';
} elseif(Banlist::add($ticket->getEmail(),$thisstaff->getName()) && $ticket->delete()) {
$msg='Email ('.$ticket->getEmail().') added to banlist & ' .
'Ticket #'.$ticket->getNumber().' deleted successfully';
$ost->logDebug('Ticket #'.$ticket->getNumber().' deleted',sprintf('Ticket #%s deleted by %s',$ticket->getNumber(), $thisstaff->getName()));
$ticket=null; //clear the object.
} else {
$errors['err']='Unable to add the email to banlist or delete post.. try individually?';

Then open /include/staff/

<li><a id=\"ticket-banemail\" href=\"#banemail\"><i class=\"icon-ban-circle\"></i> Ban Email (<?php echo $ticket->getEmail(); ?>)</a></li>

Add beneath:
<li><a id=\"ticket-bandemail\" href=\"#bandemail\"><i class=\"icon-ban-circle\"></i> Ban & Delete (<?php echo $ticket->getEmail(); ?>)</a></li>

 <p class=\"confirm-action\" style=\"display:none;\" id=\"banemail-confirm\">
Are you sure want to <b>ban</b> <?php echo $ticket->getEmail(); ?>? <br><br>
New tickets from the email address will be auto-rejected.

and add beneath:
<p class=\"confirm-action\" style=\"display:none;\" id=\"bandemail-confirm\">
Are you sure want to <b>ban and delete</b> <?php echo $ticket->getEmail(); ?>? <br><br>
New tickets from the email address will be auto-rejected, this post will be deleted!
<br /><br />Deleted tickets CANNOT be recovered, including any associated attachments.

I'm pretty sure that was the simplest MOD in the history of MOD's.. no database changes etc required.. just a few simple tweaks.. but it makes the Ban and Delete workflow so much quicker!


  • your last and add beneath changed to (in osticket 1.9.12)

       <li><a class="confirm-action" id="ticket-bandemail"
                                href="#bandemail"><i class="icon-ban-circle"></i> <?php echo sprintf(
                                    Format::htmlchars(__('Ban and delete email <%s>')),
                                    $ticket->getEmail()); ?></a></li>
  • second Add beneath 

    <p class="confirm-action" style="display:none;" id="bandemail-confirm">
            <?php echo sprintf(__('Are you sure want to ban and delete'), $ticket->getEmail());?> <br><br>
            <?php echo __('New tickets from the email address will be auto-rejected, this post will be deleted.');?>
  • Thks Grizly: all working fine!!
  • Cheers mate, I should modify this to be a plugin. It's on my list.
Sign In or Register to comment.