From: Laury GvR Date: Tue, 2 Oct 2018 16:10:18 +0000 (-0400) Subject: Lists & filter fixed, use fieldsMap, links fixed X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=dd8dba8d289d8aee8f160cd70be9e6b8967b83cd;p=WP-Plugins%2Fglm-member-db.git Lists & filter fixed, use fieldsMap, links fixed Every list now passes a fields map to ensure the field values its result produces correspond to the expected field names in the widget component templates. For example, the list.html component template expects an entity 'name', but packaging plugin passes this as 'title' - with the map, they are matched. getList for the lists now use custom fields array to allow this. Quicklinks, count, and list entity & ref_dest links are now working. --- diff --git a/models/admin/newDashboard/index.php b/models/admin/newDashboard/index.php index e2507a8f..10e4dedc 100644 --- a/models/admin/newDashboard/index.php +++ b/models/admin/newDashboard/index.php @@ -140,59 +140,59 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers $thisWeek = date('Y-m-d', strtotime('-'.date('w').' days')); $thisMonth = date('Y-m-d', strtotime('-'.(date('j')-1).' days')); - $clickThroughCounts = $this->wpdb->get_row(" - SELECT COALESCE (( - SELECT clicks - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."clickthrough_stats - WHERE member = $memberID - AND stat_type = 1 - AND stat_date = '$today' - ), 0) AS day, - COALESCE (( - SELECT clicks - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."clickthrough_stats - WHERE member = $memberID - AND stat_type = 2 - AND stat_date = '$thisWeek' - ), 0) AS week, - COALESCE (( - SELECT clicks - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."clickthrough_stats - WHERE member = $memberID - AND stat_type = 3 - AND stat_date = '$thisMonth' - ), 0) AS month - ", ARRAY_A); + // $clickThroughCounts = $this->wpdb->get_row(" + // SELECT COALESCE (( + // SELECT clicks + // FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."clickthrough_stats + // WHERE member = $memberID + // AND stat_type = 1 + // AND stat_date = '$today' + // ), 0) AS day, + // COALESCE (( + // SELECT clicks + // FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."clickthrough_stats + // WHERE member = $memberID + // AND stat_type = 2 + // AND stat_date = '$thisWeek' + // ), 0) AS week, + // COALESCE (( + // SELECT clicks + // FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."clickthrough_stats + // WHERE member = $memberID + // AND stat_type = 3 + // AND stat_date = '$thisMonth' + // ), 0) AS month + // ", ARRAY_A); - $detailViewCounts = $this->wpdb->get_row(" - SELECT COALESCE (( - SELECT clicks - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_detail_stats - WHERE member = $memberID - AND stat_type = 1 - AND stat_date = '$today' - ), 0) AS day, - COALESCE (( - SELECT clicks - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_detail_stats - WHERE member = $memberID - AND stat_type = 2 - AND stat_date = '$thisWeek' - ), 0) AS week, - COALESCE (( - SELECT clicks - FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_detail_stats - WHERE member = $memberID - AND stat_type = 3 - AND stat_date = '$thisMonth' - ), 0) AS month - ", ARRAY_A); + // $detailViewCounts = $this->wpdb->get_row(" + // SELECT COALESCE (( + // SELECT clicks + // FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_detail_stats + // WHERE member = $memberID + // AND stat_type = 1 + // AND stat_date = '$today' + // ), 0) AS day, + // COALESCE (( + // SELECT clicks + // FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_detail_stats + // WHERE member = $memberID + // AND stat_type = 2 + // AND stat_date = '$thisWeek' + // ), 0) AS week, + // COALESCE (( + // SELECT clicks + // FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."member_detail_stats + // WHERE member = $memberID + // AND stat_type = 3 + // AND stat_date = '$thisMonth' + // ), 0) AS month + // ", ARRAY_A); // Setup the data Abstract class for member info. require_once GLM_MEMBERS_PLUGIN_CLASS_PATH . '/data/dataMemberInfo.php'; $MemberInfo = new GlmDataMemberInfo($this->wpdb, $this->config); $hideArchived = " && T.status != ".$this->config['status_numb']['Archived']; - $memberInfoRecords = $MemberInfo->getList( "T.member = $memberID" . $hideArchived, 'T.status' ); + //$memberInfoRecords = $MemberInfo->getList( "T.member = $memberID" . $hideArchived, 'T.status' ); // Check if there's any member information records. if (is_array($memberInfoRecords) && count($memberInfoRecords) > 0) { @@ -208,10 +208,11 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers // $addons[$a['slug']]['index'] = $a['index']; // echo $a['index']; $addons[$a['slug']]['widgetData'] = apply_filters($a['slug'] . "-dashboard-widget", ""); - $addons[$a['slug']]['widgetData'] = $this->queryWidgetLists($addons[$a['slug']]['widgetData']); + //$addons[$a['slug']]['widgetData'] = $this->queryWidgetLists($addons[$a['slug']]['widgetData']); // Sort the component list based on the 'order' uasort($addons[$a['slug']]['widgetData']['components'], array($this, 'orderSort') ) ; + } else { // For testing // echo "
" . $a['slug'] . " has no filter called " . $a['slug'] . "-dashboard-widget"; @@ -249,46 +250,47 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers public function queryWidgetLists( &$widgetData = false ) { - foreach ( $widgetData['components'] as &$widgetComponent ) { - $where = " TRUE "; - $order = ""; - $limit = "5"; - if ( isset($widgetComponent['where']) && $widgetComponent['where'] !== "" ) { - $where .= " AND " . $widgetComponent['where']; - } - if ( isset($widgetComponent['orderBy']) && $widgetComponent['orderBy'] !== "" ) { - $order .= " ORDER BY " . $widgetComponent['orderBy']; - } + // foreach ( $widgetData['components'] as &$widgetComponent ) { + // $where = " TRUE "; + // $order = ""; + // $limit = "5"; + // if ( isset($widgetComponent['where']) && $widgetComponent['where'] !== "" ) { + // $where .= " AND " . $widgetComponent['where']; + // } + // if ( isset($widgetComponent['orderBy']) && $widgetComponent['orderBy'] !== "" ) { + // $order .= " ORDER BY " . $widgetComponent['orderBy']; + // } + // echo "
Result:" . var_dump( $widgetComponent['result'] ); - if ( $widgetComponent['template'] == 'list' && isset($widgetComponent['fields']) && isset($widgetComponent['table']) ) { - $table = $widgetComponent['table']; - $fields = $widgetComponent['fields']; - $resultsQuery = "SELECT " . $fields . " FROM " . $table . " WHERE" . $where . $order . " LIMIT " . $limit . ";"; - //echo "
" .$resultsQuery; - $widgetComponent['sql'] = $resultsQuery; - $widgetComponent['listItems'] = $this->wpdb->get_results($resultsQuery); + // if ( $widgetComponent['template'] == 'list' && isset($widgetComponent['fields']) && isset($widgetComponent['table']) ) { + // $table = $widgetComponent['table']; + // $fields = $widgetComponent['fields']; + // $resultsQuery = "SELECT " . $fields . " FROM " . $table . " WHERE" . $where . $order . " LIMIT " . $limit . ";"; + // //echo "
" .$resultsQuery; + // $widgetComponent['sql'] = $resultsQuery; + // $widgetComponent['listItems'] = $this->wpdb->get_results($resultsQuery); - if ( isset($widgetComponent['listItems']) ) { - foreach ( $widgetComponent['listItems'] as &$listItem ) { - if ( isset($listItem->ref_type) ) { - // Get the ref type from the config array - has to be forced lowercase due to inconsistency - // in url vs config array reference to ref_type (e.g. member vs Member, and member vs members) - $listItem->ref_type = strtolower($this->config['ref_type'][$listItem->ref_type]); - } - } - } + // if ( isset($widgetComponent['listItems']) ) { + // foreach ( $widgetComponent['listItems'] as &$listItem ) { + // if ( isset($listItem->ref_type) ) { + // // Get the ref type from the config array - has to be forced lowercase due to inconsistency + // // in url vs config array reference to ref_type (e.g. member vs Member, and member vs members) + // $listItem->ref_type = strtolower($this->config['ref_type'][$listItem->ref_type]); + // } + // } + // } // $countQuery = "SELECT COUNT(" . $widgetComponent['entityID'] . ") FROM " . $widgetComponent['table'] . " WHERE " . $where . ";"; // $widgetComponent['count'] = $this->wpdb->get_var($countQuery); - } - if ( isset($widgetComponent['table']) && ($widgetComponent['template'] == 'list' || $widgetComponent['template'] == 'entityAmount') ) { - $table = $widgetComponent['table']; - $countQuery = "SELECT COUNT(id) FROM " . $widgetComponent['table'] . " WHERE " . $where . ";"; + // } + // if ( isset($widgetComponent['table']) && ($widgetComponent['template'] == 'list' || $widgetComponent['template'] == 'entityAmount') ) { + //$table = $widgetComponent['table']; + //$countQuery = "SELECT COUNT(id) FROM " . $widgetComponent['table'] . " WHERE " . $where . ";"; //echo "
" .$countQuery; - $widgetComponent['count'] = $this->wpdb->get_var($countQuery); + //$widgetComponent['count'] = $this->wpdb->get_var($countQuery); //echo "
" . var_dump($widgetComponent['count']) . "
"; - } - } + // } + // } return $widgetData; } diff --git a/setup/adminHooks.php b/setup/adminHooks.php index ac5ca93a..727979d2 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -13,6 +13,8 @@ * @link http://dev.gaslightmedia.com/ */ +require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php'; + /* * Place Misc Hooks and Filters here. If this file exists, it will be included * by the add-on main plugin script. @@ -412,6 +414,39 @@ add_filter( $membersTable = GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info"; $membersTextTable = GLM_MEMBERS_PLUGIN_DB_PREFIX . "members"; $membersEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE.'member&glm_action=memberInfo'; + $membersSettingsPage = GLM_MEMBERS_PLUGIN_ADMIN_URL.'?page=glm-members-admin-menu-settings&settingsPage=members'; + $membersRefLink = GLM_MEMBERS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-member&glm_action=index'; + + $MemberInfo = new GlmDataMemberInfo($this->wpdb, $this->config); + + // Set default values for using getList() later, where the custom set of fields below will be used. + $where = ''; + $order = ''; + $fieldVals = true; + $idField = 'id'; + $start = false; + $limit = false; + + // Save the current fields array and make a copy. Will be restored before the return. + $fSave = $MemberInfo->fields; + + // echo "
fsave: " . var_dump($fSave) . "

