Adding ajax class for handling save for the request.
authorSteve Sutton <ssutton@gmail.com>
Wed, 20 Sep 2017 00:05:53 +0000 (20:05 -0400)
committerSteve Sutton <ssutton@gmail.com>
Wed, 20 Sep 2017 00:05:53 +0000 (20:05 -0400)
Setting up an ajax class following Chuck setup for the admin one.

js/frontRegApp.js
js/models/front/cart.js
js/models/front/request.js
models/admin/ajax/regFront.php
models/admin/ajax/regFront/request.php [new file with mode: 0644]

index a6d4458..ff44eb0 100644 (file)
@@ -96,6 +96,7 @@ app.Models.Front.Cart = Backbone.Model.extend({
 
     setRequest: function( request ){
         this.request = new app.Models.Front.Request( request );
+        this.request.save();
     },
 
     setAccounts: function( accounts ){
@@ -217,6 +218,9 @@ app.Models.Front.Request = Backbone.Model.extend({
         account_fname: '',
         account_lname: '',
     },
+
+    url: ajaxUrl+'&glm_action=regFront&collection=request',
+
 });
 
 // js/collections/accounts.js
index 6fb50a4..3e0deb4 100644 (file)
@@ -10,6 +10,7 @@ app.Models.Front.Cart = Backbone.Model.extend({
 
     setRequest: function( request ){
         this.request = new app.Models.Front.Request( request );
+        this.request.save();
     },
 
     setAccounts: function( accounts ){
index 39e1e29..cf94aef 100644 (file)
@@ -5,4 +5,7 @@ app.Models.Front.Request = Backbone.Model.extend({
         account_fname: '',
         account_lname: '',
     },
+
+    url: ajaxUrl+'&glm_action=regFront&collection=request',
+
 });
index 515c31e..87fe752 100644 (file)
@@ -2,7 +2,7 @@
 
 /**
  * Gaslight Media Members Database
- * Registration add-on front AJAX processor 
+ * Registration add-on front AJAX processor
  *
  * PHP version 5.5
  *
@@ -14,7 +14,7 @@
  */
 
 /**
- * This class processes AJAX requests from front-end Backbone.js registrations interface 
+ * This class processes AJAX requests from front-end Backbone.js registrations interface
  */
 class GlmMembersAdmin_ajax_regFront
 {
@@ -73,39 +73,39 @@ class GlmMembersAdmin_ajax_regFront
 
         // Get Backbone collection we're talking with
         $collection = filter_var( $_REQUEST['collection'], FILTER_SANITIZE_STRING );
-        
+
         // If not a valid collection, die quietly
-        if (!in_array($collection, array('regClasses', 'regRates'))) {
+        if (!in_array($collection, array('regClasses', 'request'))) {
             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($modelData);
-        
-        
+
+
     }
 }
diff --git a/models/admin/ajax/regFront/request.php b/models/admin/ajax/regFront/request.php
new file mode 100644 (file)
index 0000000..85c2998
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Registrations AJAX processing for Registration Request Events
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @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/dataRegRequest.php';
+
+class GlmMembersAdmin_registrations_ajax_request extends GlmDataRegistrationsRegRequest
+{
+
+    /**
+     * 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($modelData)
+    {
+
+trigger_error(print_r($modelData,1));
+
+        // Perform specified action
+        switch ($modelData['option']) {
+
+            case 'add':
+                break;
+
+            case 'get':
+                break;
+
+            case 'update':
+                break;
+
+            case 'delete':
+                break;
+
+            default:
+                die();  // should never get here
+                break;
+
+        }
+
+        wp_die();
+
+
+
+    }
+
+
+}