if ($_SESSION['ticket_bulk_send_message'] && $_SESSION['ticket_bulk_send_message_content']) { // send our reply! tricky! // who from? just like the admin is writing it I guess. // hack: so that the tickets do not loose their positions in the queue we want to keep the same 'last message' timestamp on the thread. $ticket_data = module_ticket::get_ticket($ticket_id); $from_user_id = $ticket_data['assigned_user_id'] ? $ticket_data['assigned_user_id'] : 1; // the <br> is a hack so that our script knows this is html. $message = $_SESSION['ticket_bulk_send_message_content'] . '<br><br>'; // replace our values. $to_user = module_user::get_user($ticket_data['user_id'], false); $replace = array('name' => $to_user['name'], 'ticket_id' => module_ticket::ticket_number($ticket_id), 'ticket_url' => module_ticket::link_public($ticket_id), 'ticket_url_cancel' => module_ticket::link_public_status($ticket_id, 7), 'ticket_url_resolved' => module_ticket::link_public_status($ticket_id, 6), 'ticket_url_inprogress' => module_ticket::link_public_status($ticket_id, 5)); foreach ($replace as $key => $val) { $message = str_replace('{' . strtoupper($key) . '}', $val, $message); $message = str_replace('{' . $key . '}', $val, $message); } $ticket_message_id = module_ticket::send_reply($ticket_id, $message, $from_user_id, $ticket_data['user_id'], 'admin'); if ($ticket_message_id) { // success! // do the timestamp. update_insert('ticket_message_id', $ticket_message_id, 'ticket_message', array('message_time' => $ticket_data['last_message_timestamp'] + 1)); update_insert('ticket_id', $ticket_id, 'ticket', array('last_message_timestamp' => $ticket_data['last_message_timestamp'] + 1)); } } ?> <script type="text/javascript"> window.parent.document.getElementById('ticket_<?php echo $ticket_id; ?> ').innerHTML = 'Done!'; </script> <?php