Home > osTicket > Limiting Tickets Based on Current Department in Merge Ticket Selection of osTicket v1.6 RC5

Limiting Tickets Based on Current Department in Merge Ticket Selection of osTicket v1.6 RC5

If you have ever implemented the modification I created titled Add Merge Ticket Feature into osTicket v1.6 RC5, and then you want to limit the tickets that being displayed in the Merge Ticket selection in viewticket page, then this modification is for you! Please note that this following modification in this current article can be implemented properly after you have implemented that modification that I mentioned via the link above.

Open your \include\staff\viewticket.inc.php, and find this code:

493
494
495
			   $sql = 'SELECT ticket_id, concat(ticketid,": ",subject) AS label FROM '.TICKET_TABLE.' WHERE email='.
                                  '(SELECT email FROM ost_ticket WHERE ticket_id = '.$id.') AND status '.
                                  '= "open" AND ticket_id <> '.$id.' ORDER BY `created` DESC ';

then replace that code with this following code:

493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
                           //if dept returns nothing...show only tickets without dept which could mean..none...
                           //and display an error. huh?
                           $depts=$thisuser->getDepts(); 			                         
                           if(!$depts or !is_array($depts) or !count($depts)){
                           //if dept returns nothing...show only orphaned tickets (without dept) which could mean..none...and display an error.
                              $qwhere =' WHERE dept_id IN ( 0 ) ';
                           }else if($thisuser->isadmin()){
                              $qwhere =' WHERE 1 '; 
                           }else{
                              //limited depts....user can access tickets assigned to them regardless of the dept.
                              $qwhere =' WHERE (dept_id IN ('.implode(',',$depts).') OR staff_id='.$thisuser->getId().') ';
                           }
 
                           $sql = 'SELECT ticket_id, concat(ticketid,": ",subject) AS label FROM '.TICKET_TABLE.' '.$qwhere.' AND email='.
                                  '(SELECT email FROM ost_ticket WHERE ticket_id = '.$id.') AND status '.
                                  '= "open" AND ticket_id <> '.$id.' ORDER BY `created` DESC ';

Actually, the additional code above was taken from the WHERE clausa in the \include\staff\tickets.inc.php file (around line 85) to verify the tickets displayed for: the department basis, user groups basis, and or also for the ticket assigned basis. The Ticket Assigned basis means that: even the ticket assigned to the staff which belongs to the different department with the current logged in staff, then that ticket will be displayed in the Merge Ticket selection.

  • Share/Bookmark
124 views Print This Post Print This Post

  1. No comments yet.
  1. No trackbacks yet.