From 754eb6f40b34a8ed2e511894ef4b1d58f5baaea4 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 12:23:15 -0500 Subject: [PATCH 01/33] Fixed Undefined Email Element Bug Since there wasn't a check for the email element before trying to validate it, admins who had the quiz set up without the email field were receiving javascript errors and validation was not working. I have decided to merge this check into the new validation system that I have been building. --- includes/mlw_quiz.php | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/includes/mlw_quiz.php b/includes/mlw_quiz.php index ceab4f291..5055aff45 100644 --- a/includes/mlw_quiz.php +++ b/includes/mlw_quiz.php @@ -459,23 +459,24 @@ function clear_field(field) function mlw_validateForm() { mlw_validateResult = true; - if (document.forms['quizForm']['mlwUserEmail'].value != '') - { - var x=document.forms['quizForm']['mlwUserEmail'].value; - var atpos=x.indexOf('@'); - var dotpos=x.lastIndexOf('.'); - if (atpos<1 || dotpos=x.length) - { - document.getElementById('mlw_error_message').innerHTML = '**Not a valid e-mail address!**'; - document.getElementById('mlw_error_message_bottom').innerHTML = '**Not a valid e-mail address!**'; - mlw_validateResult = false; - } - } jQuery('#quizForm *').filter(':input').each(function(){ jQuery(this).css("outline", ""); if (jQuery(this).attr('class')) { + if(jQuery(this).attr('class').indexOf('mlwEmail') > -1 && this.value != "") + { + var x=this.value; + var atpos=x.indexOf('@'); + var dotpos=x.lastIndexOf('.'); + if (atpos<1 || dotpos=x.length) + { + document.getElementById('mlw_error_message').innerHTML = '**Not a valid e-mail address!**'; + document.getElementById('mlw_error_message_bottom').innerHTML = '**Not a valid e-mail address!**'; + mlw_validateResult = false; + jQuery(this).css("outline", "2px solid red"); + } + } if(jQuery(this).attr('class').indexOf('mlwRequiredNumber') > -1 && this.value == "" && +this.value != NaN) { document.getElementById('mlw_error_message').innerHTML = '**This field must be a number!**'; @@ -1445,10 +1446,10 @@ function mlwDisplayContactInfo($mlw_quiz_options) } if ($mlw_quiz_options->user_email != 2) { - $mlw_contact_class = "class=\"\""; + $mlw_contact_class = "class=\"mlwEmail\""; if ($mlw_quiz_options->user_email == 1) { - $mlw_contact_class = "class=\"mlwRequiredText\""; + $mlw_contact_class = "class=\"mlwEmail mlwRequiredText\""; } $mlw_contact_display .= "".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."
"; $mlw_contact_display .= ""; @@ -1499,10 +1500,10 @@ function mlwDisplayContactInfo($mlw_quiz_options) } if ($mlw_quiz_options->user_email != 2) { - $mlw_contact_class = "class=\"\""; + $mlw_contact_class = "class=\"mlwEmail\""; if ($mlw_quiz_options->user_email == 1) { - $mlw_contact_class = "class=\"mlwRequiredText\""; + $mlw_contact_class = "class=\"mlwEmail mlwRequiredText\""; } $mlw_contact_display .= "".htmlspecialchars_decode($mlw_quiz_options->email_field_text, ENT_QUOTES)."
"; $mlw_contact_display .= ""; From 96715b30762b5007102ddacd2ff7b7f393cd1ac4 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 13:40:47 -0500 Subject: [PATCH 02/33] Created Initial Dashboard Widget File --- includes/qmn_dashboard_widgets.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 includes/qmn_dashboard_widgets.php diff --git a/includes/qmn_dashboard_widgets.php b/includes/qmn_dashboard_widgets.php new file mode 100644 index 000000000..6e11b2c99 --- /dev/null +++ b/includes/qmn_dashboard_widgets.php @@ -0,0 +1,18 @@ + From a1cadc3a8e64a5ef0eb7a2a3f368f2914fd36088 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 13:43:27 -0500 Subject: [PATCH 03/33] Added Daily Total To Dashboard Widget --- includes/qmn_dashboard_widgets.php | 40 +++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/includes/qmn_dashboard_widgets.php b/includes/qmn_dashboard_widgets.php index 6e11b2c99..7a9d6cb26 100644 --- a/includes/qmn_dashboard_widgets.php +++ b/includes/qmn_dashboard_widgets.php @@ -13,6 +13,44 @@ function qmn_add_dashboard_widget() function qmn_snapshot_dashboard_widget() { - + global $wpdb; + $mlw_qmn_today_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".date("Y-m-d")." 00:00:00' AND '".date("Y-m-d")." 23:59:59') AND deleted=0"); + $mlw_last_week = mktime(0, 0, 0, date("m") , date("d")-7, date("Y")); + $mlw_last_week = date("Y-m-d", $mlw_last_week); + $mlw_qmn_last_weekday_taken = $wpdb->get_var( "SELECT COUNT(*) FROM " . $wpdb->prefix . "mlw_results WHERE (time_taken_real BETWEEN '".$mlw_last_week." 00:00:00' AND '".$mlw_last_week." 23:59:59') AND deleted=0"); + if ($mlw_qmn_last_weekday_taken != 0) + { + $mlw_qmn_analyze_today = round((($mlw_qmn_today_taken - $mlw_qmn_last_weekday_taken) / $mlw_qmn_last_weekday_taken) * 100, 2); + } + else + { + $mlw_qmn_analyze_today = $mlw_qmn_today_taken * 100; + } + ?> +
+ + + + + + + + +
 
