| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
global $current_user,$wpscfunction; |
| 6 |
|
| 7 |
if (!($current_user->ID && $current_user->has_cap('wpsc_agent'))) {exit;} |
| 8 |
|
| 9 |
$wpsc_agent_body = get_user_meta($current_user->ID,'wpsc_agent_signature',true); |
| 10 |
|
| 11 |
$wpsc_appearance_modal_window = get_option('wpsc_modal_window'); |
| 12 |
|
| 13 |
$labels = $wpscfunction->get_ticket_filter_labels(); |
| 14 |
$rich_editing = $wpscfunction->rich_editing_status($current_user); |
| 15 |
$directionality = $wpscfunction->check_rtl(); |
| 16 |
|
| 17 |
ob_start(); |
| 18 |
?> |
| 19 |
<form id="wpsc_frm_agent_setting" method="post"> |
| 20 |
<div class="form-group"> |
| 21 |
<label class="label label-default" style="font-size:15px;"><?php _e('Signature','supportcandy') ?></label> |
| 22 |
</div> |
| 23 |
<?php if($rich_editing){?> |
| 24 |
<div class="text-right"> |
| 25 |
<button id="visual" class="wpsc-switch-editor wpsc-switch-editor-active" type="button" onclick="wpsc_get_agent_signature_tinymce('wpsc_agent_signature','agent_signature');"><?php _e('Visual','supportcandy');?></button> |
| 26 |
<button id="text" class="wpsc-switch-editor" type="button" onclick="wpsc_get_textarea('wpsc_agent_signature')"><?php _e('Text','supportcandy');?></button> |
| 27 |
</div> |
| 28 |
<?php } ?> |
| 29 |
<div class="form-group"> |
| 30 |
<textarea class="form-control" name="wpsc_agent_signature" id="wpsc_agent_signature"><?php echo esc_textarea($wpsc_agent_body) ?></textarea> |
| 31 |
</div> |
| 32 |
|
| 33 |
<div class="form-group"> |
| 34 |
<label class="label label-default" style="font-size:15px;"><?php _e('Default Filter','supportcandy') ?></label> |
| 35 |
</div> |
| 36 |
<?php //setting to add agent's default filter ?> |
| 37 |
<div class="form-group"> |
| 38 |
<select id="wpsc_agent_default_filter" class="form-control wpsc_drop_down" name="wpsc_agent_default_filter"> |
| 39 |
<?php |
| 40 |
$blog_id = get_current_blog_id(); |
| 41 |
$default_filter = get_user_meta($current_user->ID,$blog_id.'_wpsc_user_default_filter',true); |
| 42 |
|
| 43 |
$saved_filters = get_user_meta($current_user->ID, $blog_id.'_wpsc_filter',true); |
| 44 |
$saved_filters = $saved_filters ? $saved_filters : array(); |
| 45 |
foreach ($labels as $key => $val) : |
| 46 |
if($current_user->has_cap('wpsc_agent') && ($val['visibility']=='agent' || $val['visibility']=='both')): |
| 47 |
$selected = $key == $default_filter ? 'selected="selected"' : ''; |
| 48 |
?> |
| 49 |
<option <?php echo esc_attr($selected)?> value="<?php echo esc_attr($key)?>"><?php echo esc_attr($val['label'])?></option> |
| 50 |
<?php |
| 51 |
endif; |
| 52 |
endforeach; |
| 53 |
|
| 54 |
foreach ($saved_filters as $ckey => $value): |
| 55 |
if(is_numeric($default_filter) || $default_filter == 0 && !is_string($default_filter) ){ |
| 56 |
$selected = $value['save_label'] == $saved_filters[$default_filter]['save_label'] ? 'selected="selected"' : ''; |
| 57 |
} |
| 58 |
?> |
| 59 |
<option <?php echo esc_attr($selected)?> value="<?php echo esc_attr($ckey)?>"><?php echo esc_attr($value['save_label'])?></option> |
| 60 |
<?php |
| 61 |
endforeach; |
| 62 |
?> |
| 63 |
</select> |
| 64 |
</div> |
| 65 |
|
| 66 |
|
| 67 |
<?php do_action('wpsc_get_agent_setting');?> |
| 68 |
|
| 69 |
<input type="hidden" name="action" value="wpsc_support_agents" /> |
| 70 |
<input type="hidden" name="setting_action" value="set_agent_setting" /> |
| 71 |
<input type="hidden" name="_ajax_nonce" value="<?php echo wp_create_nonce('set_agent_setting')?>"> |
| 72 |
</form> |
| 73 |
|
| 74 |
<script> |
| 75 |
function wpsc_get_agent_signature_tinymce(selector,body_id){ |
| 76 |
jQuery('#visual_header').addClass('btn btn-primary visual_header'); |
| 77 |
jQuery('#text_header').removeClass('btn btn-primary text_header'); |
| 78 |
jQuery('#text_header').addClass('btn btn-default text_header'); |
| 79 |
jQuery('#text').removeClass('wpsc-switch-editor-active'); |
| 80 |
jQuery('#visual').addClass('wpsc-switch-editor-active'); |
| 81 |
tinymce.init({ |
| 82 |
selector:'#'+selector, |
| 83 |
body_id: body_id, |
| 84 |
menubar: false, |
| 85 |
statusbar: false, |
| 86 |
height : '200', |
| 87 |
plugins: [ |
| 88 |
'lists link image directionality' |
| 89 |
], |
| 90 |
image_advtab: true, |
| 91 |
toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image', |
| 92 |
branding: false, |
| 93 |
autoresize_bottom_margin: 20, |
| 94 |
browser_spellcheck : true, |
| 95 |
relative_urls : false, |
| 96 |
remove_script_host : false, |
| 97 |
convert_urls : true, |
| 98 |
setup: function (editor) { |
| 99 |
} |
| 100 |
}); |
| 101 |
} |
| 102 |
function wpsc_get_textarea(selector){ |
| 103 |
jQuery('#visual_body').addClass('btn btn-default visual_body'); |
| 104 |
jQuery('#text_body').removeClass('btn btn-primary text_body'); |
| 105 |
tinymce.remove('#'+selector); |
| 106 |
jQuery('#text').addClass('wpsc-switch-editor-active'); |
| 107 |
jQuery('#visual').removeClass('wpsc-switch-editor-active'); |
| 108 |
} |
| 109 |
|
| 110 |
tinymce.remove(); |
| 111 |
tinymce.init({ |
| 112 |
selector:'#wpsc_agent_signature', |
| 113 |
body_id: 'agent_signature', |
| 114 |
directionality : '<?php echo esc_attr($directionality); ?>', |
| 115 |
menubar: false, |
| 116 |
height : '200', |
| 117 |
plugins: [ |
| 118 |
'lists link image directionality' |
| 119 |
], |
| 120 |
image_advtab: true, |
| 121 |
toolbar: 'bold italic underline blockquote | alignleft aligncenter alignright | bullist numlist | rtl | link image', |
| 122 |
branding: false, |
| 123 |
autoresize_bottom_margin: 20, |
| 124 |
browser_spellcheck : true, |
| 125 |
relative_urls : false, |
| 126 |
remove_script_host : false, |
| 127 |
convert_urls : true, |
| 128 |
setup: function (editor) { |
| 129 |
} |
| 130 |
}); |
| 131 |
</script> |
| 132 |
|
| 133 |
<?php |
| 134 |
$body = ob_get_clean(); |
| 135 |
|
| 136 |
ob_start(); |
| 137 |
?> |
| 138 |
<button type="button" class="btn wpsc_popup_close" style="background-color:<?php echo esc_attr($wpsc_appearance_modal_window['wpsc_close_button_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_modal_window['wpsc_close_button_text_color'])?> !important;" onclick="wpsc_modal_close();"><?php _e('Close','supportcandy');?></button> |
| 139 |
<button type="button" class="btn wpsc_popup_action" style="background-color:<?php echo esc_attr($wpsc_appearance_modal_window['wpsc_action_button_bg_color'])?> !important;color:<?php echo esc_attr($wpsc_appearance_modal_window['wpsc_action_button_text_color'])?> !important;" onclick="wpsc_set_agent_setting();"><?php _e('Save Settings','supportcandy');?></button> |
| 140 |
<?php |
| 141 |
$footer = ob_get_clean(); |
| 142 |
|
| 143 |
$output = array( |
| 144 |
'body' => $body, |
| 145 |
'footer' => $footer |
| 146 |
); |
| 147 |
|
| 148 |
wp_send_json($output); |