From: Steve Sutton Date: Fri, 18 Aug 2017 12:59:10 +0000 (-0400) Subject: Updates for the Select (rename to registration) X-Git-Tag: v1.0.0^2~465 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=7ec23ecbfd45ccbe17d756830ee4df4d84a6b359;p=WP-Plugins%2Fglm-member-db-registrations.git Updates for the Select (rename to registration) Renaming the select model and view to registration. Setting up the list view to list out the events. Then the registration page will show just one event. --- diff --git a/data/events.php b/data/events.php new file mode 100644 index 0000000..b99a76d --- /dev/null +++ b/data/events.php @@ -0,0 +1,47 @@ + array( + 'id' => 1, + 'title' => 'PHP Payment Gateways', + 'short_desc' => 'Setting up your developer account and testing payment gateways', + 'levels' => array( + 3 => array( + 'id' => 3, + 'title' => 'General Admittance', + 'registrants' => array( + 1 => array( + 'id' => 1, + 'fname' => 'Dan', + 'lname' => 'Smith', + 'email' => 'dan@smith.com', + ), + 3 => array( + 'id' => 3, + 'fname' => 'Tony', + 'lname' => 'Johnson', + 'email' => 'tj@website.com', + ), + ), + ), + ), + ), + 2 => array( + 'id' => 2, + 'title' => 'Mailchimp Newsletters', + 'short_desc' => 'Learning how to setup test and use mailchimp to the fullest.', + 'levels' => array( + 4 => array( + 'id' => 4, + 'title' => 'General Admittance', + 'registrants' => array( + 2 => array( + 'id' => 2, + 'fname' => 'John', + 'lname' => 'Handler', + 'email' => 'johny@handler.com', + ), + ), + ), + ), + ) +); diff --git a/models/front/registrations/index.php b/models/front/registrations/index.php index 42179bf..7305a44 100644 --- a/models/front/registrations/index.php +++ b/models/front/registrations/index.php @@ -1,10 +1,10 @@ wpdb = $wpdb; - + // Save plugin configuration object $this->config = $config; - + } /* @@ -83,11 +83,15 @@ class GlmMembersFront_registrations_index // Check for valid page - if not valid default to "list" $page = $actionData['request']['page']; + if ( isset( $_REQUEST['page'] ) && $request = filter_var( $_REQUEST['page'], FILTER_SANITIZE_STRING ) ) { + $page = $request; + } + // Make sure the specified page is valid or default to "list" - if (!in_array($page, array('list', 'select', 'cart', 'checkout', 'summary', 'login', 'account'))) { + if (!in_array($page, array('list', 'registration', 'cart', 'checkout', 'summary', 'login', 'account'))) { $page = 'list'; } - + // Load the specified model $pageFile = GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH.'/models/front/registrations/'.$page.'.php'; require_once($pageFile); @@ -98,6 +102,6 @@ class GlmMembersFront_registrations_index $regResult = $regModel->modelAction($actionData); return $regResult; - + } } diff --git a/models/front/registrations/list.php b/models/front/registrations/list.php index bef41e1..6aa7bbd 100644 --- a/models/front/registrations/list.php +++ b/models/front/registrations/list.php @@ -16,6 +16,18 @@ * @access public */ public $config; + + public function __construct ($wpdb, $config) + { + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + /** * Constructor * @@ -24,11 +36,11 @@ * * 'status' * - * True if successfull and false if there was a fatal failure. + * True if successful and false if there was a fatal failure. * * 'view' * - * A suggested view name that the contoller should use instead of the + * A suggested view name that the controller should use instead of the * default view for this model or false to indicate that the default view * should be used. * @@ -67,9 +79,12 @@ } + // including test data for now + include GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH . '/data/events.php'; + // Compile template data $templateData = array( - + 'events' => $eventData, ); // Return status, any suggested view, and any data to controller return array( diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php new file mode 100644 index 0000000..99b3262 --- /dev/null +++ b/models/front/registrations/registration.php @@ -0,0 +1,90 @@ +wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + + } + + public function modelAction($actionData = false) + { + $regEvent = array(); + + // Get any provided option + if (isset($_REQUEST['option'])) { + $option = $_REQUEST['option']; + } + + // Get account ID if supplied + if (isset($_REQUEST['account'])) { + + // Make sure it's numeric + $this->accountID = ($_REQUEST['account'] - 0); + + if ($this->accountID <= 0) { + $this->accountID = false; + } + } + + // Get account ID if supplied + if (isset($_REQUEST['eventRegId'])) { + + // Make sure it's numeric + $eventRegID = ($_REQUEST['eventRegId'] - 0); + + if ($eventRegID <= 0) { + $eventRegID = false; + } + } + $view = 'registration'; + + switch ( $option ) { + + } + + // including test data for now + include GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH . '/data/events.php'; + + if ( isset( $eventData[$eventRegID] ) ) { + $regEvent[] = $eventData[$eventRegID]; + } else { + $regEvent = array(); + } + //echo '
$events: ' . print_r( $events, true ) . '
'; + + // Compile template data + $templateData = array( + 'events' => $regEvent, + ); + // Return status, any suggested view, and any data to controller + return array( + 'status' => true, + 'modelRedirect' => false, + 'view' => 'front/registrations/' . $view . '.html', + 'data' => $templateData + ); + + } + } diff --git a/models/front/registrations/select.php b/models/front/registrations/select.php deleted file mode 100644 index 0b8abda..0000000 --- a/models/front/registrations/select.php +++ /dev/null @@ -1,118 +0,0 @@ -wpdb = $wpdb; - - // Save plugin configuration object - $this->config = $config; - - } - - public function modelAction($actionData = false) - { - $events = array(); - - // Get any provided option - if (isset($_REQUEST['option'])) { - $option = $_REQUEST['option']; - } - - // Get account ID if supplied - if (isset($_REQUEST['account'])) { - - // Make sure it's numeric - $this->accountID = ($_REQUEST['account'] - 0); - - if ($this->accountID <= 0) { - $this->accountID = false; - } - } - - $view = 'select'; - - switch ( $option ) { - - } - - $events = array( - 1 => array( - 'id' => 1, - 'title' => 'PHP Payment Gateways', - 'short_desc' => 'Setting up your developer account and testing payment gateways', - 'levels' => array( - 3 => array( - 'id' => 3, - 'title' => 'General Admittance', - 'registrants' => array( - 1 => array( - 'id' => 1, - 'fname' => 'Dan', - 'lname' => 'Smith', - 'email' => 'dan@smith.com', - ), - 3 => array( - 'id' => 3, - 'fname' => 'Tony', - 'lname' => 'Johnson', - 'email' => 'tj@website.com', - ), - ), - ), - ), - ), - 2 => array( - 'id' => 2, - 'title' => 'Mailchimp Newsletters', - 'short_desc' => 'Learning how to setup test and use mailchimp to the fullest.', - 'levels' => array( - 4 => array( - 'id' => 4, - 'title' => 'General Admittance', - 'registrants' => array( - 2 => array( - 'id' => 2, - 'fname' => 'John', - 'lname' => 'Handler', - 'email' => 'johny@handler.com', - ), - ), - ), - ), - ) - ); - //echo '
$events: ' . print_r( $events, true ) . '
'; - - // Compile template data - $templateData = array( - 'events' => $events, - ); - // Return status, any suggested view, and any data to controller - return array( - 'status' => true, - 'modelRedirect' => false, - 'view' => 'front/registrations/' . $view . '.html', - 'data' => $templateData - ); - - } - } diff --git a/views/front/registrations/list.html b/views/front/registrations/list.html index 8eee247..ecc7bf6 100644 --- a/views/front/registrations/list.html +++ b/views/front/registrations/list.html @@ -1 +1,10 @@ -This is a list \ No newline at end of file +
+ {foreach $events as $event} +
+

