Prepare message */ // 1. Generate the array with ticket info that can be used in emails $info = array( 'email' => $ticket['email'], 'category' => $ticket['category'], 'priority' => $ticket['priority'], 'owner' => $ticket['owner'], 'trackid' => $ticket['trackid'], 'status' => $ticket['status'], 'name' => $ticket['name'], 'lastreplier' => $ticket['lastreplier'], 'subject' => $ticket['subject'], 'message' => $ticket['message'], 'attachments' => $ticket['attachments'], 'dt' => hesk_date($ticket['dt'], true), 'lastchange' => hesk_date($ticket['lastchange'], true), 'id' => $ticket['id'], ); // 2. Add custom fields to the array foreach ($hesk_settings['custom_fields'] as $k => $v) { $info[$k] = $v['use'] ? $ticket[$k] : ''; } // 3. Make sure all values are properly formatted for email $ticket = hesk_ticketToPlain($info, 1, 0); /* Need to notify any staff? */ /* --> From autoassign? */ if ($need_to_reassign && !empty($autoassign_owner['email'])) { hesk_notifyAssignedStaff($autoassign_owner, 'ticket_assigned_to_you', $modsForHesk_settings); } /* --> No autoassign, find and notify appropriate staff */ elseif (!$ticket['owner']) { hesk_notifyStaff('category_moved', "`notify_new_unassigned`='1' AND `id`!=" . intval($_SESSION['id']), $modsForHesk_settings); } /* Is the user allowed to view tickets in the new category? */ if ($category_ok) { /* Ticket has an owner */ if ($ticket['owner']) { /* Staff is owner or can view tickets assigned to others */ if ($ticket['owner'] == $_SESSION['id'] || hesk_checkPermission('can_view_ass_others', 0)) { hesk_process_messages($hesklang['moved_to'], 'admin_ticket.php?track=' . $trackingID . '&Refresh=' . rand(10000, 99999), 'SUCCESS'); } else { hesk_process_messages($hesklang['moved_to'], 'admin_main.php', 'SUCCESS'); } } /* Ticket is unassigned, staff can view unassigned tickets */ elseif (hesk_checkPermission('can_view_unassigned', 0)) { hesk_process_messages($hesklang['moved_to'], 'admin_ticket.php?track=' . $trackingID . '&Refresh=' . rand(10000, 99999), 'SUCCESS'); } /* Ticket is unassigned, staff cannot view unassigned tickets */ else { hesk_process_messages($hesklang['moved_to'], 'admin_main.php', 'SUCCESS'); } } else { hesk_process_messages($hesklang['moved_to'], 'admin_main.php', 'SUCCESS'); } ?>