*/
$GLOBALS['glmMembersAdminValidActions'] = array(
+ 'dashboardWidget' => array(
+ 'index'
+ ),
'members' => array(
'index', // member list
'list',
'glmMembersAdminScripts'
));
+ // Add dashboard widget
+ add_action( 'wp_dashboard_setup',
+ array(
+ $this,
+ 'glmMembersAdminDashboardWidget'
+
+ ));
+
}
/**
}
+ /**
+ * Add Admin Dashboard Widget
+ *
+ * This method is called by an add_action() hook setup in the contructor.
+ *
+ * (no prameters)
+ *
+ * @return void
+ * @access public
+ */
+ public function glmMembersAdminDashboardWidget ()
+ {
+
+ wp_add_dashboard_widget(
+ 'glm_members_admin_dashboard_widget',
+ 'Member DB Summary',
+ array(
+ $this,
+ 'glmMembersAdminDashboardContent'
+ )
+ );
+
+ }
+
+ /**
+ * Admin dashboard widget content
+ *
+ * (no prameters)
+ *
+ * @return void
+ * @access public
+ */
+
+
/*
* Menu item specific "Callback" methods
*
*
*/
+ // Dashboard Widget
+ public function glmMembersAdminDashboardContent ()
+ {
+ $this->controller('dashboardWidget');
+ }
+
// Main Plugin Menu Item
public function glmMembersAdminMenuMembers ()
{
// Add standard template parameters
$smarty->templateAssign ( 'adminDebug', GLM_MEMBERS_PLUGIN_ADMIN_DEBUG);
+ $smarty->templateAssign ( 'adminURL', GLM_MEMBERS_PLUGIN_ADMIN_URL);
$smarty->templateAssign ( 'baseURL', GLM_MEMBERS_PLUGIN_BASE_URL);
$smarty->templateAssign ( 'thisURL', GLM_MEMBERS_PLUGIN_CURRENT_URL );
- $smarty->templateAssign ( 'thisPage', $_REQUEST['page']);
+ $smarty->templateAssign ( 'thisPage', (isset($_REQUEST['page']) ? $_REQUEST['page']: '') );
$smarty->templateAssign ( 'glmPluginName', GLM_MEMBERS_PLUGIN_NAME );
$smarty->templateAssign ( 'glmPluginMediaURL', GLM_MEMBERS_PLUGIN_MEDIA_URL );
$smarty->templateAssign ( 'thisYear', date ( 'Y' ) );
--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Members Dashboard
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+// Load Members data abstract
+require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMembers.php');
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersAdmin_dashboardWidget_index extends GlmDataMembers
+{
+
+ /**
+ * WordPress Database Object
+ *
+ * @var $wpdb
+ * @access public
+ */
+ public $wpdb;
+ /**
+ * Plugin Configuration Data
+ *
+ * @var $config
+ * @access public
+ */
+ public $config;
+
+ /*
+ * Constructor
+ *
+ * This contructor sets up this model. At this time that only includes
+ * storing away the WordPress data object.
+ *
+ * @return object Class object
+ *
+ */
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ // Run constructor for members data class
+ parent::__construct(false, false);
+
+ }
+
+ /*
+ * Perform Model Action
+ *
+ * This method does the work for this model and returns any resulting data
+ *
+ * @return array Status and data array
+ *
+ * 'status'
+ *
+ * True if successfull and false if there was a fatal failure.
+ *
+ * 'menuItemRedirect'
+ *
+ * If not false, provides a menu item the controller should
+ * execute after this one. Normally if this is used, there would also be a
+ * modelRedirect value supplied as well.
+ *
+ * 'modelRedirect'
+ *
+ * If not false, provides an action the controller should execute after
+ * this one.
+ *
+ * 'view'
+ *
+ * A suggested view name that the contoller should use instead of the
+ * default view for this model or false to indicate that the default view
+ * should be used.
+ *
+ * 'data'
+ *
+ * Data that the model is returning for use in merging with the view to
+ * produce output.
+ *
+ */
+ public function modelAction ($actionData = false)
+ {
+
+ $success = true;
+
+ // Get stats on the current list of members
+ $stats = $this->getStats();
+
+ // Get simple member list
+ $membersList = $this->getSimpleMembersList();
+
+ // Check for required Member Types
+ require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberTypes.php');
+ $MemberTypes = new GlmDataMemberTypes($this->wpdb, $this->config);
+ $memberTypesStats = $MemberTypes->getStats();
+ $haveMemberTypes = ($memberTypesStats > 0);
+
+ // Check for required Categories
+ require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataCategories.php');
+ $Categories = new GlmDataCategories($this->wpdb, $this->config);
+ $categoriesStats = $Categories->getStats();
+ $haveCategories = ($categoriesStats > 0);
+
+ // Check for required Regions
+ require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataRegions.php');
+ $Regions = new GlmDataRegions($this->wpdb, $this->config);
+ $regionsStats = $Regions->getStats();
+ $haveRegions = ($regionsStats > 0);
+
+ // Check for required Accommodation Types
+ require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataAccommodationTypes.php');
+ $AccommodationTypes = new GlmDataAccommodationTypes($this->wpdb, $this->config);
+ $accommodationTypesStats = $AccommodationTypes->getStats();
+ $haveAccommodationTypes = ($accommodationTypesStats > 0);
+
+ // Get number of member information records with pending updates
+ require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php');
+ $MemberInfo = new GlmDataMemberInfo($this->wpdb, $this->config);
+ $membersPending = $MemberInfo->getStats('status = '.$this->config['status_numb']['Pending']);
+
+ // If there's members with pending information, list them
+ $pendingList = false;
+ if ($membersPending > 0) {
+ $pendingList = $MemberInfo->getList('status = '.$this->config['status_numb']['Pending']);
+ }
+
+ // Compile template data
+ $templateData = array(
+ 'numbMembers' => $stats,
+ 'membersList' => $membersList,
+ 'membersPending' => $membersPending,
+ 'haveMemberTypes' => $haveMemberTypes,
+ 'haveCategories' => $haveCategories,
+ 'haveRegions' => $haveRegions,
+ 'haveAccommodationTypes' => $haveAccommodationTypes,
+ 'pendingList' => $pendingList
+ );
+
+ // Return status, suggested view, and data to controller
+ return array(
+ 'status' => $success,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/dashboardWidget/index.html',
+ 'data' => $templateData
+ );
+
+ }
+
+
+}
+
+?>
\ No newline at end of file
--- /dev/null
+ <table class="glm-admin-table">
+
+{if $membersList}
+ <tr>
+ <th>Members</th>
+ <td>
+ <select id="glmMembersList" class="glm-right">
+ <option value=""></option>
+ {foreach $membersList as $m}
+ <option value="{$m.id}">{$m.name}</option>
+ {/foreach}
+ </select>
+ </td>
+ </tr>
+{/if}
+{if !$haveMemberTypes}
+ <tr>
+ <th class="glm-error">No Member Types</th>
+ <td><a href="{$adminURL}?page=glm-members-admin-menu-configure&glm_action=memberTypes" class="glm-right">Add</a></td>
+ </tr>
+{/if}
+{if !$haveCategories}
+ <tr>
+ <th><span class="glm-error">No Member Categories</span></th>
+ <td><a href="{$adminURL}?page=glm-members-admin-menu-configure&glm_action=categories" class="glm-right">Add</a></td>
+ </tr>
+{/if}
+{if !$haveRegions}
+ <tr>
+ <th><span class="glm-error">No Regions</span></th>
+ <td><a href="{$adminURL}?page=glm-members-admin-menu-configure&glm_action=regions" class="glm-right">Add</a></td>
+ </tr>
+{/if}
+{if !$haveAccommodationTypes}
+ <tr>
+ <th><span class="glm-error">No Accommodation Types</span></th>
+ <td><a href="{$adminURL}?page=glm-members-admin-menu-configure&glm_action=accommodationTypes" class="glm-right">Add</a></td>
+ </tr>
+{/if}
+{if $numbMembers == 0}
+ <tr>
+ <th> <span class="glm-error">No Members</span></th>
+ <td><a href="{$adminURL}?page=glm-members-admin-menu-member&glm_action=index&member_id=" class="glm-right">Add a Member</a></td>
+ </tr>
+{/if}
+ <tr><th>Number of Members Listed: </th><td><a href="{$adminURL}?page=glm-members-admin-menu-members-list" class="glm-right">List Members</a><span class="glm-left">{$numbMembers}</span></td></tr>
+ </table>
+
+{if $membersPending}
+ <hr>
+ <h4><span class="glm-error">Pending Member Information</span></h4>
+
+ <table class="wp-list-table widefat fixed posts glm-admin-table"">
+ <thead>
+ <tr>
+ <th>Member Name</th>
+ <th>Reference Name</th>
+ </tr>
+ </thead>
+ <tbody>
+ {assign var="i" value="0"}
+ {foreach $pendingList as $p}
+ {if $i++ is odd by 1}
+ <tr>
+ {else}
+ <tr class="alternate">
+ {/if}
+ <td>
+ <a href="{$adminURL}?page=glm-members-admin-menu-member&glm_action=memberInfo&member={$p.member_pointer}&id={$p.id}}">{$p.member}</a>
+ </td>
+ <td>
+ {$p.reference_name}
+ </td>
+ </tr>
+ {/foreach}
+ </tbody>
+ </table>
+{/if}
+
+{if $membersList}
+ <script type="text/javascript">
+ jQuery(document).ready(function($) {
+
+ $('#glmMembersList').change( function() {
+ window.location.replace("{$adminURL}?page=glm-members-admin-menu-member&glm_action=index&member=" + $(this).find('option:selected').val() );
+ });
+
+
+ });
+ </script>
+{/if}
\ No newline at end of file