/**
* Gaslight Media Members Database
- * Registration add-on front AJAX processor
+ * Registration add-on front AJAX processor
*
* PHP version 5.5
*
*/
/**
- * 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
{
// 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);
-
-
+
+
}
}
--- /dev/null
+<?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();
+
+
+
+ }
+
+
+}