예제 #1
0
function wats_options_manage_ticket_display_options()
{
    global $wpdb, $wats_settings, $wats_default_ticket_listing_columns;
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("group1_tip");>' . __('Ticket numerotation', 'WATS') . ' :</a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="radio" name="group1" value="0" ';
    echo $wats_settings['numerotation'] == 0 ? 'checked' : '';
    echo '>' . __('None', 'WATS') . ' </td></tr>';
    echo '<tr><td><input type="radio" name="group1" value="1" ';
    echo $wats_settings['numerotation'] == 1 ? 'checked' : '';
    echo '>' . __('Dated', 'WATS') . ' (ex : 090601-00001)</td></tr>';
    echo '<tr><td><input type="radio" name="group1" value="2" ';
    echo $wats_settings['numerotation'] == 2 ? 'checked' : '';
    echo '>' . __('Numbered', 'WATS') . ' (ex : 1)</td></tr><tr><td>';
    echo '<div class="wats_tip" id="group1_tip">';
    echo __('Select the preferred option. Based on this, a number will be associated to a ticket and displayed at the beginning of the title.', 'WATS') . '</div></td></tr></table><br />';
    if ($wats_settings['numerotation'] > 0) {
        echo '<h3>' . __('Latest ticket ID', 'WATS') . ' : ' . wats_get_latest_ticket_number() . '</h3><br />';
    }
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("wats_home_display_tip");>' . __('Tickets display', 'WATS') . ' :</a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="checkbox" name="homedisplay"';
    if ($wats_settings['wats_home_display'] == 1) {
        echo ' checked';
    }
    echo '> ' . __('Include tickets on homepage together with posts', 'WATS') . '</td></tr><tr><td>';
    echo '<div class="wats_tip" id="wats_home_display_tip">';
    echo __('Check this option if you want to display tickets on homepage along with usual posts. If the option is unchecked, only posts will be displayed.', 'WATS') . '</div></td></tr></table><br />';
    echo '<h3><a style="cursor:pointer;" title="' . __('Click to get some help!', 'WATS') . '" onclick=javascript:wats_invert_visibility("group2_tip");>' . __('Tickets visibility', 'WATS') . ' :</a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="radio" name="group2" value="0" ';
    echo $wats_settings['visibility'] == 0 ? 'checked' : '';
    echo '>' . __('Everybody can see all tickets', 'WATS') . ' </td></tr>';
    echo '<tr><td><input type="radio" name="group2" value="1" ';
    echo $wats_settings['visibility'] == 1 ? 'checked' : '';
    echo '>' . __('Only registered users can see tickets', 'WATS') . '</td></tr>';
    echo '<tr><td><input type="radio" name="group2" value="2" ';
    echo $wats_settings['visibility'] == 2 ? 'checked' : '';
    echo '>' . __('Only ticket creator and admins can see tickets', 'WATS') . '</td></tr>';
    echo '<tr><td><div style="margin-left:50px;"><input type="checkbox" name="ticket_visibility_read_only_capability"';
    if ($wats_settings['ticket_visibility_read_only_capability'] == 1) {
        echo ' checked';
    }
    echo '> ' . __('Grant read only access to all tickets for users with "wats_ticket_read_only" capability', 'WATS') . '</div></td></tr>';
    echo '<tr><td><div style="margin-left:50px;"><input type="checkbox" name="ticket_visibility_same_company"';
    if ($wats_settings['ticket_visibility_same_company'] == 1) {
        echo ' checked';
    }
    echo '> ' . __('Allow user to view and update tickets originated by any user from the same company', 'WATS') . ' ';
    wats_options_premium_only_without_div();
    echo '</div></td></tr><tr><td>';
    echo '<div class="wats_tip" id="group2_tip">';
    echo __('Select the preferred option. Tickets access and display in frontend and admin sides will be adjusted based on this option and user privileges.', 'WATS');
    echo __(' This option will also affect author and owner selectors filters display for the ticket listing table which will be available for everybody, only logged in users or only admins based on the selected option.', 'WATS') . '<br /><br />';
    echo __('If the third option is selected (ticket creator and admins), you can also enable the wats_ticket_read_only capability that you can then assign to specific users under the user profile page to allow them to view all tickets with a read only access (no edition, no update).', 'WATS');
    echo __(' Then, you can also allow users belonging to a company to view tickets raised by any user from the same company.', '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("comment_menuitem_visibility_tip");>' . __('Comments visibility', 'WATS') . ' : </a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="checkbox" name="comment_menuitem_visibility"';
    if ($wats_settings['comment_menuitem_visibility'] == 1) {
        echo ' checked';
    }
    echo '> ' . __('Block comments menu access for users without moderate_comments capability', 'WATS') . '</td></tr>';
    echo '<tr><td><input type="checkbox" name="internal_comment_visibility"';
    if ($wats_settings['internal_comment_visibility'] == 1) {
        echo ' checked';
    }
    echo '> ' . __('Allow admins to submit internal updates to tickets', 'WATS') . ' ';
    wats_options_premium_only_without_div();
    echo '</td></tr><tr><td>';
    echo '<div class="wats_tip" id="comment_menuitem_visibility_tip">';
    echo __('Check the first option if you want to prevent users without the comments moderation capability to browse the comments list page (on this page, they could see updates on all tickets).', 'WATS') . '<br />';
    echo __('Check the second option if you want to allow admins to submit internal updates to tickets that will be only visible to admins.', '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("template_selector_tip");>' . __('Template selector', 'WATS') . ' :</a></h3>';
    echo '<table class="wats-form-table">';
    echo '<tr><td><input type="radio" name="group_template_selector" value="0" ';
    echo $wats_settings['template_selector'] == 0 ? 'checked' : '';
    echo '>' . __('Use active theme default template', 'WATS') . ' (' . get_template() . ') </td></tr>';
    if (file_exists(get_stylesheet_directory() . '/single-ticket.php')) {
        $output = __('custom files available', 'WATS');
    } else {
        $output = __('custom files need to be copied first', 'WATS');
    }
    echo '<tr><td><input type="radio" name="group_template_selector" value="1" ';
    echo $wats_settings['template_selector'] == 1 ? 'checked' : '';
    echo '>' . __('Use active theme custom template', 'WATS') . ' (' . $output . ')</td></tr><tr><td>';
    echo '<div class="wats_tip" id="template_selector_tip">';
    echo __('Select the preferred option. Use the custom template if you want to customize the single ticket display page. ', 'WATS');
    echo __('To achieve this, you need to copy single-ticket.php and comments-ticket.php from WATS theme subdirectory to your active theme directory and then edit these according to your needs.', 'WATS');
    echo '</div></td></tr></table><br />';
    return;
}
예제 #2
0
function wats_ticket_save_meta($postID, $post, $comment_author_email = '')
{
    global $wats_settings, $wpdb;
    wats_load_settings();
    if ($post->post_type == 'ticket') {
        $newticket = 0;
        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE || $post->post_status == 'auto-draft' || $post->post_status == 'trash') {
            return $postID;
        }
        $newstatus = -1;
        if ($wats_settings['ticket_status_key_enabled'] == 1 && isset($_POST['wats_select_ticket_status'])) {
            $status = get_post_meta($postID, 'wats_ticket_status', true);
            if (get_post_meta($postID, 'wats_ticket_status', true) != wats_get_closed_status_id() || current_user_can('administrator')) {
                if ($status != $_POST['wats_select_ticket_status']) {
                    $newstatus = $_POST['wats_select_ticket_status'];
                }
                if ($status == wats_get_closed_status_id() && $newstatus != wats_get_closed_status_id()) {
                    delete_post_meta($postID, 'wats_ticket_closure_date');
                }
                if ($_POST['wats_select_ticket_status'] > 0) {
                    update_post_meta($postID, 'wats_ticket_status', $_POST['wats_select_ticket_status']);
                }
                if ($newstatus == wats_get_closed_status_id()) {
                    update_post_meta($postID, 'wats_ticket_closure_date', current_time('mysql'));
                }
            }
        }
        $newtype = -1;
        if ($wats_settings['ticket_type_key_enabled'] == 1 && isset($_POST['wats_select_ticket_type'])) {
            $type = get_post_meta($postID, 'wats_ticket_type', true);
            if ($type != $_POST['wats_select_ticket_type']) {
                $newtype = $_POST['wats_select_ticket_type'];
            }
            if ($_POST['wats_select_ticket_type'] > 0) {
                update_post_meta($postID, 'wats_ticket_type', $_POST['wats_select_ticket_type']);
            }
        }
        $newpriority = -1;
        if ($wats_settings['ticket_priority_key_enabled'] == 1 && isset($_POST['wats_select_ticket_priority'])) {
            $priority = get_post_meta($postID, 'wats_ticket_priority', true);
            if ($priority != $_POST['wats_select_ticket_priority']) {
                $newpriority = $_POST['wats_select_ticket_priority'];
            }
            if ($_POST['wats_select_ticket_priority'] > 0) {
                update_post_meta($postID, 'wats_ticket_priority', $_POST['wats_select_ticket_priority']);
            }
        }
        $newproduct = -1;
        if ($wats_settings['ticket_product_key_enabled'] == 1 && isset($_POST['wats_select_ticket_product'])) {
            $product = get_post_meta($postID, 'wats_ticket_product', true);
            if ($product != $_POST['wats_select_ticket_product']) {
                $newproduct = $_POST['wats_select_ticket_product'];
            }
            if ($_POST['wats_select_ticket_product'] > 0) {
                update_post_meta($postID, 'wats_ticket_product', $_POST['wats_select_ticket_product']);
            }
        }
        if (!get_post_meta($postID, 'wats_ticket_number', true)) {
            add_post_meta($postID, 'wats_ticket_number', wats_get_latest_ticket_number() + 1);
            $newticket = 1;
        }
        if ($newticket == 1) {
            if (!isset($_POST['view']) || isset($_POST['view']) && $_POST['view'] != 1) {
                do_action('wats_ticket_admin_submission_saved_meta', $postID);
            }
        }
        do_action('wats_ticket_saved_meta', $postID);
    }
    return;
}