* so that we're sure the other add-ons see an up to date
* version from this plugin.
*/
-define('GLM_MEMBERS_LEADS_PLUGIN_VERSION', '1.1.1');
+define('GLM_MEMBERS_LEADS_PLUGIN_VERSION', '1.1.2');
define('GLM_MEMBERS_LEADS_PLUGIN_DB_VERSION', '0.0.7');
// This is the minimum version of the GLM Members DB plugin require for this plugin.
$out = array();
$csv_file_output = '';
+ // Grab names of all interests fields.
+ $interest_fields = array();
+ $interest_field_data = $this->wpdb->get_results(
+ "SELECT *
+ FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "interests
+ ORDER BY group_id, title",
+ ARRAY_A
+ );
+ foreach ( $interest_field_data as $int_field ) {
+ $interest_fields[$int_field['id']] = $int_field['title'];
+ }
+ // echo '<pre>$interest_fields: ' . print_r( $interest_fields, true ) . '</pre>';
+
// Generate the output for the csv file
if ( isset( $leads ) && is_array( $leads ) && !empty( $leads ) ) {
$lead_counter = 0;
'date_submitted' => $lead['date_submitted'],
'source' => $source_name,
);
- // Add fields for group names
- if ( $groups ) {
- foreach ( $groups as $group ) {
- $out[$group['title']] = '';
+ // Add fields for all interest fields
+ if ( $interest_field_data ) {
+ foreach ( $interest_fields as $int_field_id => $int_field_title ) {
+ $out[$int_field_title] = '';
}
}
+ // Add fields for group names
+ // if ( $groups ) {
+ // foreach ( $groups as $group ) {
+ // $out[$group['title']] = '';
+ // }
+ // }
if ( !$user_can_edit_leads ) {
unset(
$out['source']
);
if ( $lead_interests ) {
foreach ( $lead_interests as $interest ) {
- $interest_by_groups[$interest['group']][] = $interest['title'];
+ $interest_by_groups[$interest['title']] = true;
}
- if ( $interest_by_groups ) {
- foreach ( $interest_by_groups as $group_name => $group_interest ) {
- $out[$group_name] = implode( ';', $group_interest );
- }
+ foreach ( $interest_fields as $int_field_id => $int_field_title ) {
+ $out[$int_field_title] = ( $interest_by_groups[$int_field_title] ) ? $int_field_title : '';
}
+ // if ( $interest_by_groups ) {
+ // foreach ( $interest_by_groups as $group_name => $group_interest ) {
+ // $out[$group_name] = implode( ';', $group_interest );
+ // }
+ // }
}
// First line should be the header line
if ( $lead_counter === 0 ) {