Update for interest names with specialchars
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 18 Jul 2016 17:33:11 +0000 (13:33 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 18 Jul 2016 17:33:11 +0000 (13:33 -0400)
Do htmlspecialchars_decode to check for matches.

setup/frontHooks.php
views/admin/leads/index.html

index 5a673dc..11f24bc 100644 (file)
@@ -15,7 +15,7 @@
 require_once GLM_MEMBERS_LEADS_PLUGIN_CLASS_PATH.'/data/dataInterests.php';
 require_once GLM_MEMBERS_LEADS_PLUGIN_CLASS_PATH.'/data/dataInterestGroups.php';
 
-/*
+/**
  * Place Misc Hooks and Filters here. If this file exists, it will be included
  * by the add-on main plugin script.
  *
@@ -28,7 +28,12 @@ require_once GLM_MEMBERS_LEADS_PLUGIN_CLASS_PATH.'/data/dataInterestGroups.php';
  *  *** Also note that parameters will be in the context of the main front controller constructor. ***
  */
 
-// Inject things into gravity forms fields - This intercepts all GravityForms before displaying them
+/**
+ * Add Filter: gform_pre_render action
+ *
+ * To setup the form so it can display the groups of interests. This intercepts
+ * all GravityForms before displaying them.
+ */
 add_filter( 'gform_pre_render', function( $form ) {
     $form_enabled = false;
     /*
@@ -94,6 +99,12 @@ add_filter( 'gform_pre_render', function( $form ) {
     // Return the form.
     return $form;
 });
+/**
+ * Add Filter: gform_after_submission action
+ *
+ * This action is done after the form has been validated and after the entry is
+ * made by Gravity Forms.
+ */
 add_action( 'gform_after_submission', function( $entry, $form ){
     /*
      * Get the source id for the form.
@@ -207,7 +218,7 @@ add_action( 'gform_after_submission', function( $entry, $form ){
             array(
                 'email'     => $glm_leads_entry['email'],
                 'created'   => $entry['date_created'],
-                'mail_ok'   => ( isset( $glm_leads_entry['mail_ok'] ) && $glm_leads_entry['mail_ok'] ) ? 1: 0,
+                'mail_ok'   => ( isset( $glm_leads_entry['mail_ok'] )   && $glm_leads_entry['mail_ok'] )   ? 1: 0,
                 'member_ok' => ( isset( $glm_leads_entry['member_ok'] ) && $glm_leads_entry['member_ok'] ) ? 1: 0,
             ), // data
             array( '%s', '%s', '%s', '%s' ) // data format
@@ -264,14 +275,16 @@ add_action( 'gform_after_submission', function( $entry, $form ){
     if ( $lead_entry === false ) {
         die( 'lead_entry error given' );
     }
-    $lead_entry_id = $this->wpdb->insert_id;
+    $lead_entry_id  = $this->wpdb->insert_id;
 
-    $ints = array();
+    // grab the interest
     $interestsData  = new GlmDataInterests( $this->wpdb, $this->config );
     $interests      = $interestsData->getList();
+
+    $ints           = array();
     if ( $interests ) {
         foreach ( $interests as $interest ) {
-            $ints[$interest['id']] = $interest['title'];
+            $ints[$interest['id']] = htmlspecialchars_decode( $interest['title'] );
         }
     }
     // create the lead to interest entries
index fe4eafc..e4b6791 100644 (file)
@@ -19,7 +19,7 @@
     <input type="hidden" name="prevStart" value="{$prevStart}" />
     <input type="hidden" name="nextStart" value="{$nextStart}" />
     <input type="hidden" name="limit" value="{$limit}" />
-    <table style="width: 500px;" id="lead-search-form"{if $searching && $haveLeads} class="hide"{/if}>
+    <table style="width: 500px;" id="lead-search-form"{if $searching} class="hide"{/if}>
         <tr>
             <td style="text-align: right;"><label for="glm-form-source_id">Source</label></td>
             <td>
@@ -93,7 +93,7 @@
         </tr>
     </table>
 
-{if $leads}
+{if $haveLeads}
     <h4>Search Results:</h4>
     <a href="{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=csvExport" class="button">Download as CSV File</a>
 
             <input type="Submit" name="pageSelect" value="Previous {$limit} {$terms.term_member_plur_cap}" class="button button-secondary glm-button"{if !$prevStart} disabled{/if}>
             <input type="Submit" name="pageSelect" value="Next {$limit} {$terms.term_member_plur_cap}" class="button button-secondary glm-button"{if !$nextStart} disabled{/if}>
         {/if}
+{else if $searching}
+<strong>Sorry, Nothing matches your search.</strong>
 {/if}
 
 </form>