Commented out shortcode override function
authorLaury GvR <laury@gaslightmedia.com>
Tue, 4 Oct 2016 15:05:07 +0000 (11:05 -0400)
committerLaury GvR <laury@gaslightmedia.com>
Tue, 4 Oct 2016 15:05:07 +0000 (11:05 -0400)
This function was causing the shortcode to be overridden in the
sidebar. The function itself is deprecated and has now been
disabled.

controllers/front.php
models/front/members/featured.php [new file with mode: 0644]

index 03b8dc1..7188d39 100644 (file)
@@ -314,13 +314,20 @@ class glmMembersFront extends GlmPluginSupport
             $menuItem = $shortcodeData['menu'];
             $action = $shortcodeData['action'];
 
-            // Get any requested "action" from a form submission - Overrides short-code default action
+            /* Get any requested "action" from a form submission - Overrides short-code default action
+             * 
+             * This has been commented out because it does not appear to be used
+             * and was causing the wrong model to be used after a category-based
+             * search to a page with more than one model..
+             */
+            /* 
             if (isset($_REQUEST['glm_action']) && $_REQUEST['glm_action'] != '') {
                 $a = sanitize_text_field($_REQUEST['glm_action']);
                 if ($a != '') {
                     $action = $a;
                 }
             }
+             */
 
             // Set the default attributes and create a filter to update them
             $actionData = array(
@@ -393,7 +400,7 @@ class glmMembersFront extends GlmPluginSupport
                     }
 
                     // check for an invalid model class name
-                    if (! class_exists($className)) {
+                    if (! class_exists($className)) { 
 
                         $errorMsg .= "<b>Model class doesn't exist:</b> ".$className;
 
diff --git a/models/front/members/featured.php b/models/front/members/featured.php
new file mode 100644 (file)
index 0000000..b80834d
--- /dev/null
@@ -0,0 +1,141 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Front Featured Members
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+
+// Load Members data abstract
+require_once GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberInfo.php';
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersFront_members_featured extends GlmDataMemberInfo
+{
+
+    /**
+     * 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 contoller 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)
+    {
+        $settings = array();
+
+        $view = "featured";
+        $sql = "
+            SELECT id
+              FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "members
+              WHERE featured
+              
+            ;";
+        $id = $this->wpdb->get_var($sql);
+        $memberData = $this->getActiveInfoForMember($id);
+        if (count($memberData) > 0) {
+            $success = true;
+        }
+
+        // Compile template data
+        
+//        echo "<pre>".print_r($memberData,true)."</pre>";
+        
+        $templateData = array(
+            'view'             => $view,
+            'member'           => $memberData,
+        );
+
+        // Return status, suggested view, and data to controller - also return any modified settings
+        return array(
+            'status'           => $success,
+            'menuItemRedirect' => false,
+            'modelRedirect'    => false,
+            'view'             => "front/members/featured.html",
+            'data'             => $templateData,
+            'settings'         => $settings
+        );
+
+    }
+
+
+}
+
+?>