From: Chuck Scott Date: Thu, 15 Jan 2015 04:02:18 +0000 (-0500) Subject: Now have member additions working pretty well. X-Git-Tag: v1.0.0~83 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=cd9eaadb557b0e0f13aeb65090e19659322f73e8;p=WP-Plugins%2Fglm-member-db.git Now have member additions working pretty well. --- diff --git a/classes/data/dataMembers.php b/classes/data/dataMembers.php index a201d432..2ccb33e4 100644 --- a/classes/data/dataMembers.php +++ b/classes/data/dataMembers.php @@ -80,7 +80,7 @@ abstract class GlmDataMembers extends GlmDataAbstract { 'field' => 'id', 'type' => 'integer', 'view_only' => true, - 'use' => 'lgd' + 'use' => 'a' ), // Active @@ -104,7 +104,7 @@ abstract class GlmDataMembers extends GlmDataAbstract { 'field' => 'descr', 'type' => 'text', 'required' => true, - 'use' => 'gneud' + 'use' => 'a' ), // Short description diff --git a/controllers/admin.php b/controllers/admin.php index 706f18f6..34c16643 100644 --- a/controllers/admin.php +++ b/controllers/admin.php @@ -353,6 +353,10 @@ class glmMembersAdmin extends GlmPluginSupport { $errorMsg = ''; + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + $this->addNotice("
".print_r($_REQUEST,1)."
", "Request Data"); + } + /* * Determine model to execute */ @@ -371,6 +375,7 @@ class glmMembersAdmin extends GlmPluginSupport // Loop till we have a final action $loopCheck = 0; + $redirectData = false; do { if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { @@ -430,9 +435,13 @@ class glmMembersAdmin extends GlmPluginSupport } else { + // Check if this is a re-direct with parameters + $args = false; + + // Instantiate the model and ask it to perform the work $model = new $className($this->wpdb, $this->config); - $results = $model->modelAction(); + $results = $model->modelAction($redirectData); // Check if there's been a model redirect request if ($results['modelRedirect']) { @@ -445,6 +454,11 @@ class glmMembersAdmin extends GlmPluginSupport $menuItem = $results['menuItemRedirect']; } + // Check if there's data to pass to the new model + if (isset($results['data']) && count($results['data']) > 0) { + $redirectData = $results['data']; + } + $modelRedirect = true; } diff --git a/css/admin.css b/css/admin.css index 2175f67c..4a3ce638 100644 --- a/css/admin.css +++ b/css/admin.css @@ -7,10 +7,12 @@ .glm-required { color: red !important; } - .glm-error { color: red; } +.glm-notice { + color: red; +} .glm-copyright { text-align: center; @@ -55,6 +57,13 @@ width: 90%; } +/* Admin table additions */ +.glm-table-fieldname { + text-align: left; + padding-right: 1em; +} + + /* Debug Window */ #glm-debug-header { font-weight: bold; diff --git a/lib/GlmDataAbstract/DataAbstract.php b/lib/GlmDataAbstract/DataAbstract.php index 678284af..76e14818 100755 --- a/lib/GlmDataAbstract/DataAbstract.php +++ b/lib/GlmDataAbstract/DataAbstract.php @@ -1131,26 +1131,20 @@ abstract class GlmDataAbstract $in = filter_input(INPUT_POST, $as, $filter, $filter_options); - if ($f['required'] && trim($in) == '') { - $this->inputFieldStatus = false; - $this->inputErrorReason = 'Required input not provided.'; - return $in; - } - // Check for required field - if ($f['required'] && trim($in) == '') { + if (isset($f['required']) && $f['required'] && trim($in) == '') { $this->inputFieldStatus = false; $this->inputErrorReason = 'Required input not provided.'; return $in; } // Check min/max length - if ($f['minLength'] && strlen($in) < $f['minLength']) { + if (isset($f['minLength']) && $f['minLength'] && strlen($in) < $f['minLength']) { $this->inputFieldStatus = false; $this->inputErrorReason = 'Input is shorter than minimum length of '.$f['minLength'].' characters.'; return $in; } - if ($f['maxLength'] && strlen($in) > $f['maxLength']) { + if (isset($f['maxLength']) && $f['maxLength'] && strlen($in) > $f['maxLength']) { $this->inputFieldStatus = false; $this->inputErrorReason = 'Input is longer than maximum length of '.$f['maxLength'].' characters.'; return $in; @@ -1162,7 +1156,7 @@ abstract class GlmDataAbstract // Query table to see if there's a conflict $sql = " SELECT COUNT(" - .$f['field'].") + .$f['field'].") as count FROM " .$this->table." WHERE " @@ -1175,11 +1169,11 @@ abstract class GlmDataAbstract $sql .= "AND $idField != $id"; } - $d = $this->wpdb->get_results($sql, ARRAY_A); + $d = $this->wpdb->get_row($sql, ARRAY_A); if ($d['count'] > 0) { $this->inputFieldStatus = false; - $this->inputErrorReason = 'This must be unique but it conflicts with another entry.'; + $this->inputErrorReason = 'This must be unique, but it conflicts with another entry.'; return $in; } } @@ -1368,7 +1362,7 @@ abstract class GlmDataAbstract $this->inputFieldStatus = true; $in = false; - if (in_array($_REQUEST[$as], $valid)) { + if (isset($_REQUEST[$as]) && in_array($_REQUEST[$as], $valid)) { $in = true; } @@ -2429,6 +2423,7 @@ abstract class GlmDataAbstract if ($forEdit) { return array( + 'status' => true, 'fieldData' => $data, 'fieldRequired' => $fieldRequired, 'fieldFail' => $fieldFail @@ -2585,8 +2580,9 @@ abstract class GlmDataAbstract //echo "
$sql
"; $list = $this->wpdb->get_results($sql, ARRAY_A); - if (count($list) == 0) + if (count($list) == 0) { return false; + } // Process individual fields while (list($k, $v) = each($list)) { @@ -2675,8 +2671,6 @@ abstract class GlmDataAbstract */ public function insertEntry($store = true) { - // Assume everything goes OK. - $status = true; $r = $this->processInputData('i'); @@ -2709,9 +2703,7 @@ abstract class GlmDataAbstract $this->wpdb->query($sql); // Get the current ID value and set that in the session - $sql = "SELECT CURRVAL('".$this->table."_id_seq') "; - $detail = $this->wpdb->get_row($sql, ARRAY_A); - $r['insertedID'] = $detail['currval']; + $r['insertedID'] = $this->wpdb->insert_id; if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { glmMembersAdmin::addNotice("
".print_r($sql,1)."
", "DataAbstract - insertEntry() query"); @@ -2748,6 +2740,11 @@ abstract class GlmDataAbstract $detail = $this->wpdb->get_row($sql, ARRAY_A); + // Check for failure retrieving data + if (!$detail) { + return false; + } + // Process individual fields $detail = $this->processOutputData($detail, 'e', true, $id, $idfield); @@ -2798,12 +2795,15 @@ abstract class GlmDataAbstract $sep = ''; reset($r['fieldStore']); + // Build list of fields that get updated while (list($k, $v) = each($r['fieldStore'])) { + // Determine if the field is supposed to be updated when blank; + $noUpdateWhenBlank = (isset($this->fields[$k]['no_update_when_blank']) && $this->fields[$k]['no_update_when_blank']); + // If do not store on empty option is set and the value is blank then don't store // Note that $v also includes single quote marks (') so a length of 2 is actually blank. - if (!($this->fields[$k]['no_update_when_blank'] && strlen($v) == 2)) { - + if (!($noUpdateWhenBlank && strlen($v) == 2)) { $sql .= $sep."$k = $v"; $sep = ",\n"; } diff --git a/lib/GlmDataAbstract/documentation.txt b/lib/GlmDataAbstract/documentation.txt index 01572ff4..ea0f0e60 100644 --- a/lib/GlmDataAbstract/documentation.txt +++ b/lib/GlmDataAbstract/documentation.txt @@ -332,7 +332,7 @@ Field Specifications: 'quicktip' Text description of this field and its use. -'no_update_when_blank' Do not store a new value is the submitted data is blank +'no_update_when_blank' Do not store a new value if the submitted data is blank Used particularly for password fields where you only want them updated when the user puts something in 'pw_type' Type of password to require for password fields. (default is normal, 'strong' is for strong passwords with a mix of character types) diff --git a/misc/smarty/templates_c/06926788f51c1a5a54be2a368556f9c37e2780da.file.badAction.html.php b/misc/smarty/templates_c/06926788f51c1a5a54be2a368556f9c37e2780da.file.badAction.html.php index 186d759b..88044165 100644 --- a/misc/smarty/templates_c/06926788f51c1a5a54be2a368556f9c37e2780da.file.badAction.html.php +++ b/misc/smarty/templates_c/06926788f51c1a5a54be2a368556f9c37e2780da.file.badAction.html.php @@ -1,4 +1,4 @@ - decodeProperties(array ( @@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( '06926788f51c1a5a54be2a368556f9c37e2780da' => array ( 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/error/badAction.html', - 1 => 1421264558, + 1 => 1421285081, 2 => 'file', ), ), @@ -23,7 +23,8 @@ $_valid = $_smarty_tpl->decodeProperties(array ( ), 'has_nocache_code' => false, ),false); /*/%%SmartyHeaderCode%%*/?> -
+getSubTemplate ('admin/error/header.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?> +

Sorry, we've had an error.

@@ -34,5 +35,6 @@ $_valid = $_smarty_tpl->decodeProperties(array (

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

-
+getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?> + diff --git a/misc/smarty/templates_c/081a36d97cdf30d438a1e104c26a275acc180da0.file.index.html.php b/misc/smarty/templates_c/081a36d97cdf30d438a1e104c26a275acc180da0.file.index.html.php index 95bcae6f..6f74ae14 100644 --- a/misc/smarty/templates_c/081a36d97cdf30d438a1e104c26a275acc180da0.file.index.html.php +++ b/misc/smarty/templates_c/081a36d97cdf30d438a1e104c26a275acc180da0.file.index.html.php @@ -1,4 +1,4 @@ - decodeProperties(array ( @@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( '081a36d97cdf30d438a1e104c26a275acc180da0' => array ( 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/index.html', - 1 => 1421281939, + 1 => 1421288544, 2 => 'file', ), ), @@ -20,6 +20,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( 'variables' => array ( 'numbMembers' => 0, + 'thisURL' => 0, ), 'has_nocache_code' => false, ),false); /*/%%SmartyHeaderCode%%*/?> @@ -28,12 +29,17 @@ $_valid = $_smarty_tpl->decodeProperties(array (

Members Dashboard

-

Status and notices go here

+tpl_vars['numbMembers']->value==0) {?> +

+ You do not currently have any members listed. + Click here to create your first member. +

+ -
Number of Members Listed: tpl_vars['numbMembers']->value;?>
getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?> diff --git a/misc/smarty/templates_c/1be35689c5d30d774f40ebc45e387f5f95c45e90.file.index.html.php b/misc/smarty/templates_c/1be35689c5d30d774f40ebc45e387f5f95c45e90.file.index.html.php index 6986fb30..32d12886 100644 --- a/misc/smarty/templates_c/1be35689c5d30d774f40ebc45e387f5f95c45e90.file.index.html.php +++ b/misc/smarty/templates_c/1be35689c5d30d774f40ebc45e387f5f95c45e90.file.index.html.php @@ -1,4 +1,4 @@ - decodeProperties(array ( @@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( '1be35689c5d30d774f40ebc45e387f5f95c45e90' => array ( 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/member/index.html', - 1 => 1421269603, + 1 => 1421293149, 2 => 'file', ), ), @@ -28,10 +28,20 @@ $_valid = $_smarty_tpl->decodeProperties(array (

tpl_vars['member']->value['name'];?>

- - + tpl_vars['member']->value['active']['value']) {?> +

This member is active.

+ +

Member Not Active

+ + +
Member Name:tpl_vars['member']->value['name'];?> -
+ + +
Member Name:tpl_vars['member']->value['name'];?> +
Description:tpl_vars['member']->value['descr'];?> +
Short Description:tpl_vars['member']->value['short_descr'];?> +
getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?> diff --git a/misc/smarty/templates_c/25c8610e0e0bacafec3046a296066e9f8eceedae.file.member.html.php b/misc/smarty/templates_c/25c8610e0e0bacafec3046a296066e9f8eceedae.file.member.html.php index cff656f0..256b564a 100644 --- a/misc/smarty/templates_c/25c8610e0e0bacafec3046a296066e9f8eceedae.file.member.html.php +++ b/misc/smarty/templates_c/25c8610e0e0bacafec3046a296066e9f8eceedae.file.member.html.php @@ -1,4 +1,4 @@ - decodeProperties(array ( @@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( '25c8610e0e0bacafec3046a296066e9f8eceedae' => array ( 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/member/member.html', - 1 => 1421272105, + 1 => 1421287476, 2 => 'file', ), ), @@ -15,6 +15,8 @@ $_valid = $_smarty_tpl->decodeProperties(array ( 'function' => array ( ), + 'version' => 'Smarty-3.1.21-dev', + 'unifunc' => 'content_54b6e51b158d19_68572085', 'variables' => array ( 'haveMember' => 0, @@ -23,8 +25,6 @@ $_valid = $_smarty_tpl->decodeProperties(array ( 'member' => 0, ), 'has_nocache_code' => false, - 'version' => 'Smarty-3.1.21-dev', - 'unifunc' => 'content_54b6e51b158d19_68572085', ),false); /*/%%SmartyHeaderCode%%*/?> getSubTemplate ('admin/member/header.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?> @@ -38,8 +38,15 @@ $_valid = $_smarty_tpl->decodeProperties(array (
- + + tpl_vars['haveMember']->value) {?> + + + + + @@ -73,6 +80,15 @@ $_valid = $_smarty_tpl->decodeProperties(array (

+ + + +
tpl_vars['member']->value['fieldRequired']['name']) {?>class="glm-required">Member Name:
tpl_vars['member']->value['fieldRequired']['short_descr']) {?>class="glm-required">Short Description:tpl_vars['member']->value['fieldFail']['short_descr']) {?>class="glm-form-bad-input"> + + tpl_vars['member']->value['fieldFail']['short_descr']) {?>

tpl_vars['member']->value['fieldFail']['short_descr'];?> +

+
diff --git a/misc/smarty/templates_c/50e78f1400d6db96c588c737669426ab57397d1d.file.footer.html.php b/misc/smarty/templates_c/50e78f1400d6db96c588c737669426ab57397d1d.file.footer.html.php index 542893a0..c174039c 100644 --- a/misc/smarty/templates_c/50e78f1400d6db96c588c737669426ab57397d1d.file.footer.html.php +++ b/misc/smarty/templates_c/50e78f1400d6db96c588c737669426ab57397d1d.file.footer.html.php @@ -1,4 +1,4 @@ - decodeProperties(array ( @@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( '50e78f1400d6db96c588c737669426ab57397d1d' => array ( 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/footer.html', - 1 => 1421268442, + 1 => 1421287062, 2 => 'file', ), ), @@ -34,6 +34,7 @@ $_valid = $_smarty_tpl->decodeProperties(array (
Copyright © 2014-tpl_vars['thisYear']->value;?> Gaslight Media - All Rights Reserved
+ Phone: 231-487-0692 - E-Mail: info@gaslightmedia.com
http://www.gaslightmedia.com diff --git a/misc/smarty/templates_c/60cbe99d19bbec013cbca4d9344f2fd4a4152f52.file.index.html.php b/misc/smarty/templates_c/60cbe99d19bbec013cbca4d9344f2fd4a4152f52.file.index.html.php index cf9e3a2a..cc82045a 100644 --- a/misc/smarty/templates_c/60cbe99d19bbec013cbca4d9344f2fd4a4152f52.file.index.html.php +++ b/misc/smarty/templates_c/60cbe99d19bbec013cbca4d9344f2fd4a4152f52.file.index.html.php @@ -1,4 +1,4 @@ - decodeProperties(array ( @@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array ( '60cbe99d19bbec013cbca4d9344f2fd4a4152f52' => array ( 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/error/index.html', - 1 => 1421264555, + 1 => 1421285131, 2 => 'file', ), ), @@ -17,24 +17,20 @@ $_valid = $_smarty_tpl->decodeProperties(array ( ), 'version' => 'Smarty-3.1.21-dev', 'unifunc' => 'content_54b42e9eafe502_03625329', - 'variables' => - array ( - 'errorMsg' => 0, - ), 'has_nocache_code' => false, ),false); /*/%%SmartyHeaderCode%%*/?> -
+getSubTemplate ('admin/error/header.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?> + -

Sorry, we've had an error.

+
- tpl_vars['errorMsg']->value) {?> -

tpl_vars['errorMsg']->value;?> -

- -

Error: : Unknown error.

- +

Sorry, we've had some type of fatal error.

+ +

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

+ +
+ +getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?> + -

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

- -
diff --git a/misc/smarty/templates_c/6b21e44674b437b1c7d4844f49a7ab41316a5694.file.header.html.php b/misc/smarty/templates_c/6b21e44674b437b1c7d4844f49a7ab41316a5694.file.header.html.php new file mode 100644 index 00000000..7c7cc483 --- /dev/null +++ b/misc/smarty/templates_c/6b21e44674b437b1c7d4844f49a7ab41316a5694.file.header.html.php @@ -0,0 +1,31 @@ + +decodeProperties(array ( + 'file_dependency' => + array ( + '6b21e44674b437b1c7d4844f49a7ab41316a5694' => + array ( + 0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/error/header.html', + 1 => 1421285180, + 2 => 'file', + ), + ), + 'nocache_hash' => '112530116454b716e1691b91-32861276', + 'function' => + array ( + ), + 'version' => 'Smarty-3.1.21-dev', + 'unifunc' => 'content_54b716e1693c97_05571152', + 'variables' => + array ( + 'glmPluginName' => 0, + ), + 'has_nocache_code' => false, +),false); /*/%%SmartyHeaderCode%%*/?> +
+ +

tpl_vars['glmPluginName']->value;?> +

+ + diff --git a/models/admin/configure/index.php b/models/admin/configure/index.php index d454a197..99139bc3 100644 --- a/models/admin/configure/index.php +++ b/models/admin/configure/index.php @@ -90,7 +90,7 @@ class GlmMembersAdmin_configure_index * produce output. * */ - public function modelAction () + public function modelAction ($redirectData = false) { // Determine if current user can add, edit, delete member data diff --git a/models/admin/error/badAction.php b/models/admin/error/badAction.php index 5c42a95e..2868efaa 100644 --- a/models/admin/error/badAction.php +++ b/models/admin/error/badAction.php @@ -54,9 +54,15 @@ class glmMembersAdmin_error_badAction * * @return array Array containing status, suggested view, and any data */ - public function __construct ($wpdb) + public function __construct ($wpdb, $config) { + + // Save WordPress Database object $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; + } /* @@ -93,7 +99,7 @@ class glmMembersAdmin_error_badAction * produce output. * */ - public function modelAction () + public function modelAction ($redirectData = false) { // No work to perform here so just return status diff --git a/models/admin/error/index.php b/models/admin/error/index.php index eff0d570..38ca2cfc 100644 --- a/models/admin/error/index.php +++ b/models/admin/error/index.php @@ -54,13 +54,18 @@ class GlmMembersAdmin_error_index * * @return array Array containing status, suggested view, and any data */ - public function __construct ($wpdb) + public function __construct ($wpdb, $config) { - // No work to perform here so just return status + + // Save WordPress Database object + $this->wpdb = $wpdb; + + // Save plugin configuration object + $this->config = $config; } - public function modelAction() { + public function modelAction($redirectData = false) { // Return status, any suggested view, and any data to controller return array( diff --git a/models/admin/member/index.php b/models/admin/member/index.php index 76c4f222..44c5de6c 100644 --- a/models/admin/member/index.php +++ b/models/admin/member/index.php @@ -96,7 +96,7 @@ class GlmMembersAdmin_member_index extends GlmDataMembers * produce output. * */ - public function modelAction () + public function modelAction ($redirectData = false) { $success = true; @@ -104,8 +104,13 @@ class GlmMembersAdmin_member_index extends GlmDataMembers $memberData = false; $memberID = 0; - // Check if a member ID is supplied - if (isset($_REQUEST['member_id'])) { + // Check if a redirecting model supplied the member ID + if (isset($redirectData['memberID'])) { + + $memberID = $redirectData['memberID']; + + // Otherwise check if one was supplied by the user + } elseif (isset($_REQUEST['member_id'])) { // Make sure it's a number $memberID = $_REQUEST['member_id']-0; } diff --git a/models/admin/member/member.php b/models/admin/member/member.php index 04f33bc7..16a88076 100644 --- a/models/admin/member/member.php +++ b/models/admin/member/member.php @@ -96,13 +96,14 @@ class GlmMembersAdmin_member_member extends GlmDataMembers * produce output. * */ - public function modelAction () + public function modelAction ($redirectData = false) { $success = true; $haveMember = false; $memberData = false; $memberID = 0; + $error = false; // Check if a member ID is supplied if (isset($_REQUEST['member_id'])) { @@ -110,25 +111,123 @@ class GlmMembersAdmin_member_member extends GlmDataMembers $memberID = $_REQUEST['member_id']-0; } - if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { - glmMembersAdmin::addNotice("  Member ID specified: $memberID"); + // Check for action option + $option = false; + if (isset($_REQUEST['option']) && trim($_REQUEST['option']) != '') { + $option = $_REQUEST['option']; } - // If we have a member ID, try to get the member data - if ($memberID > 0) { - $memberData = $this->editEntry($memberID); - } + // Perform requested option + switch ($option) { + + case 'addNew': + + // Insert the new member into the database + $memberData = $this->insertEntry(); + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { + glmMembersAdmin::addNotice('
'.print_r($memberData,1).'
', 'New Member Data'); + } + + if ($memberData['status']) { + return array( + 'status' => $success, + 'menuItemRedirect' => 'member', + 'modelRedirect' => 'index', + 'view' => 'admin/member/index.html', + 'data' => array( + 'memberID' => $memberData['fieldData']['id'] + ) + ); + } + + break; + + case 'submit': + + // If we have a member ID + if ($memberID > 0) { + + $haveMember = true; + + // Update the member data + $memberData = $this->updateEntry($memberID); + + // If the update went well, then redirect to the member status page + if ($memberData['status']) { + return array( + 'status' => $success, + 'menuItemRedirect' => 'member', + 'modelRedirect' => 'index', + 'view' => 'admin/member/index.html', + 'data' => array( + 'memberID' => $memberID + ) + ); + } else { + + + } + + // Else if there's no member ID, then we have a problem + } else { + $error = true; + } + + break; + + default: + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + glmMembersAdmin::addNotice("  Member ID specified: $memberID"); + } + + // If we have a member ID, try to get the member data + if ($memberID > 0) { + + // Edit the existing member + $memberData = $this->editEntry($memberID); + + // If we have member data, say so + if (is_array($memberData) && $memberData['status']) { + $haveMember = true; + + } else { + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) { + glmMembersAdmin::addNotice("  Specified Member ID is invalid: $memberID"); + } + + $error = true; + + } + + // Else if there's no member ID, assume entering a new member + } else { + + // Ask for new member data + $memberData = $this->newEntry(); + + } + + break; - // If we have member data, say so - if ($memberData !== false) { - $haveMember = true; - // Otherwise, we're going setup to enter a new one - } else { - $memberData = $this->newEntry(); } + // If we had a fatal error, redirect to the error page + if ($error) { + return array( + 'status' => $success, + 'menuItemRedirect' => 'error', + 'modelRedirect' => 'index', + 'view' => 'admin/error/index.html', + 'data' => false + ); + } + + if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) { glmMembersAdmin::addNotice("
".print_r($memberData,1)."
", 'Member Data'); } diff --git a/models/admin/members/index.php b/models/admin/members/index.php index c27ea00b..add413d7 100644 --- a/models/admin/members/index.php +++ b/models/admin/members/index.php @@ -96,7 +96,7 @@ class GlmMembersAdmin_members_index extends GlmDataMembers * produce output. * */ - public function modelAction () + public function modelAction ($redirectData = false) { $success = true; diff --git a/models/admin/members/list.php b/models/admin/members/list.php index 82495e0a..c9bbaa56 100644 --- a/models/admin/members/list.php +++ b/models/admin/members/list.php @@ -96,7 +96,7 @@ class GlmMembersAdmin_members_list extends GlmDataMembers * produce output. * */ - public function modelAction () + public function modelAction ($redirectData = false) { // Get a current list of members diff --git a/views/admin/error/badAction.html b/views/admin/error/badAction.html index 4c84eedf..a2035865 100644 --- a/views/admin/error/badAction.html +++ b/views/admin/error/badAction.html @@ -1,4 +1,4 @@ -
+{include file='admin/error/header.html'}

Sorry, we've had an error.

@@ -8,4 +8,4 @@

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

-
+{include file='admin/footer.html'} diff --git a/views/admin/error/header.html b/views/admin/error/header.html new file mode 100644 index 00000000..f9fdb916 --- /dev/null +++ b/views/admin/error/header.html @@ -0,0 +1,5 @@ +
+ +

{$glmPluginName}

+ + \ No newline at end of file diff --git a/views/admin/error/index.html b/views/admin/error/index.html index c8ede523..02945e34 100644 --- a/views/admin/error/index.html +++ b/views/admin/error/index.html @@ -1,13 +1,12 @@ -
+{include file='admin/error/header.html'} -

Sorry, we've had an error.

+
- {if $errorMsg} -

{$errorMsg}

- {else} -

Error: : Unknown error.

- {/if} +

Sorry, we've had some type of fatal error.

+ +

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

+ +
+ +{include file='admin/footer.html'} -

Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.

- -
diff --git a/views/admin/footer.html b/views/admin/footer.html index 1fc38bbe..5b06a432 100644 --- a/views/admin/footer.html +++ b/views/admin/footer.html @@ -3,6 +3,7 @@ diff --git a/views/admin/member/index.html b/views/admin/member/index.html index f3031181..b4e08b0c 100644 --- a/views/admin/member/index.html +++ b/views/admin/member/index.html @@ -1,9 +1,17 @@ {include file='admin/member/header.html'}

{$member.name}

- - + {if $member.active.value} +

This member is active.

+ {else} +

Member Not Active

+ {/if} + +
Member Name:{$member.name}
+ + +
Member Name:{$member.name}
Description:{$member.descr}
Short Description:{$member.short_descr}
{include file='admin/footer.html'} diff --git a/views/admin/member/member.html b/views/admin/member/member.html index 06fa920e..337a09a5 100644 --- a/views/admin/member/member.html +++ b/views/admin/member/member.html @@ -7,8 +7,14 @@ {/if} - + + {if $haveMember} + + {else} + + {/if} + @@ -37,6 +43,13 @@ {if $member.fieldFail.descr}

{$member.fieldFail.descr}

{/if} + + + +
Member Name:
Short Description: + + {if $member.fieldFail.short_descr}

{$member.fieldFail.short_descr}

{/if} +
diff --git a/views/admin/members/index.html b/views/admin/members/index.html index 650507d5..b8de5a44 100644 --- a/views/admin/members/index.html +++ b/views/admin/members/index.html @@ -2,11 +2,15 @@

Members Dashboard

-

Status and notices go here

+{if $numbMembers == 0} +

+ You do not currently have any members listed. + Click here to create your first member. +

+{/if} -
Number of Members Listed: {$numbMembers}
{include file='admin/footer.html'}