/**
 * If necessary, send out a support ticket reply
 *
 * @param  AUTO_LINK		Forum ID
 * @param  AUTO_LINK		Topic ID
 * @param  SHORT_TEXT	Topic title
 * @param  LONG_TEXT		Post made
 */
function handle_topic_ticket_reply($forum_id, $topic_id, $topic_title, $post)
{
    // E-mail the user or staff if the post is a new one in a support ticket
    if (addon_installed('tickets')) {
        require_code('tickets');
        require_code('tickets2');
        require_code('feedback');
        if (is_ticket_forum($forum_id)) {
            $topic_info = $GLOBALS['FORUM_DB']->query_select('f_topics', array('t_cache_first_title', 't_sunk', 't_forum_id', 't_is_open', 't_description'), array('id' => $topic_id), '', 1);
            if (!array_key_exists(0, $topic_info)) {
                warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
            }
            $topic_description = $topic_info[0]['t_description'];
            $ticket_id = extract_topic_identifier($topic_description);
            $home_url = build_url(array('page' => 'tickets', 'type' => 'ticket', 'id' => $ticket_id), 'site', NULL, false, true);
            send_ticket_email($ticket_id, $topic_title, $post, $home_url->evaluate(), '', -1);
        }
    }
}
Example #2
0
 /**
  * Actualise ticket creation/reply, then show the ticket again.
  *
  * @return tempcode		The UI
  */
 function do_update_ticket()
 {
     $title = get_page_title('SUPPORT_TICKETS');
     $id = get_param('id');
     $_title = post_param('title');
     $post = post_param('post');
     if ($post == '') {
         warn_exit(do_lang_tempcode('NO_PARAMETER_SENT', 'post'));
     }
     $ticket_type = post_param_integer('ticket_type', -1);
     $this->check_id($id);
     $staff_only = post_param_integer('staff_only', 0) == 1;
     // Update
     $_home_url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $id, 'redirect' => NULL), '_SELF', NULL, false, true, true);
     $home_url = $_home_url->evaluate();
     $email = '';
     if ($ticket_type != -1) {
         $type_string = get_translated_text($ticket_type);
         $ticket_type_details = get_ticket_type($ticket_type);
         //$_title=$type_string.' ('.$_title.')';
         if (!has_category_access(get_member(), 'tickets', $type_string)) {
             access_denied('I_ERROR');
         }
         // Check FAQ search results first
         if ($ticket_type_details['search_faq'] && post_param_integer('faq_searched', 0) == 0) {
             $results = $this->do_search($title, $id, $post);
             if (!is_null($results)) {
                 return $results;
             }
         }
         $new_post = new ocp_tempcode();
         $new_post->attach(do_lang('THIS_WITH_COMCODE', do_lang('TICKET_TYPE'), $type_string) . "\n\n");
         $email = trim(post_param('email', ''));
         if ($email != '') {
             $body = '> ' . str_replace(chr(10), chr(10) . '> ', $post);
             if (substr($body, -2) == '> ') {
                 $body = substr($body, 0, strlen($body) - 2);
             }
             $new_post->attach('[email subject="Re: ' . comcode_escape(post_param('title')) . ' [' . get_site_name() . ']" body="' . comcode_escape($body) . '"]' . $email . '[/email]' . "\n\n");
         } elseif (is_guest() && $ticket_type_details['guest_emails_mandatory']) {
             // Error if the e-mail address is required for this ticket type
             warn_exit(do_lang_tempcode('ERROR_GUEST_EMAILS_MANDATORY'));
         }
         $new_post->attach($post);
         $post = $new_post->evaluate();
     }
     if (addon_installed('captcha')) {
         if (get_option('captcha_on_feedback') == '1') {
             require_code('captcha');
             enforce_captcha();
         }
     }
     ticket_add_post(get_member(), $id, $ticket_type, $_title, $post, $home_url, $staff_only);
     // Find true ticket title
     $_forum = 1;
     $_topic_id = 1;
     $_ticket_type = 1;
     // These will be returned by reference
     $posts = get_ticket_posts($id, $_forum, $_topic_id, $_ticket_type);
     if (!is_array($posts)) {
         warn_exit(do_lang_tempcode('MISSING_RESOURCE'));
     }
     $__title = $_title;
     foreach ($posts as $ticket_post) {
         $__title = $ticket_post['title'];
         if ($__title != '') {
             break;
         }
     }
     // Send email
     if (!$staff_only) {
         if ($email == '') {
             $email = $GLOBALS['FORUM_DRIVER']->get_member_email_address(get_member());
         }
         send_ticket_email($id, $__title, $post, $home_url, $email, $ticket_type);
     }
     $url = build_url(array('page' => '_SELF', 'type' => 'ticket', 'id' => $id), '_SELF');
     if (is_guest()) {
         $url = build_url(array('page' => '_SELF'), '_SELF');
     }
     if (get_param('redirect', '') != '') {
         $url = make_string_tempcode(get_param('redirect'));
     }
     return redirect_screen($title, $url, do_lang_tempcode('TICKET_STARTED'));
 }