"; + + // Remove what we don't want from the copy and get the list + $MemberInfo->fields = array( + 'id' => $fSave['id'], + 'reference_name'=> $fSave['reference_name'], + 'status' => $fSave['status'], + 'member_pointer'=> $fSave['member_pointer'], + 'member' => $fSave['member'], + //'ref_type' => 'ref_type', // membersInfo has no ref_type field yet + ); + + // echo "
MemberInfo: " . var_dump($MemberInfo->fields) . "

"; + + // $widgetResult = $MemberInfo->getList('status='.$MemberInfo->config['status_numb']['Pending'], $order, $fieldVals, $idField, $start, $limit); + + // echo "
Widgetresult: " . var_dump($widgetResult) . "

"; /* * For list components: pass ref_type and ref_dest as part of the 'fields' string if you want to @@ -458,7 +493,7 @@ add_filter( ], 'settings' => [ 'content' => 'Settings', - 'url' => '#set', + 'url' => $membersSettingsPage, ] ], ], @@ -467,8 +502,8 @@ add_filter( 'title' => 'Number of ' . $this->config['terms']['term_member_plur_cap'], 'order' => 1, 'template' => 'entityAmount', - 'table' => $membersTable, 'url' => $membersIndexPage . "&option=search", + 'result' => $MemberInfo->getStats(), ], [ 'id' => 'membersExportModal', @@ -487,33 +522,54 @@ add_filter( 'resultUrl' => $memberIndexPage . "&glm_action=index&member=", ], [ - 'id' => 'pending', - 'title' => "Pending Member Profiles", - 'slug' => "pending-member-profiles", - 'order' => 3, - 'template' => 'list', - 'entityID' => 'memberInfo', - 'table' => $membersTable, - 'fields' => "id, reference_name as title, member as ref_dest, '10' as ref_type, status", - 'where' => 'status='.$this->config['status_numb']['Pending'], - 'url' => $membersEditPage, + 'id' => 'pending-' . $this->config['terms']['term_member_cap'] . '-profiles', + 'title' => 'Pending ' . $this->config['terms']['term_member_cap'] . ' Profiles', + 'slug' => 'pending-' . $this->config['terms']['term_member'] . '-profiles', + 'order' => 3, + 'template' => 'list', + 'entityID' => 'memberInfo', + 'defaultRefType'=> 'member', + 'refLink' => $membersRefLink, + 'url' => $membersEditPage, + 'result' => $MemberInfo->getList('status='.$MemberInfo->config['status_numb']['Pending'], $order, $fieldVals, $idField, $start, $limit), + 'count' => $MemberInfo->getStats('status='.$MemberInfo->config['status_numb']['Pending'], $order, $fieldVals, $idField, $start, $limit), + 'fieldMap' => [ + 'id' => 'id', + 'name' => 'reference_name', + 'status' => 'status', + 'ref_dest_id' => 'member_pointer', + 'ref_dest_name' => 'member', + //'ref_type' => 'ref_type', // membersInfo has no ref_type field yet + ], ], [ - 'id' => 'bad-location-data', - 'title' => "Bad Location Data", - 'slug' => "bad-location-data", - 'order' => 4, - 'template' => 'list', - 'entityID' => 'memberInfo', - 'table' => $membersTable, - 'fields' => "id, reference_name as title, member as ref_dest, '10' as ref_type, status", - 'where' => "has_no_map_data='1'", - 'url' => $membersEditPage, + 'id' => 'bad-location-data', + 'title' => "Bad Location Data", + 'slug' => "bad-location-data", + 'order' => 4, + 'template' => 'list', + 'entityID' => 'memberInfo', + 'defaultRefType'=> 'member', + 'refLink' => $membersRefLink, + 'url' => $membersEditPage, + 'result' => $MemberInfo->getList("has_no_map_data='1'", $order, $fieldVals, $idField, $start, $limit), + 'count' => $MemberInfo->getStats("has_no_map_data='1'", $order, $fieldVals, $idField, $start, $limit), + 'fieldMap' => [ + 'id' => 'id', + 'name' => 'reference_name', + 'status' => 'status', + 'ref_dest_id' => 'member_pointer', + 'ref_dest_name' => 'member', + //'ref_type' => 'ref_type', // membersInfo has no ref_type field yet + ], ], ] ]; - return $content; + // Restore the fields list + $MemberInfo->fields = $fSave; + + return $content; }, 13, 1 diff --git a/views/admin/export/index.html b/views/admin/export/index.html index af4fb911..8ce1cafa 100644 --- a/views/admin/export/index.html +++ b/views/admin/export/index.html @@ -1,118 +1,117 @@
-
- - - - - - - - - - - - - - - - - - - - {* Custom Field Part *} - {if apply_filters( 'glm-members-customfields-active', false )} - - - + + {/if} + + + + + + + + +
Categories: - -
Member Types: - -
Show Archived:
Featured Only:
Pending Only:
Name Search:
- Enter any portion of a {$terms.term_member_cap} name and press enter or select any specific {$terms.term_member_cap} found. -
Fields to export - - - - - - - - -
Check All / Uncheck All
- {$terms.term_member_cap} ID
- Old {$terms.term_member_cap} ID
- {$terms.term_member_cap} Name
- Profile Reference Name
- Address Line #1
- Address Line #2
- City
- State
- ZIP/Postal Code
- County
- Region
-
- Phone #
- Toll Free
- Main E-Mail
- Primary Contact Name
- Primary Contact E-Mail
- Web Address (URL)
- Categories
- Mailing Address Line #1
- Mailing Address Line #2
- Mailing City
- Mailing State
- Mailing ZIP/Postal Code
-
-
Custom Fields - {$customFields = apply_filters('glm-member-db-fields-get-members-fields', false, 'glm-member-db')} - {if $customFields} - {foreach $customFields as $cf} - {$cf.field_name}
+ + + + + + + + + + + - + + + + + + + + + + + + {* Custom Field Part *} + {if apply_filters( 'glm-members-customfields-active', false )} + + + - - - - - - - -
Categories: + +
Member Types: +
Show Archived:
Featured Only:
Pending Only:
Name Search:
+ Enter any portion of a {$terms.term_member_cap} name and press enter or select any specific {$terms.term_member_cap} found. +
Fields to export + + + + + + + + +
Check All / Uncheck All
+ {$terms.term_member_cap} ID
+ Old {$terms.term_member_cap} ID
+ {$terms.term_member_cap} Name
+ Profile Reference Name
+ Address Line #1
+ Address Line #2
+ City
+ State
+ ZIP/Postal Code
+ County
+ Region
+
+ Phone #
+ Toll Free
+ Main E-Mail
+ Primary Contact Name
+ Primary Contact E-Mail
+ Web Address (URL)
+ Categories
+ Mailing Address Line #1
+ Mailing Address Line #2
+ Mailing City
+ Mailing State
+ Mailing ZIP/Postal Code
+
+
Custom Fields + {$customFields = apply_filters('glm-member-db-fields-get-members-fields', false, 'glm-member-db')} + {if $customFields} + {foreach $customFields as $cf} + {$cf.field_name}
+ {/foreach} {/if} -
Include Clicks & Views - - - - - - - -
- Month: -
- URL Click Counts
- Detail Page View Counts -
-
Export to: - Export for Print
- Export to Spreadsheet (CSV) -
- Cancel - - - +
Include Clicks & Views + + + + + + + +
+ Month: +
+ URL Click Counts
+ Detail Page View Counts +
+
Export to: + Export for Print
+ Export to Spreadsheet (CSV) +
+ Cancel + +
\ No newline at end of file diff --git a/views/admin/newDashboard/components/buttons.html b/views/admin/newDashboard/components/buttons.html index 3f1826c8..94d67272 100644 --- a/views/admin/newDashboard/components/buttons.html +++ b/views/admin/newDashboard/components/buttons.html @@ -1,9 +1,9 @@
{foreach $component.buttons as $buttonName => $buttonData} - + {if $buttonData.content}{$buttonData.content}{/if} {/foreach} diff --git a/views/admin/newDashboard/components/entityAmount.html b/views/admin/newDashboard/components/entityAmount.html index 3d83c6e5..f4e810cf 100644 --- a/views/admin/newDashboard/components/entityAmount.html +++ b/views/admin/newDashboard/components/entityAmount.html @@ -1,9 +1,9 @@ -
{if $component.title}{$component.title}:{/if} +
{if $component.title}{$component.title}:{/if} {if $component.url} - {$component.count} + {$component.result} {else} - {$component.count} + {$component.result} {/if}
\ No newline at end of file diff --git a/views/admin/newDashboard/components/list.html b/views/admin/newDashboard/components/list.html index 1a3cba22..684f6309 100644 --- a/views/admin/newDashboard/components/list.html +++ b/views/admin/newDashboard/components/list.html @@ -1,20 +1,55 @@ -
{$component.title}: {$component.count}
+
{$component.title}: {$component.count}
    -{foreach $component['listItems'] as $listItem} + +{foreach $component['result'] as $listItem} {if isset($listItem)} + + {$itemID = false} + {$itemName = false} + {$itemRefType = false} + {$itemRefDestID = false} + {$itemRefDestName = false} + {$itemExpireDate = false} + + {* Convert mapped values to more easily usable variables *} + {if isset($listItem[$component['fieldMap']['id']]) && isset($listItem[$component['fieldMap']['id']])} + {$itemID = $listItem[$component['fieldMap']['id']]} + {/if} + {if isset($listItem[$component['fieldMap']['name']]) && isset($listItem[$component['fieldMap']['name']])} + {$itemName = $listItem[$component['fieldMap']['name']]} + {/if} + {if isset($listItem[$component['fieldMap']['ref_type']]) && isset($listItem[$component['fieldMap']['ref_type']]) } + {$itemRefType = $listItem[$component['fieldMap']['ref_type']]['name']|strtolower} + {else} + {$itemRefType = $component['defaultRefType']} + {/if} + {if isset($listItem[$component['fieldMap']['ref_dest_id']]) && isset($listItem[$component['fieldMap']['ref_dest_id']])} + {$itemRefDestID = $listItem[$component['fieldMap']['ref_dest_id']]} + {/if} + {if isset($listItem[$component['fieldMap']['ref_dest_name']]) && isset($listItem[$component['fieldMap']['ref_dest_name']])} + {$itemRefDestName = $listItem[$component['fieldMap']['ref_dest_name']]} + {/if} + {if isset($listItem[$component['fieldMap']['expire_date']]) && isset($listItem[$component['fieldMap']['expire_date']])} + {$itemExpireDate = $listItem[$component['fieldMap']['expire_date']]} + {/if} +
  • - expire_date)} data-position="top" data-tooltip="expired: {date( 'm/d/Y', strtotime($listItem->expire_date))}"{/if}> - {$listItem->title} - - - {if $listItem->ref_dest && $listItem->ref_type} - - {$listItem->ref_type}: {$listItem->ref_dest} + {if isset($component.url)} + + {/if} + {$itemName} + {if isset($component.url)} + + {/if} + {if $itemRefType && $itemRefDestID && $itemRefDestName} + + {$itemRefDestName} {/if}
  • +
    {/if} {/foreach}
\ No newline at end of file diff --git a/views/admin/newDashboard/summaryWidget.html b/views/admin/newDashboard/summaryWidget.html index 7470c68f..958f488a 100644 --- a/views/admin/newDashboard/summaryWidget.html +++ b/views/admin/newDashboard/summaryWidget.html @@ -15,6 +15,7 @@ {**/if**} {/if} {/foreach} +
\ No newline at end of file