Added test for glm_members_info capability to display dashboard widget. Work in progr...
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 9 Jun 2015 18:00:09 +0000 (14:00 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 9 Jun 2015 18:00:09 +0000 (14:00 -0400)
31 files changed:
classes/data/dataAccommodationTypes.php
classes/data/dataAmenities.php
classes/data/dataCategories.php
classes/data/dataCategoryMemberInfo.php
classes/data/dataCities.php
classes/data/dataMemberInfo.php
classes/data/dataMemberTypes.php
classes/data/dataMembers.php
classes/data/dataRegions.php
classes/data/settings/dataSettingsGeneral.php [new file with mode: 0644]
classes/glmPluginSupport.php
config/plugin.ini
controllers/admin.php
glm-member-db.php
misc/databaseScripts/create_database_V0.1.sql
misc/databaseScripts/drop_database_V0.1.sql
misc/smarty/templates_c/3ec5bcbe581d6335e06bc6c9474f73121a83d59b.file.header.html.php
misc/smarty/templates_c/47fb9b803e7138d215645f3c977b0b1dc2a9e718.file.index.html.php
models/admin/configure/development.php [deleted file]
models/admin/configure/index.php
models/admin/configure/memberTypes.php [deleted file]
models/admin/settings/development.php [new file with mode: 0644]
models/admin/settings/index.php [new file with mode: 0644]
views/admin/configure/development.html [deleted file]
views/admin/configure/header.html
views/admin/configure/index.html
views/admin/configure/memberTypes.html [deleted file]
views/admin/settings/development.html [new file with mode: 0644]
views/admin/settings/header.html [new file with mode: 0644]
views/admin/settings/index.html [new file with mode: 0644]
views/admin/settingsPage/index.html [new file with mode: 0644]

index 9c6f81a..c87ab97 100644 (file)
@@ -24,7 +24,6 @@
  * @license http://www.gaslightmedia.com Gaslightmedia
  *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
- * @link http://www.visitgreatlakesbay.org/
  */
 class GlmDataAccommodationTypes extends GlmDataAbstract
 {
index 4f2ba29..ee49098 100644 (file)
@@ -24,7 +24,6 @@
  * @license http://www.gaslightmedia.com Gaslightmedia
  *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
- * @link http://www.visitgreatlakesbay.org/
  */
 class GlmDataAmenities extends GlmDataAbstract
 {
index dca59b4..5f1062e 100644 (file)
@@ -24,7 +24,6 @@
  * @license http://www.gaslightmedia.com Gaslightmedia
  *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
- * @link http://www.visitgreatlakesbay.org/
  */
 class GlmDataCategories extends GlmDataAbstract
 {
index b2d2547..447d0ee 100644 (file)
@@ -24,7 +24,6 @@
  * @license http://www.gaslightmedia.com Gaslightmedia
  *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
- * @link http://www.visitgreatlakesbay.org/
  */
 class GlmDataCategoryMemberInfo extends GlmDataAbstract
 {
index 8ff0651..35396aa 100644 (file)
@@ -24,7 +24,6 @@
  * @license http://www.gaslightmedia.com Gaslightmedia
  *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
- * @link http://www.visitgreatlakesbay.org/
  */
 class GlmDataCities extends GlmDataAbstract
 {
index 893725c..ced7e2e 100644 (file)
@@ -23,7 +23,6 @@
  * @license http://www.gaslightmedia.com Gaslightmedia
  *          @release SVN: $Id: dataMemberInfo.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
- * @link http://www.visitgreatlakesbay.org/
  */
 class GlmDataMemberInfo extends GlmDataAbstract
 {
index def4de5..92cd797 100644 (file)
@@ -24,7 +24,6 @@
  * @license http://www.gaslightmedia.com Gaslightmedia
  *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
- * @link http://www.visitgreatlakesbay.org/
  */
 class GlmDataMemberTypes extends GlmDataAbstract
 {
index 6929d50..753c572 100644 (file)
@@ -23,7 +23,6 @@
  * @license http://www.gaslightmedia.com Gaslightmedia
  *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
- * @link http://www.visitgreatlakesbay.org/
  */
 class GlmDataMembers extends GlmDataAbstract {
 
index be26b2c..571df30 100644 (file)
@@ -24,7 +24,6 @@
  * @license http://www.gaslightmedia.com Gaslightmedia
  *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
- * @link http://www.visitgreatlakesbay.org/
  */
 class GlmDataRegions extends GlmDataAbstract
 {
diff --git a/classes/data/settings/dataSettingsGeneral.php b/classes/data/settings/dataSettingsGeneral.php
new file mode 100644 (file)
index 0000000..37100b1
--- /dev/null
@@ -0,0 +1,391 @@
+<?php
+
+/**
+ * GLM Member-DB WordPress Plugin
+ * General Settings data class
+ *
+ * PHP version 5.3
+ *
+ * @category Data
+ * @package  GLM Member-DB
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  SVN: $Id: dataSettingsGeneral.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ */
+
+/**
+ * EventManagementDataSettingsGeneral class
+ *
+ * PHP version 5
+ *
+ * @category Data
+ * @package EventManagement
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ *          @release SVN: $Id: dataMembers.php,v 1.0 2011/01/25 19:31:47 cscott
+ *          Exp $
+ */
+class GlmDataSettingsGeneral extends GlmDataAbstract
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Field definitions
+     *
+     * @var $ini
+     * @access public
+     */
+    public $table;
+
+    /**
+     * Field definitions
+     *
+     * 'type' is type of field as defined by the application
+     * text Regular text field
+     * pointer Pointer to an entry in another table
+     * 'filters' is the filter name for a particular filter ID in PHP filter
+     * functions
+     * See PHP filter_id()
+     *
+     * 'use' is when to use the field
+     * l = List
+     * g = Get
+     * n = New
+     * i = Insert
+     * e = Edit
+     * u = Update
+     * d = Delete
+     * a = All
+     *
+     * @var $ini
+     * @access public
+     */
+    public $fields = false;
+
+    /**
+     * Constructor
+     *
+     * @param object $d
+     *            database connection
+     *
+     * @return void
+     * @access public
+     */
+    function __construct ($wpdb, $config)
+    {
+
+        // If this class is not being extended along with existing $wpdb and $config
+           if (!$this->wpdb) {
+
+           // Save WordPress Database object
+           $this->wpdb = $wpdb;
+
+           // Save plugin configuration object
+           $this->config = $config;
+
+           }
+
+        /*
+         * Table Name
+         */
+        $this->table = GLM_MEMBERS_PLUGIN_DB_PREFIX . 'settings_general';
+
+        /*
+         * Table Data Fields
+         */
+        $this->fields = array(
+
+                'id' => array(
+                        'field' => 'id',
+                        'type' => 'integer',
+                        'view_only' => true,
+                        'use' => 'a'
+                ),
+
+                /*
+                 * Debug Options
+                 */
+
+                // Adming Debug
+                'admin_debug' => array(
+                        'field' => 'admin_debug',
+                        'type' => 'boolean',
+                        'use' => 'a'
+                ),
+
+                // Adming Debug Verbose
+                'admin_debug_verbose' => array(
+                        'field' => 'admin_debug_verbose',
+                        'type' => 'boolean',
+                        'use' => 'a'
+                ),
+
+                // Front-end Debug
+                'front_debug' => array(
+                        'field' => 'front_debug',
+                        'type' => 'boolean',
+                        'use' => 'a'
+                ),
+
+                // Front-end Debug Verbose
+                'front_debug_verbose' => array(
+                        'field' => 'front_debug_verbose',
+                        'type' => 'checkbox',
+                        'use' => 'a'
+                ),
+
+                /*
+                 * Google Maps
+                 */
+
+                // Google Maps API Key
+                'google_maps_api_key' => array(
+                        'field' => 'google_maps_api_key',
+                        'type' => 'text',
+                        'use' => 'lg'
+                ),
+
+                // Google Maps Default Latitude
+                'maps_default_lat' => array(
+                        'field'    => 'maps_default_lat',
+                        'type'     => 'float',
+                        'use'      => 'a'
+                ),
+
+                // Google Maps Default Longitude
+                'maps_default_lon' => array(
+                        'field'    => 'maps_default_lon',
+                        'type'     => 'float',
+                        'use'      => 'a'
+                ),
+
+                /*
+                 * Misc Settings
+                 */
+
+                // Time Zone
+                'time_zone' => array(
+                        'field' => 'time_zone',
+                        'type' => 'text',
+                        'use' => 'lg'
+                ),
+
+                /*
+                 * Front-end Member Search Options
+                 */
+
+                // Front-end Listings - Show Map
+                'list_show_map' => array(
+                        'field' => 'list_show_map',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show List
+                'list_show_list' => array(
+                        'field' => 'list_show_list',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Search Form
+                'list_show_search' => array(
+                        'field' => 'list_show_search',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Search Text
+                'list_show_search_text' => array(
+                        'field' => 'list_show_search_text',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Search Category
+                'list_show_search_category' => array(
+                        'field' => 'list_show_search_category',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Search Amenities
+                'list_show_search_amenities' => array(
+                        'field' => 'list_show_search_amenities',
+                        'type' => 'checkbox',
+                        'default' => false,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Search Alpha
+                'list_show_search_alpha' => array(
+                        'field' => 'list_show_search_alpha',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                /*
+                 * Front-end Member Listing Options
+                 */
+
+                // Front-end Listings - Show Detail Link
+                'list_show_detail_link' => array(
+                        'field' => 'list_show_detail_link',
+                        'type' => 'checkbox',
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Logo
+                'list_show_logo' => array(
+                        'field' => 'list_show_logo',
+                        'type' => 'checkbox',
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Logo Size
+                'list_logo_size' => array(
+                        'field' => 'list_logo_size',
+                               'type' => 'list',
+                               'list' => $this->config['image_sizes'],
+                        'required' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Address
+                'list_show_address' => array(
+                        'field' => 'list_show_address',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Street
+                'list_show_street' => array(
+                        'field' => 'list_show_Street',
+                        'type' => 'checkbox',
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show City, State, ZIP
+                'list_show_citystatezip' => array(
+                        'field' => 'list_show_citystatezip',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show country
+                'list_show_country' => array(
+                        'field' => 'list_show_country',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Region
+                'list_show_region' => array(
+                        'field' => 'list_show_region',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Description
+                'list_show_descr' => array(
+                        'field' => 'list_show_descr',
+                        'type' => 'checkbox',
+                        'default' => false,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Short Description
+                'list_show_short_descr' => array(
+                        'field' => 'list_show_short_descr',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show phone
+                'list_show_phone' => array(
+                        'field' => 'list_show_phone',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Toll Free
+                'list_show_tollfree' => array(
+                        'field' => 'list_show_tollfree',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show URL
+                'list_show_url' => array(
+                        'field' => 'list_show_url',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Categories
+                'list_show_categories' => array(
+                        'field' => 'list_show_categories',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Credit Cards
+                'list_show_logo' => array(
+                        'field' => 'list_show_creditcards',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'lg'
+                ),
+
+                // Front-end Listings - Show Amenities
+                'list_show_amenities' => array(
+                        'field' => 'list_show_amenities',
+                        'type' => 'checkbox',
+                        'default' => false,
+                        'use' => 'lg'
+                ),
+
+
+
+
+
+
+
+        );
+
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+            glmMembersAdmin::addNotice($this->fields, 'DataBlock', 'Table Fields: '.$this->table);
+        }
+
+    }
+}
+
+?>
\ No newline at end of file
index 71e599e..43b1775 100644 (file)
@@ -89,6 +89,7 @@ class GlmPluginSupport
             default;
                 $notices = get_option('glmMembersAdminNotices');
                 $notices[] = $message;
+//$notices = array();
                 update_option('glmMembersAdminNotices', $notices);
                 break;
 
index cb379d6..328ded2 100644 (file)
@@ -34,6 +34,11 @@ thumb['crop'] = null
 
 [common]
 
+image_sizes['large'] = 'Large'
+image_sizes['medium'] = 'Medium'
+image_sizes['small'] = 'Small'
+image_sizes['thumb'] = 'Thumbnail'
+
 ;
 ; Site Configuration Options
 ;
index f1c9e93..1868820 100644 (file)
@@ -30,13 +30,13 @@ $GLOBALS['glmMembersAdminValidActions'] = array(
                 'index'
         ),
         'members' => array(
-                'index', // member list
+                'index',            // member list
                 'list',
                 'reports',
                 'other'
         ),
         'member' => array(
-                'index', // Member Dashboard
+                'index',            // Member Dashboard
                 'memberInfo',
                 'locations',
                 'facilities',
@@ -45,13 +45,15 @@ $GLOBALS['glmMembersAdminValidActions'] = array(
         )
         ,
         'configure' => array(
-                'index',
-                'memberTypes',
+                'index',            // Member Types
                 'categories',
                 'cities',
                 'regions',
                 'accommodationTypes',
                 'amenities',
+        ),
+        'settings' => array(
+                'index',            // General Options
                 'development'
         ),
         'shortcodes' => array(
@@ -66,6 +68,9 @@ $GLOBALS['glmMembersAdminValidActions'] = array(
 // Load glmPluginSupport class
 require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php');
 
+// Load Smarty Template Support
+require (GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php');
+
 /**
  * Admin Controller Class
  *
@@ -214,6 +219,13 @@ class glmMembersAdmin extends GlmPluginSupport
 
                 ));
 
+/*
+        add_action( 'admin_init',
+                array(
+                        $this,
+                        'glmMembersAdminSettingsInit'
+                ));
+*/
     }
 
     /**
@@ -325,6 +337,15 @@ class glmMembersAdmin extends GlmPluginSupport
                         'glmMembersAdminMenuConfigure'
                 ));
 
+        // Add a submenu for the "Settings" section
+        add_submenu_page('glm-members-admin-menu-members',
+                'Member DB Settings', 'Settings',
+                'glm_members_settings', 'glm-members-admin-menu-settings',
+                array(
+                        $this,
+                        'glmMembersAdminMenuSettings'
+                ));
+
         // Add a submenu for the "Shortcode Reference" section
         add_submenu_page('glm-members-admin-menu-members',
                 'Shortcode Reference', 'Shortcodes',
@@ -349,15 +370,18 @@ class glmMembersAdmin extends GlmPluginSupport
     public function glmMembersAdminDashboardWidget ()
     {
 
-        wp_add_dashboard_widget(
-                'glm_members_admin_dashboard_widget',
-                'Member DB Summary',
-                array(
-                        $this,
-                        'glmMembersAdminDashboardContent'
-                )
-        );
+        if ( current_user_can( 'glm_members_info' ) ) {
 
+            wp_add_dashboard_widget(
+                    'glm_members_admin_dashboard_widget',
+                    'Member DB Summary',
+                    array(
+                            $this,
+                            'glmMembersAdminDashboardContent'
+                    )
+            );
+
+        }
     }
 
     /**
@@ -412,6 +436,11 @@ class glmMembersAdmin extends GlmPluginSupport
         $this->controller('configure');
     }
 
+    public function glmMembersAdminMenuSettings ()
+    {
+        $this->controller('settings');
+    }
+
     public function glmMembersAdminMenuShortcodes ()
     {
         $this->controller('shortcodes');
@@ -679,7 +708,6 @@ class glmMembersAdmin extends GlmPluginSupport
          */
 
         // Load Smarty Template support
-        require (GLM_MEMBERS_PLUGIN_PATH . '/lib/smartyTemplateSupport.php');
         $smarty = new smartyTemplateSupport();
 
         // Add standard template parameters
@@ -723,9 +751,11 @@ class glmMembersAdmin extends GlmPluginSupport
 
             $templateVars = '<pre>' . print_r($x, 1) . '</pre>';
             glmMembersAdmin::addNotice($templateVars, 'Template Parameters', 'Process');
+
         }
 
         // Generate output from model data and view
+
         $smarty->template->display($view);
 
         // Restore timezone that was set before our code was called
index 1faa471..c89d96d 100644 (file)
@@ -336,6 +336,7 @@ function glmMembersAdminNotices($windowed = true)
                 $output .= '<li><a href="#'.++$n.'">'.$d['title'].'</a></li>';
             }
         }
+
         $output .= '</ul></div><hr>';
         if (is_array($dataBlocks)) {
             reset($dataBlocks);
@@ -350,6 +351,7 @@ function glmMembersAdminNotices($windowed = true)
                 ';
             }
         }
+
         delete_option('glmMembersAdminNoticeDataBlocks');
 
         echo $output.'
index cef9e18..85dd1b1 100644 (file)
@@ -473,6 +473,51 @@ CREATE TABLE {prefix}restaurants (
 
 ----
 
+CREATE TABLE {prefix}settings_general (
+  id INT NOT NULL AUTO_INCREMENT,
+  admin_debug BOOLEAN NULL,
+  admin_debug_verbose BOOLEAN NULL,
+  front_debug BOOLEAN NULL,
+  front_debug_verbose BOOLEAN NULL,
+  google_maps_api_key TINYTEXT NULL,
+  maps_default_lat FLOAT NULL,
+  maps_default_lon FLOAT NULL,
+  time_zone TINYTEXT NULL,
+  list_show_map BOOLEAN NULL,
+  list_show_list BOOLEAN NULL,
+  list_show_search BOOLEAN NULL,
+  list_show_search_category BOOLEAN NULL,
+  list_show_search_amenities BOOLEAN NULL,
+  list_show_search_alphja BOOLEAN NULL,
+  list_show_detail_link BOOLEAN NULL,
+  list_show_logo BOOLEAN NULL,
+  list_logo_size TINYTEXT NULL,
+  list_show_address BOOLEAN NULL,
+  list_show_street BOOLEAN NULL,
+  list_show_citystatezip BOOLEAN NULL,
+  list_show_country BOOLEAN NULL,
+  list_show_region BOOLEAN NULL,
+  list_show_descr BOOLEAN NULL,
+  list_show_short_descr BOOLEAN NULL,
+  list_show_phone BOOLEAN NULL,
+  list_show_tollfree BOOLEAN NULL,
+  list_show_url BOOLEAN NULL,
+  list_show_categories BOOLEAN NULL,
+  list_show_creditcards BOOLEAN NULL,
+  list_show_amenities BOOLEAN NULL,
+  
+  PRIMARY KEY (id)
+);
+
+----
+
+CREATE TABLE {prefix}settings_terms (
+  id INT NOT NULL AUTO_INCREMENT,
+  PRIMARY KEY (id)
+);
+
+----
+
 CREATE TABLE {prefix}social_media (
   id INT NOT NULL AUTO_INCREMENT,
   name TINYTEXT NULL,
index 45cbfe3..2c792d8 100644 (file)
@@ -27,6 +27,8 @@ DROP TABLE
     {prefix}regions,
     {prefix}restaurant_types,
     {prefix}restaurants,
+    {prefix}settings_general,
+    {prefix}settings_terms,
     {prefix}social_media,
     {prefix}social_media_ref
 ;
index fb4f365..ed51753 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-27 02:35:45
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-06-03 13:48:24
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/configure/header.html" */ ?>
 <?php /*%%SmartyHeaderCode:124095827254c0496da79607-59867625%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->decodeProperties(array (
@@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array (
     '3ec5bcbe581d6335e06bc6c9474f73121a83d59b' => 
     array (
       0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/configure/header.html',
-      1 => 1422326142,
+      1 => 1433353557,
       2 => 'file',
     ),
   ),
@@ -34,28 +34,22 @@ $_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 }?>">General Options</a>
-        <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
-?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
-&glm_action=memberTypes" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='memberTypes') {?>-active<?php }?>">Member Types</a>
+&glm_action=index" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='index') {?>-active<?php }?>">Member Types</a>
         <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
 ?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
 &glm_action=categories" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='categories') {?>-active<?php }?>">Member Categories</a>
         <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
 ?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
-&glm_action=cities" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='cities') {?>-active<?php }?>">Cities</a>
-        <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
-?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
-&glm_action=regions" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='regions') {?>-active<?php }?>">Regions</a>
-        <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
-?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
 &glm_action=accommodationTypes" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='accommodationTypes') {?>-active<?php }?>">Accommodation Types</a>
         <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
 ?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
 &glm_action=amenities" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='amenities') {?>-active<?php }?>">Amenities</a>
         <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
 ?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
-&glm_action=development" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='development') {?>-active<?php }?>">Development</a>
+&glm_action=cities" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='cities') {?>-active<?php }?>">Cities</a>
+        <a href="<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
+?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
+&glm_action=regions" class="nav-tab<?php if ($_smarty_tpl->tpl_vars['thisAction']->value=='regions') {?>-active<?php }?>">Regions</a>
     </h2>
     <div id="glm-admin-content-container">
     <?php }} ?>
index 0474448..8c5bfbf 100644 (file)
@@ -1,4 +1,4 @@
-<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-01-22 00:50:53
+<?php /* Smarty version Smarty-3.1.21-dev, created on 2015-06-03 14:05:40
          compiled from "/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/configure/index.html" */ ?>
 <?php /*%%SmartyHeaderCode:135960089454c0496da6c5c6-30692976%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
 $_valid = $_smarty_tpl->decodeProperties(array (
@@ -7,7 +7,7 @@ $_valid = $_smarty_tpl->decodeProperties(array (
     '47fb9b803e7138d215645f3c977b0b1dc2a9e718' => 
     array (
       0 => '/var/www/server/wordpress/wp-content/plugins/glm-member-db/views/admin/configure/index.html',
-      1 => 1421691086,
+      1 => 1433354735,
       2 => 'file',
     ),
   ),
@@ -15,17 +15,193 @@ $_valid = $_smarty_tpl->decodeProperties(array (
   'function' => 
   array (
   ),
-  'has_nocache_code' => false,
   'version' => 'Smarty-3.1.21-dev',
   'unifunc' => 'content_54c0496da75c57_83289225',
+  'variables' => 
+  array (
+    'thisURL' => 0,
+    'thisPage' => 0,
+    'haveMemberTypes' => 0,
+    'memberTypes' => 0,
+    'i' => 0,
+    't' => 0,
+  ),
+  'has_nocache_code' => false,
 ),false); /*/%%SmartyHeaderCode%%*/?>
 <?php if ($_valid && !is_callable('content_54c0496da75c57_83289225')) {function content_54c0496da75c57_83289225($_smarty_tpl) {?><?php echo $_smarty_tpl->getSubTemplate ('admin/configure/header.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
 
+
+    <!-- Add Member Type Button and Dialog Box -->
+    <div id="newMemberTypeButton" class="button-primary glm-right">Add a Member Type</div>    
+    <div id="newMemberTypeDialog" class="glm-dialog-box" title="Enter New Member Type">
+        <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="index">
+            <input type="hidden" name="option" value="addNew">
+            
+            <table class="glm-admin-table">
+                <tr>
+                    <th class="glm-required">Member Type Name:</th>
+                    <td>
+                        <input type="text" name="name" class="glm-form-text-input">
+                    </td>
+                </tr>
+                <tr>
+                    <th>Description:</th>
+                    <td>
+                        <textarea name="descr" class="glm-form-textarea"></textarea>
+                    </td>
+                </tr>
+            </table>
+            <p><span class="glm-required">*</span> Required</p>
+            <a id="newMemberTypeCancel" class="button-primary glm-right">Cancel</a>
+            <input type="submit" value="Add new member type">
+        </form>
+    </div>
+
+    <!--  Delete Member Dialog Box -->
+    <div id="deleteMemberTypeDialog" class="glm-dialog-box" title="Delete Member Type">
+        <center>
+            <p>Are you sure you want to delete this member type?</p>
+            <p><div id="deleteMemberTypeConfirm" class="button-primary">Yes, delete this member type</div></p>
+            <p><div id="deleteMemberTypeCancel" class="button-primary">Cancel</div></p>
+        </center>
+    </div>
+                    
+    <!-- Edit Member Type Dialog Box -->
+    <div id="editMemberTypeDialog" class="glm-dialog-box" title="Edit Member Type">
+        <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="index">
+            <input type="hidden" name="option" value="update">
+            <input id="editMemberTypeID" type="hidden" name="id" value="">
+            <table class="glm-admin-table">
+                <tr>
+                    <th class="glm-required">Member Type Name:</th>
+                    <td>
+                        <input id="editMemberTypeName" type="text" name="name" class="glm-form-text-input">
+                    </td>
+                </tr>
+                <tr>
+                    <th>Description:</th>
+                    <td>
+                        <textarea id="editMemberTypeDescr" name="descr" class="glm-form-textarea"></textarea>
+                    </td>
+                </tr>
+            </table>
+            <p><span class="glm-required">*</span> Required</p>
+            <a id="editMemberTypeCancel" class="button-primary glm-right">Cancel</a>
+            <input type="submit" value="Update this member type">
+        </form>
+    </div>
     
-    <h2>General Configuration</h2>
-    
-    <p>General configuration options go here.</p>
-    
+    <h2>Member Types</h2>
+
+    <table class="wp-list-table widefat fixed posts glm-admin-table">
+        <thead>
+            <tr>
+                <th>Member Type</th>
+                <th>Description</th>
+                <th>&nbsp;</th>
+            </tr>
+        </thead>
+        <tbody>
+<?php if ($_smarty_tpl->tpl_vars['haveMemberTypes']->value) {?>
+    <?php if (isset($_smarty_tpl->tpl_vars["i"])) {$_smarty_tpl->tpl_vars["i"] = clone $_smarty_tpl->tpl_vars["i"];
+$_smarty_tpl->tpl_vars["i"]->value = "0"; $_smarty_tpl->tpl_vars["i"]->nocache = null; $_smarty_tpl->tpl_vars["i"]->scope = 0;
+} else $_smarty_tpl->tpl_vars["i"] = new Smarty_variable("0", null, 0);?>
+    <?php  $_smarty_tpl->tpl_vars['t'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['t']->_loop = false;
+ $_from = $_smarty_tpl->tpl_vars['memberTypes']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
+foreach ($_from as $_smarty_tpl->tpl_vars['t']->key => $_smarty_tpl->tpl_vars['t']->value) {
+$_smarty_tpl->tpl_vars['t']->_loop = true;
+?>
+        <?php if ((1 & $_smarty_tpl->tpl_vars['i']->value++ / 1)) {?> 
+            <tr>
+        <?php } else { ?>
+            <tr class="alternate">
+        <?php }?>
+                <td>
+                    <a class="editMemberType" data-memberTypeID="<?php echo $_smarty_tpl->tpl_vars['t']->value['id'];?>
+"><?php echo $_smarty_tpl->tpl_vars['t']->value['name'];?>
+</a>
+                </td>
+                <td id="editMemberTypeDescr_<?php echo $_smarty_tpl->tpl_vars['t']->value['id'];?>
+">
+                    <?php echo $_smarty_tpl->tpl_vars['t']->value['descr'];?>
+
+                </td>
+                <td>
+                    <div class="deleteMemberTypeButton button-primary glm-right" data-memberTypeID="<?php echo $_smarty_tpl->tpl_vars['t']->value['id'];?>
+">Delete</div>
+                </td>
+            </tr>
+    <?php } ?>
+<?php } else { ?>
+            <tr class="alternate"><td colspan="2">(no member types listed)</td></tr>
+<?php }?>
+        </tbody>
+    </table>
+
+    <?php echo '<script'; ?>
+ type="text/javascript">
+        jQuery(document).ready(function($) {
+               
+            $("#newMemberTypeDialog").dialog({
+               autoOpen: false,
+               minWidth: 400,
+                dialogClass: "glm-dialog-no-close"
+            });
+            $("#editMemberTypeDialog").dialog({
+                autoOpen: false,
+                minWidth: 400,
+                dialogClass: "glm-dialog-no-close"
+            });
+            $("#deleteMemberTypeDialog").dialog({
+                autoOpen: false,
+                minWidth: 400,
+                dialogClass: "glm-dialog-no-close"
+            });
+
+            $('#newMemberTypeButton').click( function() {
+                $("#newMemberTypeDialog").dialog("open");
+            });
+            $('.editMemberType').click( function() {
+                var typeID = $(this).attr('data-memberTypeID');
+                var typeName = $(this).text();
+                var typeDescr = $('#editMemberTypeDescr_' + typeID).html();
+                $('#editMemberTypeID').val(typeID);
+                $('#editMemberTypeName').val(typeName.trim());
+                $('#editMemberTypeDescr').val(typeDescr.trim());
+                $("#editMemberTypeDialog").dialog("open");
+            });
+            $('#editMemberTypeCancel').click( function() {
+                $("#editMemberTypeDialog").dialog("close");
+            });
+            $('#newMemberTypeCancel').click( function() {
+                $("#newMemberTypeDialog").dialog("close");
+            });
+
+            var id = false;
+            $('.deleteMemberTypeButton').click( function() {
+                id = $(this).attr('data-memberTypeID');
+                $("#deleteMemberTypeDialog").dialog("open");
+            });
+            $('#deleteMemberTypeConfirm').click( function() {
+                $("#deleteMemberTypeDialog").dialog("close");
+                window.location.href = "<?php echo $_smarty_tpl->tpl_vars['thisURL']->value;?>
+?page=<?php echo $_smarty_tpl->tpl_vars['thisPage']->value;?>
+&glm_action=index&option=delete&id=" + id;
+            });
+            $('#deleteMemberTypeCancel').click( function() {
+                $("#deleteMemberTypeDialog").dialog("close");
+            });
+
+        });
+    <?php echo '</script'; ?>
+>
+            
 <?php echo $_smarty_tpl->getSubTemplate ('admin/footer.html', $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0);?>
 
 <?php }} ?>
diff --git a/models/admin/configure/development.php b/models/admin/configure/development.php
deleted file mode 100644 (file)
index bcf3431..0000000
+++ /dev/null
@@ -1,345 +0,0 @@
-<?php
-
-/**
- * Gaslight Media Members Database
- * Admin Development
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package  glmMembersDatabase
- * @author   Chuck Scott <cscott@gaslightmedia.com>
- * @license  http://www.gaslightmedia.com Gaslightmedia
- * @version  0.1
- */
-
-/*
- * This class performs the work for the default action of the "Members" menu
- * option, which is to display the members dashboard.
- *
- */
-class GlmMembersAdmin_configure_development
-{
-
-    /**
-     * 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;
-
-    }
-
-    /*
-     * 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 ($actionData = false)
-    {
-
-        // Get current database version
-        $dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION;
-        settype($dbVersion, 'string');
-
-        $templateData['resultMessage'] = '';
-        $templateData['success'] = false;
-        $templateData['haveNotices'] = false;
-        $notices = array();
-        $templateData['haveMembers'] = false;
-        $templateData['import'] = false;
-        $templateData['importNotice'] = false;
-        $templateData['haveDatabaseTableList'] = false;
-
-        // Load database activation class to get access to database version information
-        require_once (GLM_MEMBERS_PLUGIN_PATH . '/activate.php');
-        $activate = new glmMembersPluginActivate($this->wpdb, $this->config, true);
-
-        $option = '';
-        if (isset($_REQUEST['option']) && $_REQUEST['option'] != '') {
-            $option = $_REQUEST['option'];
-        }
-
-        switch($option) {
-
-            case 'import_connections':
-
-                // Load Member Info Data Class and get info data for later use
-                require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/glmMemberImportFromConnections.php');
-                $Connections = new GlmMemberImportFromConnections($this->wpdb, $this->config);
-
-                if (isset($_REQUEST['import']) && $_REQUEST['import'] == 'now') {
-
-                    // Reset the database
-                    if (!$this->deleteDataTables($dbVersion)) {
-                        glmMembersAdmin::addNotice('<b>Unable to delete the database tables while resetting the database.</b><br>', 'AdminError');
-                        break;
-                    }
-                    if (!$this->createDataTables($dbVersion)) {
-                        glmMembersAdmin::addNotice('<b>Unable to create the database tables while resetting the database.</b><br>', 'AdminError');
-                        break;
-                    }
-                    glmMembersAdmin::addNotice('<b>Database tables have been reset in preparation importing members.</b><br>', 'AdminNotice');
-
-                    // Delete Images
-                    foreach( new RecursiveIteratorIterator(
-                        new RecursiveDirectoryIterator( GLM_MEMBERS_PLUGIN_IMAGES_PATH, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS ),
-                        RecursiveIteratorIterator::CHILD_FIRST ) as $value ) {
-                            if ($value->isFile()) {
-                                unlink( $value );
-                            }
-                        }
-
-                    $templateData['import'] = true;
-                    $templateData['membersImported'] = $Connections->doImport();
-
-                } else {
-
-                    // Check if Connections is not installed or not active. If active, gets count of entries.
-                    $c = $Connections->checkConnections();
-                    if ($c === false) {
-                        glmMembersAdmin::addNotice('<b>Connections Business Directory plugin is not installed or not active!</b><br>'.print_r($c,1), 'AdminError');
-                        break;
-                    }
-                    $templateData['numbEntries'] = $c;
-                    $importNotice = 'Connections Business Directory plugin is active.<br>Number of businesses listed: '.$c.'<br>';
-
-                    // Get the basic business data for review.
-                    $templateData['members'] = $Connections->getList();
-                    if ($templateData['members'] === false) {
-                        $importNotice = 'No businesses were retieved.';
-                        break;
-                    }
-
-                    $templateData['haveMembers'] = true;
-
-                    if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
-                        glmMembersAdmin::addNotice($templateData['members'], 'DataBlock', 'Base Members Data');
-                    }
-
-                }
-
-                break;
-
-            case 'drop':
-            case 'reset':
-
-                $del = $this->deleteDataTables($dbVersion);
-
-                if ($del) {
-                    glmMembersAdmin::addNotice('New database tables for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin have been deleted.', 'AdminNotice');
-
-                }
-
-                if ($option != 'reset') {
-                    break;
-                }
-
-            case 'create':
-
-                $create = $this->createDataTables($dbVersion);
-
-                // If there were no errors
-                if ($create) {
-
-                    // Notify the user that the database has been installed
-                    glmMembersAdmin::addNotice('New database tables installed for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.', 'AdminNotice');
-
-                    // Save the version of the installed database
-                    update_option('glmMembersDatabaseDbVersion', $dbVersion);
-
-                }
-
-                break;
-
-            case 'list':
-
-                    // Check if the database version set for this plugin is invalid.
-                    if (!isset($activate->dbVersions[$dbVersion])) {
-                        $resultMessage .= "The last database version set for the ".GLM_MEMBERS_PLUGIN_NAME." (V$dbVersion) isn't valid.<br>";
-                        break;
-                    }
-
-                    // Get the number of tables for this plugin database version that should exist.
-                    $tables = $activate->dbVersions[$dbVersion]['tables'];
-
-                    // Get the number of tables for this plugin that do currently exist.
-                    $existingTables = $this->wpdb->get_results("
-                        SELECT table_name
-                          FROM information_schema.tables
-                         WHERE table_name like '".GLM_MEMBERS_PLUGIN_DB_PREFIX."%';
-                    ", ARRAY_A);
-
-                    if (is_array($existingTables)) {
-
-                        $
-
-
-                        $resultMessage .= '<b>Current database tables</b><br><ul>';
-                        foreach($existingTables as $t){
-                            $resultMessage .= "<li>".$t['table_name'].'</li><br>';
-                        }
-                        $resultMessage .= '</ul>';
-                    } else {
-                        $resultMessage .= '<b>No tables currently exist</b><br>';
-                    }
-
-                break;
-
-            default:
-
-                break;
-
-        }
-
-        // Return status, suggested view, and data to controller
-        return array(
-            'status' => true,
-            'menuItemRedirect' => false,
-            'modelRedirect' => false,
-            'view' => 'admin/configure/development.html',
-            'data' => $templateData
-        );
-
-    }
-
-    /*
-     * Delete Members Database Tables
-     *
-     * @param string $dbVersion Current version of Members Database
-     *
-     * @return boolean
-     * @access public
-     */
-    public function deleteDataTables($dbVersion)
-    {
-
-        // Read in Database deletion script - assumes the current db version.
-        $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/drop_database_V'.$dbVersion.'.sql';
-        $sql = file_get_contents($sqlFile);
-
-        // Replace {prefix} with table name prefix
-        $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql);
-
-        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
-            glmMembersAdmin::addNotice('Dropping all database tables', 'Process');
-            glmMembersAdmin::addNotice($sql, 'DataBlock', 'Drop Tables SQL');
-        }
-
-        // Removing the tables using the script
-        $this->wpdb->query($sql);
-
-        // If there's been an error, display in debug Alert
-        $queryError = $this->wpdb->last_error;
-        if ($queryError) {
-            glmMembersAdmin::addNotice('<b>Error when deleting database: Database tables may not have existed.</b><br>Check following message.<br>'.$queryError, 'AdminError');
-            return false;
-        }
-
-        return true;
-
-    }
-
-    /*
-     * Create Members Database Tables
-     *
-     * @param string $dbVersion Current version of Members Database
-     *
-     * @return boolean
-     * @access public
-     */
-    public function createDataTables($dbVersion)
-    {
-
-        // Read in Database creation script
-        $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/create_database_V'.$dbVersion.'.sql';
-        $sql = file_get_contents($sqlFile);
-
-        // Replace {prefix} with table name prefix
-        $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql);
-
-        // Split script into separate queries by looking for lines with only "---"
-        $queries = preg_split('/^----$/m', $sql);
-
-        // Try executing all queries to build database
-        $qForDebug = '';
-        do {
-            $q = current($queries);
-            $this->wpdb->query($q);
-            $queryError = $this->wpdb->last_error;
-
-            if ($queryError) {
-                glmMembersAdmin::addNotice('<b>Error when creating database: Database tables may already exist.</b><br>Check following message.<br>'.$queryError, 'AdminError');
-                return false;
-            }
-            $qForDebug .= $queryError.$q;
-
-        } while ($queryError == '' && next($queries));
-
-        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
-            glmMembersAdmin::addNotice('Creating database tables', 'Process');
-            glmMembersAdmin::addNotice($qForDebug, 'DataBlock', 'Create Tables SQL');
-        }
-
-        return true;
-
-    }
-
-}
-
-?>
\ No newline at end of file
index 3d23663..4b42f0d 100644 (file)
@@ -2,7 +2,7 @@
 
 /**
  * Gaslight Media Members Database
- * Admin Configure
+ * Admin Member Type List
  *
  * PHP version 5.5
  *
  * @version  0.1
  */
 
+// Load Member Types data abstract
+require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberTypes.php');
+
 /*
  * This class performs the work for the default action of the "Members" menu
  * option, which is to display the members dashboard.
  *
  */
-class GlmMembersAdmin_configure_index
+class GlmMembersAdmin_configure_index extends GlmDataMemberTypes
 {
 
     /**
@@ -54,6 +57,9 @@ class GlmMembersAdmin_configure_index
         // Save plugin configuration object
         $this->config = $config;
 
+        // Run constructor for members data class
+        parent::__construct(false, false);
+
     }
 
     /*
@@ -93,17 +99,86 @@ class GlmMembersAdmin_configure_index
     public function modelAction ($actionData = false)
     {
 
-        // Determine if current user can add, edit, delete member data
-        $canEdit = current_user_can('glm_members_edit');
+        $success = true;
+        $haveMemberTypes = false;
+        $memberTypes = false;
+        $error = false;
+
+        // Check for member type id
+        $id = 0;
+        if (isset($_REQUEST['id'])) {
+            $id = $_REQUEST['id']-0;
+        }
+
+        // If there's an action option
+        if (isset($_REQUEST['option'])) {
+
+            switch($_REQUEST['option']) {
+
+                case 'addNew':
+                    $this->insertEntry();
+                    break;
+
+                case 'update':
+                    if ($id > 0) {
+                        $this->updateEntry($id);
+                    }
+                    break;
+
+                case 'delete':
+                    if ($id > 0) {
+                        $this->deleteEntry($id, true);
+                    }
+                    break;
+
+            }
+
+        }
+
+        // Get a current list of member types
+        $memberTypes = $this->getList();
+
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
+            glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Type Data');
+        }
+
+        // If we have list entries - even if it's an empty list
+        $success = true;
+        $haveMemberTypes = false;
+        if ($memberTypes !== false) {
+
+            $success = true;
+
+            // If we have any entries
+            if (count($memberTypes) > 0) {
+                $haveMemberTypes = true;
+            }
+        }
+
+        // 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($memberTypes, 'DataBlock', 'Member Types Data');
+        }
 
         // Compile template data
         $templateData = array(
-            'canEdit' => $canEdit
+            'haveMemberTypes' => $haveMemberTypes,
+            'memberTypes' => $memberTypes
         );
 
         // Return status, suggested view, and data to controller
         return array(
-            'status' => true,
+            'status' => $success,
             'menuItemRedirect' => false,
             'modelRedirect' => false,
             'view' => 'admin/configure/index.html',
@@ -112,6 +187,7 @@ class GlmMembersAdmin_configure_index
 
     }
 
+
 }
 
 ?>
\ No newline at end of file
diff --git a/models/admin/configure/memberTypes.php b/models/admin/configure/memberTypes.php
deleted file mode 100644 (file)
index 524fa46..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-<?php
-
-/**
- * Gaslight Media Members Database
- * Admin Member Type List
- *
- * PHP version 5.5
- *
- * @category glmWordPressPlugin
- * @package  glmMembersDatabase
- * @author   Chuck Scott <cscott@gaslightmedia.com>
- * @license  http://www.gaslightmedia.com Gaslightmedia
- * @version  0.1
- */
-
-// Load Member Types data abstract
-require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/data/dataMemberTypes.php');
-
-/*
- * This class performs the work for the default action of the "Members" menu
- * option, which is to display the members dashboard.
- *
- */
-class GlmMembersAdmin_configure_memberTypes extends GlmDataMemberTypes
-{
-
-    /**
-     * 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(false, false);
-
-    }
-
-    /*
-     * 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 ($actionData = false)
-    {
-
-        $success = true;
-        $haveMemberTypes = false;
-        $memberTypes = false;
-        $error = false;
-
-        // Check for member type id
-        $id = 0;
-        if (isset($_REQUEST['id'])) {
-            $id = $_REQUEST['id']-0;
-        }
-
-        // If there's an action option
-        if (isset($_REQUEST['option'])) {
-
-            switch($_REQUEST['option']) {
-
-                case 'addNew':
-                    $this->insertEntry();
-                    break;
-
-                case 'update':
-                    if ($id > 0) {
-                        $this->updateEntry($id);
-                    }
-                    break;
-
-                case 'delete':
-                    if ($id > 0) {
-                        $this->deleteEntry($id, true);
-                    }
-                    break;
-
-            }
-
-        }
-
-        // Get a current list of member types
-        $memberTypes = $this->getList();
-
-        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG_VERBOSE) {
-            glmMembersAdmin::addNotice($memberTypes, 'DataBlock', 'Member Type Data');
-        }
-
-        // If we have list entries - even if it's an empty list
-        $success = true;
-        $haveMemberTypes = false;
-        if ($memberTypes !== false) {
-
-            $success = true;
-
-            // If we have any entries
-            if (count($memberTypes) > 0) {
-                $haveMemberTypes = true;
-            }
-        }
-
-        // 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($memberTypes, 'DataBlock', 'Member Types Data');
-        }
-
-        // Compile template data
-        $templateData = array(
-            'haveMemberTypes' => $haveMemberTypes,
-            'memberTypes' => $memberTypes
-        );
-
-        // Return status, suggested view, and data to controller
-        return array(
-            'status' => $success,
-            'menuItemRedirect' => false,
-            'modelRedirect' => false,
-            'view' => 'admin/configure/memberTypes.html',
-            'data' => $templateData
-        );
-
-    }
-
-
-}
-
-?>
\ No newline at end of file
diff --git a/models/admin/settings/development.php b/models/admin/settings/development.php
new file mode 100644 (file)
index 0000000..bded5bd
--- /dev/null
@@ -0,0 +1,345 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Development
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersAdmin_settings_development
+{
+
+    /**
+     * 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;
+
+    }
+
+    /*
+     * 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 ($actionData = false)
+    {
+
+        // Get current database version
+        $dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION;
+        settype($dbVersion, 'string');
+
+        $templateData['resultMessage'] = '';
+        $templateData['success'] = false;
+        $templateData['haveNotices'] = false;
+        $notices = array();
+        $templateData['haveMembers'] = false;
+        $templateData['import'] = false;
+        $templateData['importNotice'] = false;
+        $templateData['haveDatabaseTableList'] = false;
+
+        // Load database activation class to get access to database version information
+        require_once (GLM_MEMBERS_PLUGIN_PATH . '/activate.php');
+        $activate = new glmMembersPluginActivate($this->wpdb, $this->config, true);
+
+        $option = '';
+        if (isset($_REQUEST['option']) && $_REQUEST['option'] != '') {
+            $option = $_REQUEST['option'];
+        }
+
+        switch($option) {
+
+            case 'import_connections':
+
+                // Load Member Info Data Class and get info data for later use
+                require_once(GLM_MEMBERS_PLUGIN_CLASS_PATH.'/glmMemberImportFromConnections.php');
+                $Connections = new GlmMemberImportFromConnections($this->wpdb, $this->config);
+
+                if (isset($_REQUEST['import']) && $_REQUEST['import'] == 'now') {
+
+                    // Reset the database
+                    if (!$this->deleteDataTables($dbVersion)) {
+                        glmMembersAdmin::addNotice('<b>Unable to delete the database tables while resetting the database.</b><br>', 'AdminError');
+                        break;
+                    }
+                    if (!$this->createDataTables($dbVersion)) {
+                        glmMembersAdmin::addNotice('<b>Unable to create the database tables while resetting the database.</b><br>', 'AdminError');
+                        break;
+                    }
+                    glmMembersAdmin::addNotice('<b>Database tables have been reset in preparation importing members.</b><br>', 'AdminNotice');
+
+                    // Delete Images
+                    foreach( new RecursiveIteratorIterator(
+                        new RecursiveDirectoryIterator( GLM_MEMBERS_PLUGIN_IMAGES_PATH, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS ),
+                        RecursiveIteratorIterator::CHILD_FIRST ) as $value ) {
+                            if ($value->isFile()) {
+                                unlink( $value );
+                            }
+                        }
+
+                    $templateData['import'] = true;
+                    $templateData['membersImported'] = $Connections->doImport();
+
+                } else {
+
+                    // Check if Connections is not installed or not active. If active, gets count of entries.
+                    $c = $Connections->checkConnections();
+                    if ($c === false) {
+                        glmMembersAdmin::addNotice('<b>Connections Business Directory plugin is not installed or not active!</b><br>'.print_r($c,1), 'AdminError');
+                        break;
+                    }
+                    $templateData['numbEntries'] = $c;
+                    $importNotice = 'Connections Business Directory plugin is active.<br>Number of businesses listed: '.$c.'<br>';
+
+                    // Get the basic business data for review.
+                    $templateData['members'] = $Connections->getList();
+                    if ($templateData['members'] === false) {
+                        $importNotice = 'No businesses were retieved.';
+                        break;
+                    }
+
+                    $templateData['haveMembers'] = true;
+
+                    if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+                        glmMembersAdmin::addNotice($templateData['members'], 'DataBlock', 'Base Members Data');
+                    }
+
+                }
+
+                break;
+
+            case 'drop':
+            case 'reset':
+
+                $del = $this->deleteDataTables($dbVersion);
+
+                if ($del) {
+                    glmMembersAdmin::addNotice('New database tables for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin have been deleted.', 'AdminNotice');
+
+                }
+
+                if ($option != 'reset') {
+                    break;
+                }
+
+            case 'create':
+
+                $create = $this->createDataTables($dbVersion);
+
+                // If there were no errors
+                if ($create) {
+
+                    // Notify the user that the database has been installed
+                    glmMembersAdmin::addNotice('New database tables installed for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.', 'AdminNotice');
+
+                    // Save the version of the installed database
+                    update_option('glmMembersDatabaseDbVersion', $dbVersion);
+
+                }
+
+                break;
+
+            case 'list':
+
+                    // Check if the database version set for this plugin is invalid.
+                    if (!isset($activate->dbVersions[$dbVersion])) {
+                        $templateData['resultMessage'] .= "The last database version set for the ".GLM_MEMBERS_PLUGIN_NAME." (V$dbVersion) isn't valid.<br>";
+                        break;
+                    }
+
+                    // Get the number of tables for this plugin database version that should exist.
+                    $tables = $activate->dbVersions[$dbVersion]['tables'];
+
+                    // Get the number of tables for this plugin that do currently exist.
+                    $existingTables = $this->wpdb->get_results("
+                        SELECT table_name
+                          FROM information_schema.tables
+                         WHERE table_name like '".GLM_MEMBERS_PLUGIN_DB_PREFIX."%';
+                    ", ARRAY_A);
+
+                    if (is_array($existingTables)) {
+
+
+
+
+                        $templateData['resultMessage'] .= '<b>Current database tables</b><br><ul>';
+                        foreach($existingTables as $t){
+                            $templateData['resultMessage'] .= "<li>".$t['table_name'].'</li><br>';
+                        }
+                        $templateData['resultMessage'] .= '</ul>';
+                    } else {
+                        $templateData['resultMessage'] .= '<b>No tables currently exist</b><br>';
+                    }
+
+                break;
+
+            default:
+
+                break;
+
+        }
+
+        // Return status, suggested view, and data to controller
+        return array(
+            'status' => true,
+            'menuItemRedirect' => false,
+            'modelRedirect' => false,
+            'view' => 'admin/settings/development.html',
+            'data' => $templateData
+        );
+
+    }
+
+    /*
+     * Delete Members Database Tables
+     *
+     * @param string $dbVersion Current version of Members Database
+     *
+     * @return boolean
+     * @access public
+     */
+    public function deleteDataTables($dbVersion)
+    {
+
+        // Read in Database deletion script - assumes the current db version.
+        $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/drop_database_V'.$dbVersion.'.sql';
+        $sql = file_get_contents($sqlFile);
+
+        // Replace {prefix} with table name prefix
+        $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql);
+
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+            glmMembersAdmin::addNotice('Dropping all database tables', 'Process');
+            glmMembersAdmin::addNotice($sql, 'DataBlock', 'Drop Tables SQL');
+        }
+
+        // Removing the tables using the script
+        $this->wpdb->query($sql);
+
+        // If there's been an error, display in debug Alert
+        $queryError = $this->wpdb->last_error;
+        if ($queryError) {
+            glmMembersAdmin::addNotice('<b>Error when deleting database: Database tables may not have existed.</b><br>Check following message.<br>'.$queryError, 'AdminError');
+            return false;
+        }
+
+        return true;
+
+    }
+
+    /*
+     * Create Members Database Tables
+     *
+     * @param string $dbVersion Current version of Members Database
+     *
+     * @return boolean
+     * @access public
+     */
+    public function createDataTables($dbVersion)
+    {
+
+        // Read in Database creation script
+        $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/create_database_V'.$dbVersion.'.sql';
+        $sql = file_get_contents($sqlFile);
+
+        // Replace {prefix} with table name prefix
+        $sql = str_replace('{prefix}', GLM_MEMBERS_PLUGIN_DB_PREFIX, $sql);
+
+        // Split script into separate queries by looking for lines with only "---"
+        $queries = preg_split('/^----$/m', $sql);
+
+        // Try executing all queries to build database
+        $qForDebug = '';
+        do {
+            $q = current($queries);
+            $this->wpdb->query($q);
+            $queryError = $this->wpdb->last_error;
+
+            if ($queryError) {
+                glmMembersAdmin::addNotice('<b>Error when creating database: Database tables may already exist.</b><br>Check following message.<br>'.$queryError, 'AdminError');
+                return false;
+            }
+            $qForDebug .= $queryError.$q;
+
+        } while ($queryError == '' && next($queries));
+
+        if (GLM_MEMBERS_PLUGIN_ADMIN_DEBUG) {
+            glmMembersAdmin::addNotice('Creating database tables', 'Process');
+            glmMembersAdmin::addNotice($qForDebug, 'DataBlock', 'Create Tables SQL');
+        }
+
+        return true;
+
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/models/admin/settings/index.php b/models/admin/settings/index.php
new file mode 100644 (file)
index 0000000..e5645f5
--- /dev/null
@@ -0,0 +1,117 @@
+<?php
+
+/**
+ * Gaslight Media Members Database
+ * Admin Configure
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @version  0.1
+ */
+
+/*
+ * This class performs the work for the default action of the "Members" menu
+ * option, which is to display the members dashboard.
+ *
+ */
+class GlmMembersAdmin_settings_index
+{
+
+    /**
+     * 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;
+
+    }
+
+    /*
+     * 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 ($actionData = false)
+    {
+
+        // Determine if current user can add, edit, delete member data
+        $canEdit = current_user_can('glm_members_edit');
+
+        // Compile template data
+        $templateData = array(
+            'canEdit' => $canEdit
+        );
+
+        // Return status, suggested view, and data to controller
+        return array(
+            'status' => true,
+            'menuItemRedirect' => false,
+            'modelRedirect' => false,
+            'view' => 'admin/settings/index.html',
+            'data' => $templateData
+        );
+
+    }
+
+}
+
+?>
\ No newline at end of file
diff --git a/views/admin/configure/development.html b/views/admin/configure/development.html
deleted file mode 100644 (file)
index 75e6421..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-{include file='admin/configure/header.html'}
-    
-    <p>Note: Customers will not have access to this tab.</p>
-    
-    <h2>Development Activities</h2>
-    
-    <ul>
-        <li>
-            <H3>Import</H3>
-            <ul>
-                <li>
-                    <p>
-                        <a href="{$thisURL}?page={$thisPage}&glm_action=development&option=import_connections">Import data from "Connections" business directory</a>
-
-    {if $importNotice} 
-                        <div class="glm-indent glm-notice">{$importNotice}</div>
-    {/if}
-                    </p>
-
-    {if $import}
-
-                    <h3 style="margin-left: 2em;">Members imported: {$membersImported}</h3>
-                    
-    {else}
-        {if $haveMembers}
-                    <form action="{$thisURL}?page={$thisPage}&glm_action=development&option=import_connections" method="POST">
-                        <div class="glm-item-container">
-                            <b>Default data to use when importing members.</b>
-                            <table>
-                                <tr><td>Default member type: </td><td><input type="text" name="memberType" value="Standard"></td></tr>
-                                <tr><td>Default region name: </td><td><input type="text" name="region" value="Region"></td></tr>
-                            </table>
-                        </div>
-                        <p>
-                            <input class="glm-right" type="submit" value="Click here to import all members not marked as Skip">
-                            <span id="skipAll" class="button-primary">Skip All</span>&nbsp;&nbsp;
-                            <span id="skipNone" class="button-primary">Import All</span>
-                        </p>
-                        <div class="glm-nitice glm-indent">
-                            <ul class="glm-required glm-indent">
-                                <li>*** THIS ACTION WILL FULLY RESET YOUR MEMBERS DATABASE ***</li>
-                                <li>This action does not check for duplicate members!</li>
-                            </ul>
-                        </div>
-                        <input type="hidden" name="import" value="now">
-                        <table class="wp-list-table widefat fixed posts glm-admin-table">
-                            <thead>
-                                <tr>
-                                    <th>Skip</th>
-                                    <th>Name</th>
-                                    <th>Addr Line 1</th>
-                                    <th>Addr Line 2</th>
-                                    <th>Addr Line 3</th>
-                                    <th>City</th>
-                                    <th>State</th>
-                                    <th>ZIP</th>
-                                    <th>Country</th>
-                                    <th>Lat/Lon</th>
-                                </tr>
-                            </thead>
-                            <tbody>
-            {foreach $members as $m}
-                                <tr class="alternate">
-                                    <td><input type="checkbox" name="skip[{$m.id}]" class="skip">{$m.id}</td>
-                                    <td>{$m.organization}</td>
-                {assign var="i" value="0"}                        
-                {foreach $m.addresses as $a}
-                    {if $i++ gt 1}
-                                <tr>
-                                    <td>&nbsp;</td>
-                                    <td>&nbsp;</td>
-                    {/if}                                
-                                    <td>{$a.line_1}</td>
-                                    <td>{$a.line_2}</td>
-                                    <td>{$a.line_3}</td>
-                                    <td>{$a.city}</td>
-                                    <td>{$a.state}</td>
-                                    <td>{$a.zipcode}</td>
-                                    <td>{$a.country}</td>
-                                    <td>{$a.latitude|number_format:3:".":","}/{$a.longitude|number_format:3:".":","}</td>
-                                </tr>
-                {/foreach}
-            {/foreach}               
-                            </tbody>         
-                        </table>
-                    </form>
-        {/if}
-    {/if}
-                </li>
-            </ul>
-            <H3>Database</H3>
-            <ul>
-                <li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=drop">Drop database tables</a> (WARNING: Destroys all current data)</li>
-                <li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=create">Create database tables</a></li>
-                <li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=reset">Fully Reset Database (drop/create)</a> (WARNING: Destroys all current data)</li>
-                <li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=list">List database tables</a></li>
-            </ul>
-        </li>
-    </ul>
-
-    <div>
-        <h3>Docuemtation and References</h3>    
-        <p><a href="{$baseURL}/lib/GlmDataAbstract/GlmDataAbstract_Programmers_Manual.pdf">Data Abstract Class Documentation</a></p>
-    </div>
-{if $resultMessage}    
-    <div>
-        <h3>Results</h3>
-        {$resultMessage}
-    </div>
-{/if}    
-    
-{if $haveMembers}
-    <script type="text/javascript">
-        jQuery(document).ready(function($) {
-
-               $('#skipAll').click(function(event) {
-                   $('.skip').each(function() { //loop through each checkbox
-                       this.checked = true;  //select all checkboxes with class "checkbox1"              
-                   });
-                   return false;
-           });
-               
-            $('#skipNone').click(function(event) {
-                $('.skip').each(function() { //loop through each checkbox
-                    this.checked = false;  //select all checkboxes with class "checkbox1"              
-                });
-                return false;
-            });
-               
-        });
-    </script>
-{/if}            
-    
-    
-{include file='admin/footer.html'}
index be5e15a..5ce2e0c 100644 (file)
@@ -3,14 +3,12 @@
     <h2>{$glmPluginName} Configuration</h2>
        
     <h2 class="nav-tab-wrapper">
-        <a href="{$thisURL}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index}-active{/if}">General Options</a>
-        <a href="{$thisURL}?page={$thisPage}&glm_action=memberTypes" class="nav-tab{if $thisAction==memberTypes}-active{/if}">Member Types</a>
+        <a href="{$thisURL}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index}-active{/if}">Member Types</a>
         <a href="{$thisURL}?page={$thisPage}&glm_action=categories" class="nav-tab{if $thisAction==categories}-active{/if}">Member Categories</a>
-        <a href="{$thisURL}?page={$thisPage}&glm_action=cities" class="nav-tab{if $thisAction==cities}-active{/if}">Cities</a>
-        <a href="{$thisURL}?page={$thisPage}&glm_action=regions" class="nav-tab{if $thisAction==regions}-active{/if}">Regions</a>
         <a href="{$thisURL}?page={$thisPage}&glm_action=accommodationTypes" class="nav-tab{if $thisAction==accommodationTypes}-active{/if}">Accommodation Types</a>
         <a href="{$thisURL}?page={$thisPage}&glm_action=amenities" class="nav-tab{if $thisAction==amenities}-active{/if}">Amenities</a>
-        <a href="{$thisURL}?page={$thisPage}&glm_action=development" class="nav-tab{if $thisAction==development}-active{/if}">Development</a>
+        <a href="{$thisURL}?page={$thisPage}&glm_action=cities" class="nav-tab{if $thisAction==cities}-active{/if}">Cities</a>
+        <a href="{$thisURL}?page={$thisPage}&glm_action=regions" class="nav-tab{if $thisAction==regions}-active{/if}">Regions</a>
     </h2>
     <div id="glm-admin-content-container">
     
\ No newline at end of file
index 6ac1fe5..0cbedb6 100644 (file)
@@ -1,7 +1,155 @@
 {include file='admin/configure/header.html'}
+
+    <!-- Add Member Type Button and Dialog Box -->
+    <div id="newMemberTypeButton" class="button-primary glm-right">Add a Member Type</div>    
+    <div id="newMemberTypeDialog" class="glm-dialog-box" title="Enter New Member Type">
+        <form action="{$thisURL}?page={$thisPage}" method="post" enctype="multipart/form-data">
+            <input type="hidden" name="glm_action" value="index">
+            <input type="hidden" name="option" value="addNew">
+            
+            <table class="glm-admin-table">
+                <tr>
+                    <th class="glm-required">Member Type Name:</th>
+                    <td>
+                        <input type="text" name="name" class="glm-form-text-input">
+                    </td>
+                </tr>
+                <tr>
+                    <th>Description:</th>
+                    <td>
+                        <textarea name="descr" class="glm-form-textarea"></textarea>
+                    </td>
+                </tr>
+            </table>
+            <p><span class="glm-required">*</span> Required</p>
+            <a id="newMemberTypeCancel" class="button-primary glm-right">Cancel</a>
+            <input type="submit" value="Add new member type">
+        </form>
+    </div>
+
+    <!--  Delete Member Dialog Box -->
+    <div id="deleteMemberTypeDialog" class="glm-dialog-box" title="Delete Member Type">
+        <center>
+            <p>Are you sure you want to delete this member type?</p>
+            <p><div id="deleteMemberTypeConfirm" class="button-primary">Yes, delete this member type</div></p>
+            <p><div id="deleteMemberTypeCancel" class="button-primary">Cancel</div></p>
+        </center>
+    </div>
+                    
+    <!-- Edit Member Type Dialog Box -->
+    <div id="editMemberTypeDialog" class="glm-dialog-box" title="Edit Member Type">
+        <form action="{$thisURL}?page={$thisPage}" method="post" enctype="multipart/form-data">
+            <input type="hidden" name="glm_action" value="index">
+            <input type="hidden" name="option" value="update">
+            <input id="editMemberTypeID" type="hidden" name="id" value="">
+            <table class="glm-admin-table">
+                <tr>
+                    <th class="glm-required">Member Type Name:</th>
+                    <td>
+                        <input id="editMemberTypeName" type="text" name="name" class="glm-form-text-input">
+                    </td>
+                </tr>
+                <tr>
+                    <th>Description:</th>
+                    <td>
+                        <textarea id="editMemberTypeDescr" name="descr" class="glm-form-textarea"></textarea>
+                    </td>
+                </tr>
+            </table>
+            <p><span class="glm-required">*</span> Required</p>
+            <a id="editMemberTypeCancel" class="button-primary glm-right">Cancel</a>
+            <input type="submit" value="Update this member type">
+        </form>
+    </div>
     
-    <h2>General Configuration</h2>
-    
-    <p>General configuration options go here.</p>
-    
+    <h2>Member Types</h2>
+
+    <table class="wp-list-table widefat fixed posts glm-admin-table">
+        <thead>
+            <tr>
+                <th>Member Type</th>
+                <th>Description</th>
+                <th>&nbsp;</th>
+            </tr>
+        </thead>
+        <tbody>
+{if $haveMemberTypes}
+    {assign var="i" value="0"}
+    {foreach $memberTypes as $t}
+        {if $i++ is odd by 1} 
+            <tr>
+        {else}
+            <tr class="alternate">
+        {/if}
+                <td>
+                    <a class="editMemberType" data-memberTypeID="{$t.id}">{$t.name}</a>
+                </td>
+                <td id="editMemberTypeDescr_{$t.id}">
+                    {$t.descr}
+                </td>
+                <td>
+                    <div class="deleteMemberTypeButton button-primary glm-right" data-memberTypeID="{$t.id}">Delete</div>
+                </td>
+            </tr>
+    {/foreach}
+{else}
+            <tr class="alternate"><td colspan="2">(no member types listed)</td></tr>
+{/if}
+        </tbody>
+    </table>
+
+    <script type="text/javascript">
+        jQuery(document).ready(function($) {
+               
+            $("#newMemberTypeDialog").dialog({
+               autoOpen: false,
+               minWidth: 400,
+                dialogClass: "glm-dialog-no-close"
+            });
+            $("#editMemberTypeDialog").dialog({
+                autoOpen: false,
+                minWidth: 400,
+                dialogClass: "glm-dialog-no-close"
+            });
+            $("#deleteMemberTypeDialog").dialog({
+                autoOpen: false,
+                minWidth: 400,
+                dialogClass: "glm-dialog-no-close"
+            });
+
+            $('#newMemberTypeButton').click( function() {
+                $("#newMemberTypeDialog").dialog("open");
+            });
+            $('.editMemberType').click( function() {
+                var typeID = $(this).attr('data-memberTypeID');
+                var typeName = $(this).text();
+                var typeDescr = $('#editMemberTypeDescr_' + typeID).html();
+                $('#editMemberTypeID').val(typeID);
+                $('#editMemberTypeName').val(typeName.trim());
+                $('#editMemberTypeDescr').val(typeDescr.trim());
+                $("#editMemberTypeDialog").dialog("open");
+            });
+            $('#editMemberTypeCancel').click( function() {
+                $("#editMemberTypeDialog").dialog("close");
+            });
+            $('#newMemberTypeCancel').click( function() {
+                $("#newMemberTypeDialog").dialog("close");
+            });
+
+            var id = false;
+            $('.deleteMemberTypeButton').click( function() {
+                id = $(this).attr('data-memberTypeID');
+                $("#deleteMemberTypeDialog").dialog("open");
+            });
+            $('#deleteMemberTypeConfirm').click( function() {
+                $("#deleteMemberTypeDialog").dialog("close");
+                window.location.href = "{$thisURL}?page={$thisPage}&glm_action=index&option=delete&id=" + id;
+            });
+            $('#deleteMemberTypeCancel').click( function() {
+                $("#deleteMemberTypeDialog").dialog("close");
+            });
+
+        });
+    </script>
+            
 {include file='admin/footer.html'}
diff --git a/views/admin/configure/memberTypes.html b/views/admin/configure/memberTypes.html
deleted file mode 100644 (file)
index 1756e4d..0000000
+++ /dev/null
@@ -1,155 +0,0 @@
-{include file='admin/configure/header.html'}
-
-    <!-- Add Member Type Button and Dialog Box -->
-    <div id="newMemberTypeButton" class="button-primary glm-right">Add a Member Type</div>    
-    <div id="newMemberTypeDialog" class="glm-dialog-box" title="Enter New Member Type">
-        <form action="{$thisURL}?page={$thisPage}" method="post" enctype="multipart/form-data">
-            <input type="hidden" name="glm_action" value="memberTypes">
-            <input type="hidden" name="option" value="addNew">
-            
-            <table class="glm-admin-table">
-                <tr>
-                    <th class="glm-required">Member Type Name:</th>
-                    <td>
-                        <input type="text" name="name" class="glm-form-text-input">
-                    </td>
-                </tr>
-                <tr>
-                    <th>Description:</th>
-                    <td>
-                        <textarea name="descr" class="glm-form-textarea"></textarea>
-                    </td>
-                </tr>
-            </table>
-            <p><span class="glm-required">*</span> Required</p>
-            <a id="newMemberTypeCancel" class="button-primary glm-right">Cancel</a>
-            <input type="submit" value="Add new member type">
-        </form>
-    </div>
-
-    <!--  Delete Member Dialog Box -->
-    <div id="deleteMemberTypeDialog" class="glm-dialog-box" title="Delete Member Type">
-        <center>
-            <p>Are you sure you want to delete this member type?</p>
-            <p><div id="deleteMemberTypeConfirm" class="button-primary">Yes, delete this member type</div></p>
-            <p><div id="deleteMemberTypeCancel" class="button-primary">Cancel</div></p>
-        </center>
-    </div>
-                    
-    <!-- Edit Member Type Dialog Box -->
-    <div id="editMemberTypeDialog" class="glm-dialog-box" title="Edit Member Type">
-        <form action="{$thisURL}?page={$thisPage}" method="post" enctype="multipart/form-data">
-            <input type="hidden" name="glm_action" value="memberTypes">
-            <input type="hidden" name="option" value="update">
-            <input id="editMemberTypeID" type="hidden" name="id" value="">
-            <table class="glm-admin-table">
-                <tr>
-                    <th class="glm-required">Member Type Name:</th>
-                    <td>
-                        <input id="editMemberTypeName" type="text" name="name" class="glm-form-text-input">
-                    </td>
-                </tr>
-                <tr>
-                    <th>Description:</th>
-                    <td>
-                        <textarea id="editMemberTypeDescr" name="descr" class="glm-form-textarea"></textarea>
-                    </td>
-                </tr>
-            </table>
-            <p><span class="glm-required">*</span> Required</p>
-            <a id="editMemberTypeCancel" class="button-primary glm-right">Cancel</a>
-            <input type="submit" value="Update this member type">
-        </form>
-    </div>
-    
-    <h2>Member Types</h2>
-
-    <table class="wp-list-table widefat fixed posts glm-admin-table">
-        <thead>
-            <tr>
-                <th>Member Type</th>
-                <th>Description</th>
-                <th>&nbsp;</th>
-            </tr>
-        </thead>
-        <tbody>
-{if $haveMemberTypes}
-    {assign var="i" value="0"}
-    {foreach $memberTypes as $t}
-        {if $i++ is odd by 1} 
-            <tr>
-        {else}
-            <tr class="alternate">
-        {/if}
-                <td>
-                    <a class="editMemberType" data-memberTypeID="{$t.id}">{$t.name}</a>
-                </td>
-                <td id="editMemberTypeDescr_{$t.id}">
-                    {$t.descr}
-                </td>
-                <td>
-                    <div class="deleteMemberTypeButton button-primary glm-right" data-memberTypeID="{$t.id}">Delete</div>
-                </td>
-            </tr>
-    {/foreach}
-{else}
-            <tr class="alternate"><td colspan="2">(no member types listed)</td></tr>
-{/if}
-        </tbody>
-    </table>
-
-    <script type="text/javascript">
-        jQuery(document).ready(function($) {
-               
-            $("#newMemberTypeDialog").dialog({
-               autoOpen: false,
-               minWidth: 400,
-                dialogClass: "glm-dialog-no-close"
-            });
-            $("#editMemberTypeDialog").dialog({
-                autoOpen: false,
-                minWidth: 400,
-                dialogClass: "glm-dialog-no-close"
-            });
-            $("#deleteMemberTypeDialog").dialog({
-                autoOpen: false,
-                minWidth: 400,
-                dialogClass: "glm-dialog-no-close"
-            });
-
-            $('#newMemberTypeButton').click( function() {
-                $("#newMemberTypeDialog").dialog("open");
-            });
-            $('.editMemberType').click( function() {
-                var typeID = $(this).attr('data-memberTypeID');
-                var typeName = $(this).text();
-                var typeDescr = $('#editMemberTypeDescr_' + typeID).html();
-                $('#editMemberTypeID').val(typeID);
-                $('#editMemberTypeName').val(typeName.trim());
-                $('#editMemberTypeDescr').val(typeDescr.trim());
-                $("#editMemberTypeDialog").dialog("open");
-            });
-            $('#editMemberTypeCancel').click( function() {
-                $("#editMemberTypeDialog").dialog("close");
-            });
-            $('#newMemberTypeCancel').click( function() {
-                $("#newMemberTypeDialog").dialog("close");
-            });
-
-            var id = false;
-            $('.deleteMemberTypeButton').click( function() {
-                id = $(this).attr('data-memberTypeID');
-                $("#deleteMemberTypeDialog").dialog("open");
-            });
-            $('#deleteMemberTypeConfirm').click( function() {
-                $("#deleteMemberTypeDialog").dialog("close");
-                window.location.href = "{$thisURL}?page={$thisPage}&glm_action=memberTypes&option=delete&id=" + id;
-            });
-            $('#deleteMemberTypeCancel').click( function() {
-                $("#deleteMemberTypeDialog").dialog("close");
-            });
-
-        });
-    </script>
-            
-{include file='admin/footer.html'}
diff --git a/views/admin/settings/development.html b/views/admin/settings/development.html
new file mode 100644 (file)
index 0000000..87ef9dd
--- /dev/null
@@ -0,0 +1,135 @@
+{include file='admin/settings/header.html'}
+    
+    <p>Note: Customers will not have access to this tab.</p>
+    
+    <h2>Development Activities</h2>
+    
+    <ul>
+        <li>
+            <H3>Import</H3>
+            <ul>
+                <li>
+                    <p>
+                        <a href="{$thisURL}?page={$thisPage}&glm_action=development&option=import_connections">Import data from "Connections" business directory</a>
+
+    {if $importNotice} 
+                        <div class="glm-indent glm-notice">{$importNotice}</div>
+    {/if}
+                    </p>
+
+    {if $import}
+
+                    <h3 style="margin-left: 2em;">Members imported: {$membersImported}</h3>
+                    
+    {else}
+        {if $haveMembers}
+                    <form action="{$thisURL}?page={$thisPage}&glm_action=development&option=import_connections" method="POST">
+                        <div class="glm-item-container">
+                            <b>Default data to use when importing members.</b>
+                            <table>
+                                <tr><td>Default member type: </td><td><input type="text" name="memberType" value="Standard"></td></tr>
+                                <tr><td>Default region name: </td><td><input type="text" name="region" value="Region"></td></tr>
+                            </table>
+                        </div>
+                        <p>
+                            <input class="glm-right" type="submit" value="Click here to import all members not marked as Skip">
+                            <span id="skipAll" class="button-primary">Skip All</span>&nbsp;&nbsp;
+                            <span id="skipNone" class="button-primary">Import All</span>
+                        </p>
+                        <div class="glm-nitice glm-indent">
+                            <ul class="glm-required glm-indent">
+                                <li>*** THIS ACTION WILL FULLY RESET YOUR MEMBERS DATABASE ***</li>
+                                <li>This action does not check for duplicate members!</li>
+                            </ul>
+                        </div>
+                        <input type="hidden" name="import" value="now">
+                        <table class="wp-list-table widefat fixed posts glm-admin-table">
+                            <thead>
+                                <tr>
+                                    <th>Skip</th>
+                                    <th>Name</th>
+                                    <th>Addr Line 1</th>
+                                    <th>Addr Line 2</th>
+                                    <th>Addr Line 3</th>
+                                    <th>City</th>
+                                    <th>State</th>
+                                    <th>ZIP</th>
+                                    <th>Country</th>
+                                    <th>Lat/Lon</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+            {foreach $members as $m}
+                                <tr class="alternate">
+                                    <td><input type="checkbox" name="skip[{$m.id}]" class="skip">{$m.id}</td>
+                                    <td>{$m.organization}</td>
+                {assign var="i" value="0"}                        
+                {foreach $m.addresses as $a}
+                    {if $i++ gt 1}
+                                <tr>
+                                    <td>&nbsp;</td>
+                                    <td>&nbsp;</td>
+                    {/if}                                
+                                    <td>{$a.line_1}</td>
+                                    <td>{$a.line_2}</td>
+                                    <td>{$a.line_3}</td>
+                                    <td>{$a.city}</td>
+                                    <td>{$a.state}</td>
+                                    <td>{$a.zipcode}</td>
+                                    <td>{$a.country}</td>
+                                    <td>{$a.latitude|number_format:3:".":","}/{$a.longitude|number_format:3:".":","}</td>
+                                </tr>
+                {/foreach}
+            {/foreach}               
+                            </tbody>         
+                        </table>
+                    </form>
+        {/if}
+    {/if}
+                </li>
+            </ul>
+            <H3>Database</H3>
+            <ul>
+                <li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=drop">Drop database tables</a> (WARNING: Destroys all current data)</li>
+                <li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=create">Create database tables</a></li>
+                <li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=reset">Fully Reset Database (drop/create)</a> (WARNING: Destroys all current data)</li>
+                <li><a href="{$thisURL}?page={$thisPage}&glm_action=development&option=list">List database tables</a></li>
+            </ul>
+        </li>
+    </ul>
+
+    <div>
+        <h3>Docuemtation and References</h3>    
+        <p><a href="{$baseURL}/lib/GlmDataAbstract/GlmDataAbstract_Programmers_Manual.pdf">Data Abstract Class Documentation</a></p>
+    </div>
+{if $resultMessage}    
+    <div>
+        <hr>
+        {$resultMessage}
+    </div>
+{/if}    
+    
+{if $haveMembers}
+    <script type="text/javascript">
+        jQuery(document).ready(function($) {
+
+               $('#skipAll').click(function(event) {
+                   $('.skip').each(function() { //loop through each checkbox
+                       this.checked = true;  //select all checkboxes with class "checkbox1"              
+                   });
+                   return false;
+           });
+               
+            $('#skipNone').click(function(event) {
+                $('.skip').each(function() { //loop through each checkbox
+                    this.checked = false;  //select all checkboxes with class "checkbox1"              
+                });
+                return false;
+            });
+               
+        });
+    </script>
+{/if}            
+    
+    
+{include file='admin/footer.html'}
diff --git a/views/admin/settings/header.html b/views/admin/settings/header.html
new file mode 100644 (file)
index 0000000..a2ac339
--- /dev/null
@@ -0,0 +1,10 @@
+<div class="wrap">
+
+    <h2>{$glmPluginName} Configuration</h2>
+       
+    <h2 class="nav-tab-wrapper">
+        <a href="{$thisURL}?page={$thisPage}&glm_action=index" class="nav-tab{if $thisAction==index}-active{/if}">General Settings</a>
+        <a href="{$thisURL}?page={$thisPage}&glm_action=development" class="nav-tab{if $thisAction==development}-active{/if}">Development</a>
+    </h2>
+    <div id="glm-admin-content-container">
+    
\ No newline at end of file
diff --git a/views/admin/settings/index.html b/views/admin/settings/index.html
new file mode 100644 (file)
index 0000000..2799597
--- /dev/null
@@ -0,0 +1,7 @@
+{include file='admin/settings/header.html'}
+    
+    <h2>General Settings</h2>
+    
+    <p>General settings go here.</p>
+    
+{include file='admin/footer.html'}
diff --git a/views/admin/settingsPage/index.html b/views/admin/settingsPage/index.html
new file mode 100644 (file)
index 0000000..de804cf
--- /dev/null
@@ -0,0 +1,14 @@
+
+<div id="icon-themes" class="icon32"><br></div>
+<h2 class="nav-tab-wrapper">
+    <a class='{if $settingsTab=="tab1"}nav-tab-active{else}nav-tab{/if}' href='{$thisURL}?page=glm-member-db-settings&tab=tab1'>Tab 1</a>
+    <a class='{if $settingsTab=="tab2"}nav-tab-active{else}nav-tab{/if}' href='{$thisURL}?page=glm-member-db-settings&tab=tab2'>Tab 2</a>
+</h2>
+<div class="wrap">
+    <h2>My Plugin Options</h2>
+    <form action="options.php?tab={$settingsTab}" method="POST">
+        {php} settings_fields( 'glm-member-db-settings-group' ); {/php}
+       {php} do_settings_sections( 'glm-member-db-settings' ); {/php}
+       {php} submit_button(); {/php}
+    </form>
+</div>