From: Steve Sutton Date: Wed, 21 Jun 2017 16:35:38 +0000 (-0400) Subject: Updating member import scripts X-Git-Tag: v2.10.0^2~21 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=b78117e2c2406eee2d7690f32dc5591fc3cf11d1;p=WP-Plugins%2Fglm-member-db.git Updating member import scripts Adding in mailing address city state zip. --- diff --git a/models/admin/management/import/members.php b/models/admin/management/import/members.php index ab7db7dc..34c6fd0d 100644 --- a/models/admin/management/import/members.php +++ b/models/admin/management/import/members.php @@ -418,9 +418,10 @@ if (!$failure) { // Since there was no problem, we'll post-process the cities into an array indexed by city_id $city = array(); - // Reprocess into array indexed by city_id + // Reprocess into array indexed by city_id and by city_name foreach ($tmp as $x) { $city[$x['city_id']] = $x; + $cityNames[$x['city_name']] = $x['city_id']; } } } @@ -550,11 +551,11 @@ if (!$failure && isset($_REQUEST['dbReset']) && $_REQUEST['dbReset'] == 'on') { // Reset the database if (!$this->deleteDataTables($dbVersion)) { glmMembersAdmin::addNotice('Unable to delete the database tables while resetting the database.
', 'AdminError'); - break; + //break; } if (!$this->createDataTables($dbVersion)) { glmMembersAdmin::addNotice('Unable to create the database tables while resetting the database.
', 'AdminError'); - break; + //break; } glmMembersAdmin::addNotice('Database tables have been reset in preparation importing members.
', 'AdminNotice'); @@ -812,6 +813,12 @@ if (!$failure) { } } $this->wpdb->show_errors(); + + // Find the city id if mailing city is given + // Need the new city id inserted. + $mailingOldCityId = ( ( isset( $cityNames[$val['mailing_city']] ) && $val['mailing_city'] ) ? $cityNames[$val['mailing_city']] : 0 ); + $mailingCityId = ( (isset($city[$mailingOldCityId]['new_id'] ) && $city[$mailingOldCityId]['new_id'] ) ? $city[$mailingOldCityId]['new_id']: 0 ); + // Insert Member Information Record $res = $this->wpdb->insert( GLM_MEMBERS_PLUGIN_DB_PREFIX.'member_info', @@ -828,6 +835,12 @@ if (!$failure) { 'state' => $state[$val['state_id']]['state_abb'], 'country' => 'US', 'zip' => $val['zip'], + + 'mailing_addr1' => $val['mailing_address'], + 'mailing_city' => $mailingCityId, + 'mailing_state' => ( (isset($state[$val['mailing_state_id']]['state_abb']) && $val['mailing_state_id']) ? $state[$val['mailing_state_id']]['state_abb']: ''), + 'mailing_zip' => $val['mailing_zip'], + 'lat' => $val['lat'], 'lon' => $val['lon'], 'region' => (isset($region[$val['region']]) ? $region[$val['region']]['new_id'] : 0), @@ -842,30 +855,36 @@ if (!$failure) { 'modify_time' => $val['last_update'] ), array( - '%d', - '%s', - '%d', - '%s', - '%s', - '%s', - '%s', - '%s', - '%d', - '%s', - '%s', - '%s', - '%f', - '%f', - '%d', - '%s', - '%s', - '%s', - '%s', - '%s', - '%d', - '%s', - '%s', - '%s' + '%d', // member id + '%s', // name + '%d', // status + '%s', // ref name + '%s', // descr + '%s', // short_descr + '%s', // addr1 + '%s', // addr2 + '%d', // city + '%s', // state + '%s', // country + '%s', // zip + + '%s', // mailing addr1 + '%d', // mailing city + '%s', // mailing state + '%s', // mailing zip + + '%f', // lat + '%f', // lon + '%d', // region + '%s', // phone + '%s', // toll_free + '%s', // url + '%s', // email + '%s', // logo + '%d', // email + '%s', // notes + '%s', // create_time + '%s' // modify_time ) ); $infoID = $this->wpdb->insert_id; diff --git a/setup/databaseScripts/drop_database_V1.1.31.sql b/setup/databaseScripts/drop_database_V1.1.31.sql deleted file mode 100644 index ef327d88..00000000 --- a/setup/databaseScripts/drop_database_V1.1.31.sql +++ /dev/null @@ -1,29 +0,0 @@ --- Gaslight Media Members Database --- File Created: 12/09/14 15:27:15 --- Database Version: 1.1.23 --- Database Deletion Script --- Note: Tables with DELETE CASCADE must appear before referenced table - -DROP TABLE IF EXISTS - {prefix}amenities, - {prefix}amenity_ref, - {prefix}category_member_info, - {prefix}cities, - {prefix}clickthrough_stats, - {prefix}images, - {prefix}files, - {prefix}members, - {prefix}member_detail_stats, - {prefix}member_info, - {prefix}member_type, - {prefix}regions, - {prefix}counties, - {prefix}settings_general, - {prefix}settings_terms, - {prefix}settings_theme, - {prefix}categories, - {prefix}amenity_groups, - {prefix}grouped_amenities, - {prefix}cache -; - diff --git a/setup/databaseScripts/drop_database_V1.1.32.sql b/setup/databaseScripts/drop_database_V1.1.32.sql new file mode 100644 index 00000000..ef327d88 --- /dev/null +++ b/setup/databaseScripts/drop_database_V1.1.32.sql @@ -0,0 +1,29 @@ +-- Gaslight Media Members Database +-- File Created: 12/09/14 15:27:15 +-- Database Version: 1.1.23 +-- Database Deletion Script +-- Note: Tables with DELETE CASCADE must appear before referenced table + +DROP TABLE IF EXISTS + {prefix}amenities, + {prefix}amenity_ref, + {prefix}category_member_info, + {prefix}cities, + {prefix}clickthrough_stats, + {prefix}images, + {prefix}files, + {prefix}members, + {prefix}member_detail_stats, + {prefix}member_info, + {prefix}member_type, + {prefix}regions, + {prefix}counties, + {prefix}settings_general, + {prefix}settings_terms, + {prefix}settings_theme, + {prefix}categories, + {prefix}amenity_groups, + {prefix}grouped_amenities, + {prefix}cache +; + diff --git a/views/admin/management/import.html b/views/admin/management/import.html index 5cdffad7..115d1f63 100644 --- a/views/admin/management/import.html +++ b/views/admin/management/import.html @@ -20,7 +20,6 @@ Import member Clicks and Views
Import member Mailing Addresses
List old/new member IDs
- Import Trail Maps