function wats_ticket_get_product($post) { global $wats_settings; $wats_ticket_product = isset($wats_settings['wats_products']) ? $wats_settings['wats_products'] : 0; $product = get_post_meta($post->ID, 'wats_ticket_product', true); if (wats_is_numeric($product) && isset($wats_ticket_product[$product])) { $output = esc_html__($wats_ticket_product[$product], 'WATS'); } else { $output = ''; } return $output; }
function wats_options_admin_menu() { global $wpdb, $wats_version, $wats_settings, $wats_default_ticket_listing_columns; if (!current_user_can('administrator')) { die('-1'); } $submenu = isset($_GET['sub']) ? $_GET['sub'] : ''; $url = explode('&', $_SERVER['REQUEST_URI']); $url = $url[0]; if (isset($_POST['save'])) { check_admin_referer('update-wats-options'); wats_load_settings(); $wats_settings['wats_version'] = $wats_version; if ($submenu == 'notifications') { $wats_settings['new_ticket_notification_admin'] = isset($_POST['new_ticket_notification_admin']) ? 1 : 0; $wats_settings['ticket_update_notification_all_tickets'] = isset($_POST['ticket_update_notification_all_tickets']) ? 1 : 0; $wats_settings['ticket_update_notification_my_tickets'] = isset($_POST['ticket_update_notification_my_tickets']) ? 1 : 0; $wats_settings['notification_signature'] = esc_html(preg_replace("/(\r\n|\n|\r)/", "", nl2br($_POST['notification_signature']))); $wats_settings['ticket_notification_bypass_mode'] = isset($_POST['ticket_notification_bypass_mode']) ? 1 : 0; $wats_settings['source_email_address'] = isset($_POST['source_email_address']) ? 1 : 0; $wats_settings['ticket_notification_custom_list'] = isset($_POST['ticket_notification_custom_list']) ? 1 : 0; } else { if ($submenu == 'ticket-submission') { if (get_user_by('login', $_POST['guestlist'])) { $wats_settings['wats_guest_user'] = $_POST['guestlist']; } else { $wats_settings['wats_guest_user'] = -1; } $wats_settings['ticket_edition_media_upload'] = isset($_POST['ticket_edition_media_upload']) ? 1 : 0; $wats_settings['ticket_edition_media_upload_tabs'] = isset($_POST['ticket_edition_media_upload_tabs']) ? 1 : 0; $wats_settings['call_center_ticket_creation'] = isset($_POST['call_center_ticket_creation']) ? 1 : 0; $wats_settings['frontend_submit_form_access'] = $_POST['group5']; $wats_settings['frontend_submit_form_ticket_status'] = $_POST['group6']; if (get_user_by('login', $_POST['defaultauthorlist'])) { $wats_settings['submit_form_default_author'] = $_POST['defaultauthorlist']; } else { $wats_settings['submit_form_default_author'] = wats_get_first_admin_login(); } $wats_settings['ms_ticket_submission'] = isset($_POST['ms_ticket_submission']) ? 1 : 0; $wats_settings['ms_mail_server'] = strlen($_POST['ms_mail_server']) ? esc_html(stripslashes($_POST['ms_mail_server'])) : 'mail.example.com'; $wats_settings['ms_port_server'] = wats_is_numeric(stripslashes($_POST['ms_port_server'])) ? esc_html(stripslashes($_POST['ms_port_server'])) : '110'; $wats_settings['ms_mail_address'] = wats_is_string(stripslashes($_POST['ms_mail_address'])) ? esc_html(stripslashes($_POST['ms_mail_address'])) : '*****@*****.**'; $wats_settings['ms_mail_password'] = wats_is_string(stripslashes($_POST['ms_mail_password'])) ? esc_html(stripslashes($_POST['ms_mail_password'])) : 'password'; $wats_settings['fsf_success_init'] = isset($_POST['fsf_success_init']) ? 1 : 0; $wats_settings['fsf_success_redirect_url'] = esc_url($_POST['fsf_success_redirect_url']); } else { if ($submenu == 'ticket-display') { $wats_settings['numerotation'] = $_POST['group1']; $wats_settings['visibility'] = $_POST['group2']; $wats_settings['wats_home_display'] = isset($_POST['homedisplay']) ? 1 : 0; $wats_settings['comment_menuitem_visibility'] = isset($_POST['comment_menuitem_visibility']) ? 1 : 0; $wats_settings['ticket_visibility_read_only_capability'] = isset($_POST['ticket_visibility_read_only_capability']) ? 1 : 0; $wats_settings['ticket_visibility_same_company'] = isset($_POST['ticket_visibility_same_company']) ? 1 : 0; $wats_settings['internal_comment_visibility'] = isset($_POST['internal_comment_visibility']) ? 1 : 0; $wats_settings['template_selector'] = $_POST['group_template_selector']; } else { if ($submenu == 'ticket-listing') { $wats_settings['user_selector_format'] = wats_is_string(stripslashes($_POST['user_selector_format'])) ? esc_html(stripslashes($_POST['user_selector_format'])) : 'user_login'; $wats_settings['filter_ticket_listing'] = isset($_POST['filter_ticket_listing']) ? 1 : 0; $wats_settings['filter_ticket_listing_meta_key'] = $_POST['metakeylistfilter']; $wats_settings['meta_column_ticket_listing'] = isset($_POST['meta_column_ticket_listing']) ? 1 : 0; $wats_settings['meta_column_ticket_listing_meta_key'] = $_POST['metakeylistcolumn']; $wats_settings['user_selector_order_1'] = $_POST['user_selector_order_1']; $wats_settings['user_selector_order_2'] = $_POST['user_selector_order_2']; $wats_default_ticket_listing_active_columns = array(); foreach ($wats_default_ticket_listing_columns as $column => $value) { $wats_default_ticket_listing_active_columns[$column] = isset($_POST['ticket_listing_active_' . $column]) ? 1 : 0; } $wats_settings['wats_default_ticket_listing_active_columns'] = $wats_default_ticket_listing_active_columns; $wats_default_ticket_listing_default_query = array(); $wats_default_ticket_listing_default_query['type'] = $_POST['wats_select_ticket_type_tl_query']; $wats_default_ticket_listing_default_query['priority'] = $_POST['wats_select_ticket_priority_tl_query']; $wats_default_ticket_listing_default_query['status_op'] = $_POST['wats_select_ticket_status_operator_tl_query']; $wats_default_ticket_listing_default_query['status'] = $_POST['wats_select_ticket_status_tl_query']; $wats_default_ticket_listing_default_query['product'] = $_POST['wats_select_ticket_product_tl_query']; $wats_default_ticket_listing_default_query['author'] = $_POST['wats_select_ticket_author_tl_query']; $wats_default_ticket_listing_default_query['owner'] = $_POST['wats_select_ticket_owner_tl_query']; $wats_settings['wats_default_ticket_listing_default_query'] = $wats_default_ticket_listing_default_query; $wats_settings['display_list_not_authenticated'] = isset($_POST['display_list_not_authenticated']) ? 1 : 0; } else { if ($submenu == 'ticket-keys') { $wats_settings['tickets_tagging'] = isset($_POST['tickets_tagging']) ? 1 : 0; $wats_settings['tickets_custom_fields'] = isset($_POST['tickets_custom_fields']) ? 1 : 0; $wats_settings['closed_status_id'] = $_POST['closedstatusselector']; $wats_settings['default_ticket_type'] = isset($_POST['group_default_wats_types']) ? $_POST['group_default_wats_types'] : 0; $wats_settings['default_ticket_status'] = isset($_POST['group_default_wats_statuses']) ? $_POST['group_default_wats_statuses'] : 0; $wats_settings['default_ticket_priority'] = isset($_POST['group_default_wats_priorities']) ? $_POST['group_default_wats_priorities'] : 0; $wats_settings['ticket_product_key_enabled'] = isset($_POST['ticket_product_key_enabled']) ? 1 : 0; $wats_settings['ticket_priority_key_enabled'] = isset($_POST['ticket_priority_key_enabled']) ? 1 : 0; $wats_settings['ticket_status_key_enabled'] = isset($_POST['ticket_status_key_enabled']) ? 1 : 0; $wats_settings['ticket_type_key_enabled'] = isset($_POST['ticket_type_key_enabled']) ? 1 : 0; $wats_settings['default_ticket_product'] = isset($_POST['group_default_wats_products']) ? $_POST['group_default_wats_products'] : 0; if (isset($_POST['group_default_custom_selector']) && isset($_POST['wats_custom_fields_selector'])) { $wats_ticket_custom_field_values = $wats_settings['wats_ticket_custom_fields']; if (isset($wats_ticket_custom_field_values[$_POST['wats_custom_fields_selector']])) { $table = $wats_ticket_custom_field_values[$_POST['wats_custom_fields_selector']]; if (isset($table['type']) && $table['type'] == 1 && isset($table['values'])) { $values = $table['values']; if (isset($values[$_POST['group_default_custom_selector']])) { $table['default_value'] = $_POST['group_default_custom_selector']; $wats_ticket_custom_field_values[$_POST['wats_custom_fields_selector']] = $table; $wats_settings['wats_ticket_custom_fields'] = $wats_ticket_custom_field_values; } } } } } else { if ($submenu == 'ticket-assign') { $wats_settings['ticket_assign'] = $_POST['group3']; $wats_settings['ticket_assign_user_list'] = $_POST['group4']; $roles = get_editable_roles(); foreach ($roles as $role) { $rolename = strtolower($role['name']); $wats_settings['ticket_assignment_' . $rolename] = isset($_POST['ticket_assignment_' . $rolename]) ? 1 : 0; } } else { if ($submenu == 'user-profile') { $wats_settings['prevent_user_profile_mail_modification'] = isset($_POST['prevent_user_profile_mail_modification']) ? 1 : 0; $wats_settings['profile_country_enabled'] = isset($_POST['profile_country_enabled']) ? 1 : 0; $wats_settings['country_meta_key_profile'] = wats_is_string(stripslashes($_POST['country_meta_key_profile'])) ? str_replace(" ", "_", esc_html(stripslashes($_POST['country_meta_key_profile']))) : 'country'; $wats_settings['user_expiration_date_enabled'] = isset($_POST['user_expiration_date_enabled']) ? 1 : 0; $wats_settings['profile_company_enabled'] = isset($_POST['profile_company_enabled']) ? 1 : 0; $wats_settings['company_meta_key_profile'] = wats_is_string(stripslashes($_POST['company_meta_key_profile'])) ? str_replace(" ", "_", esc_html(stripslashes($_POST['company_meta_key_profile']))) : 'company_name'; $wats_settings['profile_sla_enabled'] = isset($_POST['profile_sla_enabled']) ? 1 : 0; } else { if ($submenu == 'ticket-stats') { $roles = get_editable_roles(); foreach ($roles as $role) { $rolename = strtolower($role['name']); $wats_settings['dashboard_stats_widget_' . $rolename] = isset($_POST['dashboard_stats_widget_' . $rolename]) ? 1 : 0; } } else { if ($submenu == 'ticket-troubleshoot') { $wats_settings['drop_down_user_selector_format'] = isset($_POST['drop_down_user_selector_format']) ? 1 : 0; } } } } } } } } } update_option('wats', $wats_settings); } wats_load_settings(); if (WATS_PREMIUM == true) { echo '<H2><div style="text-align:center">WATS Premium ' . $wats_settings['wats_version'] . '</div></H2><br />'; } else { echo '<H2><div style="text-align:center">WATS ' . $wats_settings['wats_version'] . '</div></H2><br />'; } echo '<form action="" method="post">'; wp_nonce_field('update-wats-options'); echo '<div style="float:right;">'; echo '<ul class="wats-options-menu">'; echo __('WATS Options', 'WATS'); echo '<li ' . ($submenu == '' ? 'class="selected"' : '') . '><a href="' . $url . '">' . __('Home', 'WATS') . '</a></li>'; echo '<li ' . ($submenu == 'ticket-submission' ? 'class="selected"' : '') . '><a href="' . $url . '&sub=ticket-submission">' . __('Ticket submission', 'WATS') . '</a></li>'; echo '<li ' . ($submenu == 'ticket-display' ? 'class="selected"' : '') . '><a href="' . $url . '&sub=ticket-display">' . __('Ticket display and visibility', 'WATS') . '</a></li>'; echo '<li ' . ($submenu == 'ticket-listing' ? 'class="selected"' : '') . '><a href="' . $url . '&sub=ticket-listing">' . __('Ticket listing', 'WATS') . '</a></li>'; echo '<li ' . ($submenu == 'ticket-keys' ? 'class="selected"' : '') . '><a href="' . $url . '&sub=ticket-keys">' . __('Ticket keys', 'WATS') . '</a></li>'; echo '<li ' . ($submenu == 'ticket-assign' ? 'class="selected"' : '') . '><a href="' . $url . '&sub=ticket-assign">' . __('Ticket assign', 'WATS') . '</a></li>'; echo '<li ' . ($submenu == 'user-profile' ? 'class="selected"' : '') . '><a href="' . $url . '&sub=user-profile">' . __('User profile', 'WATS') . '</a></li>'; echo '<li ' . ($submenu == 'notifications' ? 'class="selected"' : '') . '><a href="' . $url . '&sub=notifications">' . __('Notifications', 'WATS') . '</a></li>'; echo '<li ' . ($submenu == 'ticket-stats' ? 'class="selected"' : '') . '><a href="' . $url . '&sub=ticket-stats">' . __('Statistics', 'WATS') . '</a></li>'; echo '<li ' . ($submenu == 'ticket-troubleshoot' ? 'class="selected"' : '') . '><a href="' . $url . '&sub=ticket-troubleshoot">' . __('Troubleshoot', 'WATS') . '</a></li>'; echo '</ul>'; echo '<br /><ul class="wats-options-menu">'; echo __('Help', 'WATS'); echo '<li>' . __('If you want to get some details about an option, just click on the option title, this will display some inline details.', 'WATS') . '<br /><br />'; echo __('In the tables, you can directly edit items by clicking on the following icon : ', 'WATS') . '<img src="' . WATS_URL . 'img/modify.png" /><br /><br /></li></ul></div>'; echo '<br />'; if ($submenu == 'notifications') { wats_options_manage_notification_options(); } else { if ($submenu == 'ticket-submission') { wats_options_manage_ticket_submission_options(); } else { if ($submenu == 'ticket-display') { wats_options_manage_ticket_display_options(); } else { if ($submenu == 'ticket-listing') { wats_options_manage_ticket_listing_options(); } else { if ($submenu == 'ticket-keys') { wats_options_manage_ticket_keys_options(); } else { if ($submenu == 'ticket-assign') { wats_options_manage_ticket_assign_options(); } else { if ($submenu == 'user-profile') { wats_options_manage_user_profile_options(); } else { if ($submenu == 'ticket-stats') { wats_options_manage_stats_options(); } else { if ($submenu == 'ticket-troubleshoot') { wats_options_manage_troubleshoot_options(); } else { if ($submenu == '') { wats_options_manage_home_options(); } } } } } } } } } } if ($submenu != '') { echo '<p class="submit">'; echo '<input class="button-primary" type="submit" name="save" value="' . __('Save the options', 'WATS') . '" /></p><br />'; } echo '</form><br /><br />'; }
function wats_edit_post_custom_column($column_name, $post_id) { global $wats_settings; $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']) ? $wats_settings['wats_products'] : 0; if ($column_name == 'priority') { $ticket_priority = get_post_meta($post_id, 'wats_ticket_priority', true); if (wats_is_numeric($ticket_priority) && isset($wats_ticket_priority[$ticket_priority])) { echo $wats_ticket_priority[$ticket_priority]; } } else { if ($column_name == 'status') { $ticket_status = get_post_meta($post_id, 'wats_ticket_status', true); if (wats_is_numeric($ticket_status) && isset($wats_ticket_status[$ticket_status])) { echo $wats_ticket_status[$ticket_status]; } } else { if ($column_name == 'type') { $ticket_type = get_post_meta($post_id, 'wats_ticket_type', true); if (wats_is_numeric($ticket_type) && isset($wats_ticket_type[$ticket_type])) { echo $wats_ticket_type[$ticket_type]; } } else { if ($column_name == 'product') { $ticket_product = get_post_meta($post_id, 'wats_ticket_product', true); if (wats_is_numeric($ticket_product) && isset($wats_ticket_product[$ticket_product])) { echo $wats_ticket_product[$ticket_product]; } } } } } return; }