From 5c3683f750f80146655c5c840fd8e4eaa4d13d6f Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Thu, 19 Jul 2018 14:21:13 -0400 Subject: [PATCH] Various preparatory work for other add-ons and minor cleanup. Started adding code to determine when a member record needs to be re-indexed by the search add-on. Temporarily commented out tell search updates are done. Removed depreciated code from glmMembersAdminNotices() - Function to be removed later. Removed some temporary debug code from admin controller. Added glmMembersConfigArraySetup() array to provide easy expansion of config data in glmPluginSupport.php --- classes/glmPluginSupport.php | 164 +++++++++++------------------ controllers/admin.php | 15 +++ models/admin/member/memberEdit.php | 13 +++ 3 files changed, 91 insertions(+), 101 deletions(-) diff --git a/classes/glmPluginSupport.php b/classes/glmPluginSupport.php index cdff7fff..751ca026 100644 --- a/classes/glmPluginSupport.php +++ b/classes/glmPluginSupport.php @@ -1,5 +1,8 @@ array( + * 'id' => Index number for this entry (key from config array) + * 'descr' => Text description of entry, + * 'name' => Name of field used to find ID (key from names array) + * 'selected' => Selected flag, all initialized to false + * ) + * ) */ -function glmMembersAdminNotices($windowed = true) +function glmMembersConfigArraySetup( $configTable, $configNumbTable = false, $configSelectedArray) { - // Depreciating debug system - return; -/* - $output = ''; - - // If windowed for debug, also include HTML header and stylesheet - if ($windowed) { - - $output .= ' - - - - - - -
'.date('m/d/Y G:i:s A').'
-
'.GLM_MEMBERS_PLUGIN_NAME.' - Debug Data
- '; - - // Display alerts - $alerts = get_option('glmMembersAdminNoticeAlerts'); - if(is_array($alerts)) { - $output .= '

Alerts

'; - foreach($alerts as $a) { - $output .= $a.'
'; - } - } else { - $output .= '

Alerts

'; - } - $output .= '

'; - delete_option('glmMembersAdminNoticeAlerts'); - - // Display process messages - $process = get_option('glmMembersAdminNoticeProcess'); - $output .= '

Processing

'; - if(is_array($process)) { - foreach($process as $p) { - $output .= $p.'
'; - } - } - $output .= '

'; - delete_option('glmMembersAdminNoticeProcess'); - - // Display data blocks table of contents then the data blocks - $dataBlocks = get_option('glmMembersAdminNoticeDataBlocks'); - $output .= '

Data Blocks

    '; - $n = 0; - if (is_array($dataBlocks)) { - foreach($dataBlocks as $d) { - $output .= '
  • '.$d['title'].'
  • '; + + // Check if config table array exits + if (!is_array($configTable) || count($configTable) == 0) { + return false; + } + + // Build base array + $conf = array(); + foreach ($configTable as $key=>$descr) { + $conf[$key] = array( + 'id' => $key, + 'descr' => $descr, + 'name' => false, + 'selected' => false + ); + } + + // If name->number array add that data + if (is_array($configNumbTable) && count($configNumbTable) > 0) { + foreach ($configNumbTable as $name=>$key) { + if (isset($conf[$key])) { + $conf[$key]['name'] = $name; } } + } - $output .= '

'; - if (is_array($dataBlocks)) { - reset($dataBlocks); - $n = 0; - foreach($dataBlocks as $d) { - $output .= ' -
-
[Top]
- -
'.print_r($d['data'],1).'
-
- '; + // If a selected array is provided, add that data + if (is_array($configSelectedArray) && count($configSelectedArray) > 0) { + foreach ($configSelectedArray as $key) { + if (isset($conf[$key])) { + $conf[$key]['selected'] = true; } } + } - echo $output.' - - - '; - - // Otherwise we're outputting data to the message block in the WordPress admin area - } else { - - // Start with div class to output in standard admin notice block - $output .= '

'; - - // Get the notice texts - $notices = get_option('glmMembersAdminNotices'); - - if (is_array($notices) && count($notices) > 0) { - - // For each notice retrieved - $br = ''; - foreach($notices as $n) { - - // Add the notice to the output - $output .= $br.$n; - $br = '
'; - } + return $conf; - } +} - echo $output.'

'; +/** + * Function to display admin notices. - Depreciated + * + * This function is only called using the add_action('admin_notices','...') function + * in the code below this function. + * + * @return void + * @access public + */ +function glmMembersAdminNotices($windowed = true) +{ - } + // Depreciating original debug system + return; - delete_option('glmMembersAdminNoticeAlerts'); - delete_option('glmMembersAdminNotices'); - delete_option('glmMembersAdminNoticeProcess'); - delete_option('glmMembersAdminNoticeDataBlocks'); -*/ } /** diff --git a/controllers/admin.php b/controllers/admin.php index 4e21f2f3..205a6a66 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -254,6 +254,11 @@ class glmMembersAdmin extends GlmPluginSupport public function glmMembersAdminAjax() { + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + trigger_error(glmAssociateMemoryUsage()." - Start AJAX Controller",E_USER_NOTICE); + trigger_error(glmAssociateTimeTracker()." - Start AJAX Controller",E_USER_NOTICE); + } + $defaultTimeZone = date_default_timezone_get(); date_default_timezone_set($this->config['settings']['time_zone']); @@ -358,6 +363,11 @@ class glmMembersAdmin extends GlmPluginSupport } + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + trigger_error("AJAX Controller, Model = $modelName",E_USER_NOTICE); + trigger_error("AJAX Controller, View = $viewPath/$viewFile",E_USER_NOTICE); + } + /* * Merge data returned from the model with the selected view */ @@ -390,6 +400,11 @@ class glmMembersAdmin extends GlmPluginSupport // Restore timezone that was set before our code was called date_default_timezone_set($defaultTimeZone); + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + trigger_error(glmAssociateMemoryUsage()." - End AJAX Controller",E_USER_NOTICE); + trigger_error(glmAssociateTimeTracker()." - End AJAX Controller",E_USER_NOTICE); + } + exit; // Need to test if this is here for a reason! wp_die(); diff --git a/models/admin/member/memberEdit.php b/models/admin/member/memberEdit.php index 8e991237..d02c39a0 100644 --- a/models/admin/member/memberEdit.php +++ b/models/admin/member/memberEdit.php @@ -182,6 +182,8 @@ class GlmMembersAdmin_member_memberEdit extends GlmDataMembers } + $memberStatusBefore = $this->getDisplayStatus($this->memberID); + /* * Perform requested action */ @@ -228,6 +230,17 @@ class GlmMembersAdmin_member_memberEdit extends GlmDataMembers glmClearShortcodeCache(); + // Get member display status again and if status goes from true to false, remove it from the search index +/* + $memberStatusAfter = $this->getDisplayStatus($this->memberID); + $url = ''; // ************************* NEED TO PUT URL HERE ************************* + if ($memberStatusBefore && !$memberStatusAfter) { + $result = apply_filters( 'glm_member_db_common_search_removeurl', $url ); + } + if (!$memberStatusBefore && $memberStatusAfter) { + $result = apply_filters( 'glm_member_db_common_search_indexurl', $url ); + } +*/ break; // Add the new member -- 2.17.1