Example #1
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'));
 }
Example #2
0
 /**
  * The UI to edit a ticket.
  *
  * @return tempcode		The UI
  */
 function edit_ticket_type()
 {
     $title = get_page_title('EDIT_TICKET_TYPE');
     require_code('form_templates');
     require_code('permissions2');
     $ticket_type = get_param_integer('ticket_type');
     $details = get_ticket_type($ticket_type);
     $type_text = get_translated_text($ticket_type);
     $post_url = build_url(array('page' => '_SELF', 'type' => '_edit', 'ticket_type' => $ticket_type), '_SELF');
     $submit_name = do_lang_tempcode('SAVE');
     $fields = new ocp_tempcode();
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('SETTINGS'))));
     $fields->attach(form_input_line(do_lang_tempcode('TYPE'), do_lang_tempcode('DESCRIPTION_TICKET_TYPE'), 'new_type', $type_text, false));
     $fields->attach(form_input_tick(do_lang_tempcode('TICKET_GUEST_EMAILS_MANDATORY'), do_lang_tempcode('DESCRIPTION_TICKET_GUEST_EMAILS_MANDATORY'), 'guest_emails_mandatory', $details['guest_emails_mandatory']));
     $fields->attach(form_input_tick(do_lang_tempcode('TICKET_SEARCH_FAQ'), do_lang_tempcode('DESCRIPTION_TICKET_SEARCH_FAQ'), 'search_faq', $details['search_faq']));
     $fields->attach(get_category_permissions_for_environment('tickets', $type_text));
     $fields->attach(do_template('FORM_SCREEN_FIELD_SPACER', array('TITLE' => do_lang_tempcode('ACTIONS'))));
     $fields->attach(form_input_tick(do_lang_tempcode('DELETE'), do_lang_tempcode('DESCRIPTION_DELETE'), 'delete', false));
     return do_template('FORM_SCREEN', array('_GUID' => '0a505a779c1639fd2d3ee10c24a7905a', 'SKIP_VALIDATION' => true, 'TITLE' => $title, 'HIDDEN' => '', 'TEXT' => '', 'FIELDS' => $fields, 'SUBMIT_NAME' => $submit_name, 'URL' => $post_url));
 }