From 72edcb790fb7bf8e0d2dab7bee801b978f35559d Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Tue, 19 Sep 2017 13:04:31 -0400 Subject: [PATCH] More updates for admin registrations interface via backbone. Added AJAX processrs for front and admin AJAX calls from backbone. Added sample regRequestEvent.php AJAX method for handling backbone event requests. --- classes/data/dataRegRequest.php | 2 +- js/adminRegApp.js | 65 ++++---- js/collections/admin/regClasses.js | 5 +- js/collections/admin/regRates.js | 4 +- js/models/admin/regClass.js | 3 +- js/models/admin/regEvent.js | 3 +- js/models/admin/regRate.js | 4 +- js/views/admin/regClass.js | 38 +++-- js/views/admin/regEvent.js | 2 +- js/views/admin/regRate.js | 6 +- models/admin/ajax/regAdmin.php | 121 +++++++++++++++ models/admin/ajax/regAdmin/regClasses.php | 144 ++++++++++++++++++ models/admin/ajax/regFront.php | 119 +++++++++++++++ .../admin/ajax/regFront/regRequestEvent.php | 123 +++++++++++++++ setup/validActions.php | 1 + .../admin/registrations/eventEditLevels.html | 2 +- 16 files changed, 584 insertions(+), 58 deletions(-) create mode 100644 models/admin/ajax/regAdmin.php create mode 100644 models/admin/ajax/regAdmin/regClasses.php create mode 100644 models/admin/ajax/regFront.php create mode 100644 models/admin/ajax/regFront/regRequestEvent.php diff --git a/classes/data/dataRegRequest.php b/classes/data/dataRegRequest.php index c459b2c..e2546e2 100644 --- a/classes/data/dataRegRequest.php +++ b/classes/data/dataRegRequest.php @@ -24,7 +24,7 @@ * @release SVN: $Id: dataRegRequest.php,v 1.0 2011/01/25 19:31:47 cscott * Exp $ */ -class GlmDataRegistrationsRequest extends GlmDataAbstract +class GlmDataRegistrationsRegRequest extends GlmDataAbstract { /** diff --git a/js/adminRegApp.js b/js/adminRegApp.js index 09ce599..599a16e 100644 --- a/js/adminRegApp.js +++ b/js/adminRegApp.js @@ -6,7 +6,6 @@ app.Models.Admin.RegClass = Backbone.Model.extend({ // Defaults defaults: { id: null, - parent: 0, reg_event: 0, name: '', descr: '', @@ -16,6 +15,8 @@ app.Models.Admin.RegClass = Backbone.Model.extend({ this.rates = new app.Collections.Admin.RegRates; }, + url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses' + }); // js/models/regAdminEvent.js @@ -25,7 +26,6 @@ app.Models.Admin.RegEvent = Backbone.Model.extend({ // Default regEvent values defaults: { - name: 'regEvent', event_name: '', event_code: '', notify_email: '', @@ -43,7 +43,7 @@ app.Models.Admin.RegEvent = Backbone.Model.extend({ setClasses: function( regClasses ){ this.classes.reset( regClasses ); - }, + } }); @@ -56,7 +56,6 @@ app.Models.Admin.RegRate = Backbone.Model.extend({ // Default regRate values defaults: { id: null, - parent: 0, reg_event: 0, reg_class: '', name: '', @@ -68,8 +67,9 @@ app.Models.Admin.RegRate = Backbone.Model.extend({ }, initialize: function(){ - localStorage: new Backbone.LocalStorage( 'Rates' ); }, + + url: ajaxUrl+'&glm_action=regAdmin&collection=regRates' }); @@ -78,9 +78,8 @@ app.Models.Admin.RegRate = Backbone.Model.extend({ // Classes Collection app.Collections.Admin.RegClasses = Backbone.Collection.extend({ model: app.Models.Admin.RegClass, - - localStorage: new Backbone.LocalStorage( 'Classes' ), - + url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses', + add: }); // js/collections/regRates.js @@ -88,9 +87,7 @@ app.Collections.Admin.RegClasses = Backbone.Collection.extend({ // Registration Rate Collection app.Collections.Admin.RegRates = Backbone.Collection.extend({ model: app.Models.Admin.RegRate, - - localStorage: new Backbone.LocalStorage( 'Rates' ) - + url: ajaxUrl+'&glm_action=regAdmin&collection=regRates' }); // js/views/app.js @@ -140,16 +137,6 @@ app.Views.Admin.RegClass = Backbone.View.extend({ 'click .class-add-rate': 'addRate' }, - update: function(){ - console.log('update called'); - var cName = this.$('.class-name').val().trim(); - var cDescr = this.$('.class-descr').val().trim(); -// this.model.save({ name: cName, descr: cDescr }); - this.$('.class-display-template').show(); - this.$('.class-edit-template').hide(); - glmSubmitRequired--; - }, - add: function(){ console.log('add called'); this.$('.class-display-template').show(); @@ -159,12 +146,19 @@ app.Views.Admin.RegClass = Backbone.View.extend({ var cName = this.$('.class-name').val().trim(); var cDescr = this.$('.class-descr').val().trim(); this.model.set({ name: cName, descr: cDescr }); + + if (!this.model.save({ name: cName, descr: cDescr })) { + console.log('AJAX Save Error'); + } else { + console.log('AJAX Save Successful'); + } // Add this new model to the collection. var parentEvent = this.model.get( 'parent' ); // ???????? // parentEvent.classes.create( this.model ); }, deleteLevel: function(){ + console.log('deleteLevel called'); if (this.newClass) { alert('removing a new class. May have to avoid doing any ajax call if not updated yet.') } @@ -182,13 +176,27 @@ app.Views.Admin.RegClass = Backbone.View.extend({ this.$('.class-display-template').hide(); this.$('.class-edit-template').show(); this.$('.class-name').focus(); - glmSubmitRequired++; + glmSubmitRequired += 1; + }, + + update: function(){ + console.log('update called'); + var cName = this.$('.class-name').val().trim(); + var cDescr = this.$('.class-descr').val().trim(); + if (!this.model.save({ name: cName, descr: cDescr })) { + console.log('AJAX Save Error'); + } else { + console.log('AJAX Save Successful'); + } + this.$('.class-display-template').show(); + this.$('.class-edit-template').hide(); + glmSubmitRequired -= 1; }, render: function(addFlag){ this.$el.html( this.template( this.model.toJSON() ) ); // If addFlag set then we know the call to this is to add a class and not to initialize existing classes - if (addFlag) { + if (addFlag == true) { console.log('New level created'); this.$('.class-display-template').hide(); this.$('.class-edit-template').show(); @@ -196,7 +204,7 @@ app.Views.Admin.RegClass = Backbone.View.extend({ this.$('.class-add').show(); this.$('.class-name').focus(); this.newClass = true; - glmSubmitRequired++; + glmSubmitRequired += 1; } return this; }, @@ -210,6 +218,7 @@ app.Views.Admin.RegClass = Backbone.View.extend({ }, addAll: function(){ + console.log('addAll called'); jQuery('.glm-reg-level').html(''); }, @@ -252,7 +261,7 @@ app.Views.Admin.RegEvent = Backbone.View.extend({ console.log( 'addLevel Called' ); // create a new view and model and add it to classes and call render. // Create the model for the view and add it to the collection - var regClass = new app.Models.Admin.RegClass({ parent: this.model }); + var regClass = new app.Models.Admin.RegClass({ glmAction: 'regClass', parent: this.model }); //this.model.classes.add( regClass ); var view = new app.Views.Admin.RegClass({ model: regClass }); this.$el.append(view.render(true).el); @@ -296,7 +305,7 @@ app.Views.Admin.RegRate = Backbone.View.extend({ this.$('.rate-display-template').hide(); this.$('.rate-edit-template').show(); this.$('.rate-name').focus(); - glmSubmitRequired++; +// glmSubmitRequired++; }, update: function() { @@ -305,7 +314,7 @@ app.Views.Admin.RegRate = Backbone.View.extend({ // this.model.save({ name: cName }); this.$('.rate-display-template').show(); this.$('.rate-edit-template').hide(); - glmSubmitRequired--; +// glmSubmitRequired--; }, @@ -347,7 +356,7 @@ console.log('Need to check that this is actually removing from database..'); this.$('.rate-add').show(); this.$('.rate-name').focus(); this.newRate = true; - glmSubmitRequired++; +// glmSubmitRequired++; } return this; } diff --git a/js/collections/admin/regClasses.js b/js/collections/admin/regClasses.js index 5c226b3..4e183ce 100644 --- a/js/collections/admin/regClasses.js +++ b/js/collections/admin/regClasses.js @@ -3,7 +3,6 @@ // Classes Collection app.Collections.Admin.RegClasses = Backbone.Collection.extend({ model: app.Models.Admin.RegClass, - - localStorage: new Backbone.LocalStorage( 'Classes' ), - + url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses', + add: }); diff --git a/js/collections/admin/regRates.js b/js/collections/admin/regRates.js index d192345..ff3ac3e 100644 --- a/js/collections/admin/regRates.js +++ b/js/collections/admin/regRates.js @@ -3,7 +3,5 @@ // Registration Rate Collection app.Collections.Admin.RegRates = Backbone.Collection.extend({ model: app.Models.Admin.RegRate, - - localStorage: new Backbone.LocalStorage( 'Rates' ) - + url: ajaxUrl+'&glm_action=regAdmin&collection=regRates' }); diff --git a/js/models/admin/regClass.js b/js/models/admin/regClass.js index 1ba7314..de805f9 100644 --- a/js/models/admin/regClass.js +++ b/js/models/admin/regClass.js @@ -6,7 +6,6 @@ app.Models.Admin.RegClass = Backbone.Model.extend({ // Defaults defaults: { id: null, - parent: 0, reg_event: 0, name: '', descr: '', @@ -16,4 +15,6 @@ app.Models.Admin.RegClass = Backbone.Model.extend({ this.rates = new app.Collections.Admin.RegRates; }, + url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses' + }); diff --git a/js/models/admin/regEvent.js b/js/models/admin/regEvent.js index f276af3..ae923d6 100644 --- a/js/models/admin/regEvent.js +++ b/js/models/admin/regEvent.js @@ -5,7 +5,6 @@ app.Models.Admin.RegEvent = Backbone.Model.extend({ // Default regEvent values defaults: { - name: 'regEvent', event_name: '', event_code: '', notify_email: '', @@ -23,6 +22,6 @@ app.Models.Admin.RegEvent = Backbone.Model.extend({ setClasses: function( regClasses ){ this.classes.reset( regClasses ); - }, + } }); diff --git a/js/models/admin/regRate.js b/js/models/admin/regRate.js index a431494..2fe44e1 100644 --- a/js/models/admin/regRate.js +++ b/js/models/admin/regRate.js @@ -7,7 +7,6 @@ app.Models.Admin.RegRate = Backbone.Model.extend({ // Default regRate values defaults: { id: null, - parent: 0, reg_event: 0, reg_class: '', name: '', @@ -19,7 +18,8 @@ app.Models.Admin.RegRate = Backbone.Model.extend({ }, initialize: function(){ - localStorage: new Backbone.LocalStorage( 'Rates' ); }, + + url: ajaxUrl+'&glm_action=regAdmin&collection=regRates' }); diff --git a/js/views/admin/regClass.js b/js/views/admin/regClass.js index 0a71465..133e987 100644 --- a/js/views/admin/regClass.js +++ b/js/views/admin/regClass.js @@ -21,16 +21,6 @@ app.Views.Admin.RegClass = Backbone.View.extend({ 'click .class-add-rate': 'addRate' }, - update: function(){ - console.log('update called'); - var cName = this.$('.class-name').val().trim(); - var cDescr = this.$('.class-descr').val().trim(); -// this.model.save({ name: cName, descr: cDescr }); - this.$('.class-display-template').show(); - this.$('.class-edit-template').hide(); - glmSubmitRequired--; - }, - add: function(){ console.log('add called'); this.$('.class-display-template').show(); @@ -40,12 +30,19 @@ app.Views.Admin.RegClass = Backbone.View.extend({ var cName = this.$('.class-name').val().trim(); var cDescr = this.$('.class-descr').val().trim(); this.model.set({ name: cName, descr: cDescr }); + + if (!this.model.save({ name: cName, descr: cDescr })) { + console.log('AJAX Save Error'); + } else { + console.log('AJAX Save Successful'); + } // Add this new model to the collection. var parentEvent = this.model.get( 'parent' ); // ???????? // parentEvent.classes.create( this.model ); }, deleteLevel: function(){ + console.log('deleteLevel called'); if (this.newClass) { alert('removing a new class. May have to avoid doing any ajax call if not updated yet.') } @@ -63,13 +60,27 @@ app.Views.Admin.RegClass = Backbone.View.extend({ this.$('.class-display-template').hide(); this.$('.class-edit-template').show(); this.$('.class-name').focus(); - glmSubmitRequired++; + glmSubmitRequired += 1; + }, + + update: function(){ + console.log('update called'); + var cName = this.$('.class-name').val().trim(); + var cDescr = this.$('.class-descr').val().trim(); + if (!this.model.save({ name: cName, descr: cDescr })) { + console.log('AJAX Save Error'); + } else { + console.log('AJAX Save Successful'); + } + this.$('.class-display-template').show(); + this.$('.class-edit-template').hide(); + glmSubmitRequired -= 1; }, render: function(addFlag){ this.$el.html( this.template( this.model.toJSON() ) ); // If addFlag set then we know the call to this is to add a class and not to initialize existing classes - if (addFlag) { + if (addFlag == true) { console.log('New level created'); this.$('.class-display-template').hide(); this.$('.class-edit-template').show(); @@ -77,7 +88,7 @@ app.Views.Admin.RegClass = Backbone.View.extend({ this.$('.class-add').show(); this.$('.class-name').focus(); this.newClass = true; - glmSubmitRequired++; + glmSubmitRequired += 1; } return this; }, @@ -91,6 +102,7 @@ app.Views.Admin.RegClass = Backbone.View.extend({ }, addAll: function(){ + console.log('addAll called'); jQuery('.glm-reg-level').html(''); }, diff --git a/js/views/admin/regEvent.js b/js/views/admin/regEvent.js index 3a52ba4..4e9ceee 100644 --- a/js/views/admin/regEvent.js +++ b/js/views/admin/regEvent.js @@ -25,7 +25,7 @@ app.Views.Admin.RegEvent = Backbone.View.extend({ console.log( 'addLevel Called' ); // create a new view and model and add it to classes and call render. // Create the model for the view and add it to the collection - var regClass = new app.Models.Admin.RegClass({ parent: this.model }); + var regClass = new app.Models.Admin.RegClass({ glmAction: 'regClass', parent: this.model }); //this.model.classes.add( regClass ); var view = new app.Views.Admin.RegClass({ model: regClass }); this.$el.append(view.render(true).el); diff --git a/js/views/admin/regRate.js b/js/views/admin/regRate.js index b9a6798..4af9870 100644 --- a/js/views/admin/regRate.js +++ b/js/views/admin/regRate.js @@ -25,7 +25,7 @@ app.Views.Admin.RegRate = Backbone.View.extend({ this.$('.rate-display-template').hide(); this.$('.rate-edit-template').show(); this.$('.rate-name').focus(); - glmSubmitRequired++; +// glmSubmitRequired++; }, update: function() { @@ -34,7 +34,7 @@ app.Views.Admin.RegRate = Backbone.View.extend({ // this.model.save({ name: cName }); this.$('.rate-display-template').show(); this.$('.rate-edit-template').hide(); - glmSubmitRequired--; +// glmSubmitRequired--; }, @@ -76,7 +76,7 @@ console.log('Need to check that this is actually removing from database..'); this.$('.rate-add').show(); this.$('.rate-name').focus(); this.newRate = true; - glmSubmitRequired++; +// glmSubmitRequired++; } return this; } diff --git a/models/admin/ajax/regAdmin.php b/models/admin/ajax/regAdmin.php new file mode 100644 index 0000000..38d3bd3 --- /dev/null +++ b/models/admin/ajax/regAdmin.php @@ -0,0 +1,121 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +/** + * This class processes AJAX requests from admin Backbone.js registrations interface + */ +class GlmMembersAdmin_ajax_regAdmin +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration 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 data class + // parent::__construct(false, false); + + } + + /* + * Perform Model Action + * + * This model checks to see if the creditials passed in are correct. + * + * This model action does not return, it simply does it's work then calls wp_die(); + * + * @param $actionData + * + * Echos JSON string as response and does not return + */ + public function modelAction( $actionData = false ) + { + +trigger_error(print_r($_REQUEST,1), E_USER_NOTICE); + + // Get Backbone collection we're talking with + $collection = filter_var( $_REQUEST['collection'], FILTER_SANITIZE_STRING ); + + // Get the submission method + $method = filter_var( $_REQUEST['_method'], FILTER_SANITIZE_STRING ); + + // If not a valid collection, die quietly + if (!in_array($collection, array('regClasses', 'regRates'))) { + wp_die(); + } + + // If not a valid method, die quietly + if (!in_array($method, array('POST', 'GET', 'PUT', 'PATCH', 'DELETE'))) { + wp_die(); + } + + // Try to decode the JSON + $modelData = json_decode(stripslashes($_REQUEST['model']), true); + + // Build model and path and class names + $modelName = GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH.'/models/admin/ajax/regAdmin/'.$collection.'.php'; + $className = 'GlmMembersAdmin_registrations_ajax_'.$collection; + + // Check if model for this request exists + if (!file_exists($modelName)) { + trigger_error ( "ERROR: The specified model file doesn't exist. ($modelName)", E_USER_ERROR); + wp_die(); + } + + // Load the model file + require_once $modelName; + + // check for an invalid model class name + if (!class_exists($className)) { + trigger_error ( "ERROR: The specified class name doesn't exist. ($className)", E_USER_ERROR); + wp_die(); + } + + // Instantiate the model and ask it to perform the work + $model = new $className($this->wpdb, $this->config); + + $results = $model->modelAction($method, $modelData); + + + } +} diff --git a/models/admin/ajax/regAdmin/regClasses.php b/models/admin/ajax/regAdmin/regClasses.php new file mode 100644 index 0000000..f55521f --- /dev/null +++ b/models/admin/ajax/regAdmin/regClasses.php @@ -0,0 +1,144 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release regClasses.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Registrations data abstract +require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegClass.php'; + +class GlmMembersAdmin_registrations_ajax_regClasses extends GlmDataRegistrationsRegClass +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /** + * 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($method, $modelData) + { + +//trigger_error(print_r($modelData,1)."Method = $method"); + + // Perform specified action + switch ($method) { + + // Create + case 'POST': + break; + + // Read + case 'GET': + break; + + // Update + case 'PUT': + + // If we have a numeric class (level) ID + $classID = ($modelData['id'] - 0); + if ($classID > 0) { + + // Try to update the class (level) data + $this->wpdb->update( + $this->table, + array( + 'name' => $modelData['name'], + 'descr' => $modelData['descr'] + ), + array('id' => $classID), + array( + '%s', + '%s' + ), + array( '%d' ) + ); + + } + + break; + + // Patch + case 'PATCH': + break; + + // Delete + case 'DELETE': + break; + + default: + die(); // should never get here + break; + + } + + wp_die(); + + + + } + + +} diff --git a/models/admin/ajax/regFront.php b/models/admin/ajax/regFront.php new file mode 100644 index 0000000..0715e97 --- /dev/null +++ b/models/admin/ajax/regFront.php @@ -0,0 +1,119 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @version 0.1 + */ + +/** + * This class processes AJAX requests from front-end Backbone.js registrations interface + */ +class GlmMembersAdmin_ajax_regFront +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration 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 data class + // parent::__construct(false, false); + + } + + /* + * Perform Model Action + * + * This model checks to see if the creditials passed in are correct. + * + * This model action does not return, it simply does it's work then calls wp_die(); + * + * @param $actionData + * + * Echos JSON string as response and does not return + */ + public function modelAction( $actionData = false ) + { + + // Get Backbone collection we're talking with + $collection = filter_var( $_REQUEST['collection'], FILTER_SANITIZE_STRING ); + + // Get the submission method + $method = filter_var( $_REQUEST['_method'], FILTER_SANITIZE_STRING ); + + // If not a valid collection, die quietly + if (!in_array($collection, array('regClasses', 'regRates'))) { + wp_die(); + } + + // If not a valid method, die quietly + if (!in_array($method, array('POST', 'GET', 'PUT', 'PATCH', 'DELETE'))) { + wp_die(); + } + + // Try to decode the JSON + $modelData = json_decode(stripslashes($_REQUEST['model']), true); + + // Build model and path and class names + $modelName = GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH.'/models/admin/ajax/regFront/'.$collection.'.php'; + $className = 'GlmMembersAdmin_registrations_ajax_'.$collection; + + // Check if model for this request exists + if (!file_exists($modelName)) { + trigger_error ( "ERROR: The specified model file doesn't exist. ($modelName)", E_USER_ERROR); + wp_die(); + } + + // Load the model file + require_once $modelName; + + // check for an invalid model class name + if (!class_exists($className)) { + trigger_error ( "ERROR: The specified class name doesn't exist. ($className)", E_USER_ERROR); + wp_die(); + } + + // Instantiate the model and ask it to perform the work + $model = new $className($this->wpdb, $this->config); + + $results = $model->modelAction($method, $modelData); + + + } +} diff --git a/models/admin/ajax/regFront/regRequestEvent.php b/models/admin/ajax/regFront/regRequestEvent.php new file mode 100644 index 0000000..f313a6e --- /dev/null +++ b/models/admin/ajax/regFront/regRequestEvent.php @@ -0,0 +1,123 @@ + + * @license http://www.gaslightmedia.com Gaslightmedia + * @release regRequestEvent.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @link http://dev.gaslightmedia.com/ + */ + +// Load Registrations data abstract +require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegEvent.php'; + +class GlmMembersAdmin_registrations_ajax_regClasses extends GlmDataRegistrationsRequestEvent +{ + + /** + * WordPress Database Object + * + * @var $wpdb + * @access public + */ + public $wpdb; + /** + * Plugin Configuration Data + * + * @var $config + * @access public + */ + public $config; + + /** + * 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($method, $modelData) + { + +//trigger_error(print_r($modelData,1)."Method = $method"); + + // Perform specified action + switch ($method) { + + // Create + case 'POST': + break; + + // Read + case 'GET': + break; + + // Update + case 'PUT': + + break; + + // Patch + case 'PATCH': + break; + + // Delete + case 'DELETE': + break; + + default: + die(); // should never get here + break; + + } + + wp_die(); + + + + } + + +} diff --git a/setup/validActions.php b/setup/validActions.php index 76b0c10..faf16c1 100644 --- a/setup/validActions.php +++ b/setup/validActions.php @@ -61,6 +61,7 @@ $glmMembersRegistrationsAddOnValidActions = array( 'adminActions' => array( 'ajax' => array( 'account' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, + 'regAdmin' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG ), 'registrations' => array( 'index' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG, diff --git a/views/admin/registrations/eventEditLevels.html b/views/admin/registrations/eventEditLevels.html index e56e774..1158d35 100644 --- a/views/admin/registrations/eventEditLevels.html +++ b/views/admin/registrations/eventEditLevels.html @@ -107,7 +107,7 @@ var glmSubmitRequired = 0; //var $=jQuery.noConflict(); - var ajaxUrl = '{$ajaxUrl}?action=glm_members_admin_ajax'; + var ajaxUrl = '{$ajaxUrl}?action=glm_members_admin_ajax'; var app = { Models: { Admin: {} }, Collections: { Admin: {} }, -- 2.17.1