From 4d3edb0fe52f635a179cbbb4b760e58d68b3d9e2 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Wed, 10 Jul 2019 16:37:27 -0400 Subject: [PATCH] Add new option in management for allow_member_coupons This is to hide the coupons from user member only section if turned off. --- classes/data/dataManagement.php | 8 ++++++++ index.php | 5 ++++- setup/adminMenus.php | 5 ++++- ...se_V0.0.3.sql => create_database_V0.0.4.sql} | 17 +++++++++-------- setup/databaseScripts/dbVersions.php | 1 + .../databaseScripts/update_database_V0.0.4.sql | 17 +++++++++++++++++ views/admin/management/coupons.html | 7 +++++++ 7 files changed, 50 insertions(+), 10 deletions(-) rename setup/databaseScripts/{create_database_V0.0.3.sql => create_database_V0.0.4.sql} (79%) create mode 100644 setup/databaseScripts/update_database_V0.0.4.sql diff --git a/classes/data/dataManagement.php b/classes/data/dataManagement.php index 1c0c637..b391c0c 100644 --- a/classes/data/dataManagement.php +++ b/classes/data/dataManagement.php @@ -158,6 +158,14 @@ class GlmDataCouponsManagement extends GlmDataAbstract 'use' => 'a', ), + // Allow Members + 'allow_member_coupons' => array( + 'field' => 'allow_member_coupons', + 'type' => 'checkbox', + 'required' => false, + 'use' => 'a', + ), + ); } diff --git a/index.php b/index.php index a96908a..671f3b1 100644 --- a/index.php +++ b/index.php @@ -38,7 +38,10 @@ * version from this plugin. */ define('GLM_MEMBERS_COUPONS_PLUGIN_VERSION', '1.0.1'); -define('GLM_MEMBERS_COUPONS_PLUGIN_DB_VERSION', '0.0.3'); +/** + * Database Version + */ +define('GLM_MEMBERS_COUPONS_PLUGIN_DB_VERSION', '0.0.4'); // This is the minimum version of the GLM Members DB plugin require for this plugin. define('GLM_MEMBERS_COUPONS_PLUGIN_MIN_MEMBERS_REQUIRED_VERSION', '2.8.0'); diff --git a/setup/adminMenus.php b/setup/adminMenus.php index 7e6f0b3..3419132 100644 --- a/setup/adminMenus.php +++ b/setup/adminMenus.php @@ -67,7 +67,10 @@ add_submenu_page( ); // If a contact is logged in (ownEntity isn't false), add Contact Profile menu item -if (isset($this->config['loggedInUser']) && isset($this->config['loggedInUser']['contactUser']) && $this->config['loggedInUser']['contactUser']) { +if ( isset( $this->config['loggedInUser'] ) + && isset( $this->config['loggedInUser']['contactUser'] ) && $this->config['loggedInUser']['contactUser'] + && $this->config['settings']['allow_member_coupons'] +) { add_submenu_page( $mainMenuSlug, diff --git a/setup/databaseScripts/create_database_V0.0.3.sql b/setup/databaseScripts/create_database_V0.0.4.sql similarity index 79% rename from setup/databaseScripts/create_database_V0.0.3.sql rename to setup/databaseScripts/create_database_V0.0.4.sql index f87b6a2..13c7410 100644 --- a/setup/databaseScripts/create_database_V0.0.3.sql +++ b/setup/databaseScripts/create_database_V0.0.4.sql @@ -1,6 +1,6 @@ -- Gaslight Media Members Database - Coupons Add-On -- File Created: 11/15/16 --- Database Version: 0.0.3 +-- Database Version: 0.0.4 -- Database Creation Script -- -- This file is called to create a new set of tables for this @@ -63,11 +63,12 @@ CREATE TABLE {prefix}coupon_categories ( -- Settings CREATE TABLE {prefix}management ( id INT NOT NULL AUTO_INCREMENT, - notify_to TINYTEXT NULL, -- To for the notify email - notify_from TINYTEXT NULL, -- From header for notify email - notify_message TEXT NULL, -- Message to add to the notify email - default_date_range TINYTEXT NULL, -- Default span for start and end dates - ribbon_text TEXT NULL, -- Text for the Coupon ribbon on the list and grid views + notify_to TINYTEXT NULL, -- To for the notify email + notify_from TINYTEXT NULL, -- From header for notify email + notify_message TEXT NULL, -- Message to add to the notify email + default_date_range TINYTEXT NULL, -- Default span for start and end dates + ribbon_text TEXT NULL, -- Text for the Coupon ribbon on the list and grid views + allow_member_coupons BOOLEAN DEFAULT true, -- Allow Members to add Coupons PRIMARY KEY (id) ); @@ -75,6 +76,6 @@ CREATE TABLE {prefix}management ( -- Data for Settings INSERT INTO {prefix}management -(id,notify_to,notify_from,notify_message,default_date_range,ribbon_text) +(id,notify_to,notify_from,notify_message,default_date_range,ribbon_text,allow_member_coupons) VALUES -(1, '', '', '','6 months','Savings Coupon'); +(1, '', '', '','6 months','Savings Coupon', true); diff --git a/setup/databaseScripts/dbVersions.php b/setup/databaseScripts/dbVersions.php index 7230d2f..e882c2d 100644 --- a/setup/databaseScripts/dbVersions.php +++ b/setup/databaseScripts/dbVersions.php @@ -17,5 +17,6 @@ $glmMembersCouponsDbVersions = array( '0.0.1' => array('version' => '0.0.1', 'tables' => 3), '0.0.2' => array('version' => '0.0.2', 'tables' => 4), '0.0.3' => array('version' => '0.0.3', 'tables' => 4), + '0.0.4' => array('version' => '0.0.4', 'tables' => 4), ); diff --git a/setup/databaseScripts/update_database_V0.0.4.sql b/setup/databaseScripts/update_database_V0.0.4.sql new file mode 100644 index 0000000..2547264 --- /dev/null +++ b/setup/databaseScripts/update_database_V0.0.4.sql @@ -0,0 +1,17 @@ +-- Gaslight Media Members Database - Coupons Add-On +-- File Created: 7/10/19 +-- Database Version: 0.0.4 +-- 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 + + +-- Coupon-Category - CategorieAllow Members to add Coupons +ALTER TABLE {prefix}management ADD COLUMN allow_member_coupons BOOLEAN DEFAULT true; + + +---- + +-- Update the management record +UPDATE {prefix}management SET allow_member_coupons = true; diff --git a/views/admin/management/coupons.html b/views/admin/management/coupons.html index 80789a3..836da70 100644 --- a/views/admin/management/coupons.html +++ b/views/admin/management/coupons.html @@ -36,6 +36,13 @@ {if $couponsSettings.fieldFail.ribbon_text}

{$couponsSettings.fieldFail.ribbon_text}

{/if} + + + + + {if $couponsSettings.fieldFail.allow_member_coupons}

{$couponsSettings.fieldFail.allow_member_coupons}

{/if} + +

E-Mail Notification Settings

-- 2.17.1