'haveFilter' => $haveFilter,
'userDeleted' => $userDeleted,
'wpUserDeleted' => $wpUserDeleted,
-
'numbDisplayed' => $numbDisplayed,
'lastDisplayed' => $lastDisplayed,
'paging' => $paging,
// Return status, any suggested view, and any data to controller
return array(
- 'status' => true,
- 'modelRedirect' => false,
- 'view' => 'admin/contacts/'.$view,
- 'data' => $templateData
+ 'status' => true,
+ 'modelRedirect' => false,
+ 'view' => 'admin/contacts/'.$view,
+ 'data' => $templateData
);
}
}
}
-?>
\ No newline at end of file
+?>
--- /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_CONTACTS_PLUGIN_CLASS_PATH.'/data/dataContacts.php';
+
+/**
+ * Dashboard Class Model
+ *
+ * Each Add-On can have one or more dashboards.
+ */
+
+class GlmMembersAdmin_dashboard_contacts extends GlmDataContacts
+{
+ /**
+ * 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;
+ $haveContacts = false;
+ $contactsList = false;
+ $memberID = false;
+ $where = '';
+
+ // Get list of member contacts.
+ if ( isset( $this->config['loggedInUser']['contactUser']['ref_dest'] )
+ && $memberID = filter_var( $this->config['loggedInUser']['contactUser']['ref_dest'], FILTER_VALIDATE_INT )
+ ) {
+ $where = "ref_type = " . $this->config['ref_type_numb']['Member'] . ' AND ref_dest = ' . $memberID;
+ // Get list of contacts
+ $contactsList = $this->getSimplified( $where, false, 'lname, fname', true, 'id', 1, 5 );
+ //echo '<pre>$contactsList: ' . print_r( $contactsList, true ) . '</pre>';
+ if ( $contactsList != false ) {
+
+ // Get paging results
+ if ( count($contactsList ) > 0) {
+ $haveContacts = true;
+ }
+
+ }
+ }
+
+ // Compile template data.
+ $templateData = array(
+ 'memberID' => $memberID,
+ 'haveContacts' => $haveContacts,
+ 'contactsList' => $contactsList['list'],
+ );
+
+ // Return status, suggested view, and data to controller.
+ return array(
+ 'status' => $success,
+ 'menuItemRedirect' => false,
+ 'modelRedirect' => false,
+ 'view' => 'admin/dashboard/contacts.html',
+ 'data' => $templateData
+ );
+
+ }
+
+}
--- /dev/null
+<div class="glm-widget-container">
+ <div class="glm-widget">
+ <h2><span>Contacts</span></h2>
+ <span class="glm-right">
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=contacts&member={$memberID}&option=create" class="button button-primary glm-button glm-right">Add New {$terms.term_member_cap} Contact</a>
+ </span>
+ <div class="glm-widget-content">
+ <table class="striped glm-admin-table">
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Active</th>
+ <th>Primary</th>
+ </tr>
+ </thead>
+ {if $haveContacts}
+ {foreach $contactsList as $c}
+ <tr>
+ <td class="glm-shrink">
+ <a href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=contacts&option=edit&member={$c.ref_dest}&contact={$c.id}">{$c.lname}, {$c.fname}</a>
+ </td>
+ <td class="glm-shrink">{$c.active.name}</td>
+ <td class="glm-shrink">{if $c.primary_contact.value}Yes{/if}</td>
+ </tr>
+ {/foreach}
+ {else}
+ <tr class="alternate"><td colspan="7">(no contacts listed)</td></tr>
+ {/if}
+ </table>
+ </div>
+ </div>
+</div>