Changeset 1592607
- Timestamp:
- 02/09/2017 04:03:34 PM (9 years ago)
- Location:
- nifty-desk
- Files:
-
- 200 added
- 13 edited
-
tags/1.01 (added)
-
tags/1.01/css (added)
-
tags/1.01/css/dashboard.css (added)
-
tags/1.01/css/jquery-ui-theme (added)
-
tags/1.01/css/jquery-ui-theme/images (added)
-
tags/1.01/css/jquery-ui-theme/images/animated-overlay.gif (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-bg_flat_0_aaaaaa_40x100.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-bg_flat_75_ffffff_40x100.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-bg_glass_55_fbf9ee_1x400.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-bg_glass_65_ffffff_1x400.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-bg_glass_75_dadada_1x400.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-bg_glass_75_e6e6e6_1x400.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-bg_glass_95_fef1ec_1x400.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-bg_highlight-soft_75_cccccc_1x100.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-icons_222222_256x240.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-icons_2e83ff_256x240.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-icons_454545_256x240.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-icons_888888_256x240.png (added)
-
tags/1.01/css/jquery-ui-theme/images/ui-icons_cd0a0a_256x240.png (added)
-
tags/1.01/css/jquery-ui-theme/jquery-ui.css (added)
-
tags/1.01/css/jquery-ui.css (added)
-
tags/1.01/css/nifty-desk-admin.css (added)
-
tags/1.01/css/nifty-desk.css (added)
-
tags/1.01/css/reporting.css (added)
-
tags/1.01/css/templates_base.css (added)
-
tags/1.01/images (added)
-
tags/1.01/images/ajax-loader - Copy (2).gif (added)
-
tags/1.01/images/ajax-loader - Copy.gif (added)
-
tags/1.01/images/ajax-loader.gif (added)
-
tags/1.01/images/logo.png (added)
-
tags/1.01/images/nifty-desk-welcome.png (added)
-
tags/1.01/images/pro1.png (added)
-
tags/1.01/images/pro2.png (added)
-
tags/1.01/images/pro3.png (added)
-
tags/1.01/images/reload.png (added)
-
tags/1.01/includes (added)
-
tags/1.01/includes/PHPMailer-master (added)
-
tags/1.01/includes/PHPMailer-master/.gitignore (added)
-
tags/1.01/includes/PHPMailer-master/.scrutinizer.yml (added)
-
tags/1.01/includes/PHPMailer-master/.travis.yml (added)
-
tags/1.01/includes/PHPMailer-master/LICENSE (added)
-
tags/1.01/includes/PHPMailer-master/PHPMailerAutoload.php (added)
-
tags/1.01/includes/PHPMailer-master/README.md (added)
-
tags/1.01/includes/PHPMailer-master/VERSION (added)
-
tags/1.01/includes/PHPMailer-master/changelog.md (added)
-
tags/1.01/includes/PHPMailer-master/class.phpmailer.php (added)
-
tags/1.01/includes/PHPMailer-master/class.pop3.php (added)
-
tags/1.01/includes/PHPMailer-master/class.smtp.php (added)
-
tags/1.01/includes/PHPMailer-master/composer.json (added)
-
tags/1.01/includes/PHPMailer-master/extras (added)
-
tags/1.01/includes/PHPMailer-master/extras/EasyPeasyICS.php (added)
-
tags/1.01/includes/PHPMailer-master/extras/README.md (added)
-
tags/1.01/includes/PHPMailer-master/extras/htmlfilter.php (added)
-
tags/1.01/includes/PHPMailer-master/extras/ntlm_sasl_client.php (added)
-
tags/1.01/includes/PHPMailer-master/language (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-am.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-ar.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-az.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-be.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-bg.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-br.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-ca.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-ch.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-cz.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-de.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-dk.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-el.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-eo.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-es.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-et.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-fa.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-fi.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-fo.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-fr.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-gl.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-he.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-hr.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-hu.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-id.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-it.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-ja.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-ka.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-lt.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-lv.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-ms.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-nl.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-no.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-pl.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-pt.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-ro.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-ru.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-se.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-sk.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-sl.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-sr.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-tr.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-uk.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-vi.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-zh.php (added)
-
tags/1.01/includes/PHPMailer-master/language/phpmailer.lang-zh_cn.php (added)
-
tags/1.01/includes/PHPMailer-master/travis.phpunit.xml.dist (added)
-
tags/1.01/includes/error-log-page.php (added)
-
tags/1.01/includes/feedback-page.php (added)
-
tags/1.01/includes/footer.php (added)
-
tags/1.01/includes/settings-page.php (added)
-
tags/1.01/includes/welcome-page.php (added)
-
tags/1.01/js (added)
-
tags/1.01/js/dashboard.js (added)
-
tags/1.01/js/jquery.form-validator.min.js (added)
-
tags/1.01/js/nifty_desk.js (added)
-
tags/1.01/js/nifty_desk_frontend.js (added)
-
tags/1.01/js/nifty_desk_tabs.js (added)
-
tags/1.01/js/reporting.js (added)
-
tags/1.01/js/widgets.js (added)
-
tags/1.01/languages (added)
-
tags/1.01/languages/nifty-desk-en_EN.mo (added)
-
tags/1.01/languages/nifty-desk-en_EN.po (added)
-
tags/1.01/modules (added)
-
tags/1.01/modules/api (added)
-
tags/1.01/modules/api/nifty-desk-api-functions.php (added)
-
tags/1.01/modules/api/nifty-desk-api-routes.php (added)
-
tags/1.01/modules/api/nifty-desk-api.php (added)
-
tags/1.01/modules/autoassign.php (added)
-
tags/1.01/modules/channels.php (added)
-
tags/1.01/modules/dashboard-ajax.php (added)
-
tags/1.01/modules/dashboard.php (added)
-
tags/1.01/modules/email.php (added)
-
tags/1.01/modules/reporting-ajax.php (added)
-
tags/1.01/modules/reporting.php (added)
-
tags/1.01/modules/views.php (added)
-
tags/1.01/modules/widgets.php (added)
-
tags/1.01/nifty-desk.php (added)
-
tags/1.01/readme.txt (added)
-
tags/1.01/templates (added)
-
tags/1.01/templates/basic_templates (added)
-
tags/1.01/templates/basic_templates/classic (added)
-
tags/1.01/templates/basic_templates/classic/classic.css (added)
-
tags/1.01/templates/basic_templates/classic/submit_ticket.php (added)
-
tags/1.01/templates/basic_templates/classic/support_center.php (added)
-
tags/1.01/templates/basic_templates/classic/ticket_view.php (added)
-
tags/1.01/templates/mail_login_template.html (added)
-
tags/1.01/templates/mail_template.html (added)
-
tags/1.01/templates/mail_ticket_template.html (added)
-
tags/1.01/templates/templates.php (added)
-
trunk/css/dashboard.css (modified) (8 diffs)
-
trunk/includes/PHPMailer-master/docs (added)
-
trunk/includes/PHPMailer-master/docs/Callback_function_notes.txt (added)
-
trunk/includes/PHPMailer-master/docs/DomainKeys_notes.txt (added)
-
trunk/includes/PHPMailer-master/docs/Note_for_SMTP_debugging.txt (added)
-
trunk/includes/PHPMailer-master/docs/extending.html (added)
-
trunk/includes/PHPMailer-master/docs/faq.html (added)
-
trunk/includes/PHPMailer-master/docs/generatedocs.sh (added)
-
trunk/includes/PHPMailer-master/docs/pop3_article.txt (added)
-
trunk/includes/PHPMailer-master/examples (added)
-
trunk/includes/PHPMailer-master/examples/code_generator.phps (added)
-
trunk/includes/PHPMailer-master/examples/contents.html (added)
-
trunk/includes/PHPMailer-master/examples/exceptions.phps (added)
-
trunk/includes/PHPMailer-master/examples/gmail.phps (added)
-
trunk/includes/PHPMailer-master/examples/index.html (added)
-
trunk/includes/PHPMailer-master/examples/mail.phps (added)
-
trunk/includes/PHPMailer-master/examples/mailing_list.phps (added)
-
trunk/includes/PHPMailer-master/examples/pop_before_smtp.phps (added)
-
trunk/includes/PHPMailer-master/examples/send_file_upload.phps (added)
-
trunk/includes/PHPMailer-master/examples/sendmail.phps (added)
-
trunk/includes/PHPMailer-master/examples/smtp.phps (added)
-
trunk/includes/PHPMailer-master/examples/smtp_check.phps (added)
-
trunk/includes/PHPMailer-master/examples/smtp_no_auth.phps (added)
-
trunk/includes/PHPMailer-master/test (added)
-
trunk/includes/PHPMailer-master/test/bootstrap.php (added)
-
trunk/includes/PHPMailer-master/test/fakepopserver.sh (added)
-
trunk/includes/PHPMailer-master/test/fakesendmail.sh (added)
-
trunk/includes/PHPMailer-master/test/phpmailerLangTest.php (added)
-
trunk/includes/PHPMailer-master/test/phpmailerTest.php (added)
-
trunk/includes/PHPMailer-master/test/runfakepopserver.sh (added)
-
trunk/includes/PHPMailer-master/test/test_callback.php (added)
-
trunk/includes/PHPMailer-master/test/testbootstrap-dist.php (added)
-
trunk/includes/settings-page.php (modified) (2 diffs)
-
trunk/js/dashboard.js (modified) (10 diffs)
-
trunk/js/nifty_desk_promo.js (added)
-
trunk/js/widgets.js (modified) (2 diffs)
-
trunk/languages/nifty_desk-bn_BD.mo (added)
-
trunk/languages/nifty_desk-bn_BD.po (added)
-
trunk/languages/nifty_desk-da_DK.mo (added)
-
trunk/languages/nifty_desk-da_DK.po (added)
-
trunk/languages/nifty_desk-de_DE.mo (added)
-
trunk/languages/nifty_desk-de_DE.po (added)
-
trunk/languages/nifty_desk-en_EN.mo (added)
-
trunk/languages/nifty_desk-en_EN.po (added)
-
trunk/languages/nifty_desk-es_ES.mo (added)
-
trunk/languages/nifty_desk-es_ES.po (added)
-
trunk/languages/nifty_desk-fr_FR.mo (added)
-
trunk/languages/nifty_desk-fr_FR.po (added)
-
trunk/languages/nifty_desk-hr.mo (added)
-
trunk/languages/nifty_desk-hr.po (added)
-
trunk/languages/nifty_desk-it_IT.mo (added)
-
trunk/languages/nifty_desk-it_IT.po (added)
-
trunk/languages/nifty_desk-nl_NL.mo (added)
-
trunk/languages/nifty_desk-nl_NL.po (added)
-
trunk/languages/nifty_desk-pt_PT.mo (added)
-
trunk/languages/nifty_desk-pt_PT.po (added)
-
trunk/languages/nifty_desk-tr_TR.mo (added)
-
trunk/languages/nifty_desk-tr_TR.po (added)
-
trunk/modules/api/nifty-desk-api-functions.php (modified) (3 diffs)
-
trunk/modules/archive.php (added)
-
trunk/modules/dashboard-ajax.php (modified) (10 diffs)
-
trunk/modules/dashboard.php (modified) (1 diff)
-
trunk/modules/email.php (modified) (1 diff)
-
trunk/modules/metaboxes.php (added)
-
trunk/modules/reporting-ajax.php (modified) (1 diff)
-
trunk/modules/views.php (modified) (2 diffs)
-
trunk/modules/widgets.php (modified) (1 diff)
-
trunk/nifty-desk.php (modified) (15 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nifty-desk/trunk/css/dashboard.css
r1535609 r1592607 1 #wpcontent { 2 padding-left:0 !important; 3 } 4 .wrap { margin: 0 !important;} 5 6 .ui-tabs-panel { 7 /* padding-left: 0 !important; */ 8 padding-right: 0 !important; 9 margin-top:0 !important; 10 padding:0 !important; 11 border-top: 1px solid #eee; 12 } 13 #nifty_desk_tabs_ul { 14 margin:0; 15 } 16 .ui-tabs-nav li { margin-bottom:0 !important; } 17 1 18 a{ 2 19 color: #303E47; … … 4 21 } 5 22 23 24 .bold { 25 font-weight:bold; 26 27 } 28 .grey { 29 color:#666; 30 } 31 .italic { 32 font-style:italic; 33 34 } 6 35 a:hover{ 7 36 color: #303E47; … … 113 142 } 114 143 .ui-tabs-nav li:first-child { 115 margin-left: 16px;144 /*margin-left: 16px;*/ 116 145 } 117 146 … … 563 592 .ui-tabs-panel { 564 593 background: white; 565 margin-top: -19px !important;566 padding: 13px;594 /*margin-top: -19px !important; */ 595 /* padding: 13px; */ 567 596 } 568 597 … … 715 744 left: 20px; 716 745 right: 20px; 717 top: 280px;746 top: 330px; 718 747 } 719 748 #nifty_desk_prompt_content { … … 745 774 bottom: 0; 746 775 width:0px; 747 height: 3 00px;776 height: 330px; 748 777 background-color: #fff; 749 778 z-index: 10001; … … 851 880 852 881 853 @media screen and (max-width:1 500px) {882 @media screen and (max-width:1600px) { 854 883 td.ticket_responses { display: none; } 855 884 .ticket_title { max-width:250px; } … … 893 922 height:30px; 894 923 } 924 925 .nifty_desk_seen_list { 926 opacity: 0.6; 927 display: inline-block; 928 width: 15px; 929 text-align: center; 930 font-size: 10px; 931 line-height: 15px; 932 padding: 0px; 933 border-radius: 2px; 934 } 935 936 .nifty_desk_sentiment_block { 937 opacity: 0.6; 938 display: inline-block; 939 text-align: center; 940 font-size: 10px; 941 line-height: 15px; 942 padding: 0px; 943 padding-left:2px; 944 padding-right:2px; 945 border-radius: 2px; 946 } 947 .sent_neutral { 948 background-color: #666666; 949 color: #FFF; 950 } 951 952 .sent_happy { 953 background-color: #80af74; 954 color:#FFF; 955 } 956 .sent_very_happy { 957 background-color: #2e9c12; 958 color:#FFF; 959 } 960 .sent_very_unhappy { 961 background-color: #b70000; 962 color:#fff; 963 } 964 .sent_unhappy { 965 background-color: #b5626a; 966 color:#FFF; 967 } -
nifty-desk/trunk/includes/settings-page.php
r1535609 r1592607 1 1 <?php 2 2 $nifty_desk_settings = get_option("nifty_desk_settings"); 3 /*4 5 6 $notification_array = array();7 $notification_array[1] = 'nick@codecabin.co.za';8 $notification_array[7] = 'sales@wp-livechat.com';9 $notification_array[9] = 'nick2@codecabin.co.za';10 11 $notification_array = apply_filters("nifty_filter_notification_email_array",$nifty_desk_settings,$notification_array);12 var_dump($notification_array);13 exit();14 */15 16 3 17 4 $st_notification = get_option("nifty_desk_notifications"); 18 5 $nifty_desk_ajax_nonce = wp_create_nonce("nifty_desk"); 6 7 8 19 9 20 10 if(function_exists('nifty_desk_pro_activate')){ … … 738 728 739 729 </div> 730 </div> 740 731 741 732 <?php } ?> -
nifty-desk/trunk/js/dashboard.js
r1535609 r1592607 8 8 var nifty_desk_offset = 0; 9 9 var nifty_desk_rotate_degree = 0, rotate_timer, nifty_desk_is_refreshing; 10 11 var current_nd_ajax; 10 12 11 13 jQuery(document).ready(function(){ … … 48 50 view_type = 1; 49 51 nifty_desk_fetch_tickets_by_view(view_type,nifty_desk_limit,0,0,false,false,false); 50 } 51 52 } 52 53 53 54 }); … … 174 175 175 176 176 jQuery.post( ajaxurl, data, function(response){177 current_nd_ajax = jQuery.post( ajaxurl, data, function(response){ 177 178 response = JSON.parse(response); 178 179 … … 746 747 747 748 var current_ticketid = jQuery(this).attr("tid"); 749 if (typeof current_ticketid == "undefined" || parseInt(current_ticketid) < 1) { 750 alert("No ticket ID found. Cannot send message"); 751 return; 752 } 753 754 var agent_id = jQuery("#nifty_desk_agent_id_"+current_ticketid).val(); 755 if (typeof agent_id == "undefined" || parseInt(agent_id) < 1) { 756 alert("No agent ID found. Cannot send message"); 757 return; 758 } 759 748 760 jQuery("#submit_ticket_response_"+current_ticketid).attr('disabled', 'disabled'); 749 761 … … 755 767 formData.append('parent', current_ticketid); 756 768 formData.append('content', jQuery("#nifty_desk_db_response_textarea_"+current_ticketid).val()); 757 formData.append('title', jQuery("#nifty_desk_response_title_"+ ticket_id).val());758 formData.append('author', jQuery("#nifty_desk_agent_id_"+ticket_id).val());769 formData.append('title', jQuery("#nifty_desk_response_title_"+current_ticketid).val()); 770 formData.append('author', agent_id); 759 771 760 772 if (typeof nifty_desk_file !== "undefined" && typeof nifty_desk_file[current_ticketid] !== "undefined") { … … 800 812 801 813 802 jQuery("#ticket_response_content_holder_"+ ticket_id).prepend( response.content );814 jQuery("#ticket_response_content_holder_"+current_ticketid).prepend( response.content ); 803 815 jQuery("#nifty_desk_db_response_textarea_"+current_ticketid).val(''); 804 816 … … 862 874 jQuery("#nifty_desk_prompt_content").html("<p>"+nifty_desk_dashboard_strings.merge_content1+"</p><p><label>"+nifty_desk_dashboard_strings.merge_label1+"</label> <input type='text' autofocus ticket_id='"+ticket_id+"' name='nifty_desk_ticket_merge_id' value='' placeholder='12345' id='nifty_desk_ticket_merge_id' /> <a href='javascript:void(0);' class='button button-secondary'>"+nifty_desk_dashboard_strings.merge_button1+"</a></p>"); 863 875 jQuery("#nifty_desk_prompt_content").prepend("<input type='hidden' id='nifty_desk_ticket_id_merge_id' value='"+ticket_id+"' />"); 864 jQuery("#nifty_desk_prompt_content").append("<div id='nifty_desk_ticket_merge_preview' style='display:none !important; border:1px solid #ccc; padding:5px; width:100%; '></div>");876 jQuery("#nifty_desk_prompt_content").append("<div id='nifty_desk_ticket_merge_preview' style='display:none !important; border:1px solid #ccc; padding:5px; width:100%; height:150px; overflow-y: auto;'></div>"); 865 877 866 878 jQuery(".nifty_desk_prompt_close").html(nifty_desk_dashboard_strings.merge_cancel); … … 1143 1155 jQuery(".nifty_desk_loader_placeholder").html("<img src='"+nifty_desk_db_plugins_url+"/nifty-desk/images/ajax-loader.gif' class='nifty_desk_loader' />"); 1144 1156 //jQuery(".nifty_desk_db_ticket_container tbody").html("<tr><td colspan='11'><img src='"+nifty_desk_db_plugins_url+"/nifty-desk/images/ajax-loader.gif' style='display: block; margin: 0 auto;' class='nifty_desk_loader' /></td></tr>"); 1157 1158 // abort any current ajax requests so they dont overlap 1159 if (typeof current_nd_ajax !== "undefined" && typeof current_nd_ajax.abort !== "undefined") { current_nd_ajax.abort(); } 1145 1160 1146 1161 url = document.URL ; … … 1169 1184 } 1170 1185 1171 jQuery.post( ajaxurl, data, function(response){ 1172 response = JSON.parse(response); 1173 1186 current_nd_ajax = jQuery.post( ajaxurl, data, function(response){ 1187 response = JSON.parse(response); 1174 1188 if (typeof response.counts !== "undefined") { 1175 1189 /* update ticket counts.. */ 1176 1190 jQuery.each( response.counts, function( index, value ){ 1191 // console.log(index); 1192 // console.log(value); 1177 1193 jQuery("#nifty_desk_view_count_"+index).html(value); 1178 1194 }); … … 1210 1226 1211 1227 } 1228 1229 jQuery(document).keyup(function(e) { 1230 1231 if (e.keyCode == 27){ 1232 jQuery(".nifty_desk_prompt_close").click(); 1233 } 1234 1235 }); -
nifty-desk/trunk/js/widgets.js
r1535609 r1592607 42 42 console.log(response); 43 43 } 44 44 45 45 if (typeof response.user_email !== "undefined") { 46 46 jQuery(".ticket_originator_change_btn_"+tid).remove(); … … 53 53 jQuery(".nifty_author_email_"+tid).html(response.user_email); 54 54 jQuery(".ticket_originator_"+tid).html(response.user_email); 55 jQuery(".author_display_name_"+tid).html(response.user_name); 55 56 56 57 -
nifty-desk/trunk/modules/api/nifty-desk-api-functions.php
r1535609 r1592607 48 48 49 49 if(function_exists('send_automated_emails')) { 50 send_automated_emails($email,__('Your support desk log in details','nifty_desk'), __("Login URL:","nifty_desk"). " ". wp_login_url(). " <br/><br/> ".__("Username:","nifty_desk"). " ".$username. " <br/><br/> ".__("Password:","nifty_desk")." ".$random_password,$channel['id'],$post_id);50 //send_automated_emails($email,__('Your support desk log in details','nifty_desk'), __("Login URL:","nifty_desk"). " ". wp_login_url(). " <br/><br/> ".__("Username:","nifty_desk"). " ".$username. " <br/><br/> ".__("Password:","nifty_desk")." ".$random_password,$channel['id'],$post_id); 51 51 } 52 52 } … … 78 78 add_post_meta($post_id, 'ticket_public', '', true); 79 79 } 80 80 81 81 82 82 if (isset($_POST['nifty_desk_submit_priority'])) { … … 91 91 } 92 92 93 if (!isset($custom_fields['ticket_assigned_to'])) { 94 if (!get_option("nifty_desk_default_assigned_to")) { 95 $super_admins = get_super_admins(); 96 $user = get_user_by('slug', $super_admins[0]); 97 if(is_object($user)) 98 { 99 add_option('nifty_desk_default_assigned_to', $user->ID); 100 } 101 } 102 $default_user = get_option("nifty_desk_default_assigned_to"); 103 add_post_meta($post_id, 'ticket_assigned_to', $default_user, true); 104 } else { 105 add_post_meta($post_id, 'ticket_assigned_to', '', true); 106 } 107 update_post_meta( $parent_id, 'ticket_last_updated', current_time('timestamp')); 93 $assigned_to = apply_filters("nifty_desk_assigned_to_new_ticket",false); 94 if ($assigned_to) { 95 update_post_meta( $post_id, 'ticket_assigned_to', $assigned_to); 96 } 97 98 update_post_meta( $post_id, 'ticket_last_updated', current_time('timestamp')); 108 99 109 100 add_post_meta($post_id, 'ticket_origin', 'api', true); -
nifty-desk/trunk/modules/dashboard-ajax.php
r1535609 r1592607 472 472 473 473 $ticket_subject = $post->post_title; 474 $ticket_content = $post->post_content;474 $ticket_content = stripslashes( $post->post_content ); 475 475 476 476 $ticket_actual_date = $post->post_date; … … 709 709 710 710 $ret .= "<div class='ticket_container'>"; 711 712 $ret .= apply_filters("nifty_desk_filter_warning_control","",$ticket_id); 711 713 712 714 $ret .= nifty_desk_output_ticket_actions($ticket_id); … … 721 723 $ret .= " <div class='ticket_subject'>$ticket_subject </div>"; 722 724 723 $ret .= " <div class='ticket_author'><span class='author_name'> $ticket_author_name(<a class='nifty_author_email_".$ticket_id."' href='mailto:".$ticket_author_email."'>".$ticket_author_email."</a>)</span> | <span title='".$ticket_actual_date."'>".$ticket_request_date."</span> | <div class='ticket_id_label'>".__('Ticket #', 'nifty_desk')."$ticket_id</div> <a href='".admin_url('admin.php?page=support-tickets&tid='.$ticket_id)."' target='_BLANK' class='nifty_desk_view_front_end' title='".$ticket_subject."'>".__("Back end link","nifty_desk")."</a> | <a href='".get_permalink($ticket_id)."' target='_BLANK' class='nifty_desk_view_front_end' title='".$ticket_subject."'>".__("Front end link","nifty_desk")."</a></div>";725 $ret .= " <div class='ticket_author'><span class='author_name'><span class='author_display_name_".$ticket_id."'>$ticket_author_name</span> (<a class='nifty_author_email_".$ticket_id."' href='mailto:".$ticket_author_email."'>".$ticket_author_email."</a>)</span> | <span title='".$ticket_actual_date."'>".$ticket_request_date."</span> | <div class='ticket_id_label'>".__('Ticket #', 'nifty_desk')."$ticket_id</div> <a href='".admin_url('admin.php?page=support-tickets&tid='.$ticket_id)."' target='_BLANK' class='nifty_desk_view_front_end' title='".$ticket_subject."'>".__("Back end link","nifty_desk")."</a> | <a href='".get_permalink($ticket_id)."' target='_BLANK' class='nifty_desk_view_front_end' title='".$ticket_subject."'>".__("Front end link","nifty_desk")."</a></div>"; 724 726 725 727 $ret .= " </div>"; … … 753 755 $nifty_desk_tags = nifty_desk_get_allowed_tags(); 754 756 //$ret .= wp_kses(utf8_decode($ticket_content),$nifty_desk_tags); 755 $ret .= wp_kses( $ticket_content,$nifty_desk_tags);757 $ret .= wp_kses(nifty_desk_normalize(html_entity_decode($ticket_content)),$nifty_desk_tags); 756 758 757 759 … … 971 973 $response_contents .= " </div>"; 972 974 $response_contents .= " <div class='ticket_contents ticket_contents_response'>"; 973 $response_contents .= nl2br( $content_current);975 $response_contents .= nl2br( stripslashes( $content_current ) ); 974 976 975 977 $ticket_attachments = maybe_unserialize(get_post_custom_values('ticket_attachments', $post_id)); … … 1134 1136 /* SEARCH FOR A TICKET NUMBER FIRST */ 1135 1137 global $wpdb; 1136 $search_id = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE ID = '$query' AND post_type = 'nifty_desk_tickets' AND post_status = 'publish' "); 1137 1138 1139 $search_query = "SELECT * FROM $wpdb->posts WHERE ID = '$query' AND post_type = 'nifty_desk_tickets' AND post_status = 'publish' "; 1140 1141 if (strpos($query, "@") !== false) { 1142 $split = explode("@", $query); 1143 if (strpos($split['1'], ".") !== false) { 1144 $user_data = get_user_by( "email", sanitize_email( $query ) ); 1145 $search_query = "SELECT * FROM $wpdb->posts WHERE post_author = '".$user_data->ID."' AND post_type = 'nifty_desk_tickets' AND post_status = 'publish' "; 1146 } 1147 } 1148 1149 $search_id = $wpdb->get_results( $search_query ); 1138 1150 $ret = ""; 1139 1151 … … 1148 1160 1149 1161 $ticket_id = $search->ID; 1162 1163 1164 $post_meta = get_post_meta($ticket_id); 1165 1166 if (isset($post_meta['ticket_channel_id'])) { 1167 1168 $ticket_channel = $post_meta['ticket_channel_id'][0]; 1169 if (function_exists('nifty_desk_get_ticket_channel_name')) { 1170 1171 $ticket_channel_id = $ticket_channel; 1172 $channel_name_full = nifty_desk_get_ticket_channel_name($ticket_channel); 1173 $channel_name = $channel_name_full; 1174 1175 } else { 1176 $ticket_channel_id = 0; 1177 $channel_name_full = __('Support Desk','nifty_desk'); 1178 $channel_name = __('s.desk','nifty_desk'); 1179 } 1180 } else { 1181 $ticket_channel_id = 0; 1182 $channel_name_full = __('Support Desk','nifty_desk'); 1183 $channel_name = __('s.desk','nifty_desk'); 1184 } 1185 1186 1150 1187 $nifty_desk_status = get_post_custom_values('ticket_status', intval( $search->ID ), true); 1151 1188 if ($nifty_desk_status) { … … 1163 1200 $data = nifty_desk_get_last_response( intval( $search->ID ) ); 1164 1201 1165 if (isset($ data->post_author)) {1166 $author = $ data->post_author;1202 if (isset($search->post_author)) { 1203 $author = $search->post_author; 1167 1204 if ($author) { 1168 1205 $author_data = get_userdata( intval( $author ) ); 1206 1169 1207 $author_name = $author_data->display_name; 1170 1208 $author_email = $author_data->user_email; … … 1172 1210 $last_responder .= $author_data->display_name; 1173 1211 1174 $last_responder .= "<br /><small>" . nifty_desk_time_elapsed_string(strtotime($ data->post_date)) . "</small>";1212 $last_responder .= "<br /><small>" . nifty_desk_time_elapsed_string(strtotime($search->post_date)) . "</small>"; 1175 1213 } else { 1176 1214 $last_responder .= "-"; 1177 1215 } 1178 } else { 1216 } else { 1217 // $user_data = get_user_by( 'id', $search->post_at) 1179 1218 $last_responder .= "-"; 1180 1219 } 1181 1220 $ret .= "<tr id='nifty_desk_modern_ticket_row_".$search->ID."' class='nifty_desk_modern_ticket_row'>"; 1182 1221 $ret .= "<td><input type='checkbox' class='nifty_desk_checkbox' value='".$search->ID."' /></td>"; 1183 $ret .= "<td class='nifty_desk_db_single_ticket ticket_status' ticket_id='".$ticket_id."'>" . $post_status . " </td>";1222 $ret .= "<td class='nifty_desk_db_single_ticket ticket_status' ticket_id='".$ticket_id."'>" . $post_status . " ".apply_filters("nifty_desk_return_seen_tag_in_list","",$ticket_id)."</td>"; 1184 1223 $ret .= "<td class='nifty_desk_db_single_ticket ticket_id' ticket_id='".$ticket_id."'>#" . $ticket_id . "</td>"; 1224 if( function_exists( 'nifty_desk_filter_control_sa_ticket_view_list_column_body' ) ){ 1225 $ret .= nifty_desk_filter_control_sa_ticket_view_list_column_body( "", $ticket_id, $post_meta); 1226 } else { 1227 $ret .= "<td class='nifty_desk_db_single_ticket'> </td>"; 1228 } 1185 1229 $ret .= "<td class='nifty_desk_db_single_ticket ticket_title' ticket_id='".$search->ID."' >" . $search->post_title . "</td>"; 1186 1230 $ret .= "<td class='nifty_desk_db_single_ticket ticket_author' ticket_id='".$search->ID."' title='".$author_email."'>" . $author_name . "</td>"; … … 1189 1233 $ret .= "<td class='nifty_desk_db_single_ticket ticket_responses' ticket_id='".$search->ID."'>" . $response_count . "</td>"; 1190 1234 $ret .= "<td class='nifty_desk_db_single_ticket ticket_responser' ticket_id='".$search->ID."'>" . $last_responder . "</td>"; 1191 $ret .= "<td class='nifty_desk_db_single_ticket ticket_status' ticket_id='".$search->ID."'>" . $post_status . "</td>"; 1192 $ret .= "<td class='nifty_desk_db_single_ticket ticket_owner' ticket_id='".$ticket_id."'>" . $user_data->display_name . "</td>"; 1193 $ret .= "<td class='nifty_desk_db_single_ticket ticket_channel' ticket_id='".$ticket_id."'>" . $channel_name . "</td>"; 1235 $ret .= "<td class='nifty_desk_db_single_ticket ticket_owner' ticket_id='".$ticket_id."'>" . $author_name . "</td>"; 1236 $ret .= "<td class='nifty_desk_db_single_ticket ticket_channel' ticket_id='".$ticket_id."'>" . nifty_desk_return_ticket_channel_html_block($channel_name,$ticket_channel_id,$channel_name_full) . "</td>"; 1194 1237 $ret .= "</tr>"; 1195 1238 -
nifty-desk/trunk/modules/dashboard.php
r1535609 r1592607 87 87 <td class='ticket_status_clause nifty_desk_sortby' sortbytype='meta' sortbyvalue='ticket_status' sortby='ASC'> </td> 88 88 <td class='ID nifty_desk_sortby' sortbytype='default' sortbyvalue='ticket_id' sortby='ASC'><?php _e("ID","nifty_desk_"); ?></td> 89 <?php echo apply_filters("nifty_desk_ticket_view_list_column_header",""); ?> 89 90 <td class='title nifty_desk_sortby' sortbytype='default' sortbyvalue='ticket_title' sortby='ASC'><?php _e('Subject', 'nifty_desk'); ?></td> 90 91 <td class='author nifty_desk_sortby' sortbytype='default' sortbyvalue='ticket_author' sortby='ASC'><?php _e('Requester', 'nifty_desk'); ?></td> -
nifty-desk/trunk/modules/email.php
r1535609 r1592607 123 123 124 124 $content = str_replace("{reply_above_line}",apply_filters("nifty_desk_email_body_user_ticket_reply_above_line",""),$content); 125 if (isset($data['ticket_reference'])) { $content = str_replace("{ticket_reference}",apply_filters("nifty_desk_email_body_ticket_reference","",$data['ticket_reference'],$data['response_id']),$content); } 125 if ( isset( $data['ticket_reference'] ) ) { 126 if( isset( $data['response_id'] ) ){ 127 $content = str_replace("{ticket_reference}",apply_filters("nifty_desk_email_body_ticket_reference","",$data['ticket_reference'],$data['response_id']),$content); 128 } else { 129 $content = str_replace("{ticket_reference}",apply_filters("nifty_desk_email_body_ticket_reference","",$data['ticket_reference'],""),$content); 130 } 131 } 126 132 127 133 return $content; -
nifty-desk/trunk/modules/reporting-ajax.php
r1535609 r1592607 7 7 if ($_POST['action'] == 'nifty_desk_rep_update_stats') { 8 8 if(isset($_POST['payload']['nifty_desk_rep_period'])){ 9 $return_data = nifty_desk_get_tickets_for_period(intval(sanitize_text_field($_POST['payload']['nifty_desk_rep_period'])), sanitize_text_field( $_POST['payload']));9 $return_data = nifty_desk_get_tickets_for_period(intval(sanitize_text_field($_POST['payload']['nifty_desk_rep_period'])), $_POST['payload'] ); 10 10 echo json_encode($return_data); 11 11 wp_die(); -
nifty-desk/trunk/modules/views.php
r1545853 r1592607 1 1 <?php 2 2 3 4 3 5 add_action("nifty_desk_view_control","nifty_desk_hook_control_view_control",10); 6 4 7 function nifty_desk_hook_control_view_control() { 8 5 9 $current_views = get_option("nifty_desk_views"); 10 6 11 echo '<ul class="nifty_desk_db_controls">'; 12 7 13 foreach ($current_views as $key => $view) { 14 8 15 echo '<li><a href="javascript:void(0)" class="nifty_desk_view_control" id="nifty_desk_view_control_'.$key.'" view="'.$key.'"><span class="nifty_desk_view_control_ticket_name" id="nifty_desk_view_control_ticket_name_'.$key.'">'.$view['title'].'</span><span class="nifty_desk_view_control_ticket_count" id="nifty_desk_view_count_'.$key.'"">'.nifty_desk_ticket_count_by_view($key).'</span></a></li>'; 16 9 17 } 18 10 19 echo '</ul>'; 20 11 21 } 12 22 23 24 13 25 function nifty_desk_ticket_count_by_view($key) { 14 26 15 $check = json_decode(nifty_desk_get_tickets_by_view($key,0,1,false)); 27 28 29 $check = json_decode(nifty_desk_get_tickets_by_view($key,0,1,0,false,false,false,false,true)); 30 16 31 return $check->cnt; 32 17 33 } 18 34 19 35 20 function nifty_desk_get_tickets_by_view($view,$offset = 0,$limit = 20,$return_all_counts = 0,$sortbytype = false,$sortbyvalue = false,$sortby = false,$search_string = false) { 36 37 38 39 function nifty_desk_get_tickets_by_view($view, $offset = 0, $limit = 20, $return_all_counts = 0, $sortbytype = false, $sortbyvalue = false, $sortby = false, $search_string = false, $just_count = false) { 40 21 41 $return_all_counts = intval($return_all_counts); 22 42 43 44 23 45 $orderby = 'date'; 46 24 47 $order = 'DESC'; 25 48 49 26 50 if (!$search_string) { 51 27 52 $current_views = get_option("nifty_desk_views"); 28 53 54 55 29 56 if (isset($current_views[$view])) { } else { echo "error2"; wp_die(); } 30 57 58 59 31 60 $orderby = $current_views[$view]['data']['orderby']; 61 32 62 if (!isset($current_views[$view]['data']['channel'])) { 63 33 64 $channel = false; 65 34 66 } else { 67 35 68 $channel = $current_views[$view]['data']['channel']; 36 } 69 70 } 71 37 72 73 38 74 $order = $current_views[$view]['data']['order']; 75 39 76 $priority = $current_views[$view]['data']['priority']; 77 40 78 if (isset($current_views[$view]['data']['department'])) { $department = $current_views[$view]['data']['department']; } else { $department = false; } 79 41 80 if (!isset($current_views[$view]['data']['status'])) { 81 42 82 /* if a user created a view and selected no statuses, select all by default now */ 83 43 84 $status = array( 85 44 86 0 => true, 87 45 88 1 => true, 89 46 90 2 => true, 91 47 92 3 => true, 93 48 94 9 => true 95 49 96 ); 97 50 98 } else { 99 51 100 $status = $current_views[$view]['data']['status']; 52 } 101 102 } 103 53 104 $agents = $current_views[$view]['data']['agents']; 105 54 106 } 107 55 108 109 56 110 57 111 112 113 58 114 $department_string = ""; 59 115 116 117 60 118 $and_relation = array("relation" => "AND"); 61 119 … … 64 122 65 123 124 125 126 127 128 129 66 130 $meta_query = array(); 67 131 132 133 68 134 if (!$search_string) { 135 69 136 if (count($status) > 1) { 137 70 138 $status_meta_query = array("relation" => "OR"); 71 139 140 141 72 142 /* multiple status values requested */ 143 73 144 $cnter = 0; 145 74 146 foreach ($status as $key => $status_val) { 75 147 148 149 76 150 if ((string)$key == "-1") { 151 77 152 /* Unassigned statuses */ 153 78 154 $status_meta_query_sub = array( 155 79 156 'key' => 'ticket_status', 157 80 158 'compare' => 'NOT EXISTS', 159 81 160 ); 82 161 162 163 83 164 } else { 165 84 166 $status_meta_query_sub = array( 167 85 168 'key' => 'ticket_status', 169 86 170 'value' => (string)$key, 171 87 172 'compare' => '=', 173 88 174 ); 175 89 176 } 177 90 178 array_push($status_meta_query,$status_meta_query_sub); 179 91 180 } 181 92 182 183 93 184 185 94 186 } else { 187 95 188 /* single status value requested */ 189 96 190 if ((string)key($status) == "-1") { 191 97 192 /* Unassigned statuses */ 193 98 194 $status_meta_query = array( 195 99 196 'key' => 'ticket_status', 197 100 198 'compare' => 'NOT EXISTS', 199 101 200 ); 102 201 202 203 103 204 } else { 205 104 206 $status_meta_query = array( 207 105 208 'key' => 'ticket_status', 209 106 210 'value' => (string)key($status), 211 107 212 'compare' => '=', 213 108 214 ); 215 109 216 } 217 110 218 111 } 219 220 } 221 112 222 223 113 224 if ($department) { 114 225 226 227 115 228 $cnter = 0; 229 116 230 foreach ($department as $key => $department_val) { 231 117 232 if ($cnter == 0) { 233 118 234 $department_string = $key; 235 119 236 } else { 237 120 238 $department_string = $department_string.",".$key; 239 121 240 } 241 122 242 $cnter++; 243 123 244 } 124 } 245 246 } 247 125 248 126 249 127 250 128 251 252 253 254 255 129 256 if ($priority > 0) { 130 257 258 259 131 260 if (count($priority) > 1) { 261 132 262 $priority_meta_query = array("relation" => "OR"); 133 263 264 265 134 266 /* multiple priority values requested */ 267 135 268 $cnter = 0; 269 136 270 foreach ($priority as $key => $priority_val) { 271 137 272 if ((string)$key == "0") { 273 138 274 /* all priorities, so just ignore this meta query build subset */ 275 139 276 /* set $priority to zero so that we do not include this meta query sub build */ 277 140 278 $priority = 0; 279 141 280 break; 142 281 143 282 283 284 285 144 286 } else if ((string)$key == "-1") { 287 145 288 /* Unassigned tickets */ 289 146 290 $priority_meta_query_sub = array( 291 147 292 'key' => 'ticket_priority', 293 148 294 'compare' => 'NOT EXISTS', 295 149 296 ); 150 297 298 299 151 300 } else { 301 152 302 $priority_meta_query_sub = array( 303 153 304 'key' => 'ticket_priority', 305 154 306 'value' => (string)$key, 307 155 308 'compare' => '=', 309 156 310 ); 311 157 312 } 313 158 314 array_push($priority_meta_query,$priority_meta_query_sub); 315 159 316 } 317 160 318 319 161 320 321 162 322 } else { 323 163 324 /* single priority value requested */ 325 164 326 if ((string)key($priority) == "0") { 327 165 328 /* all agents, so just ignore this meta query build subset */ 329 166 330 } else if ((string)key($priority) == "-1") { 331 167 332 /* Unassigned tickets */ 333 168 334 $priority_meta_query = array( 335 169 336 'key' => 'ticket_priority', 337 170 338 'compare' => 'NOT EXISTS', 339 171 340 ); 172 341 342 343 173 344 } else { 174 345 346 347 175 348 $priority_meta_query = array( 349 176 350 'key' => 'ticket_priority', 351 177 352 'value' => (string)key($priority), 353 178 354 'compare' => '=', 355 179 356 ); 357 180 358 } 359 181 360 $include_priority = true; 361 182 362 } 183 } 363 364 } 365 366 184 367 185 368 if ($agents > 0) { 186 369 370 371 187 372 if (count($agents) > 1) { 188 373 374 375 189 376 $agent_meta_query = array("relation" => "OR"); 190 377 378 379 191 380 /* multiple agent values requested */ 381 192 382 $cnter = 0; 383 193 384 foreach ($agents as $key => $agents_val) { 385 194 386 if ((string)$key == "0") { 387 195 388 /* all agents, so just ignore this meta query build subset */ 389 196 390 /* set $agents to zero so that we do not include this meta query sub build */ 391 197 392 $agents = 0; 393 198 394 break; 199 395 200 396 397 398 399 201 400 } else if ((string)$key == "-1") { 401 202 402 /* Unassigned tickets */ 403 203 404 $agent_meta_query_sub = array( 405 204 406 'key' => 'ticket_assigned_to', 407 205 408 'compare' => 'NOT EXISTS', 409 206 410 ); 207 411 412 413 208 414 } else if ((string)$key == "current_agent") { 415 209 416 /* Tickets for this current user only */ 417 210 418 $agent_meta_query_sub = array( 419 211 420 'key' => 'ticket_assigned_to', 421 212 422 'value' => get_current_user_id(), 423 213 424 'compare' => '=', 214 425 426 427 215 428 ); 216 429 217 430 431 432 433 218 434 } else { 435 219 436 $agent_meta_query_sub = array( 437 220 438 'key' => 'ticket_assigned_to', 439 221 440 'value' => (string)$key, 441 222 442 'compare' => '=', 443 223 444 ); 445 224 446 } 447 225 448 array_push($agent_meta_query,$agent_meta_query_sub); 449 226 450 } 451 227 452 453 228 454 455 229 456 } else { 230 457 458 459 231 460 /* single priority value requested */ 461 232 462 if ((string)key($agents) == "0") { 463 233 464 /* all agents, so just ignore this meta query build subset */ 465 234 466 } else if ((string)key($agents) == "-1") { 467 235 468 /* Unassigned tickets */ 469 236 470 $agent_meta_query = array( 471 237 472 'key' => 'ticket_assigned_to', 473 238 474 'compare' => 'NOT EXISTS', 475 239 476 ); 240 477 478 479 241 480 } else if ((string)key($agents) == "current_agent") { 242 481 482 483 243 484 /* Tickets for this current user only */ 485 244 486 $agent_meta_query = array( 487 245 488 'key' => 'ticket_assigned_to', 489 246 490 'value' => get_current_user_id(), 491 247 492 'compare' => '=', 248 493 494 495 249 496 ); 250 497 251 498 499 500 501 252 502 } 503 253 504 else { 505 254 506 $agent_meta_query = array( 507 255 508 'key' => 'ticket_assigned_to', 509 256 510 'value' => (string)key($agents), 511 257 512 'compare' => '=', 513 258 514 ); 515 259 516 $include_agent = true; 517 260 518 } 519 261 520 } 262 } 521 522 } 523 263 524 264 525 526 527 265 528 if ($priority > 0 || $agents > 0) { 266 529 267 530 531 532 533 268 534 $meta_query = array("relation" => "AND"); 535 269 536 $meta_query['status_query_clause'] = $status_meta_query; 537 270 538 //array_push($meta_query,$status_meta_query); 539 271 540 541 272 542 if ($priority) { 543 273 544 $meta_query['priority_query_clause'] = $priority_meta_query; 545 274 546 //array_push($meta_query,$priority_meta_query); 547 275 548 } 549 276 550 if ($agents) { 551 277 552 $meta_query['agent_query_clause'] = $agent_meta_query; 553 278 554 //array_push($meta_query,$agent_meta_query); 555 279 556 } 280 557 558 559 281 560 } else { 561 282 562 /* one line query, do not use AND or OR */ 563 283 564 $meta_query = array("relation" => "AND"); 565 284 566 285 567 286 568 569 570 571 287 572 $meta_query['status_query_clause'] = $status_meta_query; 288 573 289 574 290 } 575 576 577 578 } 579 291 580 } 292 581 293 582 294 583 584 585 586 587 295 588 global $wpdb; 589 296 590 //$meta_sql = get_meta_sql( $meta_query, 'post', $wpdb->posts, 'ID' ); 297 591 298 592 593 594 595 299 596 //echo $required_action; 300 597 598 599 301 600 $ret = ""; 302 601 303 602 603 604 605 304 606 /* limit is set to $limit+1 here because we are actively seeking if there are more posts than what has been asked for, if true, then we can let the JS know that it can keep the "next" button active. */ 305 607 608 609 306 610 $posts_per_page_default = get_option("posts_per_page"); 307 611 612 613 308 614 update_option("posts_per_page",$limit+1); 309 615 616 617 310 618 if ($department) { 311 619 620 621 312 622 $terms = explode(",",$department_string); 623 313 624 $terms = array_values($terms); 314 625 626 627 315 628 $tax_query = array( 629 316 630 array( 631 317 632 'taxonomy' => 'nifty_desk_departments', 633 318 634 'field' => 'term_id', 635 319 636 'terms' => $terms 637 320 638 ) 639 321 640 ); 641 322 642 $args = array( 643 323 644 'post_type' => 'nifty_desk_tickets', 645 324 646 'posts_per_page ' => $limit+1, 647 325 648 'offset' => $offset, 649 326 650 'meta_query' => array($meta_query), 651 327 652 'orderby' => $orderby, 653 328 654 'order' => $order, 655 329 656 'tax_query' => $tax_query 657 330 658 ); 659 331 660 } else { 661 332 662 $args = array( 663 333 664 'post_type' => 'nifty_desk_tickets', 665 334 666 'posts_per_page ' => $limit+1, 667 335 668 'offset' => $offset, 669 336 670 'meta_query' => array($meta_query), 671 337 672 'orderby' => $orderby, 673 338 674 'order' => $order 675 339 676 ); 677 340 678 } 679 341 680 681 342 682 if ($search_string) { 683 343 684 $args['s'] = $search_string; 685 344 686 } 687 345 688 346 689 690 691 347 692 348 693 694 695 349 696 /* do sort by over-rides (when users click on the table headings */ 697 350 698 if ($sortbytype == 'meta') { 699 351 700 if ($sortbyvalue=='ticket_last_updated') { 701 352 702 /* this is a date.. */ 353 703 354 704 705 706 707 355 708 $last_updated_meta_query_sub = array( 709 356 710 'key' => 'ticket_last_updated', 711 357 712 'compare' => "EXISTS" 358 713 714 715 359 716 ); 717 360 718 $meta_query['ticket_last_updated_clause'] = $last_updated_meta_query_sub; 719 361 720 $args['orderby'] = 'ticket_last_updated_clause'; 721 362 722 $args['order'] = $sortby; 723 363 724 $args['meta_query'] = $meta_query; 725 364 726 727 365 728 366 } 729 730 } 731 732 if ($sortbyvalue=='ticket_sentiment') { 733 734 /* this is a date.. */ 735 736 737 738 739 740 $last_updated_meta_query_sub = array( 741 742 'key' => 'ticket_sentiment', 743 744 'compare' => "EXISTS" 745 746 747 748 ); 749 750 $meta_query['ticket_sentiment_clause'] = $last_updated_meta_query_sub; 751 752 $args['orderby'] = 'ticket_sentiment_clause'; 753 754 $args['order'] = $sortby; 755 756 $args['meta_query'] = $meta_query; 757 758 759 760 761 762 } 763 764 367 765 368 766 if ($sortbyvalue=='ticket_priority') { 767 369 768 /* this is a date.. */ 769 370 770 $priority_meta_query_sub = array( 771 371 772 'key' => 'ticket_priority', 773 372 774 'compare' => "EXISTS" 775 373 776 ); 777 374 778 $meta_query['ticket_priority_clause'] = $priority_meta_query_sub; 779 375 780 $args['orderby'] = 'ticket_priority_clause'; 781 376 782 $args['order'] = $sortby; 783 377 784 $args['meta_query'] = $meta_query; 785 378 786 379 } 787 788 } 789 380 790 if ($sortbyvalue=='ticket_status') { 791 381 792 /* this is a date.. */ 793 382 794 $status_meta_query_sub = array( 795 383 796 'key' => 'ticket_status', 797 384 798 'compare' => "EXISTS" 799 385 800 ); 801 386 802 $meta_query['ticket_status_clause'] = $status_meta_query_sub; 803 387 804 $args['orderby'] = 'ticket_status_clause'; 805 388 806 $args['order'] = $sortby; 807 389 808 $args['meta_query'] = $meta_query; 809 390 810 391 } 811 812 } 813 392 814 if ($sortbyvalue=='ticket_assigned_to') { 815 393 816 /* this is a date.. */ 817 394 818 $status_meta_query_sub = array( 819 395 820 'key' => 'ticket_assigned_to', 821 396 822 'compare' => "EXISTS" 823 397 824 ); 825 398 826 $meta_query['ticket_assigned_to_clause'] = $status_meta_query_sub; 827 399 828 $args['orderby'] = 'ticket_assigned_to_clause'; 829 400 830 $args['order'] = $sortby; 831 401 832 $args['meta_query'] = $meta_query; 833 402 834 403 } 835 836 } 837 404 838 if ($sortbyvalue=='ticket_channel_id') { 839 405 840 /* this is a date.. */ 841 406 842 $status_meta_query_sub = array( 843 407 844 'key' => 'ticket_channel_id', 845 408 846 'compare' => "EXISTS" 847 409 848 ); 849 410 850 $meta_query['ticket_channel_id_clause'] = $status_meta_query_sub; 851 411 852 $args['orderby'] = 'ticket_channel_id_clause'; 853 412 854 $args['order'] = $sortby; 855 413 856 $args['meta_query'] = $meta_query; 857 414 858 859 415 860 } 861 416 862 } else if ($sortbytype == 'default') { 417 863 864 865 418 866 if ($sortbyvalue=='ticket_id') { 867 419 868 $args['orderby'] = 'ID'; 869 420 870 $args['order'] = $sortby; 421 } 871 872 } 873 422 874 if ($sortbyvalue=='ticket_title') { 875 423 876 $args['orderby'] = 'title'; 877 424 878 $args['order'] = $sortby; 425 } 879 880 } 881 426 882 if ($sortbyvalue=='ticket_author') { 883 427 884 $args['orderby'] = 'author'; 885 428 886 $args['order'] = $sortby; 429 } 887 888 } 889 430 890 if ($sortbyvalue=='ticket_created') { 891 431 892 $args['orderby'] = 'date'; 893 432 894 $args['order'] = $sortby; 433 } 895 896 } 897 898 434 899 435 900 } 436 901 902 903 904 905 437 906 $my_query = new WP_Query( $args ); 438 907 908 909 910 911 if ($just_count) { 912 913 $js = json_encode(array( 914 915 'cnt' => $my_query->found_posts 916 917 ) 918 919 ); 920 921 return $js; 922 923 } 924 925 926 439 927 $ticket_counter = 0; 928 440 929 $is_more = false; 930 441 931 $is_less = false; 442 932 933 934 443 935 if ($offset > 0) { $is_less = true; } /* if we've offset anything, logically there would be previous items so set is_less to true */ 444 936 937 445 938 if ( $my_query->have_posts() ) { 446 939 940 941 447 942 while ( $my_query->have_posts() ) { 943 448 944 $my_query->the_post(); 945 449 946 $ticket_id = get_the_ID(); 450 947 948 949 950 451 951 $post_meta = get_post_meta($ticket_id); 952 953 954 955 $post_status = nifty_desk_return_ticket_status_html_block( $post_meta['ticket_status'][0] ); 956 957 958 if (isset($post_meta['ticket_channel_id'])) { 959 960 961 962 $ticket_channel = $post_meta['ticket_channel_id'][0]; 963 964 if (function_exists('nifty_desk_get_ticket_channel_name')) { 965 966 967 968 $ticket_channel_id = $ticket_channel; 969 970 $channel_name_full = nifty_desk_get_ticket_channel_name($ticket_channel); 971 972 $channel_name = $channel_name_full; 973 974 975 976 } else { 977 978 $ticket_channel_id = 0; 979 980 $channel_name_full = __('Support Desk','nifty_desk'); 981 982 $channel_name = __('s.desk','nifty_desk'); 983 984 } 985 986 } else { 987 988 $ticket_channel_id = 0; 989 990 $channel_name_full = __('Support Desk','nifty_desk'); 991 992 $channel_name = __('s.desk','nifty_desk'); 993 994 } 995 996 if (isset($post_meta['ticket_status'][0])) { $is_public = $post_meta['ticket_public'][0]; } else { $is_public = false; } 997 998 if (isset($post_meta['ticket_assigned_to'][0])) { $assigned_to = $post_meta['ticket_assigned_to'][0]; } else { $assigned_to = false; } 999 1000 1001 1002 $user_data = get_user_by('id', $assigned_to); 1003 1004 if (!$user_data) { $user_data = (object)[]; $user_data->display_name = "-"; } 1005 1006 1007 1008 1009 1010 $response_count = nifty_desk_cnt_responses( $ticket_id ); 1011 1012 1013 $priority = nifty_desk_return_ticket_priority_returns( $ticket_id ); 1014 1015 1016 1017 $last_updated = false; 1018 1019 if (isset($post_meta['ticket_last_updated'][0])) { 1020 1021 $last_updated = $post_meta['ticket_last_updated'][0]; 1022 1023 } else { 1024 1025 /* backwards compatibility - get last response date and then save it to the 'ticket_last_updated' meta */ 1026 1027 $last_updated = nifty_desk_get_last_updated_time( $ticket_id ); 1028 1029 if ($last_updated) { 1030 1031 /* we found a response date via backwards compa, let's save it so we dont need to do that again. */ 1032 1033 update_post_meta( $ticket_id, 'ticket_last_updated', strtotime($last_updated)); 1034 1035 } 1036 1037 } 1038 1039 if ($last_updated) { 1040 1041 1042 1043 $last_updated_actual = date("Y-m-d H:i:s",intval($last_updated)); 1044 1045 $last_updated = nifty_desk_time_elapsed_string($last_updated); 1046 1047 } else { 1048 1049 $last_updated_actual = '-'; 1050 1051 $last_updated = "-"; 1052 1053 } 1054 1055 1056 1057 $author_id = get_the_author_meta('ID'); 1058 1059 $user_info = get_userdata($author_id); 1060 1061 1062 1063 1064 1065 $author_name = $user_info->display_name; 1066 1067 $author_email = $user_info->user_email; 1068 1069 1070 1071 1072 452 1073 453 if( isset( $post_meta['ticket_status'] ) ){ $nd_ticket_status = $post_meta['ticket_status'][0]; } else { $nd_ticket_status = null; } 454 455 $post_status = nifty_desk_return_ticket_status_html_block( $nd_ticket_status ); 456 457 if (isset($post_meta['ticket_channel_id'])) { 458 459 $ticket_channel = $post_meta['ticket_channel_id'][0]; 460 if (function_exists('nifty_desk_get_ticket_channel_name')) { 461 462 $ticket_channel_id = $ticket_channel; 463 $channel_name_full = nifty_desk_get_ticket_channel_name($ticket_channel); 464 $channel_name = $channel_name_full; 465 466 } else { 467 $ticket_channel_id = 0; 468 $channel_name_full = __('Support Desk','nifty_desk'); 469 $channel_name = __('s.desk','nifty_desk'); 470 } 1074 1075 $ticket_counter++; 1076 1077 if ($ticket_counter <= $limit) { 1078 1079 1080 1081 1082 1083 $ret .= "<tr id='nifty_desk_modern_ticket_row_".$ticket_id."' class='nifty_desk_modern_ticket_row'>"; 1084 1085 $ret .= "<td class='ticket_checkbox'><input type='checkbox' class='nifty_desk_checkbox' value='".$ticket_id."' /></td>"; 1086 1087 $ret .= "<td class='nifty_desk_db_single_ticket ticket_status' ticket_id='".$ticket_id."'>" . $post_status . " ".apply_filters("nifty_desk_return_seen_tag_in_list","",$ticket_id)."</td>"; 1088 1089 $ret .= "<td class='nifty_desk_db_single_ticket ticket_id' ticket_id='".$ticket_id."'>#" . $ticket_id . "</td>"; 1090 1091 $ret .= apply_filters("nifty_desk_ticket_view_list_column_body","",$ticket_id,$post_meta); 1092 1093 $ret .= "<td class='nifty_desk_db_single_ticket ticket_title' ticket_id='".$ticket_id."' ><span title='".get_the_title()."'>" . get_the_title() . "</span></td>"; 1094 1095 $ret .= "<td class='nifty_desk_db_single_ticket ticket_author' ticket_id='".$ticket_id."'><span title='".$author_email."'>" . $author_name . "</span></td>"; 1096 1097 $ret .= "<td class='nifty_desk_db_single_ticket ticket_date' ticket_id='".$ticket_id."'><span title='".date("Y-m-d H:i:s",get_the_date('U'))."'>".nifty_desk_time_elapsed_string(get_the_time('U')) . "</span></td>"; 1098 1099 $ret .= "<td class='nifty_desk_db_single_ticket ticket_updated' ticket_id='".$ticket_id."'><span title='".$last_updated_actual."'>" . $last_updated . "</span></td>"; 1100 1101 $ret .= "<td class='nifty_desk_db_single_ticket ticket_priority' ticket_id='".$ticket_id."'>" . $priority . "</td>"; 1102 1103 $ret .= "<td class='nifty_desk_db_single_ticket ticket_responses' ticket_id='".$ticket_id."'>" . $response_count . "</td>"; 1104 1105 $ret .= "<td class='nifty_desk_db_single_ticket ticket_owner' ticket_id='".$ticket_id."'>" . $user_data->display_name . "</td>"; 1106 1107 $ret .= "<td class='nifty_desk_db_single_ticket ticket_channel' ticket_id='".$ticket_id."'>" . nifty_desk_return_ticket_channel_html_block($channel_name,$ticket_channel_id,$channel_name_full) . "</td>"; 1108 1109 $ret .= "</tr>"; 1110 471 1111 } else { 472 $ticket_channel_id = 0; 473 $ channel_name_full = __('Support Desk','nifty_desk');474 $channel_name = __('s.desk','nifty_desk'); 1112 1113 $is_more = true; 1114 475 1115 } 476 if ( isset( $post_meta['ticket_status'] ) ) { $is_public = $post_meta['ticket_public'][0]; } else { $is_public = false; } 477 if ( isset( $post_meta['ticket_assigned_to'] ) ) { $assigned_to = $post_meta['ticket_assigned_to'][0]; } else { $assigned_to = false; } 478 479 $user_data = get_user_by('id', $assigned_to); 480 if (!$user_data) { $user_data = (object)[]; $user_data->display_name = "-"; } 481 482 $response_count = nifty_desk_cnt_responses( $ticket_id ); 483 $priority = nifty_desk_return_ticket_priority_returns( $ticket_id ); 484 485 $last_updated = false; 486 if ( isset( $post_meta['ticket_last_updated'] ) ) { 487 $last_updated = $post_meta['ticket_last_updated'][0]; 488 } else { 489 /* backwards compatibility - get last response date and then save it to the 'ticket_last_updated' meta */ 490 $last_updated = nifty_desk_get_last_updated_time( $ticket_id ); 491 if ($last_updated) { 492 /* we found a response date via backwards compa, let's save it so we dont need to do that again. */ 493 update_post_meta( $ticket_id, 'ticket_last_updated', strtotime($last_updated)); 494 } 495 } 496 if ($last_updated) { 497 498 $last_updated_actual = date("Y-m-d H:i:s",intval($last_updated)); 499 $last_updated = nifty_desk_time_elapsed_string($last_updated); 500 } else { 501 $last_updated_actual = '-'; 502 $last_updated = "-"; 503 } 504 505 $author_id = get_the_author_meta('ID'); 506 $user_info = get_userdata($author_id); 507 508 509 $author_name = $user_info->display_name; 510 $author_email = $user_info->user_email; 511 512 513 514 $ticket_counter++; 515 if ($ticket_counter <= $limit) { 516 517 518 $ret .= "<tr id='nifty_desk_modern_ticket_row_".$ticket_id."' class='nifty_desk_modern_ticket_row'>"; 519 $ret .= "<td class='ticket_checkbox'><input type='checkbox' class='nifty_desk_checkbox' value='".$ticket_id."' /></td>"; 520 $ret .= "<td class='nifty_desk_db_single_ticket ticket_status' ticket_id='".$ticket_id."'>" . $post_status . "</td>"; 521 $ret .= "<td class='nifty_desk_db_single_ticket ticket_id' ticket_id='".$ticket_id."'>#" . $ticket_id . "</td>"; 522 $ret .= "<td class='nifty_desk_db_single_ticket ticket_title' ticket_id='".$ticket_id."' ><span title='".get_the_title()."'>" . get_the_title() . "</span></td>"; 523 $ret .= "<td class='nifty_desk_db_single_ticket ticket_author' ticket_id='".$ticket_id."'><span title='".$author_email."'>" . $author_name . "</span></td>"; 524 $ret .= "<td class='nifty_desk_db_single_ticket ticket_date' ticket_id='".$ticket_id."'><span title='".date("Y-m-d H:i:s",get_the_date('U'))."'>".nifty_desk_time_elapsed_string(get_the_time('U')) . "</span></td>"; 525 $ret .= "<td class='nifty_desk_db_single_ticket ticket_updated' ticket_id='".$ticket_id."'><span title='".$last_updated_actual."'>" . $last_updated . "</span></td>"; 526 $ret .= "<td class='nifty_desk_db_single_ticket ticket_priority' ticket_id='".$ticket_id."'>" . $priority . "</td>"; 527 $ret .= "<td class='nifty_desk_db_single_ticket ticket_responses' ticket_id='".$ticket_id."'>" . $response_count . "</td>"; 528 $ret .= "<td class='nifty_desk_db_single_ticket ticket_owner' ticket_id='".$ticket_id."'>" . $user_data->display_name . "</td>"; 529 $ret .= "<td class='nifty_desk_db_single_ticket ticket_channel' ticket_id='".$ticket_id."'>" . nifty_desk_return_ticket_channel_html_block($channel_name,$ticket_channel_id,$channel_name_full) . "</td>"; 530 $ret .= "</tr>"; 531 } else { 532 $is_more = true; 533 } 534 535 536 } 1116 1117 1118 1119 1120 } 1121 537 1122 } else { 1123 538 1124 $ret .= "<tr><td colspan='11' style='padding: 10px 0;'>".__('No tickets found', 'nifty_desk')."</td></tr>"; 1125 539 1126 } 1127 540 1128 if ($return_all_counts) { 1129 541 1130 $js = json_encode(array( 1131 542 1132 'ticket_cnt' => $ticket_counter, 1133 543 1134 'ticket_html' => $ret, 1135 544 1136 'is_more' => $is_more, 1137 545 1138 'is_less' => $is_less, 1139 546 1140 'orderby' => $args['orderby'], 1141 547 1142 'order' => $args['order'], 1143 548 1144 'priority' => $priority, 1145 549 1146 'ticket_status' => $status, 1147 550 1148 'cnt' => $my_query->found_posts, 1149 551 1150 'limit' => $limit, 1151 552 1152 'offset' => $offset, 1153 553 1154 'counts' => nifty_desk_return_ticket_count_array() 1155 554 1156 ) 1157 555 1158 ); 1159 556 1160 } else { 1161 557 1162 $js = json_encode(array( 1163 558 1164 'ticket_cnt' => $ticket_counter, 1165 559 1166 'ticket_html' => $ret, 1167 560 1168 'is_more' => $is_more, 1169 561 1170 'is_less' => $is_less, 1171 562 1172 'orderby' => $args['orderby'], 1173 563 1174 'order' => $args['order'], 1175 564 1176 'priority' => $priority, 1177 565 1178 'ticket_status' => $status, 1179 566 1180 'cnt' => $my_query->found_posts, 1181 567 1182 'limit' => $limit, 1183 568 1184 'offset' => $offset 1185 569 1186 ) 1187 570 1188 ); 571 1189 1190 1191 572 1192 } 1193 573 1194 //var_dump($js); 1195 574 1196 update_option("posts_per_page",$posts_per_page_default); 575 1197 1198 1199 576 1200 return $js; 1201 577 1202 } 578 1203 1204 1205 579 1206 function nifty_desk_return_ticket_count_array() { 1207 580 1208 $current_views = get_option("nifty_desk_views"); 581 1209 582 1210 1211 1212 1213 583 1214 $view_array = array(); 1215 584 1216 foreach ($current_views as $key => $view) { 1217 585 1218 $view_array[$key] = intval(nifty_desk_ticket_count_by_view($key)); 586 1219 1220 1221 587 1222 } 1223 588 1224 return $view_array; 589 1225 1226 1227 590 1228 1229 591 1230 } 592 1231 1232 1233 593 1234 function nifty_desk_views_html_output() { 594 1235 1236 1237 595 1238 $current_views = get_option("nifty_desk_views"); 596 1239 1240 1241 597 1242 echo "<p><span class='update-nag'>".sprintf(__("Upgrade to the <a href='%s' target='_BLANK'>Pro version</a> of Nifty Desk and create an unlimited amount of customizable views.","nifty_desk"),'http://niftydesk.org/pro-version/?utm_source=plugin&utm_medium=link&utm_campaign=views')."</span></p>"; 598 1243 599 1244 1245 1246 1247 600 1248 echo "<table class='wp-list-table widefat fixed striped pages'>"; 1249 601 1250 echo "<thead>"; 1251 602 1252 echo "<tr>"; 1253 603 1254 echo "<th>Name</th>"; 1255 604 1256 echo "<th class='nifty_desk_table_action'>Action</th>"; 1257 605 1258 echo "</tr>"; 1259 606 1260 echo "</thead>"; 1261 607 1262 echo "<tbody>"; 1263 608 1264 foreach ($current_views as $key => $view) { 1265 609 1266 echo "<tr id='view_tr_'".$key.">"; 1267 610 1268 echo "<td>".$view['title']."</td>"; 1269 611 1270 echo "<td>".apply_filters("nifty_desk_filter_view_action_control","",$key)."</td>"; 1271 612 1272 echo "</tr>"; 613 1273 614 1274 1275 1276 1277 615 1278 } 1279 616 1280 echo "</tbody>"; 1281 617 1282 echo "</table>"; 618 1283 619 1284 1285 1286 1287 620 1288 } 621 1289 1290 1291 622 1292 function nifty_desk_set_default_views() { 1293 623 1294 $current_views = array( 1295 624 1296 1 => array( 1297 625 1298 "readonly" => true, 1299 626 1300 "active" => 1, 1301 627 1302 "title" => __("Your unsolved tickets","nifty_desk"), 1303 628 1304 "data" => array( 1305 629 1306 "status" => array( 1307 630 1308 "-1" => true, 1309 631 1310 "0" => true, 1311 632 1312 "3" => true, 1313 633 1314 "9" => true 1315 634 1316 ), 1317 635 1318 "priority" => false, 1319 636 1320 "agents" => array( 1321 637 1322 "current_agent" => true 1323 638 1324 ), 1325 639 1326 "orderby" => "date", 1327 640 1328 "order" => "asc", 1329 641 1330 "department" => false 1331 642 1332 ) 1333 643 1334 ), 1335 644 1336 2 => array( 1337 645 1338 "readonly" => true, 1339 646 1340 "active" => 1, 1341 647 1342 "title" => __("All unsolved tickets","nifty_desk"), 1343 648 1344 "data" => array( 1345 649 1346 "status" => array( 1347 650 1348 "0" => true, 1349 651 1350 "3" => true, 1351 652 1352 "9" => true 1353 653 1354 ), 1355 654 1356 "priority" => false, 1357 655 1358 "agents" => false, 1359 656 1360 "orderby" => "date", 1361 657 1362 "order" => "asc", 1363 658 1364 "department" => false 1365 659 1366 ) 1367 660 1368 ), 1369 661 1370 3 => array( 1371 662 1372 "readonly" => true, 1373 663 1374 "active" => 1, 1375 664 1376 "title" => __("New tickets","nifty_desk"), 1377 665 1378 "data" => array( 1379 666 1380 "status" => array( 1381 667 1382 "9" => true 1383 668 1384 ), 1385 669 1386 "priority" => false, 1387 670 1388 "agents" => false, 1389 671 1390 "orderby" => "date", 1391 672 1392 "order" => "asc", 1393 673 1394 "department" => false 1395 674 1396 ) 1397 675 1398 ), 1399 676 1400 4 => array( 1401 677 1402 "readonly" => true, 1403 678 1404 "active" => 1, 1405 679 1406 "title" => __("Open tickets","nifty_desk"), 1407 680 1408 "data" => array( 1409 681 1410 "status" => array( 1411 682 1412 "0" => true 1413 683 1414 ), 1415 684 1416 "priority" => false, 1417 685 1418 "agents" => false, 1419 686 1420 "orderby" => "date", 1421 687 1422 "order" => "asc", 1423 688 1424 "department" => false 1425 689 1426 ) 1427 690 1428 ), 1429 691 1430 5 => array( 1431 692 1432 "readonly" => true, 1433 693 1434 "active" => 1, 1435 694 1436 "title" => __("Pending tickets","nifty_desk"), 1437 695 1438 "data" => array( 1439 696 1440 "status" => array( 1441 697 1442 "3" => true 1443 698 1444 ), 1445 699 1446 "priority" => false, 1447 700 1448 "agents" => false, 1449 701 1450 "orderby" => "date", 1451 702 1452 "order" => "asc", 1453 703 1454 "department" => false 1455 704 1456 ) 1457 705 1458 ), 1459 706 1460 6 => array( 1461 707 1462 "readonly" => true, 1463 708 1464 "active" => 0, 1465 709 1466 "title" => __("Closed Tickets","nifty_desk"), 1467 710 1468 "data" => array( 1469 711 1470 "status" => array( 1471 712 1472 "1" => true, 1473 713 1474 "2" => true 1475 714 1476 ), 1477 715 1478 "priority" => false, 1479 716 1480 "agents" => false, 1481 717 1482 "orderby" => "date", 1483 718 1484 "order" => "asc", 1485 719 1486 "department" => false 1487 720 1488 ) 1489 721 1490 ) 722 1491 723 1492 1493 1494 1495 724 1496 ); 725 1497 1498 1499 726 1500 update_option("nifty_desk_views",$current_views); 1501 727 1502 } 728 1503 1504 1505 729 1506 function nifty_desk_output_ticket_actions($ticket_id) { 730 1507 731 1508 1509 1510 1511 732 1512 if( current_user_can('manage_options' ) ){ 1513 733 1514 $delete_button = '<a href="javascript:void(0);" id="nifty_desk_delete_ticket" ticket_id="'.$ticket_id.'">'.__('Delete', 'nifty_desk').'</a>'; 1515 734 1516 } else { 1517 735 1518 $delete_button = ""; 736 } 1519 1520 } 1521 1522 1523 737 1524 738 1525 739 1526 $ret .= '<div class="nifty_desk_dropdown_button">'; 1527 740 1528 $ret .= ' <span><a href="javascript:void(0);" class="button button-secondary nifty_desk_action_button">'.__("Actions","nifty_desk").' <span class="nifty_desk_more_button"> <span></a></span>'; 1529 741 1530 $ret .= ' <div class="nifty_desk_dropdown-content">'; 1531 742 1532 $ret .= $delete_button.''; 1533 743 1534 $ret .= ' <a href="javascript:void(0);" id="nifty_desk_merge_ticket" ticket_id="'.$ticket_id.'">'.__('Merge into another ticket', 'nifty_desk').'</a>'; 1535 744 1536 $ret .= ' </div>'; 1537 745 1538 $ret .= '</div>'; 746 1539 747 1540 1541 1542 1543 748 1544 return $ret; 749 1545 1546 1547 750 1548 } 751 1549 1550 1551 752 1552 function nifty_desk_check_for_followup($ticket_id) { 1553 753 1554 $check = get_post_meta( $ticket_id, '_ticket_follow_up', true ); 1555 754 1556 if ($check) { 755 1557 1558 1559 756 1560 $merged_link = sprintf( __( 'This ticket was a follow up from <a href="javascript:void(0);" tid="%1$s" class="nifty_desk_followup_from">#%1$s</a>.</a>', 'nifty_desk' ), 1561 757 1562 $check 1563 758 1564 ); 1565 759 1566 return "<span class='nifty_desk_error' id='nifty_desk_followup_from_".$check."'>".$merged_link."</span>"; 1567 760 1568 } 1569 761 1570 } 762 1571 763 1572 1573 1574 1575 764 1576 function nifty_desk_check_for_merge($ticket_id) { 1577 765 1578 $check = get_post_meta( $ticket_id, '_nifty_desk_merged_with', true ); 1579 766 1580 if ($check) { 767 1581 1582 1583 768 1584 $merged_link = sprintf( __( 'This ticket was merged into <a href="javascript:void(0);" tid="%1$s" class="nifty_desk_merged_with">#%1$s</a>.</a>', 'nifty_desk' ), 1585 769 1586 $check 1587 770 1588 ); 1589 771 1590 return "<span class='nifty_desk_error' id='nifty_desk_merged_with_".$check."'>".$merged_link."</span>"; 1591 772 1592 } 1593 773 1594 } 774 1595 775 1596 1597 1598 1599 776 1600 function nifty_desk_check_for_merge_from($ticket_id) { 1601 777 1602 $check = get_post_meta( $ticket_id, '_nifty_desk_merged_from', true ); 1603 778 1604 if ($check) { 779 1605 1606 1607 780 1608 $merged_link = sprintf( __( 'This ticket was merged from <a href="javascript:void(0);" tid="%1$s" class="nifty_desk_merged_with">#%1$s</a>.</a>', 'nifty_desk' ), 1609 781 1610 $check 1611 782 1612 ); 1613 783 1614 return "<span class='nifty_desk_error' id='nifty_desk_merged_with_".$check."'>".$merged_link."</span>"; 1615 784 1616 } 1617 785 1618 } 786 1619 1620 1621 787 1622 function nifty_desk_get_last_updated_time($ticket_id) { 1623 788 1624 1625 789 1626 $data = nifty_desk_get_last_response( $ticket_id ); 1627 790 1628 if (isset($data->post_author)) { 1629 791 1630 $author = $data->post_author; 1631 792 1632 if ($author) { 1633 793 1634 $author_data = get_userdata($author); 1635 794 1636 return $data->post_date; 1637 795 1638 } else { 1639 796 1640 return false; 1641 797 1642 } 1643 798 1644 } else { 1645 799 1646 return false; 1647 800 1648 } 1649 801 1650 } 802 1651 803 1652 1653 1654 1655 804 1656 add_filter("nifty_desk_response_after_author_name","nifty_desk_filter_control_response_after_author_name",10,2); 1657 805 1658 function nifty_desk_filter_control_response_after_author_name($content,$ticket_id) { 1659 806 1660 $ticket_raw = get_post_meta($ticket_id, 'ticket_full_raw', true ); 1661 807 1662 $ticket_html = get_post_meta($ticket_id, 'ticket_html', true ); 808 1663 1664 1665 809 1666 if ($ticket_raw) { 1667 810 1668 $content .= " | <a href='".admin_url("?nifty_desk_raw=".$ticket_id)."' target='_BLANK' class='nifty_desk_view_front_end'>view email source</a>"; 1669 811 1670 } 1671 812 1672 if ($ticket_html) { 1673 813 1674 $content .= " | <a href='".admin_url("?nifty_desk_html=".$ticket_id)."' target='_BLANK' class='nifty_desk_view_front_end'>view HTML</a>"; 1675 814 1676 } 815 1677 1678 1679 816 1680 return $content; 817 1681 1682 1683 818 1684 } 819 1685 1686 1687 820 1688 function nifty_desk_mark_ticket_as_read($tid) { 1689 821 1690 update_post_meta ($tid, 'nifty_desk_seen', current_time('timestamp')); 1691 822 1692 } -
nifty-desk/trunk/modules/widgets.php
r1535609 r1592607 43 43 $post_user_data = get_user_by('email',$originator_email); 44 44 $post_user = $post_user_data->ID; 45 46 45 $username = $post_user_data->data->display_name; 46 47 47 } else { 48 48 /* create the user */ -
nifty-desk/trunk/nifty-desk.php
r1545853 r1592607 4 4 Plugin URI: http://niftydesk.org/ 5 5 Description: Create a support centre within your WordPress admin. No need for third party systems! 6 Version: 1.0 16 Version: 1.02 7 7 Author: CODECABIN_ 8 8 Author URI: http://niftydesk.org/ 9 9 */ 10 10 11 /** 12 * 1.01 - 2016-11-29 - Medium Priority 13 * Fixed a PHP syntax error 11 /* 12 * 1.02 - 2017-02-09 - Medium Priority 13 * You can now search for tickets based on the author email address 14 * Bug Fix: Correct timestamp shown in search results for last responder 15 * Bug Fix: Author name displays correctly in search results 16 * Bug Fix: Slashes are now removed from ticket replies 17 * Bug Fix: Two PHP errors after submitting a ticket while logged in 18 * Bug Fix: Headers already sent once a ticket is submitted and needs to redirect to the thank you page 19 * Enhancement: You can now close the 'Merge Tickets' popup by pressing the escape key 20 * Bug Fix: Changing originator's email address will change their display name in the ticket too 21 * Enhancement: Styling fixes made to the 'Merge Tickets' popup 22 * 23 * 1.01 - 2016-11-22 24 * Fixed bugs when creating a ticket from the API (no last_update timestamp and support tickets were being incorrectly assigned) 25 * Fixed a bug when creating a ticket from the front end (user's side) 26 * Fixed a bug that caused html entities to show up incorrectly in tickets 27 * Added a check in place to abort the previous XHR requests when clicking on views sequentially 14 28 * 15 29 * 1.00 - 2016-11-17 - Launch … … 21 35 global $nifty_desk_version; 22 36 global $nifty_desk_version_string; 23 $nifty_desk_version = "1.0 1";37 $nifty_desk_version = "1.02"; 24 38 $nifty_desk_version_string = "basic"; 25 39 … … 33 47 include_once "modules/email.php"; 34 48 include_once "modules/widgets.php"; 49 include_once "modules/archive.php"; 35 50 include_once "templates/templates.php"; 36 51 … … 50 65 51 66 if (function_exists("nifty_desk_pro_user_head")) { 52 add_action(' wp_head', 'nifty_desk_pro_user_head');67 add_action('init', 'nifty_desk_pro_user_head'); 53 68 } else { 54 add_action(' wp_head', 'nifty_desk_user_head');69 add_action('init', 'nifty_desk_user_head'); 55 70 } 56 71 if (function_exists("nifty_desk_pro_admin_head")) { … … 351 366 } 352 367 368 function nifty_desk_normalize($text) { 369 return $text; 370 } 371 372 353 373 /** 354 374 * Nifty Desk Activation Function … … 908 928 /* update parent's 'last updated' time */ 909 929 update_post_meta( $parent_id, 'ticket_last_updated', current_time('timestamp') ); 930 931 932 $ticket_array = array( 933 'ticket_id' => $post_id, 934 'parent_id' => $parent_id, 935 'content' => $content, 936 'userid' => $author 937 ); 938 do_action("nifty_desk_after_create_response",$ticket_array); 910 939 911 940 … … 1159 1188 if(is_object(get_userdata($userid))) { 1160 1189 $user_email = get_userdata($userid)->user_email; 1190 } else { 1191 $user_email = null; 1161 1192 } 1162 1193 … … 1886 1917 1887 1918 $nifty_desk_settings = get_option("nifty_desk_settings"); 1888 1919 $title = sanitize_text_field( $_POST['nifty_desk_ticket_title'] ); 1889 1920 $data = array( 1890 1921 'post_content' => $content, 1891 1922 'post_status' => 'publish', 1892 'post_title' => sanitize_text_field( $_POST['nifty_desk_ticket_title'] ),1923 'post_title' => $title, 1893 1924 'post_type' => 'nifty_desk_tickets', 1894 1925 'post_author' => get_current_user_id(), … … 1899 1930 1900 1931 $custom_fields = get_post_custom($post_id); 1901 if (!isset($custom_fields['ticket_status'])) { 1902 add_post_meta($post_id, 'ticket_status', '9', true); 1903 } else { 1904 add_post_meta($post_id, 'ticket_status', '', true); 1905 } 1906 if (!isset($custom_fields['ticket_public'])) { 1907 add_post_meta($post_id, 'ticket_public', '0', true); 1908 } else { 1909 add_post_meta($post_id, 'ticket_public', '', true); 1910 } 1932 if (!isset($custom_fields['ticket_status'])) { add_post_meta($post_id, 'ticket_status', '9', true); } else { add_post_meta($post_id, 'ticket_status', '', true); } 1933 if (!isset($custom_fields['ticket_public'])) { add_post_meta($post_id, 'ticket_public', '0', true); } else { add_post_meta($post_id, 'ticket_public', '', true); } 1911 1934 1912 1935 if (isset($_POST['nifty_desk_submit_priority'])) { … … 1921 1944 } 1922 1945 1923 if (!isset($custom_fields['ticket_assigned_to'])) { 1924 if (!get_option("nifty_desk_default_assigned_to")) { 1925 $super_admins = get_super_admins(); 1926 $user = get_user_by('slug', $super_admins[0]); 1927 if(is_object($user)) { 1928 add_option('nifty_desk_default_assigned_to', $user->ID); 1929 } 1930 } 1931 $default_user = get_option("nifty_desk_default_assigned_to"); 1932 add_post_meta($post_id, 'ticket_assigned_to', $default_user, true); 1933 } else { 1934 add_post_meta($post_id, 'ticket_assigned_to', '', true); 1935 } 1946 $ticket_array = array( 1947 'ticket_id' => $post_id, 1948 'title' => $title, 1949 'content' => $content 1950 ); 1951 do_action("nifty_desk_after_create_ticket",$ticket_array); 1952 1953 $assigned_to = apply_filters("nifty_desk_assigned_to_new_ticket",false); 1954 if ($assigned_to) { update_post_meta( $post_id, 'ticket_assigned_to', $assigned_to); } 1936 1955 update_post_meta( $post_id, 'ticket_last_updated', current_time('timestamp')); 1937 1938 1956 add_post_meta($post_id, 'ticket_reference', md5($post_id . get_current_user_id()), true); 1939 1957 nifty_desk_notification_control('ticket', $post_id, get_current_user_id()); … … 3368 3386 $php_mailer_object->msgHTML($message."<br/><br/> <b>Sent using SMTP settings</b>"); 3369 3387 3370 if(!$php_mailer_object->send()) { $result=use_wp_mail_as_default($email, $subject, $message, $wp_mail_headers,$attachments ); }3388 if(!$php_mailer_object->send()) { $result=use_wp_mail_as_default($email, $subject, $message, $wp_mail_headers,$attachments, $post_id); } 3371 3389 else { 3372 3390 $result=true; … … 3375 3393 } 3376 3394 else { 3377 $result=use_wp_mail_as_default($email, $subject, $message, $wp_mail_headers,$attachments );3395 $result=use_wp_mail_as_default($email, $subject, $message, $wp_mail_headers,$attachments, $post_id); 3378 3396 } 3379 3397 if (!$result && $post_id) { … … 3454 3472 * @return boolean ? 3455 3473 */ 3456 function use_wp_mail_as_default($email,$subject,$message,$wp_mail_headers,$attachments = false ) {3474 function use_wp_mail_as_default($email,$subject,$message,$wp_mail_headers,$attachments = false, $post_id = false) { 3457 3475 add_filter( 'wp_mail_content_type', 'nifty_desk_set_html_mail_content_type' ); 3458 3476 $message = apply_filters("nifty_desk_wrap_body_in_html",$message); … … 3462 3480 if(is_array($wp_mail_headers)) 3463 3481 { 3464 $headers_mail = 'From: '.$wp_mail_headers['from_name'].' < '.$wp_mail_headers['from_email'].' >' ."\r\n"; 3465 $headers_mail.= 'Reply-To: '.$wp_mail_headers['replyto_name'].' < '.$wp_mail_headers['replyto_address'].' >' ."\r\n"; 3482 $headers_mail = array(); 3483 $headers_mail[] = 'From: '.$wp_mail_headers['from_name'].' < '.$wp_mail_headers['from_email'].' >' ; 3484 $headers_mail[] = 'Reply-To: '.$wp_mail_headers['replyto_name'].' < '.$wp_mail_headers['replyto_address'].' >' ; 3466 3485 if (isset($wp_mail_headers['In-Reply-To'])) { 3467 $headers_mail .= 'In-Reply-To: '.$wp_mail_headers['In-Reply-To']."\r\n";3468 $headers_mail .= 'References: '.$wp_mail_headers['References']."\r\n";3486 $headers_mail[] = 'In-Reply-To: '.$wp_mail_headers['In-Reply-To']; 3487 $headers_mail[] = 'References: '.$wp_mail_headers['References']; 3469 3488 } 3470 3489 //$headers_mail.= 'Content-type: text/html; charset=utf-8' . "\r\n"; 3471 //$headers_mail.= 'MIME-Version: 1.0' . "\r\n"; 3472 $result=wp_mail($email,$subject,$message.nifty_desk_signature(),$headers_mail,$attachments); 3490 //$headers_mail.= 'MIME-Version: 1.0' . "\r\n"; 3491 3492 $headers_mail = apply_filters( 'nifty_desk_email_header_filter_string', $headers_mail, $post_id ); 3493 3494 $result=wp_mail($email,$subject,$message.nifty_desk_signature(),$headers_mail,$attachments); 3473 3495 } 3474 3496 else … … 4065 4087 4066 4088 4089 function nifty_desk_get_post_meta_last_non_agent($post_id){ 4090 global $wpdb; 4091 $data = array(); 4092 $sql = "SELECT `meta_key`, `meta_value`, `post_id` FROM $wpdb->postmeta WHERE `meta_key` = '_response_parent_id' AND `meta_value` = '$post_id' ORDER BY `meta_id` DESC LIMIT 3"; 4093 4094 $results = $wpdb->get_results($sql); 4095 $i = 0; 4096 4097 foreach($results as $k => $v){ 4098 if (isset($v->post_id)) { 4099 $tmp_post_id = $v->post_id; 4100 $post_data = get_post($tmp_post_id); 4101 $post_author = $post_data->post_author; 4102 if (get_the_author_meta('nifty_desk_agent', $post_author) != "1") { 4103 /* this came from a non-agent */ 4104 $data[0] = $v; 4105 break; 4106 } 4107 } 4108 4109 4110 $i++; 4111 }; 4112 return $data; 4113 } 4114 4115 4116 4117 4067 4118 /** 4068 4119 * Checks if any of the system pages have been trashed (not deleted forever) -
nifty-desk/trunk/readme.txt
r1545854 r1592607 4 4 Tags: support ticket, support tickets, support, support plugin, ticket plugin, tickets, helpdesk, help desk, support desk 5 5 Requires at least: 3.5 6 Tested up to: 4.7 6 Tested up to: 4.7.2 7 7 Stable tag: trunk 8 8 License: GPLv2 … … 98 98 == Changelog == 99 99 100 = 1.01 - 2016-12-05 - Medium Priority = 101 * Fixed a PHP syntax error 100 = 1.02 - 2017-02-09 - Medium Priority = 101 * You can now search for tickets based on the author email address 102 * Bug Fix: Correct timestamp shown in search results for last responder 103 * Bug Fix: Author name displays correctly in search results 104 * Bug Fix: Slashes are now removed from ticket replies 105 * Bug Fix: Two PHP errors after submitting a ticket while logged in 106 * Bug Fix: Headers already sent once a ticket is submitted and needs to redirect to the thank you page 107 * Enhancement: You can now close the 'Merge Tickets' popup by pressing the escape key 108 * Bug Fix: Changing originator's email address will change their display name in the ticket too 109 * Enhancement: Styling fixes made to the 'Merge Tickets' popup 110 111 = 1.01 - 2016-11-22 = 112 * Fixed bugs when creating a ticket from the API (no last_update timestamp and support tickets were being incorrectly assigned) 113 * Fixed a bug when creating a ticket from the front end (user's side) 114 * Fixed a bug that caused html entities to show up incorrectly in tickets 115 * Added a check in place to abort the previous XHR requests when clicking on views sequentially 102 116 103 117 = 1.00 - 2016-11-17 - Launch =
Note: See TracChangeset
for help on using the changeset viewer.