Ejemplo n.º 1
0
function wats_options_manage_ticket_submission_options()
{
    global $wpdb, $wats_settings, $wats_default_ticket_listing_columns, $current_user;
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("ticket_edition_media_upload_tip");>' . __('Media upload', 'WATS') . ' : </a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="checkbox" name="ticket_edition_media_upload"';
    if ($wats_settings['ticket_edition_media_upload'] == 1) {
        echo ' checked';
    }
    echo '> ' . __('Allow media upload on ticket creation and edition pages', 'WATS') . '</td></tr><tr><td>';
    echo '<div class="wats_tip" id="ticket_edition_media_upload_tip">';
    echo __('Check this option if you want to allow media upload while creating and editing tickets. This will allow users to attach media files to tickets.', 'WATS') . '</div></td></tr></table><br />';
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("ticket_edition_media_upload_tabs_tip");>' . __('Media upload tabs', 'WATS') . ' : </a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="checkbox" name="ticket_edition_media_upload_tabs"';
    if ($wats_settings['ticket_edition_media_upload_tabs'] == 1) {
        echo ' checked';
    }
    echo '> ' . __('Allow media library browsing during media upload', 'WATS') . '</td></tr><tr><td>';
    echo '<div class="wats_tip" id="ticket_edition_media_upload_tabs_tip">';
    echo __('Check this option if you want to allow media library browsing during media upload while creating and editing tickets. This will allow users to view the library and insert files directly from it.', 'WATS') . '</div></td></tr></table><br />';
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("guestlist_tip");>' . __('Shared guest user', 'WATS') . ' : </a></h3>';
    echo '<table class="wats-form-table"><tr><td>' . __('User', 'WATS') . ' : ';
    if ($wats_settings['drop_down_user_selector_format'] == 0) {
        echo '<select name="guestlist" id="guestlist" class="wats_select">';
        $userlist = wats_build_user_list(__("None", 'WATS'), 'edit_posts');
        foreach ($userlist as $userlogin => $username) {
            if ($current_user->user_login !== $userlogin) {
                echo '<option value="' . $userlogin . '" ';
                if ($userlogin == $wats_settings['wats_guest_user']) {
                    echo 'selected';
                }
                echo '>' . $username . '</option>';
            }
        }
        echo '</select></td></tr><tr><td>';
    } else {
        if ($wats_settings['wats_guest_user'] === -1) {
            $guest_user = __('None', 'WATS');
            $guest_user_hidden = -1;
        } else {
            $guest_user = get_user_by('login', $wats_settings['wats_guest_user']);
            $guest_user = wats_build_formatted_name($guest_user->ID);
            $guest_user = $guest_user[$wats_settings['wats_guest_user']];
            $guest_user_hidden = $wats_settings['wats_guest_user'];
        }
        echo '<input class="ui-autocomplete-input" type="text" name="guestlist_ac" id="guestlist_ac" value="' . esc_attr($guest_user) . '" />';
        echo '<input type="hidden" name="guestlist" id="guestlist" value="' . esc_attr($guest_user_hidden) . '" /></td></tr><tr><td>';
    }
    echo '<div class="wats_tip" id="guestlist_tip">';
    echo __('The shared guest user is a user that must have at least contributor user level. This user will only have access to the ticket creation page on the admin side. You can share the guest user login/password with your visitors so that they can submit tickets without having to register first. This is a shared account.', 'WATS');
    echo '</div></td></tr></table><br />';
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("frontendsubmitformaccess_tip");>' . __('Frontend submission form access', 'WATS') . ' : </a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="radio" name="group5" value="0" ';
    echo $wats_settings['frontend_submit_form_access'] == 0 ? 'checked' : '';
    echo '>' . __('Disable frontend ticket submission form', 'WATS') . ' </td></tr>';
    echo '<tr><td><input type="radio" name="group5" value="1" ';
    echo $wats_settings['frontend_submit_form_access'] == 1 ? 'checked' : '';
    echo '>' . __('Enable frontend ticket submission form for any visitor with a valid email address', 'WATS') . '</td></tr>';
    echo '<tr><td><input type="radio" name="group5" value="2" ';
    echo $wats_settings['frontend_submit_form_access'] == 2 ? 'checked' : '';
    echo '>' . __('Enable frontend ticket submission form for registered users only', 'WATS') . '</td></tr><tr><td>';
    wats_options_premium_only();
    echo '<div class="wats_tip" id="frontendsubmitformaccess_tip">';
    echo __('Set this option to allow users to use a ticket submission form in the frontend to submit new tickets.', 'WATS');
    echo '<br /><br />' . __('Warning : if option is selected, users will have the opportunity to submit tickets without being authenticated. This could result in large amount of SPAM.', 'WATS') . '</div></td></tr></table><br />';
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("frontendsubformstatus_tip");>' . __('Frontend submission form ticket status', 'WATS') . ' : </a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="radio" name="group6" value="0" ';
    echo $wats_settings['frontend_submit_form_ticket_status'] == 0 ? 'checked' : '';
    echo '>' . __('All tickets submitted will be in \'pending\' status', 'WATS') . ' </td></tr>';
    echo '<tr><td><input type="radio" name="group6" value="1" ';
    echo $wats_settings['frontend_submit_form_ticket_status'] == 1 ? 'checked' : '';
    echo '>' . __('Tickets from unauthenticated users will be submitted in \'pending\' status and tickets from authenticated users will be in \'publish\' status', 'WATS') . '</td></tr>';
    echo '<tr><td><input type="radio" name="group6" value="2" ';
    echo $wats_settings['frontend_submit_form_ticket_status'] == 2 ? 'checked' : '';
    echo '>' . __('Tickets from unauthenticated users will be submitted in \'pending\' status and tickets from authenticated users will be set according to user level capability', 'WATS') . '</td></tr>';
    echo '<tr><td><input type="radio" name="group6" value="3" ';
    echo $wats_settings['frontend_submit_form_ticket_status'] == 3 ? 'checked' : '';
    echo '>' . __('All tickets submitted will be in \'publish\' status', 'WATS') . '</td></tr><tr><td>';
    wats_options_premium_only();
    echo '<div class="wats_tip" id="frontendsubformstatus_tip">';
    echo __('Set this option to define the ticket publications status upon ticket submission. It is advisable to set unauthenticated users tickets status to \'pending\' to allow admin moderation before publication and limit SPAM.', 'WATS');
    echo '</div></td></tr></table><br />';
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("frontendsubformsubmission_tip");>' . __('Frontend submission form successfull submission', 'WATS') . ' : </a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="checkbox" name="fsf_success_init" ';
    echo $wats_settings['fsf_success_init'] == 1 ? 'checked' : '';
    echo '> ' . __('Reinitiliaze the form upon successfull submission', 'WATS') . ' </td></tr>';
    echo '<tr><td>' . __('Redirect user to this URL upon successfull submission', 'WATS') . ': <input type="text" name="fsf_success_redirect_url" id="fsf_success_redirect_url" size="30" value="' . esc_attr($wats_settings['fsf_success_redirect_url']) . '" /></td></tr>';
    echo '<tr><td>';
    wats_options_premium_only();
    echo '<div class="wats_tip" id="frontendsubformsubmission_tip">';
    echo __('The first option allows to initialize the form upon successfull submission of a ticket. The second option allows to redirect user to success page upon successfull submission.', 'WATS');
    echo '</div></td></tr></table><br />';
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("email_ticket_submission_tip");>' . __('Email ticket submission', 'WATS') . ' : </a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="checkbox" name="ms_ticket_submission"';
    if ($wats_settings['ms_ticket_submission'] == 1) {
        echo ' checked';
    }
    echo '> ' . __('Allow ticket submission through email', 'WATS') . '</td></tr><tr><td>';
    echo '<tr><td>' . __('Server : ', 'WATS') . '<input type="text" name="ms_mail_server" value="' . esc_attr(stripslashes($wats_settings['ms_mail_server'])) . '" size=30></td></tr><tr><td>';
    echo '<tr><td>' . __('Port : ', 'WATS') . '<input type="text" name="ms_port_server" value="' . esc_attr(stripslashes($wats_settings['ms_port_server'])) . '" size=30></td></tr><tr><td>';
    echo '<tr><td>' . __('Login : '******'WATS') . '<input type="text" name="ms_mail_address" value="' . esc_attr(stripslashes($wats_settings['ms_mail_address'])) . '" size=30></td></tr><tr><td>';
    echo '<tr><td>' . __('Password : '******'WATS') . '<input type="password" name="ms_mail_password" value="' . esc_attr(stripslashes($wats_settings['ms_mail_password'])) . '" size=30></td></tr><tr><td>';
    wats_options_premium_only();
    echo '<div class="wats_tip" id="email_ticket_submission_tip">';
    echo __('This feature allows users to submit tickets directly through email. You have to define a secret email on a POP3 server.', 'WATS');
    echo '<br/><br />' . __('Warning : every email received on this account will result in a ticket. Therefore, make sure that your email address isn\'t known by SPAM robots.', 'WATS');
    echo '</div></td></tr></table><br />';
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("submitformdefaultauthor_tip");>' . __('Default author for unregistered visitors tickets', 'WATS') . ' : </a></h3>';
    echo '<table class="wats-form-table"><tr><td>' . __('User', 'WATS') . ' : ';
    if ($wats_settings['drop_down_user_selector_format'] == 0) {
        echo '<select name="defaultauthorlist" id="defaultauthorlist" class="wats_select">';
        $userlist = wats_build_user_list(0, 0);
        foreach ($userlist as $userlogin => $username) {
            echo '<option value="' . $userlogin . '" ';
            if ($userlogin == $wats_settings['submit_form_default_author']) {
                echo 'selected';
            }
            echo '>' . $username . '</option>';
        }
        echo '</select></td></tr><tr><td>';
    } else {
        $author = get_user_by('login', $wats_settings['submit_form_default_author']);
        $author = wats_build_formatted_name($author->ID);
        echo '<input type="text" name="defaultauthorlist_ac" id="defaultauthorlist_ac" value="' . esc_attr($author[$wats_settings['submit_form_default_author']]) . '" />';
        echo '<input type="hidden" name="defaultauthorlist" id="defaultauthorlist" value="' . esc_attr($wats_settings['submit_form_default_author']) . '" /></td></tr><tr><td>';
    }
    wats_options_premium_only();
    echo '<div class="wats_tip" id="submitformdefaultauthor_tip">';
    echo __('This option will be used to set the author of tickets submitted through the frontend submit form or through email by unregistered users.', 'WATS') . '</div></td></tr></table><br />';
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("call_center_ticket_creation_tip");>' . __('Call center ticket creation', 'WATS') . ' : </a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="checkbox" name="call_center_ticket_creation"';
    if ($wats_settings['call_center_ticket_creation'] == 1) {
        echo ' checked';
    }
    echo '> ' . __('Allow admins to create a ticket on behalf of any user', 'WATS') . '</td></tr><tr><td>';
    echo '<div class="wats_tip" id="call_center_ticket_creation_tip">';
    echo __('Check this option if you want to allow admins to create tickets on behalf of any user. This will allow them to set the ticket originator while submitting a new ticket.', 'WATS') . '</div></td></tr></table><br />';
    return;
}
Ejemplo n.º 2
0
function wats_ticket_details_meta_box($post, $view = 0)
{
    global $wats_settings, $current_user, $pagenow;
    if (is_array($view)) {
        $view = $view['args']['view'];
    }
    $wats_ticket_priority = isset($wats_settings['wats_priorities']) ? $wats_settings['wats_priorities'] : 0;
    $wats_ticket_type = isset($wats_settings['wats_types']) ? $wats_settings['wats_types'] : 0;
    $wats_ticket_status = isset($wats_settings['wats_statuses']) ? $wats_settings['wats_statuses'] : 0;
    $wats_ticket_product = isset($wats_settings['wats_products']) ? apply_filters('wats_product_list_filter', $wats_settings['wats_products']) : 0;
    if (is_object($post)) {
        $ticket_priority = get_post_meta($post->ID, 'wats_ticket_priority', true);
        $ticket_status = get_post_meta($post->ID, 'wats_ticket_status', true);
        $ticket_type = get_post_meta($post->ID, 'wats_ticket_type', true);
        $ticket_owner = get_post_meta($post->ID, 'wats_ticket_owner', true);
        $ticket_product = get_post_meta($post->ID, 'wats_ticket_product', true);
    } else {
        $ticket_priority = 0;
        $ticket_status = 0;
        $ticket_type = 0;
        $ticket_owner = 0;
        $ticket_product = 0;
    }
    $output = '';
    if ($wats_settings['ticket_type_key_enabled'] == 1) {
        if ($view == 1) {
            $output .= '<div class="wats_select_ticket_type_frontend">';
        }
        if ($view == 0 && !is_admin()) {
            $output .= '<div class="wats_select_ticket_type_frontend_update_form">';
        }
        if (is_admin()) {
            $output .= '<br />';
        }
        $output .= '<label class="wats_label">' . __('Ticket type', 'WATS') . ' : </label>';
        $output .= '<select name="wats_select_ticket_type" id="wats_select_ticket_type" class="wats_select">';
        if (is_array($wats_ticket_type)) {
            foreach ($wats_ticket_type as $key => $value) {
                $output .= '<option value=' . $key;
                if ($key == $ticket_type || !$ticket_type && $key == $wats_settings['default_ticket_type']) {
                    $output .= ' selected';
                }
                $output .= '>' . esc_html__($value, 'WATS') . '</option>';
            }
        }
        $output .= '</select><br /><br />';
        if ($view == 1 || $view == 0 && !is_admin()) {
            $output .= '</div>';
        }
    }
    if ($wats_settings['ticket_priority_key_enabled'] == 1) {
        if ($view == 1) {
            $output .= '<div class="wats_select_ticket_priority_frontend">';
        }
        if ($view == 0 && !is_admin()) {
            $output .= '<div class="wats_select_ticket_priority_frontend_update_form">';
        }
        $output .= '<label class="wats_label">' . __('Ticket priority', 'WATS') . ' : </label>';
        $output .= '<select name="wats_select_ticket_priority" id="wats_select_ticket_priority" class="wats_select">';
        if (is_array($wats_ticket_priority)) {
            foreach ($wats_ticket_priority as $key => $value) {
                $output .= '<option value=' . $key;
                if ($key == $ticket_priority || !$ticket_priority && $key == $wats_settings['default_ticket_priority']) {
                    $output .= ' selected';
                }
                $output .= '>' . esc_html__($value, 'WATS') . '</option>';
            }
        }
        $output .= '</select><br /><br />';
        if ($view == 1 || $view == 0 && !is_admin()) {
            $output .= '</div>';
        }
    }
    if ($wats_settings['ticket_status_key_enabled'] == 1) {
        if ($view == 1) {
            $output .= '<div class="wats_select_ticket_status_frontend">';
        }
        if ($view == 0 && !is_admin()) {
            $output .= '<div class="wats_select_ticket_status_frontend_update_form">';
        }
        if (is_admin() && is_object($post) && get_post_meta($post->ID, 'wats_ticket_status', true) == wats_get_closed_status_id() && !current_user_can('administrator')) {
            $output .= __('Ticket status', 'WATS') . ' : ' . $wats_ticket_status[wats_get_closed_status_id()] . '<br /><br />';
        } else {
            $output .= '<label class="wats_label">' . __('Ticket status', 'WATS') . ' : </label>';
            $output .= '<select name="wats_select_ticket_status" id="wats_select_ticket_status" class="wats_select">';
            if (is_array($wats_ticket_status)) {
                foreach ($wats_ticket_status as $key => $value) {
                    $output .= '<option value=' . $key;
                    if ($key == $ticket_status || !$ticket_status && $key == $wats_settings['default_ticket_status']) {
                        $output .= ' selected';
                    }
                    $output .= '>' . esc_html__($value, 'WATS') . '</option>';
                }
            }
            $output .= '</select><br /><br />';
        }
        if ($view == 1 || $view == 0 && !is_admin()) {
            $output .= '</div>';
        }
    }
    if ($wats_settings['ticket_product_key_enabled'] == 1) {
        if ($view == 1) {
            $output .= '<div class="wats_select_ticket_product_frontend">';
        }
        if ($view == 0 && !is_admin()) {
            $output .= '<div class="wats_select_ticket_product_frontend_update_form">';
        }
        $output .= '<label class="wats_label">' . __('Ticket product', 'WATS') . ' : </label>';
        $output .= '<select name="wats_select_ticket_product" id="wats_select_ticket_product" class="wats_select">';
        if (is_array($wats_ticket_product)) {
            foreach ($wats_ticket_product as $key => $value) {
                $output .= '<option value=' . $key;
                if ($key == $ticket_product || !$ticket_product && $key == $wats_settings['default_ticket_product']) {
                    $output .= ' selected';
                }
                $output .= '>' . esc_html__($value, 'WATS') . '</option>';
            }
        }
        $output .= '</select><br /><br />';
        if ($view == 1 || $view == 0 && !is_admin()) {
            $output .= '</div>';
        }
    }
    if (is_object($post)) {
        setup_postdata($post);
    }
    if (is_admin()) {
        $output .= wp_nonce_field('wats-edit-ticket', '_wpnonce_wats_edit_ticket', true, false) . "\n";
    }
    if ((is_admin() || $view == 1) && current_user_can('administrator') && $wats_settings['call_center_ticket_creation'] == 1) {
        if (is_object($post)) {
            $selected_login = get_the_author_meta('user_login');
        } else {
            $selected_login = $current_user->user_login;
        }
        $output .= '<div id="wats_div_ticket_originator"><label class="wats_label">' . __('Ticket originator : ', 'WATS') . '</label>';
        $userlist = wats_build_user_list(0, 0);
        $output .= '<select name="wats_select_ticket_originator" id="wats_select_ticket_originator" class="wats_select">';
        foreach ($userlist as $userlogin => $username) {
            $output .= '<option value="' . $userlogin . '" ';
            if ($selected_login == $userlogin) {
                $output .= " selected";
            }
            $output .= '>' . $username . '</option>';
        }
        $output .= '</select></div>';
    } else {
        if (is_admin()) {
            if ($post->ID) {
                $output .= '<label class="wats_label">' . __('Ticket originator : ', 'WATS') . '</label>';
                $output .= get_the_author();
            }
        }
    }
    if (is_admin()) {
        $ticket_author_name = get_post_meta($post->ID, 'wats_ticket_author_name', true);
        if ($ticket_author_name) {
            $output .= '<br /><br /><label class="wats_label">' . __('Ticket author name : ', 'WATS') . '</label>' . $ticket_author_name;
        }
        $ticket_author_email = get_post_meta($post->ID, 'wats_ticket_author_email', true);
        if ($ticket_author_email) {
            $output .= '<br /><br /><label class="wats_label">' . __('Ticket author email : ', 'WATS') . '</label>' . '<a href="mailto:' . $ticket_author_email . '">' . $ticket_author_email . '</a>';
        }
        $ticket_author_url = get_post_meta($post->ID, 'wats_ticket_author_url', true);
        if ($ticket_author_url) {
            $output .= '<br /><br /><label class="wats_label">' . __('Ticket author url : ', 'WATS') . '</label>' . '<a href="' . $ticket_author_url . '">' . $ticket_author_url . '</a>';
        }
        $output .= '<br /><br />';
    }
    if ($view == 1) {
        return $output;
    } else {
        echo $output;
    }
}