From: Chuck Scott Date: Thu, 26 Apr 2018 14:27:23 +0000 (-0400) Subject: Added Management "Crons" tab to display a sorted lsit of GLM Cron requests X-Git-Tag: v2.10.30^2~5 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=149fc5bd4b1a7d743124acacd85dfa6a5e82a1eb;p=WP-Plugins%2Fglm-member-db.git Added Management "Crons" tab to display a sorted lsit of GLM Cron requests --- diff --git a/index.php b/index.php index c3b89287..68b60927 100644 --- a/index.php +++ b/index.php @@ -222,8 +222,9 @@ require_once 'defines.php'; // Get configuration require_once 'config.php'; -if (GLM_MEMBERS_PLUGIN_DEBUG_VERBOSE) { - trigger_error(glmAssociateMemoryUsage()." - Start glm-member-db setup",E_USER_NOTICE); +if (GLM_MEMBERS_PLUGIN_DEBUG) { + ini_set('log_errors_max_len', 4096); + trigger_error("GLM Associate Index Start: ".glmAssociateMemoryUsage()." - Start glm-member-db setup",E_USER_NOTICE); } /* @@ -839,4 +840,7 @@ if (!$timestamp) { wp_schedule_event( $t, 'hourly', 'glm_associate_cron' ); } +if (GLM_MEMBERS_PLUGIN_DEBUG) { + trigger_error("GLM Associate Index End: ".glmAssociateMemoryUsage()." - Start glm-member-db setup",E_USER_NOTICE); +} diff --git a/models/admin/ajax/glmCron.php b/models/admin/ajax/glmCron.php index 52babfb7..d370fb4f 100644 --- a/models/admin/ajax/glmCron.php +++ b/models/admin/ajax/glmCron.php @@ -83,8 +83,8 @@ class GlmMembersAdmin_ajax_glmCron extends glmMembersAdmin foreach ($cronActions as $act) { - // Check if this action should be run now - if (in_array($thisDay, $act['daysOfWeek']) && in_array($thisHour, $act['times'])) { + // Check if this action should be run now - If daysOfWeek or times are false they they always match. + if ((!$act['daysOfWeek'] || in_array($thisDay, $act['daysOfWeek'])) && (!$act['times'] || in_array($thisHour, $act['times']))) { // Run the action by calling the controller - force controller to use supplied action (no REQUEST override) $this->controller($act['menu'], $act['action'], $act['params'], false, true); diff --git a/models/admin/management/cron.php b/models/admin/management/cron.php new file mode 100644 index 00000000..18b83dda --- /dev/null +++ b/models/admin/management/cron.php @@ -0,0 +1,141 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 1.0.43 + */ + +/* + * This class performs the work for the default action of the "Members" menu + * option, which is to display the members dashboard. + * + */ +class GlmMembersAdmin_management_cron +{ + + /** + * 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) + { + + $haveCronActions = false; + + // Get requested cron actions + $cronActions = apply_filters('glm_associate_cron_request', array()); + + + // Loop through these actions and call what's appropriate for the current time + if (is_array($cronActions)) { + if (count($cronActions) > 0) { + $haveCronActions = true; + + function sortCrons($a, $b) { + if ($a['menu'] < $b['menu']) { return -1; } + if ($a['menu'] > $b['menu']) { return 1; } + if ($a['action'] < $b['action']) { return -1; } + if ($a['action'] > $b['action']) { return 1; } + return 0; + } + + usort($cronActions, 'sortCrons'); + + } + } else { + trigger_error('GLM Associate Cron: Bad request array!', E_USER_WARNING); + } + + $viewData = array( + 'haveCronActions' => $haveCronActions, + 'cronActions' => $cronActions + ); + + // echo "
".print_r($viewData,1)."
"; + + // Return status, suggested view, and data to controller + return array( + 'status' => true, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/management/cron.html', + 'data' => $viewData + ); + + } + +} + +?> \ No newline at end of file diff --git a/setup/validActions.php b/setup/validActions.php index cde1cd42..c9d93a05 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -84,7 +84,8 @@ $glmMembersValidActions = array( 'theme' => 'glm-member-db', 'import' => 'glm-member-db', 'addons' => 'glm-member-db', - 'hooks' => 'glm-member-db' + 'hooks' => 'glm-member-db', + 'cron' => 'glm-member-db' ), 'shortcodes' => array( 'index' => 'glm-member-db' diff --git a/views/admin/management/cron.html b/views/admin/management/cron.html new file mode 100644 index 00000000..7d30ad50 --- /dev/null +++ b/views/admin/management/cron.html @@ -0,0 +1,51 @@ +{include file='admin/management/header.html'} + +

Current Cron Action Requests

+
 
+ + + + + + + + + + + + +{$m = ''} +{foreach $cronActions as $ca} + + + + + + + +{/foreach} + +
MenuActionDaysTimesParameters
+ {if $ca.menu != $m} + {$m = $ca.menu} + {$ca.menu} + {/if} + {$ca.action} + {if $ca.daysOfWeek} + {', '|implode:$ca.daysOfWeek} + {else} + All + {/if} + + {if $ca.times} + {', '|implode:$ca.times} + {else} + All + {/if} + + {if $ca.params}Yes{else} {/if} +
+ + + +{include file='admin/footer.html'} diff --git a/views/admin/management/header.html b/views/admin/management/header.html index b1080caa..5e957347 100644 --- a/views/admin/management/header.html +++ b/views/admin/management/header.html @@ -10,6 +10,7 @@ Members Add-Ons Hooks + Crons Videos {foreach $addOnTabs as $a} {$a.text}