Interim commit
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 12 Oct 2015 15:29:05 +0000 (11:29 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 12 Oct 2015 15:29:05 +0000 (11:29 -0400)
21 files changed:
activate.php
classes/data/dataMemberInfo.php
classes/data/settings/dataSettingsGeneral.php
classes/glmPluginSupport.php
config.php
controllers/admin.php
controllers/front.php
defines.php
glm-member-db.php
misc/databaseScripts/create_database_V0.1.sql
misc/databaseScripts/update_database_V1.0.28.php [new file with mode: 0644]
misc/databaseScripts/update_database_V1.0.28.sql [new file with mode: 0644]
models/admin/management/import.php
models/admin/member/memberInfo.php
models/front/members/detail.php
models/front/members/list.php
views/admin/management/index.html
views/admin/member/memberInfo.html
views/admin/shortcodes/index.html
views/front/members/detail.html
views/front/members/list.html

index dceebd5..9394f92 100644 (file)
@@ -27,24 +27,6 @@ require_once (GLM_MEMBERS_PLUGIN_PATH . '/classes/glmPluginSupport.php');
 class glmMembersPluginActivate extends glmPluginSupport
 {
 
-    /**
-     * Plugin Versions
-     *
-     * An array of past and current Member Database versions.
-     * Note that Database Versions match plugin versions.
-     *
-     * Each entry below uses a key so code can find data on
-     * a specific version and in the values are the version
-     * again and the proper number of tables that should
-     * exist with that version.
-     *
-     * @var $Versions
-     * @access private
-     */
-    public $dbVersions = array(
-        '0.1' => array('version' => '0.1', 'tables' => 26)
-    );
-
     /**
      * WordPress Database Object
      *
@@ -167,187 +149,6 @@ class glmMembersPluginActivate extends glmPluginSupport
 
     }
 
-    /*
-     * Check if database is installed and if it matches the current version
-     *
-     * @param string $capability Name of capability to add
-     * @param string $default Whether capability should be on by default
-     *
-     * @return void
-     * @access private
-     */
-    private function checkDatabase ()
-    {
-
-        $dbVersion = get_option('glmMembersDatabaseDbVersion');
-        $db_setup_status = false;
-
-        // Do a quick check for there being a database version but not all the required tables for that version
-        if ($dbVersion) {
-
-            // Check if the database version set for this plugin is invalid.
-            if (!isset($this->dbVersions[$dbVersion])) {
-                update_option('glmMembersInstallErrors', "The last database version set for the ".GLM_MEMBERS_PLUGIN_NAME." (V$dbVersion) isn't valid.");
-                return false;
-            }
-
-            // Get the number of tables for this plugin database version that should exist.
-            $tables = $this->dbVersions[$dbVersion]['tables'];
-
-            // Get the number of tables for this plugin that do currently exist.
-            $existingTables = $this->wpdb->get_var("
-                SELECT COUNT(*)
-                  FROM information_schema.tables
-                 WHERE table_name like '".GLM_MEMBERS_PLUGIN_DB_PREFIX."%';
-            ");
-
-            // If there's no tables, just assume we need to install all new ones.
-            if ($existingTables == 0) {
-                $dbVersion = false;
-
-            // Otherwise check if the number of tables is correct
-            } elseif ($tables != $existingTables) {
-                update_option('glmMembersInstallErrors', 'We do not have the correct number of tables for the currently set database version (V'.$dbVersion.') for the '.GLM_MEMBERS_PLUGIN_NAME.'.'
-                    ."<br>There should be $tables but there are currently $existingTables. Please call for support."
-                );
-                return false;
-            }
-
-        }
-
-        // If glmMembersDatabaseDbVersion is not set, install current version
-        if (!$dbVersion) {
-
-            // Get current database version
-            $dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION;
-
-            // 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
-            do {
-                $q = current($queries);
-                $this->wpdb->query($q);
-                $queryError = $this->wpdb->last_error;
-            } while ($queryError == '' && next($queries));
-
-            // If there were no errors
-            if (trim($queryError) == '') {
-
-                // Notify the user that the database has been installed
-                update_option('glmMembersInstallErrors', 'New database tables installed for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.');
-
-                // Save the version of the installed database
-                update_option('glmMembersDatabaseDbVersion', $dbVersion);
-
-                // Indicate that we were successfull
-                $db_setup_status = true;
-
-            } else {
-                update_option('glmMembersInstallErrors', 'Failure installing database tables for the '.GLM_MEMBERS_PLUGIN_NAME
-                    .'<br><b>Database Installation Error:</b> '.print_r($queryError,1)
-                    .'<br><pre>'.$q.'</pre>'
-                );
-            }
-
-        // Otherwise, check if we need to update the database
-        } elseif ($dbVersion != GLM_MEMBERS_PLUGIN_DB_VERSION) {
-
-            // Include an admin message that we're updating the database
-            $this->addNotice('<b>The '.GLM_MEMBERS_PLUGIN_NAME.' database tables require updating...</b>');
-
-            // Check if current glmMembersDatabaseDbVersion is invalid
-            if (!in_array(GLM_MEMBERS_PLUGIN_DB_VERSION, $this->dbVersions)) {
-                $this->addNotice('The database version currently installed for this plugin is unknown. '
-                    .'Unable to install the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.<br>'
-                    .'This could be due to an option naming conflict.');
-
-            }
-
-            // Traverse version list to find any required updates
-            $curVerFound = false;
-            $db_setup_status = true;
-            foreach($this->dbVersions as $ver) {
-
-                // Find the current version of the database
-                if ($ver == $dbVersion) {
-                    $this->addNotice('The database version installed for the '.GLM_MEMBERS_PLUGIN_NAME
-                            .' plugin is current and does not require updating.');
-                    $db_setup_status = true;
-
-                // Otherwise if it's already been found and $ver is not the new target version
-                } elseif ($curVerFound && $dbVersion != GLM_MEMBERS_PLUGIN_DB_VERSION) {
-
-                    // Build database update script name
-                    $updateScript = $dbVersion.'_'.$ver;
-
-                    // Read in Database creation script
-                    $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/update_database_V'.$dbVersion.'_V'.$ver.'.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 update database
-                    do {
-                        $q = current($queries);
-                        $this->wpdb->query($q);
-                        $queryError = $this->wpdb->last_error;
-                    } while ($queryError == '' && next($queries));
-
-                    // If there were no errors
-                    if ($queryError == '') {
-                        $this->addNotice('The database for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin has been updated '
-                            .'from V'.$dbVersion.'_V'.$ver.'.');
-                    } else {
-                        $this->addNotice('Failure updating the database tables for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin '
-                            .'from V'.$dbVersion.'_V'.$ver.'.');
-                        $db_setup_status = false;
-                        $this->addNotice('<b>Database Update Error:</b> '.$queryError, 'Alert');
-                    }
-
-                }
-
-                $dbVersion = $ver;
-
-                // Save the new version. If we've had a problem updating the database, then stop here.
-                if ($db_setup_status) {
-
-                    // Save the version of the installed database
-                    update_option('glmMembersDatabaseDbVersion', $dbVersion);
-
-                } else {
-                    break;
-                }
-
-            }
-
-            if ($db_setup_status) {
-
-                // Save the updated version of the installed database
-//                update_option('glmMembersDatabaseDbVersion', $dbVersion);
-
-                $this->addNotice('<b>Database tables updated.</b>');
-            }
-
-        } else {
-            $this->addNotice('The '.GLM_MEMBERS_PLUGIN_NAME.' has been reactivated using the existing database tables.');
-            $db_setup_status = true;
-        }
-
-        return $db_setup_status;
-    }
-
     /*
      * Add a role capability to all current roles
      *
index a8a0c9b..110f5c1 100644 (file)
@@ -132,6 +132,13 @@ class GlmDataMemberInfo extends GlmDataAbstract
                                'use' => 'lg'
                        ),
 
+                       // Member Name (stored by member updates) for sorting
+                       'member_slug' => array(
+                        'field' => 'member_slug',
+                               'type' => 'text',
+                               'use' => 'a'
+                       ),
+
                        // Member Pointer index
                        'member_pointer' => array (
                                'field' => 'member',
index 6fbd349..336c953 100644 (file)
@@ -148,7 +148,7 @@ class GlmDataSettingsGeneral extends GlmDataAbstract
                 ),
 
                 /*
-                 * Google Maps
+                 * Misc Settings
                  */
 
                 // Google Maps API Key
@@ -172,9 +172,13 @@ class GlmDataSettingsGeneral extends GlmDataAbstract
                         'use'      => 'a'
                 ),
 
-                /*
-                 * Misc Settings
-                 */
+                // Google Maps Default Zoom
+                'maps_default_zoom' => array(
+                        'field' => 'maps_default_zoom',
+                        'type' => 'integer',
+                        'default' => 10,
+                        'use' => 'a'
+                ),
 
                 // Time Zone
                 'time_zone' => array(
@@ -183,6 +187,13 @@ class GlmDataSettingsGeneral extends GlmDataAbstract
                         'use' => 'a'
                 ),
 
+                // Canonical Member Page Name
+                'canonical_member_page' => array(
+                        'field' => 'canonical_member_page',
+                        'type' => 'text',
+                        'use' => 'a'
+                ),
+
                 /*
                  * Front-end Member Search Options
                  */
@@ -357,6 +368,14 @@ class GlmDataSettingsGeneral extends GlmDataAbstract
                         'use' => 'a'
                 ),
 
+                // Front-end Listings - Show E-Mail
+                'list_show_email' => array(
+                        'field' => 'list_show_email',
+                        'type' => 'checkbox',
+                        'default' => true,
+                        'use' => 'a'
+                ),
+
                 // Front-end Listings - Show Categories
                 'list_show_categories' => array(
                         'field' => 'list_show_categories',
@@ -498,6 +517,14 @@ class GlmDataSettingsGeneral extends GlmDataAbstract
                         'use' => 'a'
                 ),
 
+                // Front-end Listings - Map Show E-Mail
+                'list_map_show_email' => array(
+                        'field' => 'list_map_show_email',
+                        'type' => 'checkbox',
+                        'default' => false,
+                        'use' => 'a'
+                ),
+
                 // Front-end Listings - Map Show Categories
                 'list_map_show_categories' => array(
                         'field' => 'list_map_show_categories',
@@ -647,6 +674,14 @@ class GlmDataSettingsGeneral extends GlmDataAbstract
                         'use' => 'a'
                 ),
 
+                // Front-end Memnber Detail - Show E-Mail
+                'detail_show_email' => array(
+                        'field' => 'detail_show_email',
+                        'type' => 'checkbox',
+                        'default' => false,
+                        'use' => 'a'
+                ),
+
                 // Front-end Member Detail - Show Categories
                 'detail_show_categories' => array(
                         'field' => 'detail_show_categories',
@@ -679,6 +714,22 @@ class GlmDataSettingsGeneral extends GlmDataAbstract
                         'use' => 'a'
                 ),
 
+                // Front-end Member Detail - Show Coupons
+                'detail_show_coupons' => array(
+                        'field' => 'detail_show_coupons',
+                        'type' => 'checkbox',
+                        'default' => false,
+                        'use' => 'a'
+                ),
+
+                // Front-end Member Detail - Show Coupons
+                'detail_show_packages' => array(
+                        'field' => 'detail_show_packages',
+                        'type' => 'checkbox',
+                        'default' => false,
+                        'use' => 'a'
+                ),
+
                 /*
                  * Front-end Member Detail Map Options
                  */
@@ -788,6 +839,14 @@ class GlmDataSettingsGeneral extends GlmDataAbstract
                         'use' => 'a'
                 ),
 
