$haveInfoRecords = true;
}
- // Not sure how to make the 'callback' use $this-> or this could get pulled out
- // function orderSort ($a, $b) { return (strcmp ($a['order'],$b['order'])); }
-
- // In case we want to treat the widget data before sending it to the viewfile.
- // May be able to avoid sending the (huge) Config array to the view
+ // Create a set of useful data for each registered plugin that has a filter
+ // Use that filter to retrieve table information, then run query for each 'list' field.
foreach ( $this->config[ 'addOns' ] as $a ) {
if ( has_filter( $a['slug'] . "-dashboard-widget") ) {
- //var_dump($a);
$addons[$a['slug']]['name'] = $a['short_name'];
$addons[$a['slug']]['slug'] = $a['slug'];
- $addons[$a['slug']]['index'] = $a['index'];
+ // $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']);
// Sort the component list based on the 'order'
uasort($addons[$a['slug']]['widgetData']['components'], array($this, 'orderSort') ) ;
} else {
- echo "<br>" . $a['slug'] . " has no filter called " . $a['slug'] . "-dashboard-widget";
+ // For testing
+ // echo "<br>" . $a['slug'] . " has no filter called " . $a['slug'] . "-dashboard-widget";
}
}
// Compile template data.
$templateData = array(
- 'lockedToMember' => $lockedToMember,
- 'member' => $actionData,
- 'showArchived' => $showArchived,
- 'statusTypeNumbers' => $this->config['status_numb'],
- 'memberID' => $memberID,
- 'haveInfoRecords' => $haveInfoRecords,
- 'memberInfoRecords' => $memberInfoRecords,
- 'clickThroughCounts' => $clickThroughCounts,
- 'detailViewCounts' => $detailViewCounts,
- 'statusPending' => $this->config['status_numb']['Pending'],
- //'widgetData' => $addons['widgetData'],
- 'addons' => $addons,
+ 'lockedToMember' => $lockedToMember,
+ 'member' => $actionData,
+ 'showArchived' => $showArchived,
+ 'statusTypeNumbers' => $this->config['status_numb'],
+ 'memberID' => $memberID,
+ 'haveInfoRecords' => $haveInfoRecords,
+ 'memberInfoRecords' => $memberInfoRecords,
+ 'clickThroughCounts' => $clickThroughCounts,
+ 'detailViewCounts' => $detailViewCounts,
+ 'statusPending' => $this->config['status_numb']['Pending'],
+ 'addons' => $addons,
);
// Return status, suggested view, and data to controller.
return array(
- 'status' => $success,
- 'menuItemRedirect' => false,
- 'modelRedirect' => false,
- 'view' => 'admin/newDashboard/index.html',
- 'data' => $templateData
+ 'status' => $success,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/newDashboard/index.html',
+ 'data' => $templateData
);
}
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'];
+ }
if ( $widgetComponent['template'] == 'list' && isset($widgetComponent['fields']) && isset($widgetComponent['table']) ) {
-
- if ( isset($widgetComponent['where']) && $widgetComponent['where'] !== "" ) {
- $where = $widgetComponent['where'];
- } else {
- $where = " TRUE ";
- }
-
- $resultsQuery = "SELECT " . $widgetComponent['fields'] . " FROM " . $widgetComponent['table'] . " WHERE " . $where . " LIMIT 5;";
+ $table = $widgetComponent['table'];
+ $fields = $widgetComponent['fields'];
+ $resultsQuery = "SELECT " . $fields . " FROM " . $table . " WHERE" . $where . $order . " LIMIT " . $limit . ";";
+ //echo "<br>" .$resultsQuery;
$widgetComponent['sql'] = $resultsQuery;
$widgetComponent['listItems'] = $this->wpdb->get_results($resultsQuery);
// 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(" . $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 . ";";
+ //echo "<br>" .$countQuery;
$widgetComponent['count'] = $this->wpdb->get_var($countQuery);
-
+ //echo "<pre>" . var_dump($widgetComponent['count']) . "</pre>";
}
}
return $widgetData;
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";
+ $membersTable = GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info";
$membersEditPage = GLM_MEMBERS_PLUGIN_ADMIN_MENU_URL_BASE.'member&glm_action=memberInfo';
/*
],
[
'id' => 'entityAmount',
+ 'title' => 'Number of ' . $this->config['terms']['term_member_plur_cap'],
'order' => 1,
'template' => 'entityAmount',
'table' => $membersTable,
],
[
'id' => 'pending',
- 'title' => "Pending Members",
- 'slug' => "pending-members",
+ 'title' => "Pending Member Profiles",
+ 'slug' => "pending-member-profiles",
'order' => 3,
'template' => 'list',
- 'entityID' => 'id',
+ 'entityID' => 'memberInfo',
'table' => $membersTable,
- 'fields' => "id, title, ref_type, ref_dest",
+ 'fields' => "id, reference_name as title, member as ref_dest, '10' as ref_type, status",
'where' => 'status='.$this->config['status_numb']['Pending'],
- 'resultUrl' => $membersIndexPage,
+ 'url' => $membersEditPage,
],
[
- 'id' => 'active',
- 'title' => "Bad Locaction Data",
+ 'id' => 'bad-location-data',
+ 'title' => "Bad Location Data",
'slug' => "bad-location-data",
'order' => 4,
'template' => 'list',
- 'entityID' => 'id',
+ 'entityID' => 'memberInfo',
'table' => $membersTable,
- 'fields' => "id, title, ref_type, ref_dest",
- 'where' => 'status='.$this->config['status_numb']['Active'],
- 'resultUrl' => $membersIndexPage,
+ 'fields' => "id, reference_name as title, member as ref_dest, '10' as ref_type, status",
+ 'where' => "has_no_map_data='1'",
+ 'url' => $membersEditPage,
],
]
];