Setup the event widget.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 6 Sep 2016 19:46:24 +0000 (15:46 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 6 Sep 2016 19:46:24 +0000 (15:46 -0400)
WIP work in progress...

models/admin/dashboard/events.php [new file with mode: 0644]
setup/adminHooks.php
setup/validActions.php
views/admin/dashboard/events.html [new file with mode: 0644]

diff --git a/models/admin/dashboard/events.php b/models/admin/dashboard/events.php
new file mode 100644 (file)
index 0000000..e910208
--- /dev/null
@@ -0,0 +1,127 @@
+<?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_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
+        );
+
+    }
+
+}
index ebf4363..498f409 100644 (file)
  *
  *  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
+);
index aba3399..6154de8 100644 (file)
@@ -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 (file)
index 0000000..42d7a4d
--- /dev/null
@@ -0,0 +1,23 @@
+<div class="glm-widget-container">
+    <div class="glm-widget">
+        <h2>
+            <span>Events</span>
+        </h2>
+        <div class="glm-widget-content">
+            <a class="glm-right" href="{$thisUrl}?page=glm-members-admin-menu-member&glm_action=events&option=add&member={$memberID}">
+                Add Event
+            </a><br>
+                {if $events}
+            <ul >
+                {foreach $events as $event}
+                <li>
+                    <a href="{$thisUrl}?page=glm-members-admin-menu-events-list&glm_action=list&member={$memberID}&option=edit&event={$event.id}">
+                        {$event.name}
+                    </a> ({$event.status.name})
+                </li>
+                {/foreach}
+            </ul>
+            {/if}
+        </div>
+    </div>
+</div>