From: Chuck Scott Date: Tue, 24 Apr 2018 17:59:05 +0000 (-0400) Subject: Added sendNotifications to GLM Cron - Send Notifications not complete X-Git-Tag: v1.0.0^2~18 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=649e954754cf046ebe6edfe619051029de997435;p=WP-Plugins%2Fglm-member-db-registrations.git Added sendNotifications to GLM Cron - Send Notifications not complete --- diff --git a/models/admin/registrations/sendNotifications.php b/models/admin/registrations/sendNotifications.php new file mode 100644 index 0000000..00c2544 --- /dev/null +++ b/models/admin/registrations/sendNotifications.php @@ -0,0 +1,107 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Registrations Notification data class +require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegNotification.php'; + +class GlmMembersAdmin_registrations_sendNotifications extends GlmDataRegistrationsRegNotification +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Registrations Event ID + * + * @var $eventID + * @access public + */ + public $accountID = false; + + /** + * Constructor + * + * This contructor performs the work for this model. This model returns + * an array containing the following. + * + * 'status' + * + * True if successfull and false if there was a fatal failure. + * + * '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. + * + * @wpdb object WordPress database object + * + * @return array Array containing status, suggested view, and any data + */ + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + /* + * Run constructor for the Registrations data class + * + * Note, the third parameter is a flag that indicates to the Contacts + * data class that it should flag a group of fields as 'view_only'. + */ + parent::__construct(false, false, true); + + } + + public function modelAction($actionData = false) + { + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + trigger_error('Registrations Notifications Called', E_USER_NOTICE); + } + + + // This model does not return any data + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => false, + 'data' => false + ); + + } + + +} diff --git a/setup/adminHooks.php b/setup/adminHooks.php index d562775..c5df1ff 100644 --- a/setup/adminHooks.php +++ b/setup/adminHooks.php @@ -93,3 +93,30 @@ add_filter( 10, 2 ); + + +/* + * Add a admin action or actions to GLM Associate Cron + * + * See description for "GLM Associate Cron" in main plugin index.php file. + */ +add_filter('glm_associate_cron_request', function($request) { + + // Sanity check - Must be passed an array + if (is_array($request)) { + + $request[] = array( + 'menu' => 'registrations', // Menu where action exists + 'action' => 'sendNotifications', // Name of action to run + 'daysOfWeek'=> array(1, 2, 3, 7), // All Days + 'times' => array(0, 13, 21), // All Hours + 'params' => false // Any parameters needed by the triggered action + ); + + } else { + trigger_error('Cron Request filter recieved bad request array!', E_USER_WARNING); + } + + return $request; + +}, 10, 1); diff --git a/setup/validActions.php b/setup/validActions.php index a278b4b..5bf8b7d 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -68,14 +68,15 @@ $glmMembersRegistrationsAddOnValidActions = array( 'updateAvailability' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'registrantsListExport' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'setupEventRegQueue' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, - 'runEventRegQueue' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'runEventRegQueue' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG ), 'registrations' => array( 'index' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'events' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'requests' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, 'accounts' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, - 'reports' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG + 'reports' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'sendNotifications' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG ), 'management' => array( 'registrations' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,