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] delete internal note button

NOTE: THIS MOD HAS BEEN WRITTEN FOR OST 1.6 RC5 ONCE I UPGRADE I WILL NOTE ANY CHANGES HERE


This mod adds a button to the right of each internal note allowing them to be deleted. two versions on the last step allow for either all staff or only admin to have this function.

So as always follow carefully and backup your files!


in class.ticket.php

above

function delete(){


insert

function deleteNote($note_id){
db_query ( 'DELETE FROM ' . TICKET_NOTE_TABLE . ' WHERE note_id=' . $note_id );
}



In tickets.php

below
            default:
$errors['err']='You must select action to perform';
endswitch;
break;

insert
case 'deletenote':
$ticket->deleteNote($_POST['note_id']);
break;


In viewticket.inc.php

replace
<table align=\"center\" class=\"note\" cellspacing=\"0\" cellpadding=\"1\" width=\"100%\" border=0>
<tr><th><?=Format::db_daydatetime($row['created'])?>&nbsp;-&nbsp; posted by <?=$row['source']?></th></tr>
<? if($row['title']) {?>
<tr class=\"header\"><td><?=Format::display($row['title'])?></td></tr>
<?} ?>
<tr><td><?=Format::display($row['note'])?></td></tr>
</table>

with
<table align=\"center\" class=\"note\" cellspacing=\"0\" cellpadding=\"1\" width=\"100%\" border=0>
<tr><th><?=Format::db_daydatetime($row['created'])?>&nbsp;-&nbsp; posted by <?=$row['source']?></th>
<th width = \"10%\" valign=\"middle\">
<form action=\"tickets.php\" method=\"post\">
<input type=\"hidden\" name=\"id\" value=\"<?=$id;?>\" />
<input type=\"hidden\" name=\"note_id\" value=\"<?=$row['note_id'];?>\" />
<input type=\"hidden\" name=\"a\" value=\"deletenote\">
<input class=\"button\" type=\"submit\" value=\"Delete\" onClick='return confirm(\"Are you sure you want to DELETE selected note?\");'>
</form>
</th></tr>
<? if($row['title']) {?>
<tr class=\"header\" ><td colspan=\"2\"><?=Format::display($row['title'])?></td></tr>
<?} ?>
<tr><td colspan=\"2\"><?=Format::display($row['note'])?></td></tr>
</table>


or replace with this to only allow admins this function

<table align=\"center\" class=\"note\" cellspacing=\"0\" cellpadding=\"1\" width=\"100%\" border=0>
<tr><th><?=Format::db_daydatetime($row['created'])?>&nbsp;-&nbsp; posted by <?=$row['source']?></th>
<?php
if($thisuser->isAdmin()){?>
<th width = \"10%\" valign=\"middle\">
<form action=\"tickets.php\" method=\"post\">
<input type=\"hidden\" name=\"id\" value=\"<?=$id;?>\" />
<input type=\"hidden\" name=\"note_id\" value=\"<?=$row['note_id'];?>\" />
<input type=\"hidden\" name=\"a\" value=\"deletenote\">
<input class=\"button\" type=\"submit\" value=\"Delete\" onClick='return confirm(\"Are you sure you want to DELETE selected note?\");'>
</form>
<?}?>
</th></tr>
<? if($row['title']) {?>
<tr class=\"header\" ><td colspan=\"2\"><?=Format::display($row['title'])?></td></tr>
<?}
If (!$row['note']){
?><tr><td colspan=\"2\">No note attached.</td></tr><?
}else{
?><tr><td colspan=\"2\"><?=Format::display($row['note'])?></td></tr><?
}?>
</table>

Comments

  • can this be modded to only be available for admins?
  • yes, done, edits have been added to the first post
  • mods

    osticket has been modified

    the following code is no longer in tickets.php

    default:
    $errors['err']='You must select action to perform';
    endswitch;
    break;
  • I'm still running the RC version I will up date the code for his mod in a few weeks. Right now the system is in consent use and can not be taken down. As soon as I update I will update the code here.
  • Been a while since any additions to this thread, so thought I'd add in my own experience.

    This code works perfectly!! :)

    Mazost, I think you'll find that you need to make the code changes to the tickets.php file located within the /scp/ directory of your installation, and not the one in your main installation directory.

    Next is to work out how to delete unwanted ticket threads and responses.
  • Works like a charm

    Works great but I now have a wierd box in the bottom of each thread entry to the far right....i also have the time mod so it may be tied to that, not too sure
  • MOD osTicket 1.7 DELETE COMMENTS

    Edit include/staff/ticket.view.inc.php

    search:
    <th width=\"300\" class=\"tmeta\"><?php echo Format::htmlchars($entry['poster']); ?></th>

    replace:
    <th width=\"300\" class=\"tmeta\"><?php echo Format::htmlchars($entry['poster']); ?></th>
    <th width=\"130\">
    <form id=\"deleteNote\" action=\"tickets.php?id=<?php echo $ticket->getId(); ?>#reply\" name=\"deleteNote\" method=\"post\" enctype=\"multipart/form-data\">
    <?php csrf_token(); ?>
    <span class=\"error\"></span>
    <input type=\"hidden\" name=\"id\" name=\"id\" value=\"<?php echo $ticket->getId(); ?>\" />
    <input type=\"hidden\" name=\"note_id\" value=\"<?php echo $entry['id']; ?>\" />
    <input type=\"hidden\" name=\"a\" value=\"deletenote\" />
    <input class=\"btn btn-danger btn-xs\" type=\"submit\" value=\"Borrar Comentario\" onClick='return confirm(\"¿Estás seguro de querer borrar este comentario?\");' />
    </form>
    </th>


    After, edit colspan=3 by colspan=4


    Edit include/class.ticket.php

    search: function delete() { and above add

    /* UPD 26/09/13 - Para borrar comentarios */
    function deleteNote($note_id) {
    $sql = 'DELETE FROM ' . TICKET_THREAD_TABLE . ' WHERE id =' . $note_id;
    if (!db_query($sql) || !db_affected_rows())
    return false;

    return true;
    }


    Edit scp/tickets.php

    search: case 'reply':

    ADD ABOVE

    case 'deletenote':                                
    $ticket->deleteNote($_POST['note_id']);
    break;
  • Hi,
    For MOD osTicket 1.7, how to allow only admins to execute delete function ?
    I try put this code if($thisuser->isAdmin()) but does not work.
Sign In or Register to comment.