Minor modifications to tabs.
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 15 Jan 2015 00:33:44 +0000 (19:33 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 15 Jan 2015 00:33:44 +0000 (19:33 -0500)
controllers/admin.php
index.php
lib/GlmDataAbstract/DataAbstract.php
misc/smarty/templates_c/081a36d97cdf30d438a1e104c26a275acc180da0.file.index.html.php
misc/smarty/templates_c/15f83071407dddb0b3c23ae1a70b66cefbd681db.file.header.html.php
misc/smarty/templates_c/4c287ca0e4946b3d644e61950c851e98e8906d49.file.list.html.php [new file with mode: 0644]
models/admin/members/index.php
models/admin/members/list.php [new file with mode: 0644]
views/admin/members/header.html
views/admin/members/index.html
views/admin/members/list.html [new file with mode: 0644]

index 5f3f4f0..706f18f 100644 (file)
@@ -28,6 +28,7 @@ $GLOBALS['glmMembersAdminValidActions'] = array(
 
         'members' => array(
                 'index', // member list
+                'list',
                 'reports',
                 'other'
         ),
index 3d6ded5..4bfcf0e 100644 (file)
--- a/index.php
+++ b/index.php
@@ -48,7 +48,7 @@
 
 // Debug Options
 define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG', true);
-define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', false);
+define('GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE', true);
 
 // Plugin Versions
 define('GLM_MEMBERS_PLUGIN_VERSION', 0.1);
index 9412e28..678284a 100755 (executable)
@@ -2536,7 +2536,7 @@ abstract class GlmDataAbstract
      */
     public function getStats($where = 'true')
     {
-        $sql = "SELECT count(DISTINCT id)
+        $sql = "SELECT count(DISTINCT id) as count
                   FROM $this->table
                  WHERE $where;";
 
@@ -2544,7 +2544,7 @@ abstract class GlmDataAbstract
             glmMembersAdmin::addNotice("<pre>".print_r($sql,1)."</pre>", "DataAbstract - getStats() query");
         }
 
-        $stats = $this->wpdb->get_results($sql, ARRAY_A);
+        $stats = $this->wpdb->get_row($sql, ARRAY_A);
 
         return $stats['count'];
 
index 23b62f9..95bcae6 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-14 18:10:53
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-15 00:32:22
          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 => 1421259050,
+      1 => 1421281939,
       2 => 'file',
     ),
   ),
