diff --git a/include/class.ticket.php b/include/class.ticket.php index c31f155d67fb6ff590ef01d59fec24ecc28c9058..53dce9cb9e1899977c9e403b9e6905eae7ed5ae0 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -1158,31 +1158,36 @@ class Ticket { db_query('UPDATE '.TICKET_TABLE.' SET isanswered=0,lastmessage=NOW() WHERE ticket_id='.db_input($this->getId())); - // Auto-assign to closing staff or last respondent - // If the ticket is closed and auto-claim is not enabled then put the - // ticket back to unassigned pool. - if ($this->isClosed() && !$cfg->autoClaimTickets()) { - $this->setStaffId(0); - } elseif(!($staff=$this->getStaff()) || !$staff->isAvailable()) { - // Ticket has no assigned staff - if auto-claim is enabled then - // try assigning it to the last respondent (if available) - // otherwise leave the ticket unassigned. - if ($cfg->autoClaimTickets() //Auto claim is enabled. - && ($lastrep=$this->getLastRespondent()) - && $lastrep->isAvailable()) { - $this->setStaffId($lastrep->getId()); //direct assignment; - } else { - $this->setStaffId(0); //unassign - last respondent is not available. - } - } // Reopen if closed AND reopenable // We're also checking autorespond flag because we don't want to // reopen closed tickets on auto-reply from end user. This is not to // confused with autorespond on new message setting - if ($autorespond && $this->isClosed() && $this->isReopenable()) + if ($autorespond && $this->isClosed() && $this->isReopenable()) { $this->reopen(); + // Auto-assign to closing staff or last respondent + // If the ticket is closed and auto-claim is not enabled then put the + // ticket back to unassigned pool. + if (!$cfg->autoClaimTickets()) { + $this->setStaffId(0); + } + elseif (!($staff = $this->getStaff()) || !$staff->isAvailable()) { + // Ticket has no assigned staff - if auto-claim is enabled then + // try assigning it to the last respondent (if available) + // otherwise leave the ticket unassigned. + if (($lastrep = $this->getLastRespondent()) + && $lastrep->isAvailable() + ) { + $this->setStaffId($lastrep->getId()); //direct assignment; + } + else { + // unassign - last respondent is not available. + $this->setStaffId(0); + } + } + } + /********** double check auto-response ************/ if (!($user = $message->getUser())) $autorespond=false;