From 13ea3969ec7ee7dccc956fa49993992a8f518d25 Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Wed, 3 Jan 2018 10:39:57 -0500 Subject: [PATCH] Added Attendee Notification Sub-Tab for Reg Event --- classes/data/dataRegNotification.php | 158 +++++++++++++ index.php | 2 +- models/admin/registrations/events.php | 80 +++++++ ...0.0.19.sql => create_database_V0.0.20.sql} | 14 ++ setup/databaseScripts/dbVersions.php | 3 +- ..._V0.0.19.sql => drop_database_V0.0.20.sql} | 1 + .../update_database_V0.0.20.sql | 19 ++ .../registrations/eventEditCustomFields.html | 2 + .../admin/registrations/eventEditLevels.html | 4 +- .../registrations/eventNotifications.html | 211 ++++++++++++++++++ views/admin/registrations/eventSubTabs.html | 1 + 11 files changed, 490 insertions(+), 5 deletions(-) create mode 100644 classes/data/dataRegNotification.php rename setup/databaseScripts/{create_database_V0.0.19.sql => create_database_V0.0.20.sql} (98%) rename setup/databaseScripts/{drop_database_V0.0.19.sql => drop_database_V0.0.20.sql} (95%) create mode 100644 setup/databaseScripts/update_database_V0.0.20.sql create mode 100644 views/admin/registrations/eventNotifications.html diff --git a/classes/data/dataRegNotification.php b/classes/data/dataRegNotification.php new file mode 100644 index 0000000..2d9f191 --- /dev/null +++ b/classes/data/dataRegNotification.php @@ -0,0 +1,158 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataRegNotification.php,v 1.0 2011/01/25 19:31:47 cscott Exp $ + */ + +/** + * GlmDataRegistrationsRegNotification class + * + * PHP version 5 + * + * @category Data + * @package GLM Member DB + * @author Chuck Scott + * @license http://www.gaslightmedia.com Gaslightmedia + * @release SVN: $Id: dataRegRate.php,v 1.0 2011/01/25 19:31:47 cscott + * Exp $ + */ +class GlmDataRegistrationsRegNotification extends GlmDataAbstract +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + /** + * Data Table Name + * + * @var $table + * @access public + */ + public $table; + /** + * Field definitions + * + * 'type' is type of field as defined by the application + * text Regular text field + * pointer Pointer to an entry in another table + * 'filters' is the filter name for a particular filter ID in PHP filter + * functions + * See PHP filter_id() + * + * 'use' is when to use the field + * l = List + * g = Get + * n = New + * i = Insert + * e = Edit + * u = Update + * d = Delete + * a = All + * + * @var $ini + * @access public + */ + public $fields = false; + + /** + * Constructor + * + * @param object $d database connection + * @param array $config Configuration array + * @param bool $limitedEdit Flag to say indicate limited edit requested + * + * @return void + * @access public + */ + public function __construct($wpdb, $config, $limitedEdit = false) + { + + // If this class is not being extended along with existing $wpdb and $config + if (!$this->wpdb) { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + /* + * Table Name + */ + $this->table = GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_notification'; + + /* + * Table Data Fields + */ + + $this->fields = array ( + + // ID + 'id' => array ( + 'field' => 'id', + 'type' => 'integer', + 'view_only' => true, + 'use' => 'a' + ), + + // Pointer to reg_event table + 'reg_event' => array ( + 'field' => 'reg_event', + 'type' => 'integer', + 'required' => true, + 'use' => 'lgneud' + ), + + // Name of this Notification + 'name' => array ( + 'field' => 'name', + 'type' => 'text', + 'required' => true, + 'use' => 'lgneud' + ), + + // Notification Message (textarea) + 'message' => array ( + 'field' => 'message', + 'type' => 'text', + 'required' => true, + 'use' => 'lgneud' + ), + + // # of days before/after event time for notification (- before, + after) + 'notification_days' => array ( + 'field' => 'notification_days', + 'type' => 'integer', + 'required' => true, + 'default' => 0, + 'use' => 'a' + ), + + ); + + } + +} + +?> \ No newline at end of file diff --git a/index.php b/index.php index 1bf1fd9..063645a 100644 --- a/index.php +++ b/index.php @@ -44,7 +44,7 @@ if (!defined('ABSPATH')) { * version from this plugin. */ define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_VERSION', '0.0.1'); -define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_VERSION', '0.0.19'); +define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_VERSION', '0.0.20'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_REGISTRATIONS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.10.17'); diff --git a/models/admin/registrations/events.php b/models/admin/registrations/events.php index 34c5e71..ef98636 100644 --- a/models/admin/registrations/events.php +++ b/models/admin/registrations/events.php @@ -113,6 +113,8 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent $regClassesJSON = false; $regTimesJSON = false; $regEventDeleted = false; + $regNotifications = false; + $regNotifyUpdated = false; $classes = false; $haveRegistrants = false; $registrants = false; @@ -159,6 +161,81 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent switch ($option) { + case 'notificationsUpdate': + + // New and updated notifications + if (isset($_REQUEST['name']) && is_array($_REQUEST['name'])) { + + foreach ($_REQUEST['name'] as $key=>$val) { + + // Make sure key is positive integer + $id = ($key-0); + if ($id > 0) { + + // Update existing entry + $this->wpdb->update( + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_notification', + array( + 'name' => $_REQUEST['name'][$id], + 'notification_days' => $_REQUEST['notification_days'][$id], + 'message' => $_REQUEST['message'][$id] + ), + array( 'id' => $id ), + array( '%s', '%d', '%s' ), + array( '%d' ) + ); + + // Otherwise if the id is less than 0 it must be a new one + } elseif ($id < 0) { + + // Insert a new entry + $this->wpdb->insert( + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_notification', + array( + 'reg_event' => $regEventID, + 'name' => $_REQUEST['name'][$id], + 'notification_days' => $_REQUEST['notification_days'][$id], + 'message' => $_REQUEST['message'][$id] + ), + array( '%d', '%s', '%d', '%s' ) + ); + } + } + } + + // Delete Notifications + if (isset($_REQUEST['delete']) && is_array($_REQUEST['delete'])) { + + $ids = ''; + foreach ($_REQUEST['delete'] as $key=>$val) { + + // Make sure key is positive integer + $id = ($key-0); + if ($id > 0) { + $this->wpdb->delete( GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_notification', array( 'ID' => $id ), array( '%d' ) ); + } + + } + } + + + $regNotifyUpdated = true; + + // Fall through to get the data again + + case 'notifications': + + require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegNotification.php'; + $Notifications = new GlmDataRegistrationsRegNotification($this->wpdb, $this->config); + + $regNotifications = $Notifications->getList("T.reg_event = $regEventID", 'notification_days'); + + $regEvent = $this->getEntry($regEventID); + + $view = 'eventNotifications'; + + break; + case 'registrants': $whereParts = array(); @@ -665,6 +742,9 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent 'regEventUpdateError' => $regEventUpdateError, 'regEventAdded' => $regEventAdded, 'entry' => $regEventSample, + 'regNotifications' => $regNotifications, + 'regNotifyUpdated' => $regNotifyUpdated, + 'currentUrl' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_ADMIN_URL, 'thisJsUrl' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_URL . '/js', 'regEventJSON' => $regEventJSON, 'regClassesJSON' => $regClassesJSON, diff --git a/setup/databaseScripts/create_database_V0.0.19.sql b/setup/databaseScripts/create_database_V0.0.20.sql similarity index 98% rename from setup/databaseScripts/create_database_V0.0.19.sql rename to setup/databaseScripts/create_database_V0.0.20.sql index 2cc4f23..f68af17 100644 --- a/setup/databaseScripts/create_database_V0.0.19.sql +++ b/setup/databaseScripts/create_database_V0.0.20.sql @@ -317,6 +317,20 @@ CREATE TABLE {prefix}reg_rate ( ---- +-- Notifications +-- None or more for each reg event +CREATE TABLE {prefix}reg_notification ( + id INT NOT NULL AUTO_INCREMENT, + reg_event INT NULL, -- Pointer to reg_event table + name TINYTEXT NULL, -- Namme of this notification + notification_days INT NULL, -- # of days before or after event that notification takes place (- before, + after) + message TEXT NULL, -- Content of message (uses template parameters to merge event/attendee data) + PRIMARY KEY (id), + INDEX (reg_event) +); + +---- + -- An account for a person submitting a registration or a registrant for an event -- Depending on the use of these entries may not have all data included -- A single account may be referenced as a person submitting registrations and/or a person registered for an event diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 3db96ef..dfbbb34 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -32,7 +32,8 @@ $glmMembersRegistrationsDbVersions = array( '0.0.16' => array('version' => '0.0.16', 'tables' => 15, 'date' => '10/24/2017'), '0.0.17' => array('version' => '0.0.17', 'tables' => 15, 'date' => '11/3/2017'), '0.0.18' => array('version' => '0.0.18', 'tables' => 15, 'date' => '11/7/2017'), - '0.0.19' => array('version' => '0.0.19', 'tables' => 15, 'date' => '11/22/2017') + '0.0.19' => array('version' => '0.0.19', 'tables' => 15, 'date' => '11/22/2017'), + '0.0.20' => array('version' => '0.0.20', 'tables' => 16, 'date' => '01/02/2018') ); diff --git a/setup/databaseScripts/drop_database_V0.0.19.sql b/setup/databaseScripts/drop_database_V0.0.20.sql similarity index 95% rename from setup/databaseScripts/drop_database_V0.0.19.sql rename to setup/databaseScripts/drop_database_V0.0.20.sql index 602ae27..e8754ae 100644 --- a/setup/databaseScripts/drop_database_V0.0.19.sql +++ b/setup/databaseScripts/drop_database_V0.0.20.sql @@ -14,6 +14,7 @@ DROP TABLE IF EXISTS {prefix}reg_time_pending, {prefix}reg_class, {prefix}reg_rate, + {prefix}reg_notification, {prefix}account, {prefix}reg_request, {prefix}reg_request_event, diff --git a/setup/databaseScripts/update_database_V0.0.20.sql b/setup/databaseScripts/update_database_V0.0.20.sql new file mode 100644 index 0000000..a38306a --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.20.sql @@ -0,0 +1,19 @@ +-- Gaslight Media Members Database - Registratiuons Add-On +-- File Created: 10/03/17 11:00:00 +-- Database Version: 0.0.16 +-- Database Update From Previous Version Script +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +CREATE TABLE {prefix}reg_notification ( + id INT NOT NULL AUTO_INCREMENT, + reg_event INT NULL, -- Pointer to reg_event table + name TINYTEXT NULL, -- Namme of this notification + notification_days INT NULL, -- # of days before or after event that notification takes place (- before, + after) + message TEXT NULL, -- Content of message (uses template parameters to merge event/attendee data) + PRIMARY KEY (id), + INDEX (reg_event) +); + + diff --git a/views/admin/registrations/eventEditCustomFields.html b/views/admin/registrations/eventEditCustomFields.html index 3496ac7..1a40e17 100644 --- a/views/admin/registrations/eventEditCustomFields.html +++ b/views/admin/registrations/eventEditCustomFields.html @@ -1,6 +1,8 @@ {include file='admin/registrations/eventHeader.html'} {include file='admin/registrations/eventSubTabs.html'} +

Additional (custom) Fields

+

{if $regEventUpdated}Registration Event Updated{/if} {if $regEventUpdateError}Registration Event Update Error{/if} diff --git a/views/admin/registrations/eventEditLevels.html b/views/admin/registrations/eventEditLevels.html index 42c7c44..295ec20 100644 --- a/views/admin/registrations/eventEditLevels.html +++ b/views/admin/registrations/eventEditLevels.html @@ -13,10 +13,8 @@ {literal} + +{include file='admin/footer.html'} + diff --git a/views/admin/registrations/eventSubTabs.html b/views/admin/registrations/eventSubTabs.html index d8be53b..666a3fa 100644 --- a/views/admin/registrations/eventSubTabs.html +++ b/views/admin/registrations/eventSubTabs.html @@ -13,6 +13,7 @@ {if apply_filters('glm-members-customfields-plugin-active', false)} Additional Fields {/if} + Attendee Notification {$terms.reg_term_attendee_plur_cap}

-- 2.17.1