From b754e34e2031151f570566d4d59117371505160e Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 6 Sep 2016 15:46:24 -0400 Subject: [PATCH] Setup the event widget. WIP work in progress... --- models/admin/dashboard/events.php | 127 ++++++++++++++++++++++++++++++ setup/adminHooks.php | 9 +++ setup/validActions.php | 3 + views/admin/dashboard/events.html | 23 ++++++ 4 files changed, 162 insertions(+) create mode 100644 models/admin/dashboard/events.php create mode 100644 views/admin/dashboard/events.html diff --git a/models/admin/dashboard/events.php b/models/admin/dashboard/events.php new file mode 100644 index 0000000..e910208 --- /dev/null +++ b/models/admin/dashboard/events.php @@ -0,0 +1,127 @@ + + * @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_events 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; + + // 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) + ) { + $events = $this->getList( "T.ref_dest = {$memberID}" ); + } + + // Compile template data. + $templateData = array( + 'events' => $events, + 'memberID' => $memberID, + ); + + // Return status, suggested view, and data to controller. + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/dashboard/events.html', + 'data' => $templateData + ); + + } + +} diff --git a/setup/adminHooks.php b/setup/adminHooks.php index ebf4363..498f409 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -25,3 +25,12 @@ * * Also note that parameters will be in the context of the main admin controller constructor. */ +add_filter( + 'glm-member-db-dashboard-member-widgets', + function ( $member = null ) { + $content .= $this->controller( 'dashboard', 'events', $member ); + return $content; + }, + 11, + 1 +); diff --git a/setup/validActions.php b/setup/validActions.php index aba3399..6154de8 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -40,6 +40,9 @@ $glmMembersEventsAddOnValidActions = array( 'eventsCalMonthAJAX' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, 'icalFeedImport' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, ), + 'dashboard' => array( + 'events' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, + ), 'member' => array( 'events' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG, ), diff --git a/views/admin/dashboard/events.html b/views/admin/dashboard/events.html new file mode 100644 index 0000000..42d7a4d --- /dev/null +++ b/views/admin/dashboard/events.html @@ -0,0 +1,23 @@ +
+
+

+ Events +

+
+ + Add Event +
+ {if $events} + + {/if} +
+
+
-- 2.17.1