Staff Cannot View Ticket Until They Are Assigned in osTicket v1.6 RC5

Today I made a modification in order to give solution to one of the topics in osTicket Forum Discussion.

Here is the quote of that topic:

I dont want the user to see the ticket till they are assigned to it. Only Admin and Manager of that department can view the idea.

So basically something like that:
if(usergroup == admin)
view all tickets
else if(usergroup == manager)
view ticket of their dept only
else if(usergroup == staff)
view only tickets that are assigned to them

Here, admin/manager/staff are user group with group id 1/2/3

I am not sure where do I find the querry which I can change to have this implemented. This whole thing is for backend login users.

  1. Open \include\staff\tickets.inc.php file, and find this code:

    82
    83
    84
    85
    
    }else{
        //limited depts....user can access tickets assigned to them regardless of the dept.
        $qwhere =' WHERE (ticket.dept_id IN ('.implode(',',$depts).') OR ticket.staff_id='.$thisuser->getId().')';
    }

    then replace with this following code:

    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    
    }else{
        //limited depts....user can access tickets assigned to them regardless of the dept.
        //now only admin can access all tickets 
        if ($thisuser->isadmin()) {
          $qwhere =' WHERE (ticket.dept_id IN ('.implode(',',$depts).') OR ticket.staff_id='.$thisuser->getId().')';
        } elseif ($thisuser->isManager()) { // manager can access tickets belong to his/her dept.		  
          $qwhere =' WHERE (ticket.dept_id IN ('.implode(',',$depts).') )';
        } else { // staff can only access the assigned tickets to him/her
          $qwhere =' WHERE (ticket.staff_id='.$thisuser->getId().')';
        }
    } // modified by Masino Sinaga, September 30, 2009
  2. Open your \scp\tickets.php file, and find this code:

    394
    395
    396
    
    if(!$thisuser->isAdmin()){
        $sql.=' WHERE ticket.dept_id IN('.implode(',',$thisuser->getDepts()).') OR ticket.staff_id='.db_input($thisuser->getId());
    }

    then replace with this following code:

    394
    395
    396
    397
    398
    399
    400
    401
    402
    
    /* Begin of MOD: Staff can only access the assigned tickets to him/her, by Masino Sinaga, Oct 17, 2009 */
    if($thisuser->isAdmin()){
        // there is no WHERE condition for Admin, he/she can see all tickets.
    } elseif ($thisuser->isManager()) { // manager can access tickets belong to his/her dept.          
        $sql.=' WHERE (ticket.dept_id IN ('.implode(',',$depts).') )';
    } else { // staff can only access the assigned tickets to him/her
        $sql.=' WHERE (ticket.staff_id='.$thisuser->getId().')';
    }
    /* End of MOD: Staff can only access the assigned tickets to him/her, by Masino Sinaga, Oct 17, 2009 */

Hope it helps.

Share

920 viewsPrint This Post Print This Post

Comments

  1. AJ says:

    Your osTicket mods are awesome! Saved me a lot of time and energy! Thank you so much for sharing your knowledge and expertise!! Keep up the great work!!!

  2. Greg says:

    Works great! It took 2-minutes to add the code and it worked the first time! Thanks for sharing – greatly appreciated.

  3. Dolmax says:

    Hi there,

    You have great mods that work. I do have a problem with this specific one. After I replaced the existing code with the one on this post, now I’m having syntax related problem on my mysql output. The mod works as supposed to, but I receive the mysql fault everytime I use the scp panel.

    The following error is the output received;

    [SELECT count(open.ticket_id) as open, count(answered.ticket_id) as answered ,count(overdue.ticket_id) as overdue, count(assigned.ticket_id) as assigned FROM ost_ticket ticket LEFT JOIN ost_ticket open ON open.ticket_id=ticket.ticket_id AND open.status='open' AND open.isanswered=0 LEFT JOIN ost_ticket answered ON answered.ticket_id=ticket.ticket_id AND answered.status='open' AND answered.isanswered=1 LEFT JOIN ost_ticket overdue ON overdue.ticket_id=ticket.ticket_id AND overdue.status='open' AND overdue.isoverdue=1 LEFT JOIN ost_ticket assigned ON assigned.ticket_id=ticket.ticket_id AND assigned.staff_id=2 WHERE (ticket.dept_id IN () )]

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘) )’ at line 1

Speak Your Mind

*


*