+                // Front-end Detail - Map Show Email
+                'detail_map_show_email' => array(
+                        'field' => 'detail_map_show_email',
+                        'type' => 'checkbox',
+                        'default' => false,
+                        'use' => 'a'
+                ),
+
                 // Front-end Detail - Map Show Categories
                 'detail_map_show_categories' => array(
                         'field' => 'detail_map_show_categories',
index fc7260d..0b6cb65 100644 (file)
 class GlmPluginSupport
 {
 
+    /**
+     * Plugin Versions
+     *
+     * An array of past and current Member Database versions.
+     * Note that Database Versions match plugin versions.
+     *
+     * Each entry below uses a key so code can find data on
+     * a specific version and in the values are the version
+     * again and the proper number of tables that should
+     * exist with that version.
+     *
+     * @var $Versions
+     * @access private
+     */
+    public $dbVersions = array(
+            '0.1' => array('version' => '0.1', 'tables' => 26),
+            '1.0.28' => array('version' => '1.0.28', 'tables' => 26)
+    );
+
     /*
      * Add a message to the 'glmMembersAdminNotices' option for output later.
      *
@@ -155,6 +174,200 @@ class GlmPluginSupport
 
     }
 
+    /*
+     * Check if database is installed and if it matches the current version
+     *
+     * @param string $capability Name of capability to add
+     * @param string $default Whether capability should be on by default
+     *
+     * @return void
+     * @access private
+     */
+    public function checkDatabase ()
+    {
+
+        $dbVersion = get_option('glmMembersDatabaseDbVersion');
+        $db_setup_status = false;
+
+        // Do a quick check for there being a database version but not all the required tables for that version
+        if ($dbVersion) {
+
+            // Check if the database version set for this plugin is invalid.
+            if (!isset($this->dbVersions[$dbVersion])) {
+                update_option('glmMembersInstallErrors', "The last database version set for the ".GLM_MEMBERS_PLUGIN_NAME." (V$dbVersion) isn't valid.");
+                return false;
+            }
+
+            // Get the number of tables for this plugin database version that should exist.
+            $tables = $this->dbVersions[$dbVersion]['tables'];
+
+            // Get the number of tables for this plugin that do currently exist.
+            $existingTables = $this->wpdb->get_var("
+                SELECT COUNT(*)
+                  FROM information_schema.tables
+                 WHERE table_name like '".GLM_MEMBERS_PLUGIN_DB_PREFIX."%';
+            ");
+
+            // If there's no tables, just assume we need to install all new ones.
+            if ($existingTables == 0) {
+                $dbVersion = false;
+
+                // Otherwise check if the number of tables is correct
+            } elseif ($tables != $existingTables) {
+                update_option('glmMembersInstallErrors', 'We do not have the correct number of tables for the currently set database version (V'.$dbVersion.') for '.GLM_MEMBERS_PLUGIN_NAME.'.'
+                        ."<br>There should be $tables but there are currently $existingTables. Please call for support."
+                );
+                return false;
+            }
+
+        }
+
+        // If glmMembersDatabaseDbVersion is not set, install current version
+        if (!$dbVersion) {
+
+            // Get current database version
+            $dbVersion = GLM_MEMBERS_PLUGIN_DB_VERSION;
+
+            // 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
+            do {
+                $q = current($queries);
+                $this->wpdb->query($q);
+                $queryError = $this->wpdb->last_error;
+            } while ($queryError == '' && next($queries));
+
+            // If there were no errors
+            if (trim($queryError) == '') {
+
+                // Notify the user that the database has been installed
+                update_option('glmMembersInstallErrors', 'New database tables installed for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.');
+
+                // Save the version of the installed database
+                update_option('glmMembersDatabaseDbVersion', $ver);
+
+                // Indicate that we were successfull
+                $db_setup_status = true;
+
+            } else {
+                update_option('glmMembersInstallErrors', 'Failure installing database tables for the '.GLM_MEMBERS_PLUGIN_NAME
+                        .'<br><b>Database Installation Error:</b> '.print_r($queryError,1)
+                        .'<br><pre>'.$q.'</pre>'
+                );
+            }
+
+        // Otherwise, check if we need to update the database
+        } elseif ($dbVersion != GLM_MEMBERS_PLUGIN_DB_VERSION) {
+
+            // Include an admin message that we're updating the database
+            $this->addNotice('<b>The '.GLM_MEMBERS_PLUGIN_NAME.' database tables require updating...</b>');
+
+            // Check if current glmMembersDatabaseDbVersion is invalid
+            if (!in_array(GLM_MEMBERS_PLUGIN_DB_VERSION, $this->dbVersions)) {
+                $this->addNotice('The database version currently installed for this plugin is unknown. '
+                        .'Unable to install/update the '.GLM_MEMBERS_PLUGIN_NAME.' plugin.<br>');
+            }
+
+            // Traverse version list to find any required updates
+            $curVerFound = false;
+            $db_setup_status = true;
+            foreach($this->dbVersions as $version) {
+
+                $ver = $version['version'];
+
+                // Find the current version of the database
+                if ($ver == $dbVersion) {
+//                    $this->addNotice('The database version installed for the '.GLM_MEMBERS_PLUGIN_NAME
+//                            .' plugin is current and does not require updating.');
+                    $db_setup_status = true;
+                    $curVerFound = true;
+
+                    // Otherwise if it's already been found and $ver is not the new target version
+                } elseif ($curVerFound && $dbVersion != GLM_MEMBERS_PLUGIN_DB_VERSION) {
+
+                    // Build database update script name
+                    $updateScript = $dbVersion.'_'.$ver;
+
+                    // Read in Database creation script
+                    $sqlFile = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/update_database_V'.$ver.'.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 update database
+                    do {
+                        $q = current($queries);
+                        $this->wpdb->query($q);
+                        $queryError = $this->wpdb->last_error;
+                    } while ($queryError == '' && next($queries));
+
+                    // Check for PHP script to update database
+                    $phpScript = GLM_MEMBERS_PLUGIN_DB_SCRIPTS.'/update_database_V'.$ver.'.php';
+
+                    if (is_file($phpScript)) {
+                        include ($phpScript);
+                    }
+
+                    // If there were no errors
+                    if ($queryError == '') {
+
+
+
+
+                        $this->addNotice('The database for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin has been updated '
+                                .'from V'.$dbVersion.'_V'.$ver.'.');
+                    } else {
+                        $this->addNotice('Failure updating the database tables for the '.GLM_MEMBERS_PLUGIN_NAME.' plugin '
+                                .'from V'.$dbVersion.'_V'.$ver.'.');
+                        $db_setup_status = false;
+                        $this->addNotice('<b>Database Update Error:</b> '.$queryError, 'Alert');
+                    }
+
+                }
+
+                $dbVersion = $ver;
+
+                // Save the new version. If we've had a problem updating the database, then stop here.
+                if ($db_setup_status) {
+
+                    // Save the version of the installed database
+                    update_option('glmMembersDatabaseDbVersion', $dbVersion);
+
+                } else {
+                    break;
+                }
+
+            }
+
+            if ($db_setup_status) {
+
+                // Save the updated version of the installed database
+                //                update_option('glmMembersDatabaseDbVersion', $dbVersion);
+
+                $this->addNotice('<b>Database tables updated.</b>');
+            }
+
+        } else {
+//            $this->addNotice('The '.GLM_MEMBERS_PLUGIN_NAME.' has been reactivated using the existing database tables.');
+//            $db_setup_status = true;
+        }
+
+        return $db_setup_status;
+    }
+
+
 }
 
 ?>
\ No newline at end of file
index b5f2e77..fa85c65 100644 (file)
@@ -22,14 +22,6 @@ $config['countries'] = $countryData['countries'];
 $settings = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "settings_general WHERE id = 1;", ARRAY_A);
 unset($settings['id']);
 
-// ************* NEED TO ADD TO MANAGEMENT SETTINGS - Might require database changes **************
-$settings['list_show_email'] = true;
-$settings['list_map_show_email'] = true;
-$settings['mapDefaultZoom'] = 10;
-$settings['detail_show_coupons'] = false;
-$settings['detail_show_packages'] = false;
-// ***************************************************************
-
 $config['settings'] = $settings;
 $terms = $wpdb->get_row("SELECT * FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX . "settings_terms WHERE id = 1;", ARRAY_A);
 unset($terms['id']);
index 651a757..2f10f8a 100644 (file)
@@ -185,6 +185,9 @@ class glmMembersAdmin extends GlmPluginSupport
         // Save plugin configuration object
         $this->config = $config;
 
+        // Check the database
+        $this->checkDatabase();
+
         /*
          * Check if there's a request to bypass the WordPress Dashboard and
          * display directly to the browser using a specified
index 164a6e8..d0ba49b 100644 (file)
@@ -73,6 +73,21 @@ class glmMembersFront extends GlmPluginSupport
         // Save plugin configuration object
         $this->config = $config;
 
+        // Check if database needs to be setup or updated
+        $this->checkDatabase();
+
+        // Setup rewrite for member detail pages
+        add_filter( 'rewrite_rules_array',
+                array(
+                        $this,
+                        'glm_members_insert_rewrite_rules'
+                ));
+        add_action( 'wp_loaded',
+                array(
+                        $this,
+                        'glm_members_flush_rules'
+                ));
+
         // Add front-end scripts and css
         add_action('wp_enqueue_scripts',
                 array(
@@ -94,6 +109,28 @@ class glmMembersFront extends GlmPluginSupport
 
     }
 
+    // Flush rules if the member detail rewrite hasn't been included
+    function glm_members_flush_rules(){
+        $rules = get_option( 'rewrite_rules' );
+//        if ( ! isset( $rules['('.$this->config['settings']['canonical_member_page'].')/(.*+)/?$'] ) ) {
+            global $wp_rewrite;
+            $wp_rewrite->flush_rules();
+  //      }
+    }
+
+    // Add the rewrite rule for the member detail page
+    function glm_members_insert_rewrite_rules( $rules )
+    {
+        $newrules = array();
+//        $newrules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)/?$'] = 'index.php?pagename=$matches[1]&member=$matches[2]';
+          $newrules['('.$this->config['settings']['canonical_member_page'].')/([^/]*)/?$'] = 'index.php?pagename=$matches[1]&member=$matches[2]';
+        $ret = $newrules + $rules;
+var_dump($newrules);
+echo "<P>";var_dump($_REQUEST);
+//echo "<pre>".print_r($ret,1)."</pre>";
+        return $ret;
+    }
+
     /**
      * Setup inclusion of front-end scripts and css
      *
index 16e25ff..6ae6206 100644 (file)
@@ -5,6 +5,8 @@
  * Set standard defined parameters
  */
 
+// NOTE: Plugin & Database versions are defined in "/glm-member-db.php".
+
 define('GLM_MEMBERS_PLUGIN_NAME', 'Gaslight Media Members Database');
 define('GLM_MEMBERS_PLUGIN_DIR', 'glm-member-db');
 
@@ -22,10 +24,6 @@ if (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == '443') {
 }
 define('GLM_MEMBERS_PLUGIN_HTTP_PROTOCOL', $pageProtocol);
 
-// Plugin Versions
-define('GLM_MEMBERS_PLUGIN_VERSION', 0.1);
-define('GLM_MEMBERS_PLUGIN_DB_VERSION', 0.1);
-
 // Get various pieces of the URL
 $urlParts = parse_url(get_bloginfo('url'));
 $pageUri = explode('?', $_SERVER['REQUEST_URI']);               // Bust this up to access URL path and script name only
@@ -34,6 +32,7 @@ $adminURL = admin_url('admin.php');
 $WPUploadDir = wp_upload_dir();
 
 // URLs
+define('GLM_MEMBERS_SITE_BASE_URL', $pageProtocol.'://'.$urlParts['host'].$urlParts['path'].'/');
 define('GLM_MEMBERS_PLUGIN_ADMIN_URL', $adminURL);
 define('GLM_MEMBERS_PLUGIN_URL', plugin_dir_url(__FILE__));
 define('GLM_MEMBERS_PLUGIN_BASE_URL', WP_PLUGIN_URL.'/'.GLM_MEMBERS_PLUGIN_DIR);
index 1fd17b5..fdb4ade 100644 (file)
  * @version 1.0.28
  */
 
+/*
+ *  Plugin and Database Versions
+ *
+ *  Note that the database version matches the version of the last
+ *  plugin version where there was a change in the database.
+ *
+ *  Updates to checkDatabase() in glmPluginSupport.php must be
+ *  made together with the DB_VERSION below.
+ */
+define('GLM_MEMBERS_PLUGIN_VERSION', '1.0.28');
+define('GLM_MEMBERS_PLUGIN_DB_VERSION', '1.0.28');
+
 /*
  * Copyright 2014 Charles Scott (email : cscott@gaslightmedia.com)
  *
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-$startupNotices = '';
-
-// Get standard defined parameters
-require_once('defines.php');
-
-// Get configuration
-require_once('config.php');
-
-// Try to set the DB version option to false (new plugin) - If it's already set this won't do anything.
-add_option('glmMembersDatabaseDbVersion', false);
-
 /**
  * *******************************************************************************
  *
@@ -178,6 +179,21 @@ add_option('glmMembersDatabaseDbVersion', false);
  * ********************************************************************************
  */
 
+/*
+ * Some initial setup and tests
+ */
+
+$startupNotices = '';
+
+// Get standard defined parameters
+require_once('defines.php');
+
+// Get configuration
+require_once('config.php');
+
+// Try to set the DB version option to false (new plugin) - If it's already set this won't do anything.
+add_option('glmMembersDatabaseDbVersion', false);
+
 /*
  *
  * Activate, Deactivate, Uninstall hooks
index 50c0381..3fc87ce 100644 (file)
@@ -4,7 +4,7 @@
 -- Database Creation Script
 -- 
 -- To permit each query below to be executed separately,
--- all queries must be separated by a line with ----
+-- all queries must be separated by a line with four dashes
 
 
 CREATE TABLE {prefix}accommodation_types (
@@ -383,6 +383,7 @@ CREATE TABLE {prefix}member_info (
   id INT NOT NULL AUTO_INCREMENT,
   member INT NULL,
   member_name TINYTEXT NULL,
+  member_slug TINYTEXT NULL,
   status INT NULL,
   reference_name TINYTEXT NULL,
   descr TEXT NULL,
@@ -483,7 +484,9 @@ CREATE TABLE {prefix}settings_general (
   google_maps_api_key TINYTEXT DEFAULT '',
   maps_default_lat FLOAT DEFAULT 45.3749,
   maps_default_lon FLOAT DEFAULT -84.9592,
+  maps_default_zoom INTEGER DEFAULT 10,
   time_zone TINYTEXT NULL,
+  canonical_member_page TINYTEXT NULL;
   list_show_map BOOLEAN DEFAULT true,
   list_show_list BOOLEAN DEFAULT true,
   list_show_search BOOLEAN DEFAULT true,
@@ -505,6 +508,7 @@ CREATE TABLE {prefix}settings_general (
   list_show_tollfree BOOLEAN DEFAULT true,
   list_show_url BOOLEAN DEFAULT true,
   list_show_url_newtarget BOOLEAN DEFAULT true,
+  list_show_email BOOLEAN DEFAULT true,
   list_show_categories BOOLEAN DEFAULT true,
   list_show_creditcards BOOLEAN DEFAULT true,
   list_show_amenities BOOLEAN DEFAULT false,
@@ -522,6 +526,7 @@ CREATE TABLE {prefix}settings_general (
   list_map_show_tollfree BOOLEAN DEFAULT true,
   list_map_show_url BOOLEAN DEFAULT true,
   list_map_show_url_newtarget BOOLEAN DEFAULT true,
+  list_map_show_email BOOLEAN DEFAULT true,
   list_map_show_categories BOOLEAN DEFAULT false,
   list_map_show_creditcards BOOLEAN DEFAULT false,
   list_map_show_amenities BOOLEAN DEFAULT false,
@@ -540,10 +545,13 @@ CREATE TABLE {prefix}settings_general (
   detail_show_tollfree BOOLEAN DEFAULT true,
   detail_show_url BOOLEAN DEFAULT true,
   detail_show_url_newtarget BOOLEAN DEFAULT true,
+  detail_show_email BOOLEAN DEFAULT true,
   detail_show_categories BOOLEAN DEFAULT true,
   detail_show_creditcards BOOLEAN DEFAULT true,
   detail_show_amenities BOOLEAN DEFAULT true,
   detail_show_imagegallery BOOLEAN DEFAULT true,
+  detail_show_coupons BOOLEAN DEFAULT false,
+  detail_show_packages BOOLEAN DEFAULT false,
   detail_map_show_logo BOOLEAN DEFAULT false,
   detail_map_logo_size TINYTEXT NULL,
   detail_map_show_descr BOOLEAN DEFAULT false,
@@ -557,6 +565,7 @@ CREATE TABLE {prefix}settings_general (
   detail_map_show_tollfree BOOLEAN DEFAULT true,
   detail_map_show_url BOOLEAN DEFAULT true,
   detail_map_show_url_newtarget BOOLEAN DEFAULT true,
+  detail_map_show_email BOOLEAN DEFAULT true,
   detail_map_show_categories BOOLEAN DEFAULT false,
   detail_map_show_creditcards BOOLEAN DEFAULT false,
   detail_map_show_amenities BOOLEAN DEFAULT false,
@@ -566,9 +575,9 @@ CREATE TABLE {prefix}settings_general (
 ----
 
 INSERT INTO {prefix}settings_general
-    ( id, time_zone )
+    ( id, time_zone, canonical_member_page )
    VALUES
-    ( 1, 'America/Detroit' )
+    ( 1, 'America/Detroit', 'member-detail' )
 ;
 
 ----
diff --git a/misc/databaseScripts/update_database_V1.0.28.php b/misc/databaseScripts/update_database_V1.0.28.php
new file mode 100644 (file)
index 0000000..7862727
--- /dev/null
@@ -0,0 +1,25 @@
+<?php
+/*
+ * Gaslight Media Members Database
+ *
+ * Database Update Script for version 1.0.28
+ */
+
+// Update member_info records with member name slug for URLs
+$infoRecords = $this->wpdb->get_results('SELECT id, member_name FROM '.GLM_MEMBERS_PLUGIN_DB_PREFIX.'member_info;', ARRAY_A);
+if ($infoRecords && count($infoRecords) > 0) {
+    foreach ($infoRecords as $i) {
+        $slug = sanitize_title($i['member_name']);
+        $this->wpdb->update(
+                GLM_MEMBERS_PLUGIN_DB_PREFIX.'member_info',
+                array(
+                        'member_slug' => $slug
+                ),
+                array( 'id' => $i['id'] ),
+                array( '%s' ),
+                array( '%d')
+        );
+    }
+}
+
+?>
\ No newline at end of file
diff --git a/misc/databaseScripts/update_database_V1.0.28.sql b/misc/databaseScripts/update_database_V1.0.28.sql
new file mode 100644 (file)
index 0000000..4f8a294
--- /dev/null
@@ -0,0 +1,47 @@
+-- Gaslight Media Members Database 
+-- File Created: 12/09/14 15:27:15
+-- Database Version: 1.0.28
+-- Database Update From Previous Version Script
+-- 
+-- To permit each query below to be executed separately,
+-- all queries must be separated by a line with four dashses
+
+
+ALTER TABLE {prefix}member_info ADD COLUMN member_slug TINYTEXT;
+
+----
+
+ALTER TABLE {prefix}settings_general ADD COLUMN list_show_email BOOLEAN DEFAULT true;
+
+----
+
+ALTER TABLE {prefix}settings_general ADD COLUMN list_map_show_email BOOLEAN DEFAULT true;
+
+----
+
+ALTER TABLE {prefix}settings_general ADD COLUMN maps_default_zoom integer DEFAULT 10;
+
+----
+
+ALTER TABLE {prefix}settings_general ADD COLUMN canonical_member_page TINYTEXT;
+
+----
+
+UPDATE {prefix}settings_general SET canonical_member_page = 'member';
+
+----
+
+ALTER TABLE {prefix}settings_general ADD COLUMN detail_show_email BOOLEAN DEFAULT true;
+
+----
+
+ALTER TABLE {prefix}settings_general ADD COLUMN detail_map_show_email BOOLEAN DEFAULT true;
+
+----
+
+ALTER TABLE {prefix}settings_general ADD COLUMN detail_show_coupons BOOLEAN DEFAULT false;
+
+----
+
+ALTER TABLE {prefix}settings_general ADD COLUMN detail_show_packages BOOLEAN DEFAULT false;
+
index e503e09..bd26995 100644 (file)
@@ -869,6 +869,7 @@ class GlmMembersAdmin_management_import
                                 array(
                                         'member' => $membID,
                                         'member_name' => $val['member_name'],
+                                        'member_slug' => sanitize_title($val['member_name']),
                                         'status' => $this->config['status_numb']['Active'],
                                         'reference_name' => 'Imported Member Information',
                                         'descr' => $val['description'],
@@ -895,6 +896,7 @@ class GlmMembersAdmin_management_import
                                 array(
                                         '%d',
                                         '%s',
+                                        '%s',
                                         '%d',
                                         '%s',
                                         '%s',
index bab96bb..01a3b90 100644 (file)
@@ -374,6 +374,8 @@ class GlmMembersAdmin_member_memberInfo extends GlmDataMemberInfo
                 // Clone the current member info
                 $this->memberInfoID = $CloneMemberInfo->cloneMemberInfo($this->memberInfoID);
 
+                $this->memberInfo = $this->editEntry($this->memberInfoID);
+
                 break;
 
             // Default is to display the currently selected member information record in a form for updates
index ffcba9e..179f569 100644 (file)
@@ -98,7 +98,8 @@ class GlmMembersFront_members_detail extends GlmDataMemberInfo
      */
     public function modelAction ($actionData = false)
     {
-
+//echo "top of modelAction() in front/members/detail.php<pre>".print_r($_REQUEST,1).print_r($actionData,1)."</pre>";exit;
+//echo "<pre>".print_r($_GET,1)."</pre>";
         $where = '';
         $haveMember = false;
         $haveImageGallery = false;
index 88ad297..1ed47b6 100644 (file)
@@ -251,6 +251,7 @@ class GlmMembersFront_members_list extends GlmDataMemberInfo
 
         // Compile template data
         $templateData = array(
+            'siteBaseUrl' => GLM_MEMBERS_SITE_BASE_URL,
             'haveMembers' => $haveMembers,
             'members' => $list,
             'haveFilter' => $haveFilter,
index 9243f1b..d913912 100644 (file)
                     {if $genSettings.fieldFail.maps_default_lat}<p>{$genSettings.fieldFail.maps_default_lat}</p>{/if}
                     {if $genSettings.fieldFail.maps_default_lon}<p>{$genSettings.fieldFail.maps_default_lon}</p>{/if}
                 </td>
+            </tr>
+             <tr>
+                <th>Google Maps Default Zoom:</th>
+                <td>
+                    <input type="text" name="maps_default_zoom" value="{$genSettings.fieldData.maps_default_zoom}">
+                </td>
             </tr>
             <tr>
                 <th {if $genSettings.fieldRequired.time_zone}class="glm-required"{/if}>Time Zone:</th>
                     {if $genSettings.fieldFail.time_zone}<p>{$genSettings.fieldFail.time_zone}</p>{/if}
                 </td>
             </tr>
+            <tr>
+               <th>Member Detail Page Permalink Name:</th>
+                <td>
+                    <input type="text" name="canonical_member_page" value="{$genSettings.fieldData.canonical_member_page}">
+                    <br>Use only the page name at the end of the permalink for the member detail page.
+                </td>
+            </tr>
             
             <!-- Member List Page Options -->
             
                                 Display URL as a link: <input type="checkbox" name="list_map_show_url_newtarget"{if $genSettings.fieldData.list_map_show_url_newtarget.value} checked="checked"{/if}>
                             </td>
                         </tr>
+                        <tr><th>Show E-mail:</th><td><input type="checkbox" name="list_map_show_email"{if $genSettings.fieldData.list_map_show_email.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Categories:</th><td><input type="checkbox" name="list_map_show_categories"{if $genSettings.fieldData.list_map_show_categories.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Credit Cards:</th><td><input type="checkbox" name="list_map_show_creditcards"{if $genSettings.fieldData.list_map_show_creditcards.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Amenitiies:</th><td><input type="checkbox" name="list_map_show_amenities"{if $genSettings.fieldData.list_map_show_amenities.value} checked="checked"{/if}></td></tr>
                                 Display URL as a link: <input type="checkbox" name="list_show_url_newtarget"{if $genSettings.fieldData.list_show_url_newtarget.value} checked="checked"{/if}>
                             </td>
                         </tr>
+                        <tr><th>Show E-Mail:</th><td><input type="checkbox" name="list_show_email"{if $genSettings.fieldData.list_show_email.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Categories:</th><td><input type="checkbox" name="list_show_categories"{if $genSettings.fieldData.list_show_categories.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Credit Cards Accepted:</th><td><input type="checkbox" name="list_show_creditcards"{if $genSettings.fieldData.list_show_creditcards.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Amenities:</th><td><input type="checkbox" name="list_show_amenities"{if $genSettings.fieldData.list_show_amenities.value} checked="checked"{/if}></td></tr>
                                 Display URL as a link: <input type="checkbox" name="detail_map_show_url_newtarget"{if $genSettings.fieldData.detail_map_show_url_newtarget.value} checked="checked"{/if}>
                             </td>
                         </tr>
+                        <tr><th>Show E-mail:</th><td><input type="checkbox" name="detail_map_show_email"{if $genSettings.fieldData.detail_map_show_email.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Categories:</th><td><input type="checkbox" name="detail_map_show_categories"{if $genSettings.fieldData.detail_map_show_categories.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Credit Cards:</th><td><input type="checkbox" name="detail_map_show_creditcards"{if $genSettings.fieldData.detail_map_show_creditcards.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Amenitiies:</th><td><input type="checkbox" name="detail_map_show_amenities"{if $genSettings.fieldData.detail_map_show_amenities.value} checked="checked"{/if}></td></tr>
                                 Display URL as a link: <input type="checkbox" name="detail_show_url_newtarget"{if $genSettings.fieldData.detail_show_url_newtarget.value} checked="checked"{/if}>
                             </td>
                         </tr>
+                        <tr><th>Show E-mail:</th><td><input type="checkbox" name="detail_show_email"{if $genSettings.fieldData.detail_show_email.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Categories:</th><td><input type="checkbox" name="detail_show_categories"{if $genSettings.fieldData.detail_show_categories.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Credit Cards Accepted:</th><td><input type="checkbox" name="detail_show_creditcards"{if $genSettings.fieldData.detail_show_creditcards.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Amenities:</th><td><input type="checkbox" name="detail_show_amenities"{if $genSettings.fieldData.detail_show_amenities.value} checked="checked"{/if}></td></tr>
                         <tr><th>Show Image Gallery:</th><td><input type="checkbox" name="detail_show_imagegallery"{if $genSettings.fieldData.detail_show_imagegallery.value} checked="checked"{/if}></td></tr>
+                        <tr><th>Show Coupons:</th><td><input type="checkbox" name="detail_show_coupons"{if $genSettings.fieldData.detail_show_coupons.value} checked="checked"{/if}></td></tr>
+                        <tr><th>Show Packages:</th><td><input type="checkbox" name="detail_show_packages"{if $genSettings.fieldData.detail_show_packages.value} checked="checked"{/if}></td></tr>
                     </table>
                 </td>
             </tr>
index c4eba6e..92e8e64 100644 (file)
                 <th>Member Name:</th>
                 <td>{$member.name}</td>
             </tr>
+            <tr>
+                <th {if $memberInfo.fieldRequired.member_slug}class="glm-required"{/if}>Name for URLs:</th>
+                <td {if $memberInfo.fieldFail.member_slug}class="glm-form-bad-input"{/if}>
+                    <input type="text" name="member_slug" value="{$memberInfo.fieldData.member_slug}" class="glm-form-text-input" placeholder="Slug of member name used for URLs.">
+                    {if $memberInfo.fieldFail.member_slug}<p>{$memberInfo.fieldFail.member_slug}</p>{/if}
+                </td>
+            </tr>
             <tr>
                 <th>Member Type:</th>
                 <td>{$member.member_type.name}</td>
index 096820b..0379c8c 100644 (file)
@@ -21,8 +21,9 @@
     <table class="glm-admin-table">
         <tr><th>Shortcode</th><th>Attribute</th><th>Description</th></tr>
         <tr>
-            <th colspan="2">[glm-members-list]</th>
-            <td>
+            <th>[glm-members-list]</th>
+            <td>&nbsp;</td>
+            <td width="50%">
                 Displays a list of members and a map with markers for each member. Optionally, 
                 the attributes below may used to modify the display of this page.
             </td>
@@ -40,7 +41,8 @@
             </td>
         </tr>
         <tr>
-            <th colspan="2">[glm-member-detail]</th>
+            <th>[glm-member-detail]</th>
+            <td>&nbsp;</td>
             <td>
                 Displays details for a speicif member along with a map showing their location. The 
                 "id" attribute below is required to specify which member to display. 
                 id="{ member ID }"
             </th>
             <td>
-                This is a required attribute for [glm-member-detail] that specifies the ID of
+                This is an optional attribute for [glm-member-detail] that specifies the ID of
                 the desired member. The ID for a member is displayed both in the left column
                 of the member list and at the top of the Member Dashboard. Only one ID may
-                be specified.
+                be specified. If this attribute is not supplied, the page will look for a
+                member name slug as the last part of the path in the URL and try to locate
+                an active member information record with "Name for URLs" set to the same
+                string.
+                
             </td>
         </tr>
     </table>
index a918f87..342152c 100644 (file)
                 
                 // Set default - Need to make this configurable
                 var map = new google.maps.Map(document.getElementById('glm-locationMap'), {
-                       zoom: 14,
+                       zoom: {$settings.maps_default_zoom},
                        center: memberlocation,
                     disableDefaultUI: false,   
                     mapTypeId: google.maps.MapTypeId.MAP,  
index 45a0f32..7ac353e 100644 (file)
@@ -93,7 +93,8 @@
 <!-- Member name, address, and basic information -->                    
                         <h2>
               {if $settings.list_show_detail_link}
-                            <a href="{$thisURL}?glm_action=detail&id={$m.member_pointer}">{$m.member}</a>
+                            <a href="{$siteBaseUrl}{$settings.canonical_member_page}/{$m.member_slug}/">{$m.member}</a>
+
               {else}
                             {$m.member}
               {/if}
                 // Create a Google Map object
                 var map = new google.maps.Map(document.getElementById('glm-locationMap'), {
                        center: new google.maps.LatLng({$settings.maps_default_lat}, {$settings.maps_default_lon}),
-                       zoom: {$settings.mapDefaultZoom},
+                       zoom: {$settings.maps_default_zoom},
                     disableDefaultUI: false,   
                     mapTypeId: google.maps.MapTypeId.MAP,  
                 });