@@ -19,62 +19,23 @@ $_valid = $_smarty_tpl->decodeProperties(array (
   'unifunc' => 'content_54b42f25390269_82355360',
   'variables' => 
   array (
-    'haveMembers' => 0,
-    'members' => 0,
-    'i' => 0,
-    'thisURL' => 0,
-    'm' => 0,
+    'numbMembers' => 0,
   ),
   'has_nocache_code' => false,
 ),false); /*/%%SmartyHeaderCode%%*/?>
 <?php if ($_valid && !is_callable('content_54b42f25390269_82355360')) {function content_54b42f25390269_82355360($_smarty_tpl) {?><?php echo $_smarty_tpl->getSubTemplate ('admin/members/header.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
 
     
-    <h2>List of Members</h2>
+    <h2>Members Dashboard</h2>
+    
+    <p>Status and notices go here</p>
+    
+    <table>
+        <tr><th>Number of Members Listed: </th><td><?php echo $_smarty_tpl->tpl_vars['numbMembers']->value;?>
+</td></tr>
     
-    <table class="wp-list-table widefat fixed posts">
-        <thead>
-            <tr>
-                <th>Member Name</th>
-                <th>&nbsp;</th>
-            </tr>
-        </thead>
-        <tfoot>
-            <tr>
-                <th>Member Name</th>
-                <th>&nbsp;</th>
-            </tr>
-        </tfoot>
-        <tbody>
-<?php if ($_smarty_tpl->tpl_vars['haveMembers']->value) {?>
-    <?php $_smarty_tpl->tpl_vars["i"] = new Smarty_variable("0", null, 0);?>
-    <?php  $_smarty_tpl->tpl_vars['m'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['m']->_loop = false;
- $_from = $_smarty_tpl->tpl_vars['members']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
-foreach ($_from as $_smarty_tpl->tpl_vars['m']->key => $_smarty_tpl->tpl_vars['m']->value) {
-$_smarty_tpl->tpl_vars['m']->_loop = true;
-?>
-        <?php if ((1 & $_smarty_tpl->tpl_vars['i']->value++ / 1)) {?> 
-            <tr>
-        <?php } else { ?>
-            <tr class="alternate">
-        <?php }?>
-                <td>
-                    <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
-?page=glm-members-admin-menu-member&glm_action=index&member_id=<?php echo $_smarty_tpl->tpl_vars['m']->value['id'];?>
-"><?php echo $_smarty_tpl->tpl_vars['m']->value['name'];?>
-</a>
-                </td>
-                <td>
-                    (nothing here yet)
-                </td>
-            </tr>
-    <?php } ?>
-<?php } else { ?>
-            <tr class="alternate"><td colspan="2">(no members listed)</td></tr>
-<?php }?>
-        </tbody>
     </table>
-
+    
 <?php echo $_smarty_tpl->getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
 
 <?php }} ?>
index a4c3b87..76a1638 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-14 21:33:37
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-15 00:18:04
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/header.html" */ ?>
 <?php /*%%SmartyHeaderCode:81165772654b46f32298020-09293550%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->decodeProperties(array (
@@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array (
     '15f83071407dddb0b3c23ae1a70b66cefbd681db' => 
     array (
       0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/header.html',
-      1 => 1421271213,
+      1 => 1421281076,
       2 => 'file',
     ),
   ),
@@ -30,13 +30,16 @@ $_valid = $_smarty_tpl->decodeProperties(array (
     <h2 class="nav-tab-wrapper">
         <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
 ?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
-&glm_action=index" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='index') {?>-active<?php }?>">List of Members</a>
+&glm_action=index" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='index') {?>-active<?php }?>">Dashboard</a>
         <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
 ?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
-&glm_action=reports" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='add') {?>-active<?php }?>">Reports</a>
+&glm_action=list" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='list') {?>-active<?php }?>">List of Members</a>
         <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
 ?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
-&glm_action=other" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='edit') {?>-active<?php } else { ?> disabled<?php }?>">Or Something - perahps mailing stuff?</a>
+&glm_action=index" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='add') {?>-active<?php }?>">Reports</a>
+        <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
+?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
+&glm_action=index" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='edit') {?>-active<?php } else { ?> disabled<?php }?>">Or Something - perahps mailing stuff?</a>
     </h2>
     <div id="glm-admin-content-container">
     <?php }} ?>
diff --git a/misc/smarty/templates_c/4c287ca0e4946b3d644e61950c851e98e8906d49.file.list.html.php b/misc/smarty/templates_c/4c287ca0e4946b3d644e61950c851e98e8906d49.file.list.html.php
new file mode 100644 (file)
index 0000000..3ac806c
--- /dev/null
@@ -0,0 +1,80 @@
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-15 00:17:02
+         compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/list.html" */ ?>
+<?php /*%%SmartyHeaderCode:46596749754b706fe3a62d3-72547374%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
+$_valid = $_smarty_tpl->decodeProperties(array (
+  'file_dependency' => 
+  array (
+    '4c287ca0e4946b3d644e61950c851e98e8906d49' => 
+    array (
+      0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/members/list.html',
+      1 => 1421259050,
+      2 => 'file',
+    ),
+  ),
+  'nocache_hash' => '46596749754b706fe3a62d3-72547374',
+  'function' => 
+  array (
+  ),
+  'variables' => 
+  array (
+    'haveMembers' => 0,
+    'members' => 0,
+    'i' => 0,
+    'thisURL' => 0,
+    'm' => 0,
+  ),
+  'has_nocache_code' => false,
+  'version' => 'Smarty-3.1.21-dev',
+  'unifunc' => 'content_54b706fe3c2516_38940524',
+),false); /*/%%SmartyHeaderCode%%*/?>
+<?php if ($_valid && !is_callable('content_54b706fe3c2516_38940524')) {function content_54b706fe3c2516_38940524($_smarty_tpl) {?><?php echo $_smarty_tpl->getSubTemplate ('admin/members/header.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
+
+    
+    <h2>List of Members</h2>
+    
+    <table class="wp-list-table widefat fixed posts">
+        <thead>
+            <tr>
+                <th>Member Name</th>
+                <th>&nbsp;</th>
+            </tr>
+        </thead>
+        <tfoot>
+            <tr>
+                <th>Member Name</th>
+                <th>&nbsp;</th>
+            </tr>
+        </tfoot>
+        <tbody>
+<?php if ($_smarty_tpl->tpl_vars['haveMembers']->value) {?>
+    <?php $_smarty_tpl->tpl_vars["i"] = new Smarty_variable("0", null, 0);?>
+    <?php  $_smarty_tpl->tpl_vars['m'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['m']->_loop = false;
+ $_from = $_smarty_tpl->tpl_vars['members']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
+foreach ($_from as $_smarty_tpl->tpl_vars['m']->key => $_smarty_tpl->tpl_vars['m']->value) {
+$_smarty_tpl->tpl_vars['m']->_loop = true;
+?>
+        <?php if ((1 & $_smarty_tpl->tpl_vars['i']->value++ / 1)) {?> 
+            <tr>
+        <?php } else { ?>
+            <tr class="alternate">
+        <?php }?>
+                <td>
+                    <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
+?page=glm-members-admin-menu-member&glm_action=index&member_id=<?php echo $_smarty_tpl->tpl_vars['m']->value['id'];?>
+"><?php echo $_smarty_tpl->tpl_vars['m']->value['name'];?>
+</a>
+                </td>
+                <td>
+                    (nothing here yet)
+                </td>
+            </tr>
+    <?php } ?>
+<?php } else { ?>
+            <tr class="alternate"><td colspan="2">(no members listed)</td></tr>
+<?php }?>
+        </tbody>
+    </table>
+
+<?php echo $_smarty_tpl->getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
+
+<?php }} ?>
index c7718f9..c27ea00 100644 (file)
@@ -2,7 +2,7 @@
 
 /**
  * Gaslight Media Members Database
- * Admin List Members
+ * Admin Members Dashboard
  *
  * PHP version 5.5
  *
@@ -98,10 +98,12 @@ class GlmMembersAdmin_members_index extends GlmDataMembers
      */
     public function modelAction ()
     {
+        $success = true;
 
         // Get a current list of members
-        $list = $this->getList();
+        $stats = $this->getStats();
 
+/*
         if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
             glmMembersAdmin::addNotice("<pre>".print_r($list,1)."</pre>", 'Member Data');
         }
@@ -121,12 +123,11 @@ class GlmMembersAdmin_members_index extends GlmDataMembers
 
         // Determine if current user can add, edit, delete member data
         $canEdit = current_user_can('glm_members_edit');
+*/
 
         // Compile template data
         $templateData = array(
-            'haveMembers' => $haveMembers,
-            'members' => $list,
-            'canEdit' => $canEdit
+            'numbMembers' => $stats
         );
 
         // Return status, suggested view, and data to controller
diff --git a/models/admin/members/list.php b/models/admin/members/list.php
new file mode 100644 (file)
index 0000000..82495e0
--- /dev/null
@@ -0,0 +1,146 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin List Members
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+// Load Members data abstract
+require_once(GLM_MEMBERS_PLUGIN_CLASS_DIR.'/data/dataMembers.php');
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersAdmin_members_list extends GlmDataMembers
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /*
+     * Constructor
+     *
+     * This contructor sets up this model. At this time that only includes
+     * storing away the WordPress data object.
+     *
+     * @return object Class object
+     *
+     */
+    public function __construct ($wpdb, $config)
+    {
+
+        // Save WordPress Database object
+        $this->wpdb = $wpdb;
+
+        // Save plugin configuration object
+        $this->config = $config;
+
+        // Run constructor for members data class
+        parent::__construct($this->wpdb, $this->config);
+
+    }
+
+    /*
+     * Perform Model Action
+     *
+     * This method does the work for this model and returns any resulting data
+     *
+     * @return array Status and data array
+     *
+     * 'status'
+     *
+     * True if successfull and false if there was a fatal failure.
+     *
+     * 'menuItemRedirect'
+     *
+     * If not false, provides a menu item the controller should
+     * execute after this one. Normally if this is used, there would also be a
+     * modelRedirect value supplied as well.
+     *
+     * 'modelRedirect'
+     *
+     * If not false, provides an action the controller should execute after
+     * this one.
+     *
+     * '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.
+     *
+     */
+    public function modelAction ()
+    {
+
+        // Get a current list of members
+        $list = $this->getList();
+
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+            glmMembersAdmin::addNotice("<pre>".print_r($list,1)."</pre>", 'Member Data');
+        }
+
+        // If we have list entries - even if it's an empty list
+        $success = true;
+        $haveMembers = false;
+        if ($list !== false) {
+
+            $success = true;
+
+            // If we have any entries
+            if (count($list) > 0) {
+                $haveMembers = true;
+            }
+        }
+
+        // Determine if current user can add, edit, delete member data
+        $canEdit = current_user_can('glm_members_edit');
+
+        // Compile template data
+        $templateData = array(
+            'haveMembers' => $haveMembers,
+            'members' => $list,
+            'canEdit' => $canEdit
+        );
+
+        // Return status, suggested view, and data to controller
+        return array(
+            'status' => $success,
+            'menuItemRedirect' => false,
+            'modelRedirect' => false,
+            'view' => 'admin/members/list.html',
+            'data' => $templateData
+        );
+
+    }
+
+
+}
+
+?>
\ No newline at end of file
index eaaccdf..6337c5f 100644 (file)
@@ -1,9 +1,10 @@
 <div class="wrap">
     <h2>Your Members</h2>
     <h2 class="nav-tab-wrapper">
-        <a href="{$thisURL}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index}-active{/if}">List of Members</a>
-        <a href="{$thisURL}?page={$thisPage}&glm_action=reports" class="nav-tab{if $thisAction==add}-active{/if}">Reports</a>
-        <a href="{$thisURL}?page={$thisPage}&glm_action=other" class="nav-tab{if $thisAction==edit}-active{else} disabled{/if}">Or Something - perahps mailing stuff?</a>
+        <a href="{$thisURL}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index}-active{/if}">Dashboard</a>
+        <a href="{$thisURL}?page={$thisPage}&glm_action=list" class="nav-tab{if $thisAction==list}-active{/if}">List of Members</a>
+        <a href="{$thisURL}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==add}-active{/if}">Reports</a>
+        <a href="{$thisURL}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==edit}-active{else} disabled{/if}">Or Something - perahps mailing stuff?</a>
     </h2>
     <div id="glm-admin-content-container">
     
\ No newline at end of file
index 941e6f0..650507d 100644 (file)
@@ -1,41 +1,12 @@
 {include file='admin/members/header.html'}
     
-    <h2>List of Members</h2>
+    <h2>Members Dashboard</h2>
+    
+    <p>Status and notices go here</p>
+    
+    <table>
+        <tr><th>Number of Members Listed: </th><td>{$numbMembers}</td></tr>
     
-    <table class="wp-list-table widefat fixed posts">
-        <thead>
-            <tr>
-                <th>Member Name</th>
-                <th>&nbsp;</th>
-            </tr>
-        </thead>
-        <tfoot>
-            <tr>
-                <th>Member Name</th>
-                <th>&nbsp;</th>
-            </tr>
-        </tfoot>
-        <tbody>
-{if $haveMembers}
-    {assign var="i" value="0"}
-    {foreach $members as $m}
-        {if $i++ is odd by 1} 
-            <tr>
-        {else}
-            <tr class="alternate">
-        {/if}
-                <td>
-                    <a href="{$thisURL}?page=glm-members-admin-menu-member&glm_action=index&member_id={$m.id}">{$m.name}</a>
-                </td>
-                <td>
-                    (nothing here yet)
-                </td>
-            </tr>
-    {/foreach}
-{else}
-            <tr class="alternate"><td colspan="2">(no members listed)</td></tr>
-{/if}
-        </tbody>
     </table>
-
+    
 {include file='admin/footer.html'}
diff --git a/views/admin/members/list.html b/views/admin/members/list.html
new file mode 100644 (file)
index 0000000..941e6f0
--- /dev/null
@@ -0,0 +1,41 @@
+{include file='admin/members/header.html'}
+    
+    <h2>List of Members</h2>
+    
+    <table class="wp-list-table widefat fixed posts">
+        <thead>
+            <tr>
+                <th>Member Name</th>
+                <th>&nbsp;</th>
+            </tr>
+        </thead>
+        <tfoot>
+            <tr>
+                <th>Member Name</th>
+                <th>&nbsp;</th>
+            </tr>
+        </tfoot>
+        <tbody>
+{if $haveMembers}
+    {assign var="i" value="0"}
+    {foreach $members as $m}
+        {if $i++ is odd by 1} 
+            <tr>
+        {else}
+            <tr class="alternate">
+        {/if}
+                <td>
+                    <a href="{$thisURL}?page=glm-members-admin-menu-member&glm_action=index&member_id={$m.id}">{$m.name}</a>
+                </td>
+                <td>
+                    (nothing here yet)
+                </td>
+            </tr>
+    {/foreach}
+{else}
+            <tr class="alternate"><td colspan="2">(no members listed)</td></tr>
+{/if}
+        </tbody>
+    </table>
+
+{include file='admin/footer.html'}