From 01c75046087ccf3869670f12a11bf401fc046d08 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 27 Apr 2018 12:46:02 -0400 Subject: [PATCH] Update for notice types Database update for the notification_type table. Adding field for to_email. If it is set then the notification email will goto that email. If it is not set then the notification will goto the accounts email. --- classes/billingSupport.php | 14 +++++----- classes/data/dataNotificationTypes.php | 28 ++++++++++++------- classes/notifications.php | 20 +++++++++---- index.php | 2 +- models/front/billing/becomeMember.php | 10 ++++++- ...0.0.24.sql => create_database_V0.0.25.sql} | 3 +- setup/databaseScripts/dbVersions.php | 19 +++++++------ .../update_database_V0.0.25.sql | 10 +++++++ .../admin/settings/editNotificationType.html | 21 ++++++++++++++ 9 files changed, 93 insertions(+), 34 deletions(-) rename setup/databaseScripts/{create_database_V0.0.24.sql => create_database_V0.0.25.sql} (99%) create mode 100644 setup/databaseScripts/update_database_V0.0.25.sql diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 697ee6d..83ed6e4 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -1421,13 +1421,13 @@ class GlmBillingSupport // Get the Wordpress user for this account. $account = $this->getAccountById( $account_id ); if ( isset( $account['ref_dest'] ) && $account['ref_dest'] ) { - $contactID = $this->wpdb->get_var( - $this->wpdb->prepare( - "SELECT id - FROM " . GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts - WHERE ref_dest = %d", - $this->memberID - ) + // Update the wordpress user also + apply_filters( + 'glm_contact_update_user_role_by_ref_dest', + '', + $account['ref_dest'], + 'glm_members_member_contact', + 'glm_members_own_entity_manager' ); } diff --git a/classes/data/dataNotificationTypes.php b/classes/data/dataNotificationTypes.php index c4f608b..b6c08a4 100644 --- a/classes/data/dataNotificationTypes.php +++ b/classes/data/dataNotificationTypes.php @@ -130,7 +130,15 @@ class GlmDataNotificationTypes extends GlmDataAbstract 'use' => 'a', ), - // + // To Email + 'to_email' => array( + 'field' => 'to_email', + 'type' => 'text', + 'required' => false, + 'use' => 'a', + ), + + // From Header 'from_header' => array( 'field' => 'from_header', 'type' => 'text', @@ -138,7 +146,7 @@ class GlmDataNotificationTypes extends GlmDataAbstract 'use' => 'a', ), - // + // Reply To 'replyto' => array( 'field' => 'replyto', 'type' => 'text', @@ -146,7 +154,7 @@ class GlmDataNotificationTypes extends GlmDataAbstract 'use' => 'a', ), - // + // Subject 'subject' => array( 'field' => 'subject', 'type' => 'text', @@ -154,7 +162,7 @@ class GlmDataNotificationTypes extends GlmDataAbstract 'use' => 'a', ), - // + // Message 'message' => array( 'field' => 'message', 'type' => 'text', @@ -162,7 +170,7 @@ class GlmDataNotificationTypes extends GlmDataAbstract 'use' => 'a', ), - // + // Send By Date 'send_by_date' => array( 'field' => 'send_by_date', 'type' => 'checkbox', @@ -170,7 +178,7 @@ class GlmDataNotificationTypes extends GlmDataAbstract 'use' => 'a', ), - // + // Send By Action 'send_by_action' => array( 'field' => 'send_by_action', 'type' => 'checkbox', @@ -178,7 +186,7 @@ class GlmDataNotificationTypes extends GlmDataAbstract 'use' => 'a', ), - // + // Send Action 'send_action' => array( 'field' => 'send_action', 'type' => 'integer', @@ -186,21 +194,21 @@ class GlmDataNotificationTypes extends GlmDataAbstract 'use' => 'a', ), - // + // Send Date Number 'send_date_number' => array( 'field' => 'send_date_number', 'type' => 'integer', 'use' => 'a', ), - // + // Send Date Period 'send_date_period' => array( 'field' => 'send_date_period', 'type' => 'integer', 'use' => 'a', ), - // + // Send Date When 'send_date_when' => array( 'field' => 'send_date_when', 'type' => 'integer', diff --git a/classes/notifications.php b/classes/notifications.php index 129dba2..329cf11 100644 --- a/classes/notifications.php +++ b/classes/notifications.php @@ -78,11 +78,6 @@ class GlmNotifications // If there's no account then return false. return false; } - $to_email = $account['email']; - if ( !$to_email ) { - // If there's no email then return false. - return false; - } // get the Notification type $notification_type = $this->getNotificationTypeById( $notification_id ); @@ -90,6 +85,21 @@ class GlmNotifications // If there's no notification type then return false. return false; } + + // Check to see if the notification has a to_email set. + // If it does then the email goes there. + // Else it will goto the account email. + if ( isset( $notification_type['to_email'] ) && $notification_type['to_email'] ) { + $to_email = $notification_type['to_email']; + } else { + $to_email = $account['email']; + } + if ( !$to_email ) { + // If there's no email then return false. + return false; + } + + // Set the subject of the email. $subject = $notification_type['subject']; if ( !$subject ) { // If there's no subject then return false. diff --git a/index.php b/index.php index b5ba692..41484f7 100644 --- a/index.php +++ b/index.php @@ -38,7 +38,7 @@ * version from this plugin. */ define('GLM_MEMBERS_BILLING_PLUGIN_VERSION', '0.0.1'); -define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.24'); +define('GLM_MEMBERS_BILLING_PLUGIN_DB_VERSION', '0.0.25'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_BILLING_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0'); diff --git a/models/front/billing/becomeMember.php b/models/front/billing/becomeMember.php index 5c820aa..af9df5d 100644 --- a/models/front/billing/becomeMember.php +++ b/models/front/billing/becomeMember.php @@ -279,7 +279,11 @@ class GlmMembersFront_billing_becomeMember // extends GlmDataBilling 'notes' => 'Become Member Form.', 'create_time' => date('Y-m-d H:i:s', time()), 'ref_type' => $this->config['ref_type_numb']['Member'], - 'ref_dest' => $member_id + 'ref_dest' => $member_id, + 'addr1' => $billing_addr1, + 'city' => $billing_city, + 'state' => $billing_state, + 'zip' => $billing_zip, ), array( '%d', // active @@ -295,6 +299,10 @@ class GlmMembersFront_billing_becomeMember // extends GlmDataBilling '%s', // create_time '%d', // ref_type '%d', // ref_dest + '%s', // addr1 + '%s', // city + '%s', // state + '%s', // zip ) ); $newContactID = $this->wpdb->insert_id; diff --git a/setup/databaseScripts/create_database_V0.0.24.sql b/setup/databaseScripts/create_database_V0.0.25.sql similarity index 99% rename from setup/databaseScripts/create_database_V0.0.24.sql rename to setup/databaseScripts/create_database_V0.0.25.sql index e8fec7f..b9d7d70 100644 --- a/setup/databaseScripts/create_database_V0.0.24.sql +++ b/setup/databaseScripts/create_database_V0.0.25.sql @@ -1,6 +1,6 @@ -- Gaslight Media Billing Module -- File Created: 11/08/2017 --- Database Version: 0.0.24 +-- Database Version: 0.0.25 -- Database Creation Script -- -- To permit each query below to be executed separately, @@ -146,6 +146,7 @@ CREATE TABLE {prefix}pdfs ( CREATE TABLE {prefix}notification_types ( id INT NOT NULL AUTO_INCREMENT, name TINYTEXT NOT NULL, -- name + to_email TINYTEXT NULL, -- To email from_header TINYTEXT NOT NULL, -- from headers replyto TINYTEXT NULL, -- reply-to headers subject TINYTEXT NOT NULL, -- Subject diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 964fb44..6177b2c 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -14,15 +14,15 @@ */ $glmMembersBillingDbVersions = array( - '0.0.1' => array('version' => '0.0.1', 'tables' => 10), - '0.0.2' => array('version' => '0.0.2', 'tables' => 11), - '0.0.3' => array('version' => '0.0.3', 'tables' => 12), - '0.0.4' => array('version' => '0.0.4', 'tables' => 12), - '0.0.5' => array('version' => '0.0.5', 'tables' => 12), - '0.0.6' => array('version' => '0.0.6', 'tables' => 13), - '0.0.7' => array('version' => '0.0.7', 'tables' => 13), - '0.0.8' => array('version' => '0.0.8', 'tables' => 14), - '0.0.9' => array('version' => '0.0.9', 'tables' => 14), + '0.0.1' => array('version' => '0.0.1', 'tables' => 10), + '0.0.2' => array('version' => '0.0.2', 'tables' => 11), + '0.0.3' => array('version' => '0.0.3', 'tables' => 12), + '0.0.4' => array('version' => '0.0.4', 'tables' => 12), + '0.0.5' => array('version' => '0.0.5', 'tables' => 12), + '0.0.6' => array('version' => '0.0.6', 'tables' => 13), + '0.0.7' => array('version' => '0.0.7', 'tables' => 13), + '0.0.8' => array('version' => '0.0.8', 'tables' => 14), + '0.0.9' => array('version' => '0.0.9', 'tables' => 14), '0.0.10' => array('version' => '0.0.10', 'tables' => 14), '0.0.11' => array('version' => '0.0.11', 'tables' => 14), '0.0.12' => array('version' => '0.0.12', 'tables' => 14), @@ -38,5 +38,6 @@ $glmMembersBillingDbVersions = array( '0.0.22' => array('version' => '0.0.22', 'tables' => 15), '0.0.23' => array('version' => '0.0.23', 'tables' => 15), '0.0.24' => array('version' => '0.0.24', 'tables' => 15), + '0.0.25' => array('version' => '0.0.25', 'tables' => 15), ); diff --git a/setup/databaseScripts/update_database_V0.0.25.sql b/setup/databaseScripts/update_database_V0.0.25.sql new file mode 100644 index 0000000..db042cf --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.25.sql @@ -0,0 +1,10 @@ +-- Gaslight Media Billing Database +-- File Created: 04/27/2018 +-- Database Version: 0.0.25 +-- +-- To permit each query below to be executed separately, +-- all queries must be separated by a line with four dashes + +-- Add to_email field to notification_types table +ALTER TABLE {prefix}notification_types ADD to_email TINYTEXT NULL; -- To email + diff --git a/views/admin/settings/editNotificationType.html b/views/admin/settings/editNotificationType.html index ca02852..f306130 100644 --- a/views/admin/settings/editNotificationType.html +++ b/views/admin/settings/editNotificationType.html @@ -72,6 +72,27 @@ + + +
+ + + + + + Leave the To Email blank to send this notice to the + {literal}{$account.email}{/literal} address. + + + + + To Email + + + {if $notification.fieldFail.to_email}

{$notification.fieldFail.to_email}

{/if}
+ + + Subject -- 2.17.1