{$event.title}

+

{$event.short_desc}

+ +
+ {/foreach} + +
diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html new file mode 100644 index 0000000..1f1f640 --- /dev/null +++ b/views/front/registrations/registration.html @@ -0,0 +1,31 @@ +
+ {foreach $events as $event} +
+

{$event.title}

+
+ +
+

{$event.short_desc}

+
+
+

Pick your registration dates

+ + +
+ {foreach $event.levels as $level} +
+

{$level.title}

+ + + {foreach $level.registrants as $reg} +
{$reg.fname} {$reg.lname} {$reg.email}
+ {/foreach} +
+ {/foreach} +
+ +
+
+
+ {/foreach} + +
diff --git a/views/front/registrations/select.html b/views/front/registrations/select.html deleted file mode 100644 index 1f1f640..0000000 --- a/views/front/registrations/select.html +++ /dev/null @@ -1,31 +0,0 @@ -
- {foreach $events as $event} -
-

{$event.title}

-
- -
-

{$event.short_desc}

-
-
-

Pick your registration dates

- - -
- {foreach $event.levels as $level} -
-

{$level.title}

- + - {foreach $level.registrants as $reg} -
{$reg.fname} {$reg.lname} {$reg.email}
- {/foreach} -
- {/foreach} -
- -
-
-
- {/foreach} - -