--- /dev/null
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Members Dashboard
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Steve Sutton <steve@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @version 0.1
+ */
+
+require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEvents.php';
+
+/**
+ * Dashboard Class Model
+ *
+ * Each Add-On can have one or more dashboards.
+ */
+
+class GlmMembersAdmin_dashboard_leads // extends GlmDataEvents
+{
+ /**
+ * Word Press 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 successful 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 controller 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;
+ $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']['contactUser']['ID'];
+ 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 '<pre>$last_search: ' . print_r( $last_search, true ) . '</pre>';
+ $last_search_params = $last_search['search'];
+ //echo '<pre>$last_search_params: ' . print_r( $last_search_params, true ) . '</pre>';
+ $search_params = unserialize( $last_search_params );
+ //echo '<pre>$search_params: ' . print_r( $search_params, true ) . '</pre>';
+ }
+ }
+
+ }
+
+ // Compile template data.
+ $templateData = array(
+ 'lastSearchDate' => $lastSearchDate,
+ 'hasLastDownload' => $hasLastDownload,
+ 'memberID' => $memberID,
+ );
+
+ // Return status, suggested view, and data to controller.
+ return array(
+ 'status' => $success,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/dashboard/leads.html',
+ 'data' => $templateData
+ );
+
+ }
+
+}
*
* Also note that parameters will be in the context of the main admin controller constructor.
*/
+if ( current_user_can( 'glm_members_members' ) ) {
+ function ts_dashboard_1( $post, $callback_args ) {
+ echo 'Hello Test Test!!';
+ }
-function ts_dashboard_1( $post, $callback_args ) {
- echo 'Hello Test Test!!';
-}
+ function add_ts_dashboard() {
+ wp_add_dashboard_widget( 'dashboard_widget', 'Example Dashboard Widget', 'ts_dashboard_1' );
+ }
-function add_ts_dashboard() {
- wp_add_dashboard_widget( 'dashboard_widget', 'Example Dashboard Widget', 'ts_dashboard_1' );
+ add_action( 'wp_dashboard_setup', 'add_ts_dashboard' );
}
-add_action( 'wp_dashboard_setup', 'add_ts_dashboard' );
-
+add_filter(
+ 'glm-member-db-dashboard-member-widgets',
+ function ( $member = null ) {
+ $content .= $this->controller( 'dashboard', 'leads', $member );
+ return $content;
+ },
+ 11,
+ 1
+);