Adding custom fields to events feature/customFields
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 1 Feb 2019 17:55:56 +0000 (12:55 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 1 Feb 2019 17:55:56 +0000 (12:55 -0500)
Start of custom fields branch

models/admin/settings/eventCustomFields.php [new file with mode: 0644]
setup/adminTabs.php
setup/validActions.php
views/admin/settings/eventCustomFields.html [new file with mode: 0644]

diff --git a/models/admin/settings/eventCustomFields.php b/models/admin/settings/eventCustomFields.php
new file mode 100644 (file)
index 0000000..7bc579f
--- /dev/null
@@ -0,0 +1,150 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Event Email Notification
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+// Load Event Categories data abstract
+// require_once GLM_MEMBERS_EVENTS_PLUGIN_CLASS_PATH.'/data/dataEmailNotifications.php';
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersAdmin_settings_eventCustomFields // extends GlmDataEmailNotifications
+{
+
+    /**
+     * 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 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;
+        $error          = false;
+        $email_settings = false;
+
+        // $email_settings = $this->getSettings();
+
+        // If there's an action option
+        // if (isset($_REQUEST['option'])) {
+        //
+        //     switch($_REQUEST['option']) {
+        //
+        //         case 'update':
+        //             $this->updateEntry($email_settings['id']);
+        //
+        //             break;
+        //         case 'new':
+        //             $this->insertEntry();
+        //             break;
+        //     }
+        //
+        // }
+
+        // If we had a fatal error, redirect to the error page
+        if ($error) {
+            return array(
+                'status' => $success,
+                'menuItemRedirect' => 'error',
+                'modelRedirect'    => 'index',
+                'view'             => 'admin/error/index.html',
+                'data'             => false
+            );
+        }
+
+        // Compile template data
+        $templateData = array(
+            //'email_settings'    => $email_settings
+        );
+
+        // Return status, suggested view, and data to controller
+        return array(
+            'status'           => $success,
+            'menuItemRedirect' => false,
+            'modelRedirect'    => false,
+            'view'             => 'admin/settings/eventCustomFields.html',
+            'data'             => $templateData
+        );
+
+    }
+
+}
index c233465..18d1dc9 100644 (file)
@@ -80,6 +80,19 @@ if (current_user_can('glm_members_members')) {
             return $addOnTabs;
         }
     );
+    add_filter('glm-member-db-add-tab-for-settings',
+        function($addOnTabs) {
+            $newTabs = array(
+                array(
+                    'text'   => 'Event Custom Fields',
+                    'menu'   => 'settings',
+                    'action' => 'eventCustomFields',
+                ),
+            );
+            $addOnTabs = array_merge($addOnTabs, $newTabs);
+            return $addOnTabs;
+        }
+    );
 
 
     add_filter('glm-member-db-add-tab-for-settings',
index 7d6128a..d1bbe91 100644 (file)
@@ -52,9 +52,10 @@ $glmMembersEventsAddOnValidActions = array(
             'list'  => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
         ),
         'settings' => array(
-            'eventCategories' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
-            'eventAmenities' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
+            'eventCategories'    => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
+            'eventAmenities'     => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
             'emailNotifications' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
+            'eventCustomFields'  => GLM_MEMBERS_EVENTS_PLUGIN_SLUG,
         ),
         'management' => array(
             'events' => GLM_MEMBERS_EVENTS_PLUGIN_SLUG
diff --git a/views/admin/settings/eventCustomFields.html b/views/admin/settings/eventCustomFields.html
new file mode 100644 (file)
index 0000000..b2ed9aa
--- /dev/null
@@ -0,0 +1,16 @@
+{* Event Custom Fields view file *}
+{include file='admin/settings/header.html'}
+
+<h1>
+    Event Custom fields to output here
+</h1>
+{if apply_filters('glm-members-customfields-plugin-active', false)}
+    {apply_filters('glm-members-customfields-form-edit', '', 'glm_event_customfields')}
+{/if}
+
+<script type="text/javascript">
+    jQuery(document).ready(function($) {
+
+    });
+</script>
+{include file='admin/footer.html'}