From 621a52a02498f2ab593a70171db1a7099774228b Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 20 Feb 2017 09:24:08 -0500 Subject: [PATCH] Updated development assignments documentation Cleaned up some management and settings code to be more standard Added settings for registrations misc Updated registration terms and management settings for better layout. --- misc/documentation/DevelopmentOutline.txt | 1 + models/admin/management/registrations.php | 52 +-- models/admin/settings/registrationsMisc.php | 199 ++++++++++++ .../settings/registrationsPaymentCode.php | 12 +- setup/validActions.php | 5 +- views/admin/management/header.html | 18 -- views/admin/management/registrations.html | 23 +- views/admin/management/regterms.html | 18 +- views/admin/settings/registrationsMisc.html | 296 ++++++++++++++++++ .../settings/registrationsPaymentCode.html | 7 +- 10 files changed, 543 insertions(+), 88 deletions(-) create mode 100644 models/admin/settings/registrationsMisc.php delete mode 100644 views/admin/management/header.html create mode 100644 views/admin/settings/registrationsMisc.html diff --git a/misc/documentation/DevelopmentOutline.txt b/misc/documentation/DevelopmentOutline.txt index 7390476..f5e9077 100644 --- a/misc/documentation/DevelopmentOutline.txt +++ b/misc/documentation/DevelopmentOutline.txt @@ -13,6 +13,7 @@ ADMIN - Access by Managers only * Misc + Chuck - Recall and update of Misc configurable text and flags - Accessed by Managers and Site owners diff --git a/models/admin/management/registrations.php b/models/admin/management/registrations.php index 0474ada..cfeaaa5 100644 --- a/models/admin/management/registrations.php +++ b/models/admin/management/registrations.php @@ -109,10 +109,9 @@ class GlmMembersAdmin_management_registrations extends GlmDataRegistrationsManag public function modelAction($actionData = false) { $option = false; - $option2 = 'registrations'; - $settings_updated = false; - $settings_update_error = false; - $reg_settings = false; + $settingsUpdated = false; + $settingsUpdateError = false; + $regSettings = false; // General settings are always stored in a record with ID=1. $id = 1; @@ -142,19 +141,25 @@ class GlmMembersAdmin_management_registrations extends GlmDataRegistrationsManag case 'submit': // Update the general settings - $reg_settings = $this->updateEntry( $id ); + $regSettings = $this->updateEntry( $id ); - if ($reg_settings['status']) { - $settings_updated = true; - $reg_settings = $this->editEntry( $id ); - } else { - $settings_update_error = true; - } + // Check if we were successful + if ($regSettings['status']) { + + + if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) { + glmMembersAdmin::addNotice( $misc, 'DataBlock', 'Misc Registrations Settings' ); + } + + $settingsUpdated = true; + $regSettings = $this->editEntry( $id ); - //echo "
" . print_r($reg_settings, true) . "
"; + // Display admin message that the data has been updated + glmMembersAdmin::addNotice('Management Settings for the '.GLM_MEMBERS_REGISTRATIONS_PLUGIN_NAME.' plugin have been updated.', 'AdminNotice'); - // Display admin message that the data has been updated - glmMembersAdmin::addNotice('General Settings for the '.GLM_MEMBERS_REGISTRATIONS_PLUGIN_NAME.' plugin have been updated.', 'AdminNotice'); + } else { + $settingsUpdateError = true; + } break; @@ -162,15 +167,15 @@ class GlmMembersAdmin_management_registrations extends GlmDataRegistrationsManag default: // Try to get the first (should be only) entry for general settings. - $reg_settings = $this->editEntry( $id ); + $regSettings = $this->editEntry( $id ); - //echo "
" . print_r($reg_settings, true) . "
"; + // Check if we didn't get the settings + if ($regSettings === false) { - // Check that we actually have the terms - if ($reg_settings === false) { + $errorMsg = "Unable to load the Registrations management settings"; if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - glmMembersAdmin::addNotice("/modesl/admin/settings/terms.php: Unable to load Terms Settings.", 'Alert'); + glmMembersAdmin::addNotice("/models/admin/settings/terms.php: $errorMsg", 'Alert'); } return array( @@ -179,7 +184,7 @@ class GlmMembersAdmin_management_registrations extends GlmDataRegistrationsManag 'modelRedirect' => 'index', 'view' => 'admin/error/index.html', 'data' => array( - 'reason' => 'Unable to create terms settings entry in database.' + 'reason' => $errorMsg ) ); } @@ -190,10 +195,9 @@ class GlmMembersAdmin_management_registrations extends GlmDataRegistrationsManag // Compile template data $template_data = array( - 'regSettings' => $reg_settings, - 'option2' => $option2, - 'settingsUpdated' => $settings_updated, - 'settingsUpdateError' => $settings_update_error, + 'regSettings' => $regSettings, + 'settingsUpdated' => $settingsUpdated, + 'settingsUpdateError' => $settingsUpdateError, ); //echo "
" . print_r($regSettings, true) . "
"; diff --git a/models/admin/settings/registrationsMisc.php b/models/admin/settings/registrationsMisc.php new file mode 100644 index 0000000..6a6bdd9 --- /dev/null +++ b/models/admin/settings/registrationsMisc.php @@ -0,0 +1,199 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +// Load Amenities data abstract +require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataMisc.php'; + +class GlmMembersAdmin_settings_registrationsMisc extends GlmDataRegistrationsMisc +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Settings 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; + + // Run constructor for members data class + parent::__construct( false, false ); + + } + + /* + * 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 ) + { + + $success = false; + $miscUpdated = false; + $haveMisc = false; + $regMixc = false; + + // Misc settings are always stored in a record with ID=1. + $id = 1; + + // Determine if current user can edit configurations + if (!current_user_can('glm_members_management')) { + return array( + 'status' => false, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => array( + 'reason' => 'User does not have rights to make configuration changes.' + ) + ); + } + + // Check for submission option + $option = ''; + if (isset($_REQUEST['option']) && $_REQUEST['option'] == 'submit') { + $option = $_REQUEST['option']; + } + + switch ($option) { + + // Case Update Misc settings + case 'submit': + + // Get a current Misc settings record + $regMisc = $this->getEntry($id); + + // Check if we were successful + if ($regMisc['status']) { + + if ( GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE ) { + glmMembersAdmin::addNotice( $regMisc, 'DataBlock', 'Misc Registrations Settings' ); + } + + $miscUpdated = true; + $success = true; + + $regMisc = $this->editEntry( $id ); + + // Display admin message that the data has been updated + glmMembersAdmin::addNotice('Misc Settings for the '.GLM_MEMBERS_REGISTRATIONS_PLUGIN_NAME.' plugin have been updated.', 'AdminNotice'); + + } + + break; + + // Default is to get the current misc settings and display the form + default: + + // Try getting the current settings + $regMisc = $this->editEntry($id); + + // If we didn't get the misc settings + if ($regMisc == false) { + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + glmMembersAdmin::addNotice("/models/admin/settings/registrationsMisc.php: Unable to load Misc Settings.", 'Alert'); + } + + return array( + 'status' => false, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => array( + 'reason' => 'Unable to load Misc. Settings.' + ) + ); + + } + + break; + + } + + // Compile template data + $templateData = array( + 'regMisc' => $regMisc, + 'miscUpdated' => $miscUpdated, + 'haveMisc' => $haveMisc + ); + + // Return status, suggested view, and data to controller + return array( + 'status' => $success, + 'menuItemRedirect' => false, + 'modelRedirect' => false, + 'view' => 'admin/settings/registrationsMisc.html', + 'data' => $templateData, + ); + + } + + +} diff --git a/models/admin/settings/registrationsPaymentCode.php b/models/admin/settings/registrationsPaymentCode.php index c844a37..b2b78bd 100644 --- a/models/admin/settings/registrationsPaymentCode.php +++ b/models/admin/settings/registrationsPaymentCode.php @@ -98,13 +98,12 @@ class GlmMembersAdmin_settings_registrationsPaymentCode extends GlmDataRegistrat */ public function modelAction ( $actionData = false ) { - $success = true; - $havePaymentCode = false; + $success = true; + $havePaymentCode = false; $payment_codes = false; - $error = false; - $option2 = ''; + $error = false; + $option2 = ''; $newPaymentCode = $this->newEntry(); - $enable_members = $this->config['settings']['enable_members']; // Check if a category ID is supplied $id = 0; @@ -147,8 +146,6 @@ class GlmMembersAdmin_settings_registrationsPaymentCode extends GlmDataRegistrat glmMembersAdmin::addNotice( $payment_codes, 'DataBlock', 'Payment Code Data' ); } // If we have list entries - even if it's an empty list - $success = true; - $havePaymentCode = false; if ( $payment_codes !== false ) { $success = true; @@ -174,7 +171,6 @@ class GlmMembersAdmin_settings_registrationsPaymentCode extends GlmDataRegistrat } // Compile template data $templateData = array( - 'enable_members' => $enable_members, 'havePaymentCode' => $havePaymentCode, 'payment_codes' => $payment_codes, 'groups' => null, diff --git a/setup/validActions.php b/setup/validActions.php index 33113c9..595b810 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -61,14 +61,15 @@ $glmMembersRegistrationsAddOnValidActions = array( 'adminActions' => array( 'registrations' => array( 'index' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, - 'list' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'list' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG ), 'management' => array( 'registrations' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, - 'regterms' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'regterms' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG ), 'settings' => array( 'registrationsPaymentCode' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'registrationsMisc' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG ), ), 'frontActions' => array( diff --git a/views/admin/management/header.html b/views/admin/management/header.html deleted file mode 100644 index e7a2338..0000000 --- a/views/admin/management/header.html +++ /dev/null @@ -1,18 +0,0 @@ -There's some text here too atop header.html - -This is at the bottom of header.html diff --git a/views/admin/management/registrations.html b/views/admin/management/registrations.html index 82f38b7..0331205 100644 --- a/views/admin/management/registrations.html +++ b/views/admin/management/registrations.html @@ -1,20 +1,11 @@ {include file='admin/management/header.html'} + - - +
{if $settingsUpdated}

Settings Updated

{/if} @@ -27,7 +18,6 @@
- @@ -298,9 +288,4 @@
- - - - - {include file='admin/management/footer.html'} \ No newline at end of file diff --git a/views/admin/management/regterms.html b/views/admin/management/regterms.html index 76cea48..c33da4a 100644 --- a/views/admin/management/regterms.html +++ b/views/admin/management/regterms.html @@ -1,20 +1,10 @@ {include file='admin/management/header.html'} + +

{$terms.reg_term_registrations_name} Terms and Phrases

diff --git a/views/admin/settings/registrationsMisc.html b/views/admin/settings/registrationsMisc.html new file mode 100644 index 0000000..c45ffab --- /dev/null +++ b/views/admin/settings/registrationsMisc.html @@ -0,0 +1,296 @@ +{include file='admin/management/header.html'} + + + + + + + + + + +
+ {if $settingsUpdated}

Settings Updated

{/if} + {if $settingsUpdateError}Settings Update Error{/if} +

{$terms.reg_term_registrations_name} Misc. Settings

+
+ + + + + + + + + + + + +
{$terms.reg_term_registrations_name} Bulletin: + + {if $misc.fieldFail.reg_bulletin}

{$misc.fieldFail.reg_bulletin}

{/if}
+
+ + + + +
+ +{include file='admin/footer.html'} \ No newline at end of file diff --git a/views/admin/settings/registrationsPaymentCode.html b/views/admin/settings/registrationsPaymentCode.html index 4edd412..d72b3de 100644 --- a/views/admin/settings/registrationsPaymentCode.html +++ b/views/admin/settings/registrationsPaymentCode.html @@ -1,10 +1,11 @@ -{include file='admin/settings/header.html'} +{include file='admin/management/header.html'} - +
Add Payment Code
-- 2.17.1