// do the ticket processing.
     // assign a new status?
     if ((int) $_SESSION['ticket_bulk_status_id'] > 0) {
         update_insert('ticket_id', $ticket_id, 'ticket', array('status_id' => $_SESSION['ticket_bulk_status_id']));
     }
     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 
示例#2
0
    }
    $res = module_website::get_websites(array('customer_id' => $ticket['customer_id']));
    if (count($res)) {
        $fieldset_data['elements'][] = array('title' => _l('' . module_config::c('project_name_single', 'Website')), 'fields' => array(function () use($res, $ticket) {
            $c = array();
            while ($row = array_shift($res)) {
                $c[$row['website_id']] = $row['name'];
            }
            echo print_select_box($c, 'website_id', $ticket['website_id']);
        }));
    }
    if ((int) $ticket_id > 0) {
        $fieldset_data['elements'][] = array('title' => _l('Public link'), 'fields' => array(function () use($ticket_id) {
            ?>
 <a href="<?php 
            echo module_ticket::link_public($ticket_id);
            ?>
" target="_blank"><?php 
            _e('click here');
            ?>
</a> <?php 
        }));
    }
    echo module_form::generate_fieldset($fieldset_data);
    unset($fieldset_data);
    handle_hook('ticket_sidebar', $ticket_id);
}
// end can edit
hook_handle_callback('layout_column_half', 2, '65');
if ($ticket_id > 0 && module_ticket::can_edit_tickets() && !$ticket['assigned_user_id']) {
    ob_start();
示例#3
0
 /**
  * Used only when admin/user replies via web interface
  * Or when a new ticket/reply is submitted via public interface
  * Or when an autoreply is sent
  * */
 public static function send_reply($ticket_id, $message, $from_user_id, $to_user_id, $reply_type = 'admin', $internal_from = '', $other_options = array())
 {
     // we also check if this message contains anything, or anything above the "reply line"
     // this is a hack to stop the autoreply loop that seems to happen when sending an email as yourself from  your envato profile.
     // stip out the text before our "--reply above this line-- bit.
     // copied code from ticket_admin_edit.php
     /*$reply__ine_default = '----- (Please reply above this line) -----'; // incase they change it
       $reply__ine =   module_config::s('ticket_reply_line',$reply__ine_default);
       $text = preg_replace("#<br[^>]*>#",'',$message);
       // convert to single text.
       $text = preg_replace('#\s+#imsU',' ',$text);
       if(
           preg_match('#^\s*'.preg_quote($reply__ine,'#').'.*#ims',$text) ||
           preg_match('#^\s*'.preg_quote($reply__ine_default,'#').'.*#ims',$text)
       ){
           // no content. don't send email
           //mail('*****@*****.**','ticket reply '.$ticket_id,'sending reply for text:\''.$text."' \n\n\n Original:\n".$message);
           return false;
       }*/
     // $message is in text format, need to nl2br it before printing.
     $ticket_number = self::ticket_number($ticket_id);
     $ticket_details = self::get_ticket($ticket_id);
     $to_user_a = module_user::get_user($to_user_id, false);
     $from_user_a = module_user::get_user($from_user_id, false);
     // we have to replace some special text within these messages. this is just a hack to support text in my autoreply.
     $replace = array('name' => $to_user_a['name'], '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, _TICKET_STATUS_RESOLVED_ID), 'ticket_url_inprogress' => module_ticket::link_public_status($ticket_id, 5), 'faq_product_id' => $ticket_details['faq_product_id']);
     foreach ($replace as $key => $val) {
         $message = str_replace('{' . strtoupper($key) . '}', $val, $message);
     }
     // the from details need to match the ticket account details.
     if ($ticket_details['ticket_account_id']) {
         $ticket_account = self::get_ticket_account($ticket_details['ticket_account_id']);
     } else {
         $ticket_account = false;
     }
     if ($ticket_account && $ticket_account['email']) {
         // want the user to reply to our ticketing system.
         $reply_to_address = $ticket_account['email'];
         $reply_to_name = $ticket_account['name'];
     } else {
         // reply to creator of the email.
         $reply_to_address = $from_user_a['email'];
         $reply_to_name = $from_user_a['name'];
     }
     $htmlmessage = '';
     if (self::is_text_html($message)) {
         $htmlmessage = $message;
         $message = strip_tags($message);
     }
     $ticket_message_data = array('ticket_id' => $ticket_id, 'content' => $message, 'htmlcontent' => $htmlmessage, 'message_time' => time(), 'from_user_id' => $from_user_id, 'to_user_id' => $to_user_id, 'message_type_id' => $reply_type == 'admin' ? _TICKET_MESSAGE_TYPE_ADMIN : _TICKET_MESSAGE_TYPE_CREATOR, 'private_message' => isset($other_options['private_message']) && $other_options['private_message'] ? $other_options['private_message'] : 0);
     if ($internal_from == 'autoreply') {
         $ticket_message_data['message_type_id'] = _TICKET_MESSAGE_TYPE_AUTOREPLY;
     }
     if (self::can_edit_tickets()) {
         // we look for the extra cc/bcc headers.
         if (module_config::c('ticket_allow_cc_bcc', 1)) {
             $headers = array();
             // look for cc staff options here.
             if (isset($_POST['ticket_cc_staff']) && is_array($_POST['ticket_cc_staff'])) {
                 $admins_rel = self::get_ticket_staff_rel();
                 foreach ($admins_rel as $staff_id => $staff_name) {
                     if (isset($_POST['ticket_cc_staff'][$staff_id])) {
                         $staff_user = module_user::get_user($staff_id);
                         if ($staff_user && isset($staff_user['email']) && strlen($staff_user['email'])) {
                             // found a staff member to cc!
                             if (!isset($headers['cc_emails'])) {
                                 $headers['cc_emails'] = array();
                             }
                             $headers['cc_emails'][] = array('address' => $staff_user['email']);
                         }
                     }
                 }
             }
             if (isset($_POST['ticket_cc']) && strlen($_POST['ticket_cc'])) {
                 $bits = explode(',', $_POST['ticket_cc']);
                 foreach ($bits as $b) {
                     $b = trim($b);
                     if (strlen($b)) {
                         if (!isset($headers['cc_emails'])) {
                             $headers['cc_emails'] = array();
                         }
                         $headers['cc_emails'][] = array('address' => $b);
                     }
                 }
             }
             if (isset($_POST['ticket_bcc']) && strlen($_POST['ticket_bcc'])) {
                 $bits = explode(',', $_POST['ticket_bcc']);
                 foreach ($bits as $b) {
                     $b = trim($b);
                     if (strlen($b)) {
                         if (!isset($headers['bcc_emails'])) {
                             $headers['bcc_emails'] = array();
                         }
                         $headers['bcc_emails'][] = array('address' => $b);
                     }
                 }
             }
             if (count($headers)) {
                 $ticket_message_data['cache'] = serialize($headers);
             }
         }
     }
     $ticket_message_id = update_insert('ticket_message_id', 'new', 'ticket_message', $ticket_message_data);
     if (!$ticket_message_id) {
         return false;
     }
     // handle any attachemnts.
     // are there any attachments?
     if ($ticket_message_id && isset($_FILES['attachment']) && isset($_FILES['attachment']['tmp_name']) && is_array($_FILES['attachment']['tmp_name'])) {
         foreach ($_FILES['attachment']['tmp_name'] as $key => $val) {
             if (is_uploaded_file($val)) {
                 // save attachments against ticket!
                 $mime = dtbaker_mime_type($_FILES['attachment']['name'][$key], $val);
                 $attachment_id = update_insert('ticket_message_attachment_id', 'new', 'ticket_message_attachment', array('ticket_id' => $ticket_id, 'ticket_message_id' => $ticket_message_id, 'file_name' => $_FILES['attachment']['name'][$key], 'content_type' => $mime));
                 //echo getcwd();exit;
                 //ini_set('display_errors',true);
                 if (!move_uploaded_file($val, 'includes/plugin_ticket/attachments/' . $attachment_id . '')) {
                     //echo 'error uploading file';exit;
                 }
             }
         }
     }
     if ($internal_from != 'autoreply') {
         // stops them all having the same timestamp on a big import.
         update_insert('ticket_id', $ticket_id, 'ticket', array('last_message_timestamp' => time()));
         /*}else{
           // we are sending an auto reply, flag this in the special cache field.
           // hacky!
           update_insert('ticket_message_id',$ticket_message_id,'ticket_message',array(
                    'cache'=>'autoreply',
            ));*/
     }
     //$reply_line = module_config::s('ticket_reply_line','----- (Please reply above this line) -----');
     $s = self::get_statuses();
     if (isset($other_options['private_message']) && $other_options['private_message']) {
         // private message, dont send an email to the customer.
         if (!self::is_text_html($message)) {
             $message = nl2br(htmlspecialchars($message));
             // because message is in text format, before we send admin notification do this.
         }
         module_ticket::send_admin_alert($ticket_id, strlen($htmlmessage) ? $htmlmessage : $message, true);
     } else {
         if ($to_user_id == $ticket_details['user_id']) {
             // WE ARE emailing the "User" from support.
             // so the support is emailing a response back to the customer.
             module_ticket::send_customer_alert($ticket_id, strlen($htmlmessage) ? $htmlmessage : $message, $ticket_message_id);
         } else {
             if (!self::is_text_html($message)) {
                 $message = nl2br(htmlspecialchars($message));
                 // because message is in text format, before we send admin notification do this.
             }
             module_ticket::send_admin_alert($ticket_id, strlen($htmlmessage) ? $htmlmessage : $message);
         }
         if ($reply_type == 'end_user' && (!$ticket_details['message_count'] || module_config::c('ticket_autoreply_every_message', 0))) {
             // this is the first message!
             // send an email back to the user confirming this submissions via the web interface.
             self::send_autoreply($ticket_id, $message);
         }
     }
     return $ticket_message_id;
 }