+
+ ".$mlw_qmn_analyze_today."%"; + if ($mlw_qmn_analyze_today >= 0) + { + echo ""; + } + else + { + echo ""; + } + ?> +
+
+
} ?> From a632ef545fc12a01bf81a636b17d0060eb03f8bd Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 15:16:48 -0500 Subject: [PATCH 04/33] Added Stats To Dashboard Widget Added active quiz stat, active question stat, most popular quiz, and least popular quiz. --- includes/qmn_dashboard_widgets.php | 120 +++++++++++++++++++++++++---- 1 file changed, 103 insertions(+), 17 deletions(-) diff --git a/includes/qmn_dashboard_widgets.php b/includes/qmn_dashboard_widgets.php index 7a9d6cb26..9d9817074 100644 --- a/includes/qmn_dashboard_widgets.php +++ b/includes/qmn_dashboard_widgets.php @@ -26,31 +26,117 @@ function qmn_snapshot_dashboard_widget() { $mlw_qmn_analyze_today = $mlw_qmn_today_taken * 100; } + + $mlw_stat_total_active_quiz = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0 LIMIT 1" ); + $mlw_stat_total_questions = $wpdb->get_var( "SELECT COUNT(*) FROM ".$wpdb->prefix."mlw_questions WHERE deleted=0 LIMIT 1" ); + + $mlw_stat_most_popular_quiz = $wpdb->get_row( "SELECT quiz_name FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0 ORDER BY quiz_taken Desc LIMIT 1" ); + $mlw_stat_least_popular_quiz = $wpdb->get_row( "SELECT quiz_name FROM ".$wpdb->prefix."mlw_quizzes WHERE deleted=0 ORDER BY quiz_taken ASC LIMIT 1" ); ?> -
- - - - - - - - -
 
-
+ +
    +
  • +
    + + quizzes taken today + ".$mlw_qmn_analyze_today."%"; + echo $mlw_qmn_analyze_today."% "; if ($mlw_qmn_analyze_today >= 0) { - echo ""; + echo ""; } else { - echo ""; + echo ""; } ?> -
    -
