// 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);
}
/*
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);
+}
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);
--- /dev/null
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Management - Cron
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @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 "<pre>".print_r($viewData,1)."</pre>";
+
+ // 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
--- /dev/null
+{include file='admin/management/header.html'}
+
+ <h2>Current Cron Action Requests</h2>
+ <div> </div>
+
+ <table width="90%">
+ <thead>
+ <tr>
+ <th align="left">Menu</th>
+ <th align="left">Action</th>
+ <th align="left">Days</th>
+ <th align="left">Times</th>
+ <th align="left">Parameters</th>
+ </tr>
+ </thead>
+ <tbody>
+{$m = ''}
+{foreach $cronActions as $ca}
+ <tr>
+ <td>
+ {if $ca.menu != $m}
+ {$m = $ca.menu}
+ {$ca.menu}
+ {/if}
+ </td>
+ <td>{$ca.action}</td>
+ <td>
+ {if $ca.daysOfWeek}
+ {', '|implode:$ca.daysOfWeek}
+ {else}
+ All
+ {/if}
+ </td>
+ <td>
+ {if $ca.times}
+ {', '|implode:$ca.times}
+ {else}
+ All
+ {/if}
+ </td>
+ <td>
+ {if $ca.params}Yes{else} {/if}
+ </td>
+ </tr>
+{/foreach}
+ </tbody>
+ </table>
+
+
+
+{include file='admin/footer.html'}