Added code to display issues with search management settings in the main dashboard...
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 22 Jul 2016 18:41:24 +0000 (14:41 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 22 Jul 2016 18:41:24 +0000 (14:41 -0400)
models/admin/dashboardWidget/search.php [new file with mode: 0644]
setup/adminHooks.php
setup/shortcodes.php
setup/validActions.php
views/admin/dashboardWidget/search.html [new file with mode: 0644]

diff --git a/models/admin/dashboardWidget/search.php b/models/admin/dashboardWidget/search.php
new file mode 100644 (file)
index 0000000..22f6b63
--- /dev/null
@@ -0,0 +1,149 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Search Status for Main Dashboard Widget
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Gaslight Media <info@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+/*
+ * Check whether there's any notices that should be displayed
+ * in the main dashboard widget.
+ */
+class GlmMembersAdmin_dashboardWidget_search
+{
+
+    /**
+     * 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;
+
+    }
+
+    /*
+     * 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)
+    {
+
+        // Get the Open Search Server parameters from management settings
+        $index = $this->config['settings']['search_index'];
+        $website = $this->config['settings']['website'];
+        $login = $this->config['settings']['login'];
+        $key = $this->config['settings']['login_key'];
+
+        $displayNotice = false;
+
+        $indexNotice = false;
+        if (trim($index) == '') {
+            $indexNotice = true;
+            $displayNotice = true;
+        }
+
+        $websiteNotice = false;
+        if (trim($website) != GLM_MEMBERS_HOSTNAME) {
+            $websiteNotice = true;
+            $displayNotice = true;
+        }
+
+        $loginNotice = false;
+        if (trim($website) == '') {
+            $loginNotice = true;
+            $displayNotice = true;
+        }
+
+        $keyNotice = false;
+        if (trim($key) == '') {
+            $keyNotice = true;
+            $displayNotice = true;
+        }
+
+        // Compile template data
+        $templateData = array(
+            'displayNotice'     => $displayNotice,
+            'indexNotice'          => $indexNotice,
+            'websiteNotice'        => $websiteNotice,
+            'loginNotice'          => $loginNotice,
+            'keyNotice'            => $keyNotice,
+        );
+
+        // Return status, suggested view, and data to controller - also return any modified settings
+        return array(
+            'status'            => true,
+            'menuItemRedirect'  => false,
+            'modelRedirect'     => false,
+            'view'              => 'admin/dashboardWidget/search.html',
+            'data'              => $templateData
+        );
+
+    }
+
+
+}
+
+?>
\ No newline at end of file
index 6e7ad8e..54ce2c3 100644 (file)
@@ -25,3 +25,9 @@
  *
  *  Also note that parameters will be in the context of the main admin controller constructor.
   */
+
+// Add warnings to the main dashboard widget by calling model with current controller (admin)
+add_filter( 'glm-member-db-dashboard-widget-warnings', function( $content ) {
+    $content .= $this->controller('dashboardWidget', 'search');
+    return $content;
+});
index 61f7769..f3c2c51 100644 (file)
@@ -21,7 +21,7 @@
  *
  * This array is merged with the data from any registered add-ons
  * providing short-code features. The plugin providing the short-code
- * is designated in the 'plugin' elemeent.
+ * is designated in the 'plugin' element.
  *
  * A shortcode is unique to a particular plugin. To provide additional
  * data and features to a short-code, an add-on should use filters
@@ -120,7 +120,7 @@ $glmMembersSearchShortcodesDescription = '
     </tr>
     <tr>
         <td>&nbsp;</td>
-        <th>type="{search type}"</th>
+        <th>type="{search type}" NOT YET IMPLEMENTED</th>
         <td>
             The type of search
             <p>
@@ -135,7 +135,7 @@ $glmMembersSearchShortcodesDescription = '
     </tr>
     <tr>
         <td>&nbsp;</td>
-        <th>order="{order type}"</th>
+        <th>order="{order type}" NOT YET IMPLEMENTED</th>
         <td>
             Order of search results
             <p>
index c29e80e..28b06c4 100644 (file)
@@ -42,6 +42,9 @@ $glmMembersSearchAddOnValidActions = array(
     'adminActions' => array(
         'management' => array(
             'search' => GLM_MEMBERS_SEARCH_PLUGIN_SLUG
+        ),
+        'dashboardWidget' => array(
+            'search' => GLM_MEMBERS_SEARCH_PLUGIN_SLUG
         )
     ),
     'frontActions' => array(
diff --git a/views/admin/dashboardWidget/search.html b/views/admin/dashboardWidget/search.html
new file mode 100644 (file)
index 0000000..0787060
--- /dev/null
@@ -0,0 +1,14 @@
+{if $displayNotice}
+<div>
+    <h4>
+        <span class="glm-error">Required Search Add-On Settings</span>&nbsp;&nbsp;
+        <a href="{$adminUrl}?page=glm-members-admin-menu-management&glm_action=search">Fix search settings</a>
+    </h4>
+    {if $indexNotice}No Index set<br>{/if}
+    {if $websiteNotice}No Website set or does not match current site<br>{/if}
+    {if $loginNotice}No OSS Login set<br>{/if}
+    {if $keyNotice}No OSS Key set<br>{/if}
+    
+    <p>
+</div>
+{/if}
\ No newline at end of file