Finish the groups setup for dataAbstract and fix clear cache
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 16 Apr 2019 13:32:03 +0000 (09:32 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 16 Apr 2019 13:32:03 +0000 (09:32 -0400)
Clear cache wasn't working because the model for management was only
allowing one option (submit).
DataAbstract class methods now hawe the calls for setting up groups of
fields.

classes/glmPluginSupport.php
lib/GlmDataAbstract/DataAbstract.php
models/admin/management/index.php

index 8c40d80..937f7eb 100755 (executable)
@@ -549,9 +549,10 @@ function glmClearShortcodeCache()
 
     global $wpdb;
 
+    $wpdb->show_errors();
     // Remove all cache entries from the database
-    $sql = "DELETE from ".GLM_MEMBERS_PLUGIN_DB_PREFIX."cache;";
-    $wpdb->query($sql);
+    $sql = "DELETE FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."cache";
+    $wpdb->query( $sql );
 
     return;
 }
index 3a0060f..214346c 100755 (executable)
@@ -3255,6 +3255,7 @@ $forEdit = true;
      */
     public function getList( $where = '', $order = '', $fieldVals = true, $idField = 'id', $start = false, $limit = false, $prohibitListOptions = false, $appendSelect = null )
     {
+        $this->selectGroupFields();
 
         // For testing only
         /*
@@ -3395,6 +3396,7 @@ $forEdit = true;
             );
         }
 
+        $this->restoreFields();
         // Since we're not doing paging, return the list only
         return $newList;
     }
@@ -3407,7 +3409,6 @@ $forEdit = true;
      */
     public function getEntry($id, $idfield = 'id', $where = 'true', $fieldVals = false)
     {
-
         $this->selectGroupFields();
         // If there's an ID supplied, add that to the query
         $idWhere = '';
@@ -3596,6 +3597,7 @@ $forEdit = true;
      */
     public function newEntry()
     {
+        $this->selectGroupFields();
         // Doing processInputData() with operation "n" only gets setup info
         // such as pick-lists and does not actually process input.
         $r = $this->processInputData('n');
@@ -3604,6 +3606,7 @@ $forEdit = true;
         // Check if there's a function to do other checks
         $r = $this->checkOther($r, 'n');
 
+        $this->restoreFields();
         return $r;
     }
 
@@ -3650,6 +3653,7 @@ $forEdit = true;
      */
     public function insertEntry($store = true, $fieldPrefix = '')
     {
+        $this->selectGroupFields();
 
         // Store any input field prefix
         $this->fieldPrefix = $fieldPrefix;
@@ -3691,6 +3695,7 @@ $forEdit = true;
 
         }
 
+        $this->restoreFields();
         return $r;
     }
 
@@ -3702,6 +3707,7 @@ $forEdit = true;
      */
     public function editEntry($id, $idField = 'id')
     {
+        $this->selectGroupFields();
         $this->buildFieldsList('g');
 
         $sql = "SELECT $this->select
@@ -3718,6 +3724,7 @@ $forEdit = true;
         // Process individual fields
         $detail = $this->processOutputData($detail, 'e', true, $id, $idField);
 
+        $this->restoreFields();
         return $detail;
     }
 
index eae247e..340fe80 100755 (executable)
@@ -145,9 +145,9 @@ class GlmMembersAdmin_management_index extends GlmDataSettingsGeneral
             );
         }
 
-        // Check for submission option
+        // Check for option
         $option = '';
-        if ( isset( $_REQUEST[ 'option' ] ) && $_REQUEST[ 'option' ] == 'submit' ) {
+        if ( isset( $_REQUEST[ 'option' ] ) ) {
             $option = $_REQUEST['option'];
         }
 
@@ -214,11 +214,12 @@ class GlmMembersAdmin_management_index extends GlmDataSettingsGeneral
 
         case 'clearCache':
 
-            // Cleaor the shortcode cache.
-            glmClearShortcodeCache();
-
             // Try to get the first (should be only) entry for general settings.
             $generalSettings = $this->editEntry( $id );
+
+            // Clear the shortcode cache.
+            glmClearShortcodeCache();
+
             break;
 
         // Default is to get the current settings and display the form