From: Steve Sutton Date: Tue, 11 Oct 2016 14:33:58 +0000 (-0400) Subject: Updating the dashboard model and view X-Git-Tag: v1.1.0^2~1^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=e315f194542387542915a846e5e4924c69603ccb;p=WP-Plugins%2Fglm-member-db-leads.git Updating the dashboard model and view Making this one model and view work for both a member contact logged in and a member manager. --- diff --git a/models/admin/dashboard/leads.php b/models/admin/dashboard/leads.php index 6286368..784901b 100644 --- a/models/admin/dashboard/leads.php +++ b/models/admin/dashboard/leads.php @@ -102,41 +102,35 @@ class GlmMembersAdmin_dashboard_leads // extends GlmDataEvents $hasLastDownload = false; $lastSearchDate = ''; - // Get list of member events. - if ( isset( $this->config['loggedInUser']['contactUser']['ref_dest'] ) - && $memberID = filter_var( $this->config['loggedInUser']['contactUser']['ref_dest'], FILTER_VALIDATE_INT) - ) { - // See if this member has a saved search. - // If the do not then give message about it. - $user_id = $this->config['loggedInUser']['wpUser']; - if ( $user_id ) { - $last_search = $this->wpdb->get_row( - $this->wpdb->prepare( - "SELECT * - FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "searches - WHERE user_id = %d", - $user_id - ), - ARRAY_A - ); - if ( $last_search ) { - $hasLastDownload = true; - $lastSearchDate = $last_search['date_created']; - //echo '
$last_search: ' . print_r( $last_search, true ) . '
'; - $last_search_params = $last_search['search']; - //echo '
$last_search_params: ' . print_r( $last_search_params, true ) . '
'; - $search_params = unserialize( $last_search_params ); - //echo '
$search_params: ' . print_r( $search_params, true ) . '
'; - } + // See if this member has a saved search. + // If the do not then give message about it. + $user_id = $this->config['loggedInUser']['wpUser']; + if ( $user_id ) { + $last_search = $this->wpdb->get_row( + $this->wpdb->prepare( + "SELECT * + FROM " . GLM_MEMBERS_LEADS_PLUGIN_DB_PREFIX . "searches + WHERE user_id = %d", + $user_id + ), + ARRAY_A + ); + if ( $last_search ) { + $hasLastDownload = true; + $lastSearchDate = $last_search['date_created']; + //echo '
$last_search: ' . print_r( $last_search, true ) . '
'; + $last_search_params = $last_search['search']; + //echo '
$last_search_params: ' . print_r( $last_search_params, true ) . '
'; + $search_params = unserialize( $last_search_params ); + //echo '
$search_params: ' . print_r( $search_params, true ) . '
'; } - } + // Compile template data. $templateData = array( 'lastSearchDate' => $lastSearchDate, 'hasLastDownload' => $hasLastDownload, - 'memberID' => $memberID, ); // Return status, suggested view, and data to controller. diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 400dad1..20c029e 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -46,3 +46,12 @@ add_filter( 11, 1 ); +add_filter( + 'glm-member-db-dashboard-member-admin-widgets', + function ( $member = null ) { + $content = $this->controller( 'dashboard', 'leads', $member ); + return $content; + }, + 11, + 1 +);