-
+ + + +
  • +
    + + total active quizzes +
    +
  • +
  • +
    + + total active questions +
    +
  • +
  • +
    + quiz_name; ?> + most popular quiz +
    +
  • +
  • +
    + quiz_name; ?> + least popular quiz +
    +
  • + + From 63ad7de36d1b41a0d5e19e90add49a7995f2b6fd Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 15:25:24 -0500 Subject: [PATCH 05/33] Added Include For Dashboard Widget --- mlw_quizmaster2.php | 1 + 1 file changed, 1 insertion(+) diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index 09f7da032..591bb1e20 100644 --- a/mlw_quizmaster2.php +++ b/mlw_quizmaster2.php @@ -84,6 +84,7 @@ private function load_dependencies() include("includes/mlw_template_variables.php"); include("includes/mlw_adverts.php"); include("includes/mlw_alerts.php"); + include("includes/qmn_dashboard_widgets.php"); $this->alertManager = new MlwQmnAlertManager(); From 0126d06a68c7ba1176eb3b8a20b29b09d96c29e7 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 17:23:19 -0500 Subject: [PATCH 06/33] Created System Info Function Created system information function and widget. Added system information function to support widget for sending the info with email. --- includes/mlw_help.php | 252 ++++++++++++++++++++++++++++++++---------- 1 file changed, 192 insertions(+), 60 deletions(-) diff --git a/includes/mlw_help.php b/includes/mlw_help.php index af12a1903..cd62c7e86 100644 --- a/includes/mlw_help.php +++ b/includes/mlw_help.php @@ -8,70 +8,202 @@ function mlw_generate_help_page() { + ///Creates the widgets + add_meta_box("wpss_mrts", 'Plugin Documentation', "qmn_documentation_meta_box_content", "meta_box_help"); + add_meta_box("wpss_mrts", 'Support', "qmn_support_meta_box_content", "meta_box_support"); + add_meta_box("wpss_mrts", 'System Info', "qmn_system_meta_box_content", "meta_box_sys_info"); ?> - - - +
    +

    QMN Help

    + + + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +

    Need help with the plugin? Try any of the following:

    + ", "\n", $mlw_site_info); + $mlw_site_info = str_replace("

    ", "\n", $mlw_site_info); + $mlw_site_info = str_replace("

    ", "\n", $mlw_site_info); + if ($quiz_master_email_success == 'update') + { + $mlw_message = "Message from ".$user_name." at ".$user_email." It says: \n \n ".$user_message."\n Version: ".$mlw_quiz_version."\n Quiz URL Provided: ".$user_quiz_url."\n User ".$current_user->display_name." from ".$current_user->user_email."\n Wordpress Info: ".$mlw_site_info; + wp_mail('fpcorso@mylocalwebstop.com' ,'Support From Quiz Master Next Plugin', $mlw_message); + $quiz_master_email_message = "**Message Sent**"; + } + } ?> - - - - -
    -
    -

    How-To(?)

    - Please visit our new Documentation for using this plugin. It is a work in progress, but we will be deleting this page once it is finished. -
    -
    -

    Help

    -

    This page contains numerous how-to's for using the plugin.

    -
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    If there is something you would like to suggest to add or even if you just want + to let me know if you like the plugin or not, feel free to use the email form below.
    Name (Required):
    Email (Required):
    URL To Quiz (Not Required):
    Message (Required):
    +
    +

    Disclaimer: In order to better assist you, this form will also send the system info from below with your message.

    -
    - \ No newline at end of file + +function qmn_get_system_info() +{ + global $wpdb; + $qmn_sys_info = ""; + + $theme_data = wp_get_theme(); + $theme = $theme_data->Name . ' ' . $theme_data->Version; + + $qmn_sys_info .= "

    Site Information


    "; + $qmn_sys_info .= "Site URL: ".site_url()."
    "; + $qmn_sys_info .= "Home URL: ".home_url()."
    "; + $qmn_sys_info .= "Multisite: ".( is_multisite() ? 'Yes' : 'No' )."
    "; + + $qmn_sys_info .= "

    WordPress Information


    "; + $qmn_sys_info .= "Version: ".get_bloginfo( 'version' )."
    "; + $qmn_sys_info .= "Language: ".( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' )."
    "; + $qmn_sys_info .= "Active Theme: ".$theme."
    "; + $qmn_sys_info .= "Debug Mode: ".( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' )."
    "; + $qmn_sys_info .= "Memory Limit: ".WP_MEMORY_LIMIT."
    "; + + $qmn_sys_info .= "

    Plugins Information


    "; + $qmn_plugin_mu = get_mu_plugins(); + if( count( $qmn_plugin_mu > 0 ) ) { + $qmn_sys_info .= "

    Must Use


    "; + foreach( $qmn_plugin_mu as $plugin => $plugin_data ) { + $qmn_sys_info .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "
    "; + } + } + $qmn_sys_info .= "

    Active


    "; + $plugins = get_plugins(); + $active_plugins = get_option( 'active_plugins', array() ); + foreach( $plugins as $plugin_path => $plugin ) { + if( !in_array( $plugin_path, $active_plugins ) ) + continue; + $qmn_sys_info .= $plugin['Name'] . ': ' . $plugin['Version'] . "
    "; + } + $qmn_sys_info .= "

    Inactive


    "; + foreach( $plugins as $plugin_path => $plugin ) { + if( in_array( $plugin_path, $active_plugins ) ) + continue; + $qmn_sys_info .= $plugin['Name'] . ': ' . $plugin['Version'] . "
    "; + } + + $qmn_sys_info .= "

    Server Information


    "; + $qmn_sys_info .= "PHP : ".PHP_VERSION."
    "; + $qmn_sys_info .= "MySQL : ".$wpdb->db_version()."
    "; + $qmn_sys_info .= "Webserver : ".$_SERVER['SERVER_SOFTWARE']."
    "; + + return $qmn_sys_info; +} + +?> From 90129d7a1938ffd1e8883abed14f3dd46614779c Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 17:23:47 -0500 Subject: [PATCH 07/33] Include Help File --- mlw_quizmaster2.php | 1 + 1 file changed, 1 insertion(+) diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index 591bb1e20..b645b2e27 100644 --- a/mlw_quizmaster2.php +++ b/mlw_quizmaster2.php @@ -84,6 +84,7 @@ private function load_dependencies() include("includes/mlw_template_variables.php"); include("includes/mlw_adverts.php"); include("includes/mlw_alerts.php"); + include("includes/mlw_help.php"); include("includes/qmn_dashboard_widgets.php"); $this->alertManager = new MlwQmnAlertManager(); From bc8cbfb35b2aca3e370395f97c3c9022d96ac844 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 17:30:44 -0500 Subject: [PATCH 08/33] Moved Support Widget To Help Page --- includes/mlw_dashboard.php | 157 ++----------------------------------- 1 file changed, 6 insertions(+), 151 deletions(-) diff --git a/includes/mlw_dashboard.php b/includes/mlw_dashboard.php index f11355d4b..95782352a 100644 --- a/includes/mlw_dashboard.php +++ b/includes/mlw_dashboard.php @@ -6,53 +6,16 @@ Copyright 2014, My Local Webstop (email : fpcorso@mylocalwebstop.com) */ -function mlw_generate_quiz_dashboard(){ - - //Support Email Validation Script - echo " - - "; - +function mlw_generate_quiz_dashboard() +{ //Page Variables $mlw_quiz_version = get_option('mlw_quiz_master_version'); - ///Creates the widgets add_meta_box("wpss_mrts", 'Quiz Daily Stats - Times Taken', "mlw_dashboard_box", "quiz_wpss"); add_meta_box("wpss_mrts", 'Quiz Total Stats', "mlw_dashboard_box_three", "quiz_wpss3"); add_meta_box("wpss_mrts", 'Quiz Weekly Stats - Times Taken', "mlw_dashboard_box_four", "quiz_wpss4"); add_meta_box("wpss_mrts", 'Quiz Monthly Stats - Times Taken', "mlw_dashboard_box_five", "quiz_wpss5"); - add_meta_box("wpss_mrts", 'Support', "mlw_dashboard_box_seven", "quiz_wpss7"); if ( get_option('mlw_advert_shows') == 'true' ) { add_meta_box("wpss_mrts", 'My Local Webstop Services', "mlw_dashboard_box_six", "quiz_wpss6"); @@ -82,22 +45,6 @@ function mlw_validateForm() // increase the default animation speed to exaggerate the effect $j.fx.speeds._default = 1000; $j(function() { - $j('#dialog').dialog({ - autoOpen: false, - show: 'blind', - hide: 'explode', - buttons: { - Ok: function() { - $j(this).dialog('close'); - } - } - }); - - $j('#opener').click(function() { - $j('#dialog').dialog('open'); - return false; - }); - $j(function() { $j( document ).tooltip(); }); @@ -144,7 +91,7 @@ function mlw_validateForm() }
    -

    Quiz Master Next Version (?)

    +

    Quiz Master Next Version Statistics

    @@ -188,35 +135,15 @@ function mlw_validateForm()
    -
    +
    -
    - -
    - -
    +
    - - - - -
    display_name." from ".$current_user->user_email."\n Wordpress Info: ".$mlw_site_info; - wp_mail('fpcorso@mylocalwebstop.com' ,'Support From Quiz Master Next Plugin', $mlw_message); - $quiz_master_email_message = "**Message Sent**"; - } - } - ?> -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    If there is something you would like to suggest to add or even if you just want - to let me know if you like the plugin or not, feel free to use the email form below.
    Name (Required):
    Email (Required):
    URL To Quiz (Not Required):
    Message (Required):
    -
    -

    Disclaimer: In order to better assist you, this form will also send some useful information about your WordPress installation such as version of plugin, version of WordPress, and website url along with your message.

    -
    - @@ -812,4 +667,4 @@ function mlw_qmn_quaterly_percent_taken_widget()
    \ No newline at end of file +?> From 3bb791f091e8117e57d3d7f18cc3700a3b06ad67 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 17:44:45 -0500 Subject: [PATCH 09/33] Moved News Widget To Quizzes Page --- includes/mlw_quiz_admin.php | 98 ++++++++++++++++++++----------------- 1 file changed, 52 insertions(+), 46 deletions(-) diff --git a/includes/mlw_quiz_admin.php b/includes/mlw_quiz_admin.php index 0703242f5..2e5769b7d 100644 --- a/includes/mlw_quiz_admin.php +++ b/includes/mlw_quiz_admin.php @@ -223,52 +223,58 @@ function duplicateQuiz(id, quizName){
    - "; - $quotes_list .= "" . $mlw_quiz_info->quiz_id . ""; - $quotes_list .= "" . esc_html($mlw_quiz_info->quiz_name) ." quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='javascript:();'>(Edit Name)"; - $quotes_list .= ""; - $quotes_list .= "[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."]"; - $quotes_list .= "[mlw_quizmaster_leaderboard mlw_quiz=".$mlw_quiz_info->quiz_id."]"; - $quotes_list .= "" . $mlw_quiz_info->quiz_views . ""; - $quotes_list .= "" . $mlw_quiz_info->quiz_taken .""; - $quotes_list .= "" . $mlw_quiz_info->last_activity .""; - $quotes_list .= ""; - } - - - - $display .= "
    "; - - $display .= ""; - $display .= " - - - - - - - - "; - $display .= "{$quotes_list}"; - $display .= " - - - - - - - - "; - $display .= "
    Quiz IDQuiz NameQuiz ShortcodeLeaderboard ShortcodeQuiz ViewsQuiz TakenLast Modified
    Quiz IDQuiz NameQuiz ShortcodeLeaderboard ShortcodeQuiz ViewsQuiz TakenLast Modified
    "; - echo $display; - ?> +
    + + + + + + + + + + + + + + "; + $quotes_list .= ""; + $quotes_list .= ""; + $quotes_list .= ""; + $quotes_list .= ""; + $quotes_list .= ""; + $quotes_list .= ""; + $quotes_list .= ""; + $quotes_list .= ""; + } + echo $quotes_list; ?> + + + + + + + + + + + + +
    Quiz IDQuiz NameQuiz ShortcodeLeaderboard ShortcodeQuiz ViewsQuiz TakenLast Modified
    " . $mlw_quiz_info->quiz_id . "" . esc_html($mlw_quiz_info->quiz_name) ." quiz_id."','".esc_js($mlw_quiz_info->quiz_name)."')\" href='javascript:();'>(Edit Name)"; + $quotes_list .= "[mlw_quizmaster quiz=".$mlw_quiz_info->quiz_id."][mlw_quizmaster_leaderboard mlw_quiz=".$mlw_quiz_info->quiz_id."]" . $mlw_quiz_info->quiz_views . "" . $mlw_quiz_info->quiz_taken ."" . $mlw_quiz_info->last_activity ."
    Quiz IDQuiz NameQuiz ShortcodeLeaderboard ShortcodeQuiz ViewsQuiz TakenLast Modified
    +
    +
    +

    My Local Webstop News

    + +
    +
    From 4520dc6d862dcaa10b78ae91e2905ea8290c005b Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 17:45:36 -0500 Subject: [PATCH 10/33] Moved News Widget To Quizzes Page --- includes/mlw_dashboard.php | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/includes/mlw_dashboard.php b/includes/mlw_dashboard.php index 95782352a..e40599df2 100644 --- a/includes/mlw_dashboard.php +++ b/includes/mlw_dashboard.php @@ -21,7 +21,6 @@ function mlw_generate_quiz_dashboard() add_meta_box("wpss_mrts", 'My Local Webstop Services', "mlw_dashboard_box_six", "quiz_wpss6"); add_meta_box("wpss_mrts", 'Contribution', "mlw_dashboard_box_eight", "quiz_wpss8"); } - add_meta_box("wpss_mrts", 'News From My Local Webstop', "mlw_dashboard_box_nine", "quiz_wpss9"); add_meta_box("wpss_mrts", 'Quizzes Taken Today', "mlw_qmn_daily_percent_taken_widget", "quiz_wpss10"); add_meta_box("wpss_mrts", 'Quizzes Taken Last 7 Days', "mlw_qmn_weekly_percent_taken_widget", "quiz_wpss11"); add_meta_box("wpss_mrts", 'Quizzes Taken Last 30 Days', "mlw_qmn_monthly_percent_taken_widget", "quiz_wpss12"); @@ -135,10 +134,6 @@ function mlw_generate_quiz_dashboard()
    -
    - -
    -
    @@ -462,18 +457,6 @@ function mlw_dashboard_box_eight()
    -
    - - - - -
    -
    - Date: Sat, 13 Dec 2014 17:50:54 -0500 Subject: [PATCH 11/33] Deleted Contribution Widget --- includes/mlw_dashboard.php | 86 -------------------------------------- 1 file changed, 86 deletions(-) diff --git a/includes/mlw_dashboard.php b/includes/mlw_dashboard.php index e40599df2..6ad0a0666 100644 --- a/includes/mlw_dashboard.php +++ b/includes/mlw_dashboard.php @@ -19,7 +19,6 @@ function mlw_generate_quiz_dashboard() if ( get_option('mlw_advert_shows') == 'true' ) { add_meta_box("wpss_mrts", 'My Local Webstop Services', "mlw_dashboard_box_six", "quiz_wpss6"); - add_meta_box("wpss_mrts", 'Contribution', "mlw_dashboard_box_eight", "quiz_wpss8"); } add_meta_box("wpss_mrts", 'Quizzes Taken Today', "mlw_qmn_daily_percent_taken_widget", "quiz_wpss10"); add_meta_box("wpss_mrts", 'Quizzes Taken Last 7 Days', "mlw_qmn_weekly_percent_taken_widget", "quiz_wpss11"); @@ -32,11 +31,8 @@ function mlw_generate_quiz_dashboard() -

    Quiz Master Next Version Statistics

    @@ -132,12 +91,6 @@ function mlw_generate_quiz_dashboard()
    -
    - -
    - -
    -
    -
    - - - - - - - - - - - - - - - - -
    - Quiz Master Next is and always will be a free plugin. I have spent a lot of time and effort developing and maintaining this plugin. If it has been beneficial to your site, please consider supporting this plugin by making a donation. -
     
     
    -
    -

    -

    - - - - -
    -

    -
    -
    -

    Thank you to those who have contributed so far!

    -
    - Date: Sat, 13 Dec 2014 17:55:38 -0500 Subject: [PATCH 12/33] Moving Quizzes Page To Top Menu Moved quiz admin pages as top menu. Moved dashboard into submenu and renamed stats. --- mlw_quizmaster2.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index b645b2e27..ec9f143ec 100644 --- a/mlw_quizmaster2.php +++ b/mlw_quizmaster2.php @@ -126,12 +126,13 @@ public function setup_admin_menu() { if (function_exists('add_menu_page')) { - add_menu_page('Quiz Master Next', 'Quiz Dashboard', 'moderate_comments', __FILE__, 'mlw_generate_quiz_dashboard', 'dashicons-feedback'); - add_submenu_page(__FILE__, 'Quizzes', 'Quizzes', 'moderate_comments', 'mlw_quiz_admin', 'mlw_generate_quiz_admin'); + add_menu_page('Quiz Master Next', 'Quizzes', 'moderate_comments', __FILE__, 'mlw_generate_quiz_admin', 'dashicons-feedback'); add_submenu_page(__FILE__, 'Quiz Settings', 'Quiz Settings', 'moderate_comments', 'mlw_quiz_options', 'mlw_generate_quiz_options'); add_submenu_page(__FILE__, 'Quiz Results', 'Quiz Results', 'moderate_comments', 'mlw_quiz_results', 'mlw_generate_quiz_results'); add_submenu_page(__FILE__, 'Quiz Result Details', 'Quiz Result Details', 'moderate_comments', 'mlw_quiz_result_details', 'mlw_generate_result_details'); - add_submenu_page(__FILE__, 'Tools', 'Tools', 'manage_options', 'mlw_quiz_tools', 'mlw_generate_quiz_tools'); + add_submenu_page(__FILE__, 'QMN Stats', 'QMN Stats', 'moderate_comments', 'mlw_quiz_stats', 'mlw_generate_quiz_dashboard'); + add_submenu_page(__FILE__, 'QMN Tools', 'QMN Tools', 'manage_options', 'mlw_quiz_tools', 'mlw_generate_quiz_tools'); + add_submenu_page(__FILE__, 'QMN Help', 'QMN Help', 'moderate_comments', 'mlw_quiz_help', 'mlw_generate_help_page'); add_submenu_page(__FILE__, 'QMN About', 'QMN About', 'manage_options', 'mlw_qmn_about', 'mlw_generate_about_page'); } } From da61972496640bba804a4c2446a21000c411aa66 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 19:24:40 -0500 Subject: [PATCH 13/33] Added Ability For Multiple Admin Emails Added the ability for multiple admin emails based on score. Based on same system as user email system. --- includes/mlw_quiz_options.php | 207 ++++++++++++++++++++++++++++------ 1 file changed, 174 insertions(+), 33 deletions(-) diff --git a/includes/mlw_quiz_options.php b/includes/mlw_quiz_options.php index f502e33a8..3e09b3d79 100644 --- a/includes/mlw_quiz_options.php +++ b/includes/mlw_quiz_options.php @@ -1727,7 +1727,7 @@ function mlw_options_emails_tab_content() array_unshift($mlw_qmn_email_array , $mlw_new_landing_array); $mlw_qmn_email_array = serialize($mlw_qmn_email_array); } - //Update message_after with new array then check to see if worked + //Update email template with new array then check to see if worked $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_email_array, $mlw_qmn_add_email_id ) ); if ($mlw_new_email_results != false) { @@ -1748,13 +1748,72 @@ function mlw_options_emails_tab_content() } } + //Check to add new admin email template + if (isset($_POST["mlw_add_admin_email_page"]) && $_POST["mlw_add_admin_email_page"] == "confirmation") + { + //Function variables + $mlw_qmn_add_email_id = intval($_POST["mlw_add_admin_email_quiz_id"]); + $mlw_qmn_admin_email = $wpdb->get_var( $wpdb->prepare( "SELECT admin_email_template FROM ".$wpdb->prefix."mlw_quizzes WHERE quiz_id=%d", $mlw_qmn_add_email_id ) ); + + //Load user email and check if it is array already. If not, turn it into one + if (is_serialized($mlw_qmn_admin_email) && is_array(@unserialize($mlw_qmn_admin_email))) + { + $mlw_qmn_email_array = @unserialize($mlw_qmn_admin_email); + $mlw_new_landing_array = array( + "begin_score" => 0, + "end_score" => 100, + "message" = > 'Enter Your Text Here', + "subject" => 'Quiz Results For %QUIZ_NAME%' + ); + array_unshift($mlw_qmn_email_array , $mlw_new_landing_array); + $mlw_qmn_email_array = serialize($mlw_qmn_email_array); + + } + else + { + $mlw_qmn_email_array = array(array( + "begin_score" => 0, + "end_score" => 0, + "message" = > $mlw_qmn_admin_email, + "subject" => 'Quiz Results For %QUIZ_NAME%' + )); + $mlw_new_landing_array = array( + "begin_score" => 0, + "end_score" => 100, + "message" = > 'Enter Your Text Here', + "subject" => 'Quiz Results For %QUIZ_NAME%' + ); + array_unshift($mlw_qmn_email_array , $mlw_new_landing_array); + $mlw_qmn_email_array = serialize($mlw_qmn_email_array); + } + //Update email template with new array then check to see if worked + $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_email_array, $mlw_qmn_add_email_id ) ); + if ($mlw_new_email_results != false) + { + $mlwQuizMasterNext->alertManager->newAlert('The email has been added successfully.', 'success'); + + //Insert Action Into Audit Trail + global $current_user; + get_currentuserinfo(); + $table_name = $wpdb->prefix . "mlw_qm_audit_trail"; + $insert = "INSERT INTO " . $table_name . + "(trail_id, action_user, action, time) " . + "VALUES (NULL , '" . $current_user->display_name . "' , 'New Admin Email Has Been Created For Quiz Number ".$mlw_qmn_add_email_id."' , '" . date("h:i:s A m/d/Y") . "')"; + $results = $wpdb->query( $insert ); + } + else + { + $mlwQuizMasterNext->alertManager->newAlert('There has been an error in this action. Please share this with the developer. Error Code: 0016.', 'error'); + } + } + //Check to save email templates if (isset($_POST["mlw_save_email_template"]) && $_POST["mlw_save_email_template"] == "confirmation") { //Function Variables $mlw_qmn_email_id = intval($_POST["mlw_email_quiz_id"]); $mlw_qmn_email_template_total = intval($_POST["mlw_email_template_total"]); - $mlw_qmn_admin_email = htmlspecialchars(stripslashes($_POST["mlw_quiz_admin_email_template"]), ENT_QUOTES); + $mlw_qmn_email_admin_total = intval($_POST["mlw_email_admin_total"]); //Create new array $i = 1; @@ -1768,8 +1827,27 @@ function mlw_options_emails_tab_content() } $i++; } + + //Create new array + $i = 1; + $mlw_qmn_new_admin_array = array(); + while ($i <= $mlw_qmn_email_admin_total) + { + if ($_POST["admin_email_".$i] != "Delete") + { + $mlw_qmn_email_each = array( + "begin_score" => intval($_POST["admin_email_begin_".$i]), + "end_score" => intval($_POST["admin_email_end_".$i]), + "message" => htmlspecialchars(stripslashes($_POST["admin_email_".$i]), ENT_QUOTES), + "subject" => htmlspecialchars(stripslashes($_POST["admin_email_subject_".$i]), ENT_QUOTES) + ); + $mlw_qmn_new_admin_array[] = $mlw_qmn_email_each; + } + $i++; + } $mlw_qmn_new_email_array = serialize($mlw_qmn_new_email_array); - $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_email_array, $mlw_qmn_admin_email, $mlw_qmn_email_id ) ); + $mlw_qmn_new_admin_array = serialize($mlw_qmn_new_admin_array); + $mlw_new_email_results = $wpdb->query( $wpdb->prepare( "UPDATE ".$wpdb->prefix."mlw_quizzes SET user_email_template='%s', admin_email_template='%s', last_activity='".date("Y-m-d H:i:s")."' WHERE quiz_id=%d", $mlw_qmn_new_email_array, $mlw_qmn_new_admin_array, $mlw_qmn_email_id ) ); if ($mlw_new_email_results != false) { $mlwQuizMasterNext->alertManager->newAlert('The email has been updated successfully.', 'success'); @@ -1795,7 +1873,7 @@ function mlw_options_emails_tab_content() $mlw_quiz_options = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table_name WHERE quiz_id=%d LIMIT 1", $_GET["quiz_id"])); } - //Load Email Templates + //Load User Email Templates if (is_serialized($mlw_quiz_options->user_email_template) && is_array(@unserialize($mlw_quiz_options->user_email_template))) { $mlw_qmn_user_email_array = @unserialize($mlw_quiz_options->user_email_template); @@ -1804,11 +1882,21 @@ function mlw_options_emails_tab_content() { $mlw_qmn_user_email_array = array(array(0, 0, $mlw_quiz_options->user_email_template, 'Quiz Results For %QUIZ_NAME%')); } - - if (!is_array($mlw_qmn_user_email_array)) { - // something went wrong, initialize to empty array - - } + + //Load Admin Email Templates + if (is_serialized($mlw_quiz_options->admin_email_template) && is_array(@unserialize($mlw_quiz_options->admin_email_template))) + { + $mlw_qmn_admin_email_array = @unserialize($mlw_quiz_options->admin_email_template); + } + else + { + $mlw_qmn_admin_email_array = array(array( + "begin_score" => 0, + "end_score" => 0, + "message" => $mlw_quiz_options->admin_email_template, + "subject" => 'Quiz Results For %QUIZ_NAME%' + )); + } ?>
    @@ -1957,31 +2045,84 @@ function delete_email(id)

    Email Sent To Admin

    - - - - - +
    - Email sent to admin after completion (If turned on in options) -
    -

    Allowed Variables:

    -

    - %POINT_SCORE%

    -

    - %AVERAGE_POINT%

    -

    - %AMOUNT_CORRECT%

    -

    - %TOTAL_QUESTIONS%

    -

    - %CORRECT_SCORE%

    -

    - %USER_NAME%

    -

    - %USER_BUSINESS%

    -

    - %USER_PHONE%

    -

    - %USER_EMAIL%

    -

    - %QUIZ_NAME%

    -

    - %COMMENT_SECTION%

    -

    - %QUESTIONS_ANSWERS%

    -

    - %TIMER%

    -

    - %CURRENT_DATE%

    -
    -
    + + + + + + + + + + + "; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + break; + } + else + { + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + } + } + ?> + + + + + + + + + +
    IDScore Greater Than Or Equal ToScore Less Than Or Equal ToSubjectEmail To Send
    "; + echo "Default"; + echo ""; + echo "-"; + echo ""; + echo "-"; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
    "; + echo $mlw_admin_count."
    Are you sure?
    Yes|No
    "; + echo "
    "; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "
    IDScore Greater Than Or Equal ToScore Less Than Or Equal ToSubjectEmail To Send
    +
    From 05977f56f9b2d984ad0ea96515d2a835e854dbe8 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 19:34:48 -0500 Subject: [PATCH 14/33] Added Ability For Multiple Admin Emails --- includes/mlw_quiz.php | 75 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 69 insertions(+), 6 deletions(-) diff --git a/includes/mlw_quiz.php b/includes/mlw_quiz.php index 5055aff45..a1ecf658f 100644 --- a/includes/mlw_quiz.php +++ b/includes/mlw_quiz.php @@ -1356,17 +1356,80 @@ function mlw_qmn_share(network, mlw_qmn_social_text, mlw_qmn_title) $mlw_message = ""; if ($mlw_quiz_options->send_admin_email == "0") { - $mlw_message = htmlspecialchars_decode($mlw_quiz_options->admin_email_template, ENT_QUOTES); - $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array); + if ($mlw_quiz_options->admin_email != "") + { + $mlw_message = ""; + $mlw_subject = ""; + if (is_serialized($mlw_quiz_options->admin_email_template) && is_array(@unserialize($mlw_quiz_options->admin_email_template))) + { + $mlw_admin_email_array = @unserialize($mlw_quiz_options->admin_email_template); + + //Cycle through landing pages + foreach($mlw_admin_email_array as $mlw_each) + { + + //Generate Email Subject + if (!isset($mlw_each["subject"])) + { + $mlw_each["subject"] = "Quiz Results For %QUIZ_NAME"; + } + $mlw_each["subject"] = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_each["subject"], $mlw_qmn_result_array); + + //Check to see if default + if ($mlw_each["begin_score"] == 0 && $mlw_each["end_score"] == 0) + { + $mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES); + $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array); + $mlw_message = str_replace( "\n" , "
    ", $mlw_message); + $mlw_message = str_replace( "
    " , "
    ", $mlw_message); + $mlw_message = str_replace( "
    " , "
    ", $mlw_message); + $mlw_subject = $mlw_each["subject"]; + break; + } + else + { + //Check to see if points fall in correct range + if ($mlw_quiz_options->system == 1 && $mlw_points >= $mlw_each["begin_score"] && $mlw_points <= $mlw_each["end_score"]) + { + $mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES); + $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array); + $mlw_message = str_replace( "\n" , "
    ", $mlw_message); + $mlw_message = str_replace( "
    " , "
    ", $mlw_message); + $mlw_message = str_replace( "
    " , "
    ", $mlw_message); + $mlw_subject = $mlw_each["subject"]; + break; + } + + //Check to see if score fall in correct range + if ($mlw_quiz_options->system == 0 && $mlw_total_score >= $mlw_each["begin_score"] && $mlw_total_score <= $mlw_each["end_score"]) + { + $mlw_message = htmlspecialchars_decode($mlw_each["message"], ENT_QUOTES); + $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array); + $mlw_message = str_replace( "\n" , "
    ", $mlw_message); + $mlw_message = str_replace( "
    " , "
    ", $mlw_message); + $mlw_message = str_replace( "
    " , "
    ", $mlw_message); + $mlw_subject = $mlw_each["subject"]; + break; + } + } + } + } + else + { + $mlw_message = htmlspecialchars_decode($mlw_quiz_options->admin_email_template, ENT_QUOTES); + $mlw_message = apply_filters( 'mlw_qmn_template_variable_results_page', $mlw_message, $mlw_qmn_result_array); + $mlw_message = str_replace( "\n" , "
    ", $mlw_message); + $mlw_message = str_replace( "
    " , "
    ", $mlw_message); + $mlw_message = str_replace( "
    " , "
    ", $mlw_message); + $mlw_subject = "Quiz Results For ".$mlw_quiz_options->quiz_name; + } + } if ( get_option('mlw_advert_shows') == 'true' ) {$mlw_message .= "
    This email was generated by the Quiz Master Next script by Frank Corso";} - $mlw_message = str_replace( "\n" , "
    ", $mlw_message); - $mlw_message = str_replace( "
    " , "
    ", $mlw_message); - $mlw_message = str_replace( "
    " , "
    ", $mlw_message); $mlw_headers = 'From: '.$mlw_quiz_options->email_from_text.' <'.$mlw_quiz_options->admin_email.'>' . "\r\n"; $mlw_qmn_admin_emails = explode(",", $mlw_quiz_options->admin_email); foreach($mlw_qmn_admin_emails as $admin_email) { - wp_mail($admin_email, "Quiz Results For ".$mlw_quiz_options->quiz_name, $mlw_message, $mlw_headers); + wp_mail($admin_email, $mlw_subject, $mlw_message, $mlw_headers); } } From 1c7d810beb8e9ccf2dbce7003755fa02348ad1a3 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 19:35:52 -0500 Subject: [PATCH 15/33] Fix Space Between = And > In Array --- includes/mlw_quiz_options.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/mlw_quiz_options.php b/includes/mlw_quiz_options.php index 3e09b3d79..9473f92ef 100644 --- a/includes/mlw_quiz_options.php +++ b/includes/mlw_quiz_options.php @@ -1762,7 +1762,7 @@ function mlw_options_emails_tab_content() $mlw_new_landing_array = array( "begin_score" => 0, "end_score" => 100, - "message" = > 'Enter Your Text Here', + "message" => 'Enter Your Text Here', "subject" => 'Quiz Results For %QUIZ_NAME%' ); array_unshift($mlw_qmn_email_array , $mlw_new_landing_array); @@ -1774,13 +1774,13 @@ function mlw_options_emails_tab_content() $mlw_qmn_email_array = array(array( "begin_score" => 0, "end_score" => 0, - "message" = > $mlw_qmn_admin_email, + "message" => $mlw_qmn_admin_email, "subject" => 'Quiz Results For %QUIZ_NAME%' )); $mlw_new_landing_array = array( "begin_score" => 0, "end_score" => 100, - "message" = > 'Enter Your Text Here', + "message" => 'Enter Your Text Here', "subject" => 'Quiz Results For %QUIZ_NAME%' ); array_unshift($mlw_qmn_email_array , $mlw_new_landing_array); From 1385e50077d3c1a5b6ff7db782e042f268ecb75d Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Sat, 13 Dec 2014 19:48:29 -0500 Subject: [PATCH 16/33] Added Button To Create New Admin Emails Added button above and below similar to user emails. Used jQuery button for them as well. --- includes/mlw_quiz_options.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/includes/mlw_quiz_options.php b/includes/mlw_quiz_options.php index 9473f92ef..30dd4477c 100644 --- a/includes/mlw_quiz_options.php +++ b/includes/mlw_quiz_options.php @@ -1902,7 +1902,7 @@ function mlw_options_emails_tab_content()
    "; ?>
    -
    + From 3c17206885ef9722a2e81855847c2da9cee7f7a2 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Tue, 16 Dec 2014 14:09:09 -0500 Subject: [PATCH 30/33] Fixed Not Sufficient Permission Bug Wrong page value was causing error. --- includes/mlw_quiz_admin.php | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/includes/mlw_quiz_admin.php b/includes/mlw_quiz_admin.php index f05a328d6..545ecd7df 100644 --- a/includes/mlw_quiz_admin.php +++ b/includes/mlw_quiz_admin.php @@ -77,8 +77,6 @@ function mlw_generate_quiz_admin() wp_enqueue_script( 'jquery-effects-blind' ); wp_enqueue_script( 'jquery-effects-explode' ); ?> -

    Template Variables

    @@ -2098,7 +2103,7 @@ function delete_email(id) { echo ""; echo ""; echo "
    "; - echo $mlw_admin_count."
    Are you sure?
    Yes|No
    "; + echo $mlw_admin_count."
    Are you sure?
    Yes|No
    "; echo "
    "; echo ""; From f22d452f8456df01e3ad454362279157b8237d10 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Tue, 16 Dec 2014 16:16:41 -0500 Subject: [PATCH 32/33] Created Certificates Folder And Index File --- includes/certificates/index.php | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 includes/certificates/index.php diff --git a/includes/certificates/index.php b/includes/certificates/index.php new file mode 100644 index 000000000..6eff33c4e --- /dev/null +++ b/includes/certificates/index.php @@ -0,0 +1,4 @@ + From c050d8bf9ba39fe5d539585a1a79a5a1486146c1 Mon Sep 17 00:00:00 2001 From: Frank Corso Date: Tue, 16 Dec 2014 16:24:53 -0500 Subject: [PATCH 33/33] Now Tested Up To 4.1 --- readme.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.txt b/readme.txt index 8bf025c98..e0518453d 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: fpcorso Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=RTGYAETX36ZQJ Tags: quiz, test, score, exam, survey, contact, form, email, answer, question Requires at least: 3.8.1 -Tested up to: 4.0.1 +Tested up to: 4.1 Stable tag: 3.8.1 License URI: http://www.gnu.org/licenses/gpl-2.0.html