Now have member additions working pretty well.
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 15 Jan 2015 04:02:18 +0000 (23:02 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 15 Jan 2015 04:02:18 +0000 (23:02 -0500)
26 files changed:
classes/data/dataMembers.php
controllers/admin.php
css/admin.css
lib/GlmDataAbstract/DataAbstract.php
lib/GlmDataAbstract/documentation.txt
misc/smarty/templates_c/06926788f51c1a5a54be2a368556f9c37e2780da.file.badAction.html.php
misc/smarty/templates_c/081a36d97cdf30d438a1e104c26a275acc180da0.file.index.html.php
misc/smarty/templates_c/1be35689c5d30d774f40ebc45e387f5f95c45e90.file.index.html.php
misc/smarty/templates_c/25c8610e0e0bacafec3046a296066e9f8eceedae.file.member.html.php
misc/smarty/templates_c/50e78f1400d6db96c588c737669426ab57397d1d.file.footer.html.php
misc/smarty/templates_c/60cbe99d19bbec013cbca4d9344f2fd4a4152f52.file.index.html.php
misc/smarty/templates_c/6b21e44674b437b1c7d4844f49a7ab41316a5694.file.header.html.php [new file with mode: 0644]
models/admin/configure/index.php
models/admin/error/badAction.php
models/admin/error/index.php
models/admin/member/index.php
models/admin/member/member.php
models/admin/members/index.php
models/admin/members/list.php
views/admin/error/badAction.html
views/admin/error/header.html [new file with mode: 0644]
views/admin/error/index.html
views/admin/footer.html
views/admin/member/index.html
views/admin/member/member.html
views/admin/members/index.html

index a201d43..2ccb33e 100644 (file)
@@ -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
index 706f18f..34c1664 100644 (file)
@@ -353,6 +353,10 @@ class glmMembersAdmin extends GlmPluginSupport
     {
         $errorMsg = '';
 
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+            $this->addNotice("<pre>".print_r($_REQUEST,1)."</pre>", "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;
                     }
 
index 2175f67..4a3ce63 100644 (file)
@@ -7,10 +7,12 @@
 .glm-required {
     color: red !important;
 }
-
 .glm-error {
     color: red;
 }
+.glm-notice {
+    color: red;
+}
 
 .glm-copyright {
     text-align: center;
     width: 90%;
 }
 
+/* Admin table additions */
+.glm-table-fieldname {
+    text-align: left;
+    padding-right: 1em;
+}
+
+
 /* Debug Window */
 #glm-debug-header {
     font-weight: bold;
index 678284a..76e1481 100755 (executable)
@@ -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 "<pre>$sql</pre>";
         $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("<pre>".print_r($sql,1)."</pre>", "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";
                 }
index 01572ff..ea0f0e6 100644 (file)
@@ -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)
index 186d759..8804416 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-14 22:12:00
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-15 02:20:49
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/error/badAction.html" */ ?>
 <?php /*%%SmartyHeaderCode:210264866954b42dd4bbc715-16113482%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->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%%*/?>
-<?php if ($_valid && !is_callable('content_54b42dd4c09430_68496846')) {function content_54b42dd4c09430_68496846($_smarty_tpl) {?><div class="wrap">
+<?php if ($_valid && !is_callable('content_54b42dd4c09430_68496846')) {function content_54b42dd4c09430_68496846($_smarty_tpl) {?><?php echo $_smarty_tpl->getSubTemplate ('admin/error/header.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
+
     
     <h2>Sorry, we've had an error.</h2>
     
@@ -34,5 +35,6 @@ $_valid = $_smarty_tpl->decodeProperties(array (
 
     <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
       
-</div>
+<?php echo $_smarty_tpl->getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
+
 <?php }} ?>
index 95bcae6..6f74ae1 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-15 00:32:22
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-15 02:22:28
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/index.html" */ ?>
 <?php /*%%SmartyHeaderCode:206413157254b42f2535e168-27938613%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->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 (
     
     <h2>Members Dashboard</h2>
     
-    <p>Status and notices go here</p>
+<?php if ($_smarty_tpl->tpl_vars['numbMembers']->value==0) {?>
+        <p>
+            <span class="glm-error">You do not currently have any members listed.</span>
+            <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
+?page=glm-members-admin-menu-member&glm_action=member&member_id=">Click here to create your first member.</a>
+        </p>
+<?php }?>                
     
     <table>
         <tr><th>Number of Members Listed: </th><td><?php echo $_smarty_tpl->tpl_vars['numbMembers']->value;?>
 </td></tr>
-    
     </table>
     
 <?php echo $_smarty_tpl->getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
index 6986fb3..32d1288 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-14 21:06:49
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-15 03:39:59
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/member/index.html" */ ?>
 <?php /*%%SmartyHeaderCode:163797333154b6ac77c986e8-14104892%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->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 (
 
     <h2><?php echo $_smarty_tpl->tpl_vars['member']->value['name'];?>
 </h2>
-    <table>
-        <tr><th>Member Name:</th><td><?php echo $_smarty_tpl->tpl_vars['member']->value['name'];?>
-</tr>
     
+    <?php if ($_smarty_tpl->tpl_vars['member']->value['active']['value']) {?>
+        <p>This member is active.</p>
+    <?php } else { ?>
+        <h3 class="glm-notice">Member Not Active</h3>
+    <?php }?>
+    
+    <table>
+        <tr><th class="glm-table-fieldname">Member Name:</th><td><?php echo $_smarty_tpl->tpl_vars['member']->value['name'];?>
+</td></tr>
+        <tr><th class="glm-table-fieldname">Description:</th><td><?php echo $_smarty_tpl->tpl_vars['member']->value['descr'];?>
+</td></tr>
+        <tr><th class="glm-table-fieldname">Short Description:</th><td><?php echo $_smarty_tpl->tpl_vars['member']->value['short_descr'];?>
+</td></tr>
     </table>
     
 <?php echo $_smarty_tpl->getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
index cff656f..256b564 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-14 21:52:27
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-15 02:04:44
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/member/member.html" */ ?>
 <?php /*%%SmartyHeaderCode:172471491954b6e51b1368b6-20693769%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->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%%*/?>
 <?php if ($_valid && !is_callable('content_54b6e51b158d19_68572085')) {function content_54b6e51b158d19_68572085($_smarty_tpl) {?><?php echo $_smarty_tpl->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 (
     <form action="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
 ?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
 " method="post" enctype="multipart/form-data">
-        <input type="hidden" name="glm_action" value="add">
+        <input type="hidden" name="glm_action" value="member">
+      <?php if ($_smarty_tpl->tpl_vars['haveMember']->value) {?>
         <input type="hidden" name="option" value="submit">
+        <input type="hidden" name="member_id" value="<?php echo $_smarty_tpl->tpl_vars['member']->value['fieldData']['id'];?>
+">
+      <?php } else { ?>
+        <input type="hidden" name="option" value="addNew">
+      <?php }?>
+        
         <table class="form-table">
             <tr>
                 <th <?php if ($_smarty_tpl->tpl_vars['member']->value['fieldRequired']['name']) {?>class="glm-required"<?php }?>>Member Name:</th>
@@ -73,6 +80,15 @@ $_valid = $_smarty_tpl->decodeProperties(array (
 </p><?php }?>
                 </td>
             </tr>
+            <tr>
+                <th <?php if ($_smarty_tpl->tpl_vars['member']->value['fieldRequired']['short_descr']) {?>class="glm-required"<?php }?>>Short Description:</th>
+                <td <?php if ($_smarty_tpl->tpl_vars['member']->value['fieldFail']['short_descr']) {?>class="glm-form-bad-input"<?php }?>>
+                    <input type="text" name="short_descr" value="<?php echo $_smarty_tpl->tpl_vars['member']->value['fieldData']['short_descr'];?>
+" class="glm-form-text-input">
+                    <?php if ($_smarty_tpl->tpl_vars['member']->value['fieldFail']['short_descr']) {?><p><?php echo $_smarty_tpl->tpl_vars['member']->value['fieldFail']['short_descr'];?>
+</p><?php }?>
+                </td>
+            </tr>
             
             
         </table>
index 542893a..c174039 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-14 20:47:26
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-15 01:57:45
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/footer.html" */ ?>
 <?php /*%%SmartyHeaderCode:146319615854b4cb224487c6-63517443%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->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 (
 <br>
         Copyright &copy; 2014-<?php echo $_smarty_tpl->tpl_vars['thisYear']->value;?>
  Gaslight Media - All Rights Reserved<br>
+        Phone: 231-487-0692 - E-Mail: info@gaslightmedia.com<br>
         <a href="http://www.gaslightmedia.com">http://www.gaslightmedia.com</a>
     </div>
     
index cf9e3a2..cc82045 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-14 19:42:46
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-15 01:25:35
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/error/index.html" */ ?>
 <?php /*%%SmartyHeaderCode:204984570454b42e9eaf47c6-75708563%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->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%%*/?>
-<?php if ($_valid && !is_callable('content_54b42e9eafe502_03625329')) {function content_54b42e9eafe502_03625329($_smarty_tpl) {?><div class="wrap">
+<?php if ($_valid && !is_callable('content_54b42e9eafe502_03625329')) {function content_54b42e9eafe502_03625329($_smarty_tpl) {?><?php echo $_smarty_tpl->getSubTemplate ('admin/error/header.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
+
     
-    <h2>Sorry, we've had an error.</h2>
+    <center>
     
-    <?php if ($_smarty_tpl->tpl_vars['errorMsg']->value) {?>
-        <p><?php echo $_smarty_tpl->tpl_vars['errorMsg']->value;?>
-</p>
-    <?php } else { ?>
-        <p><b>Error: </b>: Unknown error.</p>
-    <?php }?>
+        <h3>Sorry, we've had some type of fatal error.</h3>
+        
+        <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
+          
+    </center>
+    
+<?php echo $_smarty_tpl->getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
+
 
-    <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
-      
-</div>
 <?php }} ?>
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 (file)
index 0000000..7c7cc48
--- /dev/null
@@ -0,0 +1,31 @@
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-15 01:26:23
+         compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/error/header.html" */ ?>
+<?php /*%%SmartyHeaderCode:112530116454b716e1691b91-32861276%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
+$_valid = $_smarty_tpl->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%%*/?>
+<?php if ($_valid && !is_callable('content_54b716e1693c97_05571152')) {function content_54b716e1693c97_05571152($_smarty_tpl) {?><div class="wrap">
+       
+    <h2><?php echo $_smarty_tpl->tpl_vars['glmPluginName']->value;?>
+</h2>
+    
+  <?php }} ?>
index d454a19..99139bc 100644 (file)
@@ -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
index 5c42a95..2868efa 100644 (file)
@@ -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
index eff0d57..38ca2cf 100644 (file)
@@ -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(
index 76c4f22..44c5de6 100644 (file)
@@ -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;
         }
index 04f33bc..16a8807 100644 (file)
@@ -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("<b>&nbsp;&nbsp;Member ID specified:</b> $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('<pre>'.print_r($memberData,1).'</pre>', '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("<b>&nbsp;&nbsp;Member ID specified:</b> $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("<b>&nbsp;&nbsp;Specified Member ID is invalid:</b> $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("<pre>".print_r($memberData,1)."</pre>", 'Member Data');
         }
index c27ea00..add413d 100644 (file)
@@ -96,7 +96,7 @@ class GlmMembersAdmin_members_index extends GlmDataMembers
      * produce output.
      *
      */
-    public function modelAction ()
+    public function modelAction ($redirectData = false)
     {
         $success = true;
 
index 82495e0..c9bbaa5 100644 (file)
@@ -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
index 4c84eed..a203586 100644 (file)
@@ -1,4 +1,4 @@
-<div class="wrap">
+{include file='admin/error/header.html'}
     
     <h2>Sorry, we've had an error.</h2>
     
@@ -8,4 +8,4 @@
 
     <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
       
-</div>
+{include file='admin/footer.html'}
diff --git a/views/admin/error/header.html b/views/admin/error/header.html
new file mode 100644 (file)
index 0000000..f9fdb91
--- /dev/null
@@ -0,0 +1,5 @@
+<div class="wrap">
+       
+    <h2>{$glmPluginName}</h2>
+    
+  
\ No newline at end of file
index c8ede52..02945e3 100644 (file)
@@ -1,13 +1,12 @@
-<div class="wrap">
+{include file='admin/error/header.html'}
     
-    <h2>Sorry, we've had an error.</h2>
+    <center>
     
-    {if $errorMsg}
-        <p>{$errorMsg}</p>
-    {else}
-        <p><b>Error: </b>: Unknown error.</p>
-    {/if}
+        <h3>Sorry, we've had some type of fatal error.</h3>
+        
+        <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
+          
+    </center>
+    
+{include file='admin/footer.html'}
 
-    <p>Please try again. If you still get the same error, contact Gaslight Media at 231-487-0692 for assistance.</p>
-      
-</div>
index 1fc38bb..5b06a43 100644 (file)
@@ -3,6 +3,7 @@
     <div class="glm-copyright">
         {$glmPluginName}<br>
         Copyright &copy; 2014-{$thisYear} Gaslight Media - All Rights Reserved<br>
+        Phone: 231-487-0692 - E-Mail: info@gaslightmedia.com<br>
         <a href="http://www.gaslightmedia.com">http://www.gaslightmedia.com</a>
     </div>
     
index f303118..b4e08b0 100644 (file)
@@ -1,9 +1,17 @@
 {include file='admin/member/header.html'}
 
     <h2>{$member.name}</h2>
-    <table>
-        <tr><th>Member Name:</th><td>{$member.name}</tr>
     
+    {if $member.active.value}
+        <p>This member is active.</p>
+    {else}
+        <h3 class="glm-notice">Member Not Active</h3>
+    {/if}
+    
+    <table>
+        <tr><th class="glm-table-fieldname">Member Name:</th><td>{$member.name}</td></tr>
+        <tr><th class="glm-table-fieldname">Description:</th><td>{$member.descr}</td></tr>
+        <tr><th class="glm-table-fieldname">Short Description:</th><td>{$member.short_descr}</td></tr>
     </table>
     
 {include file='admin/footer.html'}
index 06fa920..337a09a 100644 (file)
@@ -7,8 +7,14 @@
     {/if}
 
     <form action="{$thisURL}?page={$thisPage}" method="post" enctype="multipart/form-data">
-        <input type="hidden" name="glm_action" value="add">
+        <input type="hidden" name="glm_action" value="member">
+      {if $haveMember}
         <input type="hidden" name="option" value="submit">
+        <input type="hidden" name="member_id" value="{$member.fieldData.id}">
+      {else}
+        <input type="hidden" name="option" value="addNew">
+      {/if}
+        
         <table class="form-table">
             <tr>
                 <th {if $member.fieldRequired.name}class="glm-required"{/if}>Member Name:</th>
                     {if $member.fieldFail.descr}<p>{$member.fieldFail.descr}</p>{/if}
                 </td>
             </tr>
+            <tr>
+                <th {if $member.fieldRequired.short_descr}class="glm-required"{/if}>Short Description:</th>
+                <td {if $member.fieldFail.short_descr}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="short_descr" value="{$member.fieldData.short_descr}" class="glm-form-text-input">
+                    {if $member.fieldFail.short_descr}<p>{$member.fieldFail.short_descr}</p>{/if}
+                </td>
+            </tr>
             
             
         </table>
index 650507d..b8de5a4 100644 (file)
@@ -2,11 +2,15 @@
     
     <h2>Members Dashboard</h2>
     
-    <p>Status and notices go here</p>
+{if $numbMembers == 0}
+        <p>
+            <span class="glm-error">You do not currently have any members listed.</span>
+            <a href="{$thisURL}?page=glm-members-admin-menu-member&glm_action=member&member_id=">Click here to create your first member.</a>
+        </p>
+{/if}                
     
     <table>
         <tr><th>Number of Members Listed: </th><td>{$numbMembers}</td></tr>
-    
     </table>
     
 {include file='admin/footer.html'}