From: Laury GvR Date: Fri, 21 Sep 2018 22:04:46 +0000 (-0400) Subject: Add filter for db widget. Start of expired list item handling X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=a90747e9dcee938bdf487aae7edca1a776819e04;p=WP-Plugins%2Fglm-member-db.git Add filter for db widget. Start of expired list item handling --- diff --git a/models/admin/newDashboard/index.php b/models/admin/newDashboard/index.php index 16e1bf1f..a5271806 100644 --- a/models/admin/newDashboard/index.php +++ b/models/admin/newDashboard/index.php @@ -251,8 +251,6 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers public function queryWidgetLists( &$widgetData = false ) { foreach ( $widgetData['components'] as &$widgetComponent ) { - echo "
Order: "; - var_dump($widgetComponent['order']); if ( $widgetComponent['template'] == 'list' && isset($widgetComponent['fields']) && isset($widgetComponent['table']) ) { @@ -261,6 +259,7 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers } else { $where = " TRUE "; } + $resultsQuery = "SELECT " . $widgetComponent['fields'] . " FROM " . $widgetComponent['table'] . " WHERE " . $where . " LIMIT 5;"; $widgetComponent['sql'] = $resultsQuery; $widgetComponent['listItems'] = $this->wpdb->get_results($resultsQuery); @@ -272,6 +271,9 @@ class GlmMembersAdmin_newDashboard_index extends GlmDataMembers // 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($listItem->expire_date)) { + + } } } $countQuery = "SELECT COUNT(id) FROM " . $widgetComponent['table'] . " WHERE " . $where . ";"; diff --git a/setup/adminHooks.php b/setup/adminHooks.php index 2886dbdc..8cf7b546 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -403,3 +403,101 @@ add_action( 'init', function(){ session_start(); } }); + +add_filter( + GLM_MEMBERS_PLUGIN_SLUG .'-dashboard-widget', + function ( $member = null ) { + $membersIndexPage = GLM_MEMBERS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-members'; + $memberIndexPage = GLM_MEMBERS_PLUGIN_ADMIN_URL . '?page=glm-members-admin-menu-member'; + $membersTable = GLM_MEMBERS_PLUGIN_PREFIX . "members"; + $membersEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE.'member&glm_action=memberInfo'; + + /* + * For list components: pass ref_type and ref_dest as part of the 'fields' string if you want to + * make these options part of the href of each
  • link + * + */ + + $content = [ + 'title' => 'Members', + 'components' => [ + [ + 'id' => 'topButtons', + 'order' => -1, + 'template' => 'buttons', + 'buttons' => [ + 'add-member' => [ + 'content' => 'Add Member', + 'url' => $memberIndexPage . "&glm_action=memberEdit&option=add", + 'classes' => '', + ], + ], + ], + [ + 'id' => 'quickLinks', + 'order' => 0, + 'template' => 'quickLinks', + 'quickLinks' => [ + 'dashboard' => [ + 'content' => 'Dashboard', + 'url' => $membersIndexPage . "&option=dashboard", + ], + 'search' => [ + 'content' => 'Advanced Search', + 'url' => $membersIndexPage . "&option=search", + ], + 'settings' => [ + 'content' => 'Settings', + 'url' => '#set', + ] + ], + ], + [ + 'id' => 'entityAmount', + 'order' => 1, + 'template' => 'entityAmount', + 'table' => $membersTable, + 'url' => $membersIndexPage . "&option=search", + ], + [ + 'id' => 'textSearch', + 'order' => 2, + 'template' => 'textSearch', + 'entityID' => 'id', + 'table' => $membersTable, + 'fields' => "id, title as name, image", + 'where' => 'title', + 'resultUrl' => $memberIndexPage . "&option=edit", + ], + [ + 'id' => 'pending', + 'title' => "Pending Members", + 'slug' => "pending-members", + 'order' => 3, + 'template' => 'list', + 'entityID' => 'id', + 'table' => $membersTable, + 'fields' => "id, title, ref_type, ref_dest", + 'where' => 'status='.$this->config['status_numb']['Pending'], + 'resultUrl' => $membersIndexPage, + ], + [ + 'id' => 'active', + 'title' => "Bad Locaction Data", + 'slug' => "bad-location-data", + 'order' => 4, + 'template' => 'list', + 'entityID' => 'id', + 'table' => $membersTable, + 'fields' => "id, title, ref_type, ref_dest", + 'where' => 'status='.$this->config['status_numb']['Active'], + 'resultUrl' => $membersIndexPage, + ], + ] + ]; + + return $content; + }, + 13, + 1 +); \ No newline at end of file diff --git a/views/admin/newDashboard/components/list.html b/views/admin/newDashboard/components/list.html index e1035704..991315b6 100644 --- a/views/admin/newDashboard/components/list.html +++ b/views/admin/newDashboard/components/list.html @@ -4,7 +4,7 @@ {if isset($listItem)}
  • - {$listItem->title} + {$listItem->title}{if isset($listItem->expire_date)} - expired: {date( "m/d/Y", strtotime($listItem->expire_date))}{/if}
  • {/if} diff --git a/views/admin/newDashboard/summaryWidget.html b/views/admin/newDashboard/summaryWidget.html index 4dff1701..1df691bf 100644 --- a/views/admin/newDashboard/summaryWidget.html +++ b/views/admin/newDashboard/summaryWidget.html @@ -9,11 +9,6 @@ {**if file_exists("./components/$component.component.html") // wouldn't it be great if this worked?**} {** This will throw a serious error if the file does not exist **} - {if isset($component['order']) && $component['order'] !== ''} -
    ====Throwing this component '{$component.template}'' in position {$component.order}====
    - {else} -
    ====No order for this component '{$component.template}', thrown to the top====
    - {/if} {include file="./components/{$component.template}.html"} {**/if**}