Fixed problems with NearMe plugin getting bad location data from lat/lon search
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 24 Oct 2019 20:49:09 +0000 (16:49 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 24 Oct 2019 20:49:09 +0000 (16:49 -0400)
classes/data/dataMemberInfo.php
classes/memberDataByLatLon.php

index 28bb446..b71cbf7 100755 (executable)
@@ -1,4 +1,5 @@
 <?php
+
 /**
  * GLM Member-DB WordPress Plugin
  * Members Basic Info data class
@@ -6,10 +7,10 @@
  * 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: dataMemberInfo.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
+ * @package GLM Member-DB
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release SVN: $Id: dataMemberInfo.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
  */
 
 /**
@@ -21,8 +22,7 @@
  * @package GLM Members Database Plugin
  * @author Chuck Scott <cscott@gaslightmedia.com>
  * @license http://www.gaslightmedia.com Gaslightmedia
- *          @release SVN: $Id: dataMemberInfo.php,v 1.0 2011/01/25 19:31:47 cscott
- *          Exp $
+ * @release SVN: $Id: dataMemberInfo.php,v 1.0 2011/01/25 19:31:47 cscott Exp $
  */
 class GlmDataMemberInfo extends GlmDataAbstract
 {
@@ -56,17 +56,16 @@ class GlmDataMemberInfo extends GlmDataAbstract
      */
     public $doPostProcessing = true;
     /**
-     * Individual post processing override
-     * Leave as false. Make true to force that specific
-     * post processing if $doPostProcessing is off.
+     * Individual post processing override Leave as false. Make true to force
+     * that specific post processing if $doPostProcessing is off.
      *
      * @var boolean
      * @access public
      */
-    public $postProcessAmenity = false;
-    public $postProcessCategory = false;
+    public $postProcessAmenity    = false;
+    public $postProcessCategory   = false;
     public $postProcessShortDescr = false;
-    public $postProcessCamUrl = false;
+    public $postProcessCamUrl     = false;
     /**
      * Post Processing Primary Contact flag
      *
@@ -75,26 +74,16 @@ class GlmDataMemberInfo extends GlmDataAbstract
      */
     public $postProcessPrimaryContact = false;
 
-
     /**
      * 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()
+     * '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
+     * '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
@@ -104,24 +93,23 @@ class GlmDataMemberInfo extends GlmDataAbstract
     /**
      * Constructor
      *
-     * @param object $d
-     *         database connection
+     * @param object
+     *            $d database connection
      *
      * @return void
      * @access public
      */
-    function __construct($wpdb, $config)
-    {
+    function __construct( $wpdb, $config ) {
 
-        // If this class is not being extended along with existing $wpdb and $config
-        if (!$this->wpdb) {
+        // 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;
-
         }
 
         /*
@@ -132,559 +120,562 @@ class GlmDataMemberInfo extends GlmDataAbstract
         /*
          * Table Data Fields
          */
-        $this->fields = array (
+        $this->fields = array(
 
-            'id' => array (
-                'field' => 'id',
-                'type' => 'integer',
+            'id' => array(
+                'field'     => 'id',
+                'type'      => 'integer',
                 'view_only' => true,
-                'use' => 'a'
+                'use'       => 'a'
             ),
 
             // Old Member ID
-            'old_id' => array (
-                'field' => 'member',
-                'as' => 'old_id',
-                'type' => 'pointer',
-                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
-                    'p_field' => 'old_member_id',
-                    'p_static' => true,
+            'old_id' => array(
+                'field'    => 'member',
+                'as'       => 'old_id',
+                'type'     => 'pointer',
+                'p_table'  => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
+                'p_field'  => 'old_member_id',
+                'p_static' => true,
                 'required' => true,
-                'use' => 'lgneud'
+                'use'      => 'lgneud'
             ),
 
             // Member Pointer
-            'member' => array (
-                'field' => 'member',
-                'type' => 'pointer',
-                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
-                    'p_field' => 'name',
-                    'p_static' => true,
+            'member' => array(
+                'field'    => 'member',
+                'type'     => 'pointer',
+                'p_table'  => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
+                'p_field'  => 'name',
+                'p_static' => true,
                 'required' => true,
-                'use' => 'a'
+                'use'      => 'a'
             ),
 
             // Member Name (stored by member updates) for sorting
             'member_name' => array(
                 'field' => 'member_name',
-                'type' => 'text',
-                'use' => 'lg'
+                'type'  => 'text',
+                'use'   => 'lg'
             ),
 
             // Member Slug
-            'member_slug' => array (
-                'field' => 'member',
-                'as' => 'member_slug',
-                'type' => 'pointer',
-                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
-                    'p_field' => 'member_slug',
-                    'p_static' => true,
+            'member_slug'  => array(
+                'field'    => 'member',
+                'as'       => 'member_slug',
+                'type'     => 'pointer',
+                'p_table'  => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
+                'p_field'  => 'member_slug',
+                'p_static' => true,
                 'required' => true,
-                'use' => 'gle'
+                'use'      => 'gle'
             ),
 
             // Member Slug
-            'member_slug_view_only' => array (
-                'field' => 'member',
-                'as' => 'member_slug',
-                'type' => 'pointer',
-                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
-                    'p_field' => 'member_slug',
-                    'p_static' => true,
+            'member_slug_view_only' => array(
+                'field'     => 'member',
+                'as'        => 'member_slug',
+                'type'      => 'pointer',
+                'p_table'   => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
+                'p_field'   => 'member_slug',
+                'p_static'  => true,
                 'view_only' => true,
-                'use' => 'u'
+                'use'       => 'u'
             ),
 
             // Member Featured
-            'featured' => array (
-                'field' => 'member',
-                'as' => 'featured',
-                'type' => 'pointer',
-                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
-                    'p_field' => 'featured',
-                    'p_static' => true,
+            'featured' => array(
+                'field'    => 'member',
+                'as'       => 'featured',
+                'type'     => 'pointer',
+                'p_table'  => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members',
+                'p_field'  => 'featured',
+                'p_static' => true,
                 'required' => false,
-                'use' => 'gle'
+                'use'      => 'gle'
             ),
 
             // Member Pointer index
-            'member_pointer' => array (
-                'field' => 'member',
-                'as' => 'member_pointer',
-                'type' => 'integer',
+            'member_pointer' => array(
+                'field'    => 'member',
+                'as'       => 'member_pointer',
+                'type'     => 'integer',
                 'required' => true,
-                'use' => 'gle'
+                'use'      => 'gle'
             ),
 
             // Reference Name - Not displayed to user
-            'reference_name' => array (
-                'field' => 'reference_name',
-                'type' => 'text',
+            'reference_name' => array(
+                'field'    => 'reference_name',
+                'type'     => 'text',
                 'required' => true,
-                'use' => 'a'
+                'use'      => 'a'
             ),
 
             // Status
-            'status' => array (
-                'field' => 'status',
-                'type' => 'list',
-                'list' => $this->config['status'],
+            'status' => array(
+                'field'    => 'status',
+                'type'     => 'list',
+                'list'     => $this->config['status'],
                 'required' => true,
-                'default' => $this->config['status_numb']['Pending'],
-                'use' => 'a'
+                'default'  => $this->config['status_numb']['Pending'],
+                'use'      => 'a'
             ),
 
             // Has no map data
             'has_no_map_data' => array(
                 'field' => 'has_no_map_data',
                 'type'  => 'checkbox',
-                'use'   => 'a',
+                'use'   => 'a'
             ),
 
             // Has no profile page
             'has_no_profile' => array(
                 'field' => 'has_no_profile',
                 'type'  => 'checkbox',
-                'use'   => 'a',
+                'use'   => 'a'
             ),
 
             // Address Line 1
-            'addr1' => array (
+            'addr1' => array(
                 'field' => 'addr1',
-                'type' => 'text',
-                'use' => 'a'
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // Address Line 2
-            'addr2' => array (
+            'addr2' => array(
                 'field' => 'addr2',
-                'type' => 'text',
-                'use' => 'a'
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // City
-            'city' => array (
-                'field' => 'city',
-                'type' => 'pointer',
-                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'cities',
-                    'p_field' => 'name',
-                    'p_orderby' => 'name',
-                'use' => 'a'
+            'city' => array(
+                'field'     => 'city',
+                'type'      => 'pointer',
+                'p_table'   => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'cities',
+                'p_field'   => 'name',
+                'p_orderby' => 'name',
+                'use'       => 'a'
             ),
 
             // City
-            'city_id' => array (
+            'city_id' => array(
                 'field' => 'city',
                 'as'    => 'city_id',
-                'type' => 'integer',
-                'use' => 'gl'
+                'type'  => 'integer',
+                'use'   => 'gl'
             ),
 
             // State
-            'state' => array (
-                'field' => 'state',
-                'type' => 'list',
-                'list' => $this->config['states'],
-                'default'  => $this->config['settings']['default_state'],
-                'use' => 'a'
+            'state' => array(
+                'field'   => 'state',
+                'type'    => 'list',
+                'list'    => $this->config['states'],
+                'default' => $this->config['settings']['default_state'],
+                'use'     => 'a'
             ),
 
             // ZIP / Postal Code
-            'zip' => array (
+            'zip' => array(
                 'field' => 'zip',
-                'type' => 'text',
-                'use' => 'a'
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // Country
-            'country' => array (
-                'field' => 'country',
-                'type' => 'list',
-                'list' => $this->config['countries'],
+            'country' => array(
+                'field'   => 'country',
+                'type'    => 'list',
+                'list'    => $this->config['countries'],
                 'default' => 'US',
-                'use' => 'a'
+                'use'     => 'a'
             ),
 
             // Latitude
             'lat' => array(
-                'field'    => 'lat',
-                'type'     => 'float',
-                'default'  => $this->config['settings']['maps_default_lat'],
-                'use'      => 'a'
+                'field'   => 'lat',
+                'type'    => 'float',
+                'default' => $this->config['settings']['maps_default_lat'],
+                'use'     => 'a'
             ),
 
             // Longitude
             'lon' => array(
-                'field'    => 'lon',
-                'type'     => 'float',
-                'default'  => $this->config['settings']['maps_default_lon'],
-                'use'      => 'a'
+                'field'   => 'lon',
+                'type'    => 'float',
+                'default' => $this->config['settings']['maps_default_lon'],
+                'use'     => 'a'
             ),
 
             // Region
-            'region' => array (
-                'field' => 'region',
-                'type' => 'pointer',
-                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'regions',
-                    'p_field' => 'name',
-                    'p_orderby' => 'name',
-                    'p_blank' => true,
-                //  'force_list' => true,
-                'use' => 'a'
+            'region' => array(
+                'field'         => 'region',
+                'type'          => 'pointer',
+                'p_table'       => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'regions',
+                'p_field'       => 'name',
+                'p_orderby'     => 'name',
+                'p_blank'       => true,
+                // 'force_list' => true,
+                'use'           => 'a'
             ),
 
             // County
             'county' => array(
-                'field' => 'county',
-                'type' => 'pointer',
-                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'counties',
-                    'p_field' => 'name',
-                    'p_orderby' => 'name',
-                    'p_blank' => false,
-                //  'force_list' => true,
-                'use' => 'a'
+                'field'         => 'county',
+                'type'          => 'pointer',
+                'p_table'       => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'counties',
+                'p_field'       => 'name',
+                'p_orderby'     => 'name',
+                'p_blank'       => false,
+                // 'force_list' => true,
+                'use'           => 'a'
             ),
 
             // Phone
             'phone' => array(
-                'field'    => 'phone',
-                'type'     => 'phone',
-                'use'      => 'a'
+                'field' => 'phone',
+                'type'  => 'phone',
+                'use'   => 'a'
             ),
 
             // Fax
             'fax' => array(
-                'field'    => 'fax',
-                'type'     => 'phone',
-                'use'      => 'a'
+                'field' => 'fax',
+                'type'  => 'phone',
+                'use'   => 'a'
             ),
 
             // Toll Free
             'toll_free' => array(
-                'field'    => 'toll_free',
-                'type'     => 'phone',
-                'use'      => 'a'
+                'field' => 'toll_free',
+                'type'  => 'phone',
+                'use'   => 'a'
             ),
 
             // E-Mail Address
             'email' => array(
-                'field'    => 'email',
-                'type'     => 'email',
-                'use'      => 'a'
+                'field' => 'email',
+                'type'  => 'email',
+                'use'   => 'a'
             ),
 
             // URL
             'url' => array(
-                'field'    => 'url',
-                'type'     => 'text',
-                'use'      => 'a'
+                'field' => 'url',
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // Reservation URL
             'reservation_url' => array(
-                'field'    => 'reservation_url',
-                'type'     => 'text',
-                'use'      => 'a'
+                'field' => 'reservation_url',
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // Logo
             'logo' => array(
-                    'field'    => 'logo',
-                    'type'     => 'image',
-                    'use'      => 'a'
+                'field' => 'logo',
+                'type'  => 'image',
+                'use'   => 'a'
             ),
 
             // Credit Cards Accepted - multi-pick
             'cc_type' => array(
-                    'field'    => 'cc_type',
-                    'type'     => 'bitmap',
-                    'bitmap'    => $this->config['credit_card'],
-                    'default'  => 0, // no cards selected
-                    'use'      => 'a'
+                'field'   => 'cc_type',
+                'type'    => 'bitmap',
+                'bitmap'  => $this->config['credit_card'],
+                'default' => 0, // no cards selected
+                'use'     => 'a'
             ),
 
             // Description
             'descr' => array(
                 'field' => 'descr',
-                'type' => 'text',
-                'use' => 'a'
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // Short description
-            'short_descr' => array (
-                'field' => 'short_descr',
-                'type' => 'text',
+            'short_descr' => array(
+                'field'     => 'short_descr',
+                'type'      => 'text',
                 'maxLength' => $this->config['settings']['short_desc_char_limit'],
-                'use' => 'a'
+                'use'       => 'a'
             ),
 
             // Video URL
-            'video_url' => array (
+            'video_url' => array(
                 'field' => 'video_url',
-                'type' => 'text',
-                'use' => 'a'
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // Video File Name
-            'video_file' => array (
+            'video_file' => array(
                 'field' => 'video_file',
-                'type' => 'file',
-                'use' => 'a'
+                'type'  => 'file',
+                'use'   => 'a'
             ),
 
             // Video Title
-            'video_title' => array (
-                'field' => 'video_title',
-                'type' => 'text',
+            'video_title' => array(
+                'field'     => 'video_title',
+                'type'      => 'text',
                 'maxLength' => '80',
-                'use' => 'a'
+                'use'       => 'a'
             ),
 
             // Video Description
-            'video_descr' => array (
+            'video_descr' => array(
                 'field' => 'video_descr',
-                'type' => 'text',
-                'use' => 'a'
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // Video Type
-            'video_type' => array (
+            'video_type' => array(
                 'field' => 'video_type',
-                'type' => 'list',
-                'list' => $this->config['video_type'],
-                'use' => 'a'
+                'type'  => 'list',
+                'list'  => $this->config['video_type'],
+                'use'   => 'a'
             ),
 
             // Live Cam URL
-            'live_cam_url' => array (
+            'live_cam_url' => array(
                 'field' => 'live_cam_url',
-                'type' => 'text',
-                'use' => 'a'
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // Live Cam Title
-            'live_cam_title' => array (
+            'live_cam_title' => array(
                 'field' => 'live_cam_title',
-                'type' => 'text',
-                'use' => 'a'
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // Live Cam Description
-            'live_cam_descr' => array (
+            'live_cam_descr' => array(
                 'field' => 'live_cam_descr',
-                'type' => 'text',
-                'use' => 'a'
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // Live Cam Type
-            'live_cam_type' => array (
+            'live_cam_type' => array(
                 'field' => 'live_cam_type',
-                'type' => 'list',
-                'list' => $this->config['live_cam_type'],
-                'use' => 'a'
+                'type'  => 'list',
+                'list'  => $this->config['live_cam_type'],
+                'use'   => 'a'
             ),
 
             // Mailing Address Line 1
-            'mailing_addr1' => array (
+            'mailing_addr1' => array(
                 'field' => 'mailing_addr1',
                 'type' => 'text',
                 'use' => 'a'
             ),
 
             // Mailing Address Line 2
-            'mailing_addr2' => array (
+            'mailing_addr2' => array(
                 'field' => 'mailing_addr2',
-                'type' => 'text',
-                'use' => 'a'
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
             // Mailing City
-            'mailing_city' => array (
-                'field' => 'mailing_city',
-                'type' => 'pointer',
-                    'p_table' => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'cities',
-                    'p_field' => 'name',
-                    'p_orderby' => 'name',
-                'use' => 'a'
+            'mailing_city' => array(
+                'field'     => 'mailing_city',
+                'type'      => 'pointer',
+                'p_table'   => GLM_MEMBERS_PLUGIN_DB_PREFIX . 'cities',
+                'p_field'   => 'name',
+                'p_orderby' => 'name',
+                'use'       => 'a'
             ),
 
             // Mailing State
-            'mailing_state' => array (
-                'field' => 'mailing_state',
-                'type' => 'list',
-                'list' => $this->config['states'],
-                'default'  => $this->config['settings']['default_state'],
-                'use' => 'a'
+            'mailing_state' => array(
+                'field'   => 'mailing_state',
+                'type'    => 'list',
+                'list'    => $this->config['states'],
+                'default' => $this->config['settings']['default_state'],
+                'use'     => 'a'
             ),
 
             // Mailing ZIP / Postal Code
-            'mailing_zip' => array (
+            'mailing_zip' => array(
                 'field' => 'mailing_zip',
-                'type' => 'text',
-                'use' => 'a'
+                'type'  => 'text',
+                'use'   => 'a'
             ),
 
-
             // Notes
-            'notes' => array (
-                    'field' => 'notes',
-                    'type' => 'text',
-                    'use' => 'a'
+            'notes' => array(
+                'field' => 'notes',
+                'type' => 'text',
+                'use' => 'a'
             ),
 
             // Create Time
-            'create_time' => array (
+            'create_time' => array(
                 'field' => 'create_time',
-                'type' => 'datetime',
-                'use' => 'lgie'
+                'type'  => 'datetime',
+                'use'   => 'lgie'
             ),
 
             // Last Modify Time
-            'modify_time' => array (
+            'modify_time' => array(
                 'field' => 'modify_time',
-                'type' => 'datetime',
-                'use' => 'a'
+                'type'  => 'datetime',
+                'use'   => 'a'
             )
-
         );
 
-        // Unset some fields if certain member info tabs are off to avoid error messages.
-        if(!$this->config['settings']['memb_info_contact']) {
-            unset($this->fields['phone']);
-            unset($this->fields['toll_free']);
-            unset($this->fields['mailing_city']);
+        // Unset some fields if certain member info tabs are off to avoid error
+        // messages.
+        if ( !$this->config['settings']['memb_info_contact'] ) {
+            unset( $this->fields['phone'] );
+            unset( $this->fields['toll_free'] );
+            unset( $this->fields['mailing_city'] );
         }
-        if(!$this->config['settings']['memb_info_location']) {
-            unset($this->fields['lat']);
-            unset($this->fields['lon']);
-            unset($this->fields['city']);
-            unset($this->fields['region']);
-            unset($this->fields['county']);
+        if ( !$this->config['settings']['memb_info_location'] ) {
+            unset( $this->fields['lat'] );
+            unset( $this->fields['lon'] );
+            unset( $this->fields['city'] );
+            unset( $this->fields['region'] );
+            unset( $this->fields['county'] );
         }
 
-       }
+    }
 
     /*
      * Entry Post Processing Call-Back Method
      *
      * Perform post-processing for all result entries.
      *
-     * In this case we're using it to append an array of category
-     * data to each member result and also sort by member name.
+     * In this case we're using it to append an array of category data to each
+     * member result and also sort by member name.
      *
-     * @param array $r Array of field result data for a single entry
-     * @param string $a Action being performed (l, i, g, ...)
+     * @param array $r Array of field result data for a single entry @param
+     * string $a Action being performed (l, i, g, ...)
      *
      * @return object Class object
      *
      */
-    public function entryPostProcessing($r, $a)
-    {
+    public function entryPostProcessing( $r, $a ) {
 
         // Only if the Member Info "Location" tab is turned on should we do this
-        if($this->config['settings']['memb_info_location'] && isset($r['lat']) && isset($r['lon'])) {
+        if ( $this->config['settings']['memb_info_location'] && isset( $r['lat'] ) && isset( $r['lon'] ) ) {
 
             // Set flag if Lat or Lon are 0
             $r['bad_lat_lon'] = false;
-            if ($r['lat'] == 0 || $r['lon'] == 0) {
+            if ( $r['lat'] == 0 || $r['lon'] == 0 ) {
                 $r['bad_lat_lon'] = true;
             }
         }
 
-        // Don't run the following tests for 'l' (getList), 'g' (getEntry), 'e' (editEntry), 'u' (updateEntry)
-        if ($a != 'l' && $a != 'g' && $a != 'e' && $a != 'u') {
+        // Don't run the following tests for 'l' (getList), 'g' (getEntry), 'e'
+        // (editEntry), 'u' (updateEntry)
+        if ( $a != 'l' && $a != 'g' && $a != 'e' && $a != 'u' ) {
             return $r;
         }
 
         // Check that URLs have http:// in front of them.
-        if (isset($r['url']) && strlen(trim($r['url'])) > 0  && strtolower(substr($r['url'],0,4)) != 'http') {
-            $r['url'] = 'http://'.$r['url'];
+        if ( isset( $r['url'] ) && strlen( trim( $r['url'] ) ) > 0 && strtolower( substr( $r['url'], 0, 4 ) ) != 'http' ) {
+            $r['url'] = 'http://' . $r['url'];
         }
-        if (isset($r['reservation_url']) && strlen(trim($r['reservation_url'])) > 0 && strtolower(substr($r['reservation_url'],0,4)) != 'http') {
-            $r['reservation_url'] = 'http://'.$r['reservation_url'];
+        if ( isset( $r['reservation_url'] ) && strlen( trim( $r['reservation_url'] ) ) > 0 &&
+            strtolower( substr( $r['reservation_url'], 0, 4 ) ) != 'http' ) {
+            $r['reservation_url'] = 'http://' . $r['reservation_url'];
         }
 
         // Get Amenity Data for this entry
-        if ($this->doPostProcessing || $this->postProcessAmenity) {
+        if ( $this->doPostProcessing || $this->postProcessAmenity ) {
             $sql = "
                SELECT A.*
-                 FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "amenities AS A,
-                      ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "amenity_ref AS R
-                WHERE R.ref_type = ".$this->config['ref_type_numb']['MemberInfo']."
-                  AND R.ref_dest = ".$r['id']."
+                 FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "amenities AS A,
+                      " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "amenity_ref AS R
+                WHERE R.ref_type = " . $this->config['ref_type_numb']['MemberInfo'] . "
+                  AND R.ref_dest = " . $r['id'] . "
                   AND A.id = R.amenity
             ;";
 
-            $r['amenities'] = $this->wpdb->get_results($sql, ARRAY_A);
+            $r['amenities'] = $this->wpdb->get_results( $sql, ARRAY_A );
         }
 
         // Get Member Category data for this entry
-        if ($this->doPostProcessing || $this->postProcessCategory) {
+        if ( $this->doPostProcessing || $this->postProcessCategory ) {
             $sql = "
                 SELECT CMI.member_info AS member_info_id, C.id, C.name, C.descr, C.short_descr,
                        COALESCE (
                             (
                             SELECT name
-                              FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "categories
+                              FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX .
+                "categories
                              WHERE id = C.parent
                             ), ''
                        ) AS parent_name,
                        COALESCE (
                             (
                             SELECT id
-                              FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."categories
+                              FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX .
+                "categories
                              WHERE id = C.parent
                             ), ''
                         ) AS parent_id
 
-                  FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "categories AS C,
-                       ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "category_member_info AS CMI
+                  FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "categories AS C,
+                       " . GLM_MEMBERS_PLUGIN_DB_PREFIX .
+                "category_member_info AS CMI
                  WHERE C.id = CMI.category
-                   AND CMI.member_info = ".$r['id']."
+                   AND CMI.member_info = " . $r['id'] . "
             ;";
-            $r['categories'] = $this->wpdb->get_results($sql, ARRAY_A);
+            $r['categories'] = $this->wpdb->get_results( $sql, ARRAY_A );
         }
 
-        if ($this->doPostProcessing || $this->postProcessShortDescr) {
-            if ((strlen($r['short_descr']) == 0) && ($r['descr'] > 0)) {
+        if ( $this->doPostProcessing || $this->postProcessShortDescr ) {
+            if ( (strlen( $r['short_descr'] ) == 0) && ($r['descr'] > 0) ) {
                 $r['short_descr'] = $r['descr'];
             }
             $dotdotdot = '';
-            if (strlen($r['short_descr']) > $this->config['settings']['short_desc_char_limit'] ) {
+            if ( strlen( $r['short_descr'] ) > $this->config['settings']['short_desc_char_limit'] ) {
                 $dotdotdot = ' ...';
             }
 
-            $formattedStr = trim(preg_replace('/\s\s+/', ' ', $r['short_descr']));
-            $r['short_descr'] = substr($formattedStr, 0, $this->config['settings']['short_desc_char_limit']).$dotdotdot;
+            $formattedStr = trim( preg_replace( '/\s\s+/', ' ', $r['short_descr'] ) );
+            $r['short_descr'] = substr( $formattedStr, 0, $this->config['settings']['short_desc_char_limit'] ) .
+                $dotdotdot;
         }
 
-
         /*
          * This will add a protocol prefix to the live cam url
          */
-        if ($this->doPostProcessing || $this->postProcessCamUrl) {
+        if ( $this->doPostProcessing || $this->postProcessCamUrl ) {
             $liveCamUrl = $r['live_cam_url'];
-            if ($liveCamUrl != "") {
-                if (!preg_match("~^(?:f|ht)tps?://~i", $liveCamUrl)) {
+            if ( $liveCamUrl != "" ) {
+                if ( !preg_match( "~^(?:f|ht)tps?://~i", $liveCamUrl ) ) {
                     $r['live_cam_url'] = "http://" . $liveCamUrl;
                 }
             }
         }
 
-        // If post processing primary contact - Yes, we're cheating here and referencing an add-on directly
-        if ($this->doPostProcessing || $this->postProcessPrimaryContact) {
-            if (isset($this->config['addOns']['glm-member-db-contacts']) && $this->postProcessPrimaryContact) {
+        // If post processing primary contact - Yes, we're cheating here and
+        // referencing an add-on directly
+        if ( $this->doPostProcessing || $this->postProcessPrimaryContact ) {
+            if ( isset( $this->config['addOns']['glm-member-db-contacts'] ) && $this->postProcessPrimaryContact ) {
 
                 // Get basic primary contact information
                 $sql = "
                     SELECT id, fname, lname, email
-                      FROM ".GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX. "contacts
-                     WHERE ref_type = ".$this->config['ref_type_numb']['Member']."
-                       AND ref_dest = ".$r['member_pointer']."
+                      FROM " . GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts
+                     WHERE ref_type = " . $this->config['ref_type_numb']['Member'] . "
+                       AND ref_dest = " . $r['member_pointer'] . "
                        AND primary_contact
                 ";
-                $r['primary_contact'] = current($this->wpdb->get_results($sql, ARRAY_A));
-
+                $r['primary_contact'] = current( $this->wpdb->get_results( $sql, ARRAY_A ) );
             }
         }
 
@@ -695,57 +686,53 @@ class GlmDataMemberInfo extends GlmDataAbstract
                 $this->wpdb->prepare(
                     "SELECT *
                        FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "accommodations
-                      WHERE ref_dest = %d",
-                    $r['id']
-                ),
-                ARRAY_A
-            );
+                      WHERE ref_dest = %d", $r['id'] ), ARRAY_A );
             if ( $accommodationData ) {
                 $r['accommodations'] = true;
-                $r['num_rooms']      = $accommodationData['num_rooms'];
-                $r['year_round']     = $accommodationData['year_round'];
+                $r['num_rooms'] = $accommodationData['num_rooms'];
+                $r['year_round'] = $accommodationData['year_round'];
             } else {
                 $r['accommodations'] = false;
-                $r['num_rooms']      = false;
-                $r['year_round']     = false;
+                $r['num_rooms'] = false;
+                $r['year_round'] = false;
             }
-
         }
 
         return $r;
+
     }
 
-       /*
-        * Find the active member info record ID for a specific member ID
-        *
-        * @param integer $member ID of the member name
-        * @param string $where Optional WHERE clause for query
-        *
-        * @return integer Member info record ID or false if not found
-        */
-       public function getActiveInfoIdForMember($member, $where = 'true') {
+    /*
+     * Find the active member info record ID for a specific member ID
+     *
+     * @param integer $member ID of the member name @param string $where
+     * Optional WHERE clause for query
+     *
+     * @return integer Member info record ID or false if not found
+     */
+    public function getActiveInfoIdForMember( $member, $where = 'true' ) {
 
-           $memberID = $member - 0;
+        $memberID = $member - 0;
 
         $sql = "
             SELECT T.id
-              FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "member_info T
+              FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info T
              WHERE $where
                AND member = $memberID
-               AND status = ".$this->config['status_numb']['Active']."
+               AND status = " . $this->config['status_numb']['Active'] . "
                AND  (
                      SELECT access
-                     FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX."members
+                     FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members
                      WHERE id = T.member
                ) IN (
-                     ".$this->config['access_numb']['NoAccess'].",
-                     ".$this->config['access_numb']['Moderated'].",
-                     ".$this->config['access_numb']['Full']."
+                     " . $this->config['access_numb']['NoAccess'] . ",
+                     " . $this->config['access_numb']['Moderated'] . ",
+                     " . $this->config['access_numb']['Full'] . "
                )
         ";
-        $memberInfo = $this->wpdb->get_row($sql, ARRAY_A);
+        $memberInfo = $this->wpdb->get_row( $sql, ARRAY_A );
 
-        if ($memberInfo) {
+        if ( $memberInfo ) {
             return $memberInfo['id'];
         }
 
@@ -753,30 +740,31 @@ class GlmDataMemberInfo extends GlmDataAbstract
 
     }
 
-       /*
-        * Gets member name, address, phones, and E-Mail only from the
-        * currently active member info record.
-        *
-        * @param integer $memberID ID of the member
-        *
-        * @return integer Member info or false if fail
-        */
-       public function getActiveInfoSimplified($member) {
-
-           // Get the ID for the current info record for this member
-           $mInfoID = $this->getActiveInfoIdForMember($member);
-           if (!$mInfoID) {
-               return false;
-           }
+    /*
+     * Gets member name, address, phones, and E-Mail only from the currently
+     * active member info record.
+     *
+     * @param integer $memberID ID of the member
+     *
+     * @return integer Member info or false if fail
+     */
+    public function getActiveInfoSimplified( $member ) {
+
+        // Get the ID for the current info record for this member
+        $mInfoID = $this->getActiveInfoIdForMember( $member );
+        if ( !$mInfoID ) {
+            return false;
+        }
 
         // Save current list of fields
         $f = $this->fields;
 
-        // Replace fields list with limited list - Result will still use original field names
+        // Replace fields list with limited list - Result will still use
+        // original field names
         $this->fields = array(
-            'member' => $f['member'],
-            'member_name' => $f['member_name'],
-            'member_slug' => $f['member_slug'],
+            'member'         => $f['member'],
+            'member_name'    => $f['member_name'],
+            'member_slug'    => $f['member_slug'],
             'member_pointer' => $f['member_pointer']
         );
 
@@ -784,8 +772,8 @@ class GlmDataMemberInfo extends GlmDataAbstract
         $dpp = $this->doPostProcessing;
         $this->doPostProcessing = false;
 
-           // Get the current member info data
-        $mInfo = $this->getEntry($mInfoID);
+        // Get the current member info data
+        $mInfo = $this->getEntry( $mInfoID );
 
         // Restore previous post processing flag
         $this->doPostProcessign = $dpp;
@@ -797,34 +785,31 @@ class GlmDataMemberInfo extends GlmDataAbstract
 
     }
 
-
     /*
-     * Get Alpha list of first characters in member name
-     * for those members that have active info.
+     * Get Alpha list of first characters in member name for those members that
+     * have active info.
      *
-     * @param string $where Where clause
-     *     Note the table refernces M and I.
+     * @param string $where Where clause Note the table refernces M and I.
      * @param string $selected Optional selected alpha character
      *
      * @return object Class object
      *
      */
-    public function getAlphaList($where = '', $selected = '')
-    {
+    public function getAlphaList( $where = '', $selected = '' ) {
 
         $sql = "
            SELECT DISTINCT LEFT(M.name, 1) AS alpha
-             FROM ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "members M,
-                  ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "member_info T
-            WHERE T.status = ".$this->config['status_numb']['Active']."
+             FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members M,
+                  " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info T
+            WHERE T.status = " . $this->config['status_numb']['Active'] . "
               AND M.id = T.member
                   $where
             ORDER BY alpha
         ;";
-        $alphaData = $this->wpdb->get_results($sql, ARRAY_A);
+        $alphaData = $this->wpdb->get_results( $sql, ARRAY_A );
 
         // Set selected
-        foreach ($alphaData as $k=>$v) {
+        foreach ( $alphaData as $k=>$v ) {
             $alphaData[$k]['default'] = ($v['alpha'] == $selected);
         }
 
@@ -835,15 +820,14 @@ class GlmDataMemberInfo extends GlmDataAbstract
     /*
      * Get simplified list of member info records.
      *
-     * @param string $where Where clause
-     *     Note the table refernces M and I.
-     * @param boolean $forMapItems If true displays info needed for map items only
+     * @param string $where Where clause Note the table refernces M and I.
+     * @param boolean $forMapItems If true displays info needed for map items
+     * only
      *
      * @return object Class object
      *
      */
-    public function getSimpleMemberInfoList($where = '', $forMapItems = false)
-    {
+    public function getSimpleMemberInfoList( $where = '', $forMapItems = false ) {
 
         $this->doPostProcessing = false;
 
@@ -854,7 +838,7 @@ class GlmDataMemberInfo extends GlmDataAbstract
         $f = $this->fields;
 
         // If for map items, do a custom query to save time (lots of map items)
-        if ($forMapItems) {
+        if ( $forMapItems ) {
 
             $sql = "
                 SELECT
@@ -879,38 +863,39 @@ class GlmDataMemberInfo extends GlmDataAbstract
                     T.short_descr,
                     T.has_no_profile
                 FROM
-                    ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "member_info T
-                LEFT OUTER JOIN ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "regions R ON (R.id = T.region)
-                LEFT OUTER JOIN ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "cities C ON (C.id = T.city),
-                    ".GLM_MEMBERS_PLUGIN_DB_PREFIX. "members M
+                    " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info T
+                LEFT OUTER JOIN " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "regions R ON (R.id = T.region)
+                LEFT OUTER JOIN " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "cities C ON (C.id = T.city),
+                    " . GLM_MEMBERS_PLUGIN_DB_PREFIX .
+                "members M
                 WHERE
                     M.id = T.member
+                    AND T.status = ".$this->config['status_numb']['Active']."
             ";
-            if ($where != '') {
+            if ( $where != '' ) {
                 $sql .= "AND $where";
             }
-            $list = $this->wpdb->get_results($sql, ARRAY_A);
+            $list = $this->wpdb->get_results( $sql, ARRAY_A );
 
-        // Otherwise get the simplified list normally
+            // Otherwise get the simplified list normally
         } else {
 
             $this->fields = array(
-                'id' => $f['id'],
-                'member' => $f['member'],
-                'member_name' => $f['member_name'],
-                'member_slug' => $f['member_slug'],
+                'id'             => $f['id'],
+                'member'         => $f['member'],
+                'member_name'    => $f['member_name'],
+                'member_slug'    => $f['member_slug'],
                 'member_pointer' => $f['member_pointer'],
                 'reference_name' => $f['reference_name'],
-                'status' => $f['status'],
-                'create_time' => $f['create_time'],
-                'modify_time' => $f['modify_time'],
-                'lat' => $f['lat'],
-                'lon' => $f['lon']
+                'status'         => $f['status'],
+                'create_time'    => $f['create_time'],
+                'modify_time'    => $f['modify_time'],
+                'lat'            => $f['lat'],
+                'lon'            => $f['lon']
             );
 
             // Get the simplified list
-            $list = $this->getList($where, false, false);
-
+            $list = $this->getList( $where, false, false );
         }
 
         // Restore full fields list
@@ -919,32 +904,32 @@ class GlmDataMemberInfo extends GlmDataAbstract
         $this->optionProhibitListOptions = $plo;
 
         return $list;
+
     }
 
     /*
      * Get Member Info For a Member
      *
-     * @param integer $member Member ID
-     * @param string $where Where clause
+     * @param integer $member Member ID @param string $where Where clause
      *
      * @return object Class object
      *
      */
-    public function getActiveInfoForMember($member)
-    {
+    public function getActiveInfoForMember( $member ) {
 
         // Get the active member info id for an active member
-        $memberInfoID = $this->getActiveInfoIdForMember($member);
+        $memberInfoID = $this->getActiveInfoIdForMember( $member );
 
         // If not found then return failure
-        if ($memberInfoID == false) {
+        if ( $memberInfoID == false ) {
             return false;
         }
 
         // Get the member info data
-        $memberInfo = $this->getEntry($memberInfoID);
+        $memberInfo = $this->getEntry( $memberInfoID );
 
         return $memberInfo;
+
     }
 
 }
index f86731b..a4a2167 100644 (file)
@@ -165,6 +165,13 @@ class GlmMembersFront_members_memberDataByLatLon extends GlmDataMemberInfo
 
             $and = ' AND ';
 
+        } else {
+
+            // This is an anywhere request, so ignore any 0,0 lat/lon
+            $where .= "
+                $and T.lat != 0 AND T.lon != 0
+            ";
+            $and = ' AND ';
         }
 
         // If searchText is supplied
@@ -178,9 +185,8 @@ class GlmMembersFront_members_memberDataByLatLon extends GlmDataMemberInfo
         }
 
         // Get the filtered list of members and return data fields for map items.
-//        $this->postProcessCategory = true;
+        // (also ignores members with only inactive profiels)
         $members = $this->getSimpleMemberInfoList($where.$suppliedWhere, true);
-//        $this->postProcessCategory = false;
 
         // Rebuild data with correct array format for map items
         if (is_array($members) && count($members) > 0) {
@@ -212,16 +218,16 @@ class GlmMembersFront_members_memberDataByLatLon extends GlmDataMemberInfo
                     'city'        => ($this->config['settings']['memb_info_location'] && isset($v['city']) ? $v['city'] : ''),
                     'state'       => $v['state'],
                     'zip'         => $v['zip'],
-//                    'country'     => $v['country']['name'],
+                    //                    'country'     => $v['country']['name'],
                     'phone'       => ($this->config['settings']['memb_info_contact'] && isset($v['phone']) ? $v['phone'] : ''),
                     'toll_free'   => ($this->config['settings']['memb_info_contact'] && isset($v['toll_free']) ? $v['toll_free'] : ''),
                     'email'       => $v['email'],
                     'url'         => $v['url'],
                     'region'      => ($this->config['settings']['memb_info_location'] && isset($v['region']) ? $v['region'] : ''),
-//                    'categories'  => $cats,
-//                    'cc_type'     => $v['cc_type'],
+                    //                    'categories'  => $cats,
+                    //                    'cc_type'     => $v['cc_type'],
                     'logo'        => $v['logo'],
-//                    'descr'       => $v['short_descr'],
+                    //                    'descr'       => $v['short_descr'],
                     'short_descr' => $v['short_descr'],
                     'detail_page' => GLM_MEMBERS_SITE_BASE_URL.$this->config['settings']['canonical_member_page'].'/'.$v['member_slug'].'/',
                     'dates'       => '',