Home > osTicket > Only The Assignee Staff or Admin Can Close and Reopen Ticket in osTicket v1.6 RC5

Only The Assignee Staff or Admin Can Close and Reopen Ticket in osTicket v1.6 RC5

This following modification will add a small feature to limit the ability for staff to close the opened ticket or to reopen the closed ticket in osTicket v1.6 RC5. Only the assignee staff or admin can close and reopen the ticket. It means that if the current ticket has not been assigned to any staff, then only admin can close that ticket. Since there is no staff_id information for the closed tickets, then the closed ticket handling is similar with the unassigned tickets. Thus, this rule will be automatically being applied to such tickets.

  1. Open your \include\class.ticket.php file, and find this code:

    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    
        //Close the ticket
        function close(){
     
            $sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('closed').',staff_id=0,isoverdue=0,duedate=NULL,updated=NOW(),closed=NOW() '.
                  ' WHERE ticket_id='.db_input($this->getId());
            return (db_query($sql) && db_affected_rows())?true:false;
        }
        //set status to open on a closed ticket.
        function reopen(){
            global $thisuser;
            $sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('open').',isanswered=0,updated=NOW(),reopened=NOW() WHERE ticket_id='.db_input($this->getId());
            return (db_query($sql) && db_affected_rows())?true:false;
        }

    then replace with this following code:

    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    
        //Close the ticket
        function close(){
        	// MOD Only The Assignee Staff Or Admin Can Close The Ticket, 
    	// by Masino Sinaga (http://www.openscriptsolution.com), December 4, 2009
        	global $thisuser;
            if ($this->getStaffId()!=$thisuser->getId() && !$thisuser->isadmin()) {
    	  return false;	
    	} else {
              $sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('closed').',staff_id=0,isoverdue=0,duedate=NULL,updated=NOW(),closed=NOW() '.
                   ' WHERE ticket_id='.db_input($this->getId());        
              return (db_query($sql) && db_affected_rows())?true:false;
            }
        }
        //set status to open on a closed ticket.
        function reopen(){
        	// MOD Only The Assignee Staff Or Admin Can ReOpen The Ticket, 
    	// by Masino Sinaga (http://www.openscriptsolution.com), December 4, 2009
            global $thisuser;
            if ($this->getStaffId()!=$thisuser->getId() && !$thisuser->isadmin()) {
    	  return false;	
    	} else {
              $sql= 'UPDATE '.TICKET_TABLE.' SET status='.db_input('open').',isanswered=0,updated=NOW(),reopened=NOW() WHERE ticket_id='.db_input($this->getId());
              return (db_query($sql) && db_affected_rows())?true:false;
            }
        }
  2. Open your \scp\tickets.php file, and find this code:

    210
    
    $errors['err']='Problems closing the ticket. Try again';

    then replace with this following code:

    210
    
    $errors['err']='Problems closing the ticket or you are not allowed to close tickets.';

    Find again this code:

    224
    
    $errors['err']='Problems reopening the ticket. Try again';

    then replace with this following code:

    224
    
    $errors['err']='Problems reopening the ticket or you are not allowed to reopen tickets.';

That’s all, everyone! Enjoy the code and its result. :-)

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

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