From: Steve Sutton Date: Thu, 19 Jul 2018 18:17:11 +0000 (-0400) Subject: More updates to connection import. X-Git-Tag: v2.10.37^2~15 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=2f7df0314c19f034e6fea8d5e89d8dbdb0a6513d;p=WP-Plugins%2Fglm-member-db.git More updates to connection import. Fix for email address update. --- diff --git a/classes/glmMemberImportFromConnections.php b/classes/glmMemberImportFromConnections.php index 086ef4ec..a3da98ac 100644 --- a/classes/glmMemberImportFromConnections.php +++ b/classes/glmMemberImportFromConnections.php @@ -401,6 +401,15 @@ class GlmMemberImportFromConnections $url = ''; } + // Get the first email + if ( is_array( $m['email'] ) ) { + reset( $m['email'] ); + $emailData = current( $m['email'] ); + $email = $emailData['address']; + } else { + $email = ''; + } + // Get phone numbers $phone = ''; $toll_free = ''; @@ -483,6 +492,7 @@ class GlmMemberImportFromConnections phone, toll_free, url, + email, logo, cc_type, notes, @@ -512,6 +522,7 @@ class GlmMemberImportFromConnections '$phone', '$toll_free', '$url', + '$email', '$logo', 0, '', diff --git a/models/admin/management/development.php b/models/admin/management/development.php index a6aa7721..58034d1b 100644 --- a/models/admin/management/development.php +++ b/models/admin/management/development.php @@ -116,6 +116,42 @@ class GlmMembersAdmin_management_development switch( $option ) { + case 'updateEmails'; + $sql = " + SELECT id,organization,email + FROM ".$this->wpdb->prefix."connections + WHERE email != '' + ORDER BY id"; + $connection_members = $this->wpdb->get_results($sql, ARRAY_A); + + foreach ( $connection_members as $member ) { + // Update the email for the member_info record + // Need to get the member_info id based on the ref_dest + $email_data = unserialize( $member['email'] ); + $email = ''; + if ( is_array( $email_data ) ) { + reset( $email_data ); + $eData = current( $email_data ); + $email = $eData['address']; + } + if ( $email ) { + $this->wpdb->query( + $this->wpdb->prepare( + "UPDATE " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "member_info + SET email = %s + WHERE member = ( SELECT id + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members + WHERE old_member_id = %d + )", + $email, + $member['id'] + ) + ); + } + } + + break; + case 'import_connections': // Load Member Info Data Class and get info data for later use diff --git a/views/admin/management/development.html b/views/admin/management/development.html index 5a5327cf..eed511f9 100644 --- a/views/admin/management/development.html +++ b/views/admin/management/development.html @@ -9,6 +9,10 @@

Import