From: Steve Sutton Date: Tue, 23 Jan 2018 19:31:17 +0000 (-0500) Subject: More updates for wmta import using csv. X-Git-Tag: v2.10.23^2~18 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=1923770835f94bb375419a1be84ccda4695a9dfe;p=WP-Plugins%2Fglm-member-db.git More updates for wmta import using csv. Since we're using old_member_id to match when doing photos have to update some things for it to get the member info id correctly. --- diff --git a/models/admin/import/index.php b/models/admin/import/index.php index 803b9ca6..29621577 100644 --- a/models/admin/import/index.php +++ b/models/admin/import/index.php @@ -305,7 +305,7 @@ class GlmMembersAdmin_import_index 'name' => 'memberData.csv', 'exists' => false, 'validate' => array( - 'id', 'member_name', 'status', 'short_descr', 'descr', + 'id', 'old_member_id', 'member_name', 'status', 'short_descr', 'descr', 'addr1', 'addr2', 'city', 'state', 'country', 'zip', 'mailing_addr1', 'mailing_addr2', 'mailing_city', 'mailing_state', 'mailing_zip', 'region', 'county', 'lat', 'lon', 'phone', 'toll_free', @@ -546,6 +546,7 @@ class GlmMembersAdmin_import_index for ( $index = $start; $index < $ending; $index++ ) { $photo = $photoData[$index]; $this->photosProcessed++; + // echo '
$photoUrl: ' . print_r( $photoUrl, true ) . '
'; // If there's no url or the url is not valid then skip it. if ( $photoUrl = filter_var( $photo['image'], FILTER_VALIDATE_URL ) ) { // Need to first get the member id from the database @@ -554,29 +555,36 @@ class GlmMembersAdmin_import_index $this->wpdb->prepare( "SELECT id FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members - WHERE old_member_id = %d", + WHERE old_member_id = %s", $photo['member_id'] ) ); + // echo '
$memberId: ' . print_r( $memberId, true ) . '
'; if ( !$memberId ) { + // var_dump( 'no member id' ); continue; } // Now that we have the member id we need to get the // id for the active member info record $memberInfoId = $memberInfoObj->getActiveInfoIdForMember( $memberId ); + // echo '
$memberInfoId: ' . print_r( $memberInfoId, true ) . '
'; if ( !$memberInfoId ) { + // var_dump( 'no member info id' ); continue; } // There's a character limit on the photo caption field // of 255 (mysql TINYTEXT) $caption = substr( $photo['caption'], 0, 250 ); + $newPhotoUrl = $this->fetchRemoteImage( $photoUrl, '/tmp' ); + // echo '
$newPhotoUrl: ' . print_r( $newPhotoUrl, true ) . '
'; $res = $ImageUpload->storeImage( - $photoUrl, + '/tmp/' . $newPhotoUrl, $refType, $refTable, $memberInfoId, $caption ); + // echo '
$res: ' . print_r( $res, true ) . '
'; if ( !$res ) { $this->errors = true; } @@ -1095,7 +1103,11 @@ class GlmMembersAdmin_import_index $dupeNames++; $data['member_name'] .= ' DUPE-' . $dupeNames; } - $access = $this->config['access_numb']['Moderated']; + if ( $data['status'] == 'Moderated' ) { + $access = $this->config['access_numb']['Moderated']; + } else { + $access = $this->config['access_numb']['NotDisplayedModerated']; + } $this->wpdb->insert( GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members', array( @@ -1104,7 +1116,7 @@ class GlmMembersAdmin_import_index 'created' => date( 'Y-m-d' ), 'name' => $data['member_name'], 'member_slug' => sanitize_title( $data['member_name'] ), - 'old_member_id' => $data['id'] + 'old_member_id' => $data['old_member_id'] ), array( '%d', @@ -1112,7 +1124,7 @@ class GlmMembersAdmin_import_index '%s', '%s', '%s', - '%d' + '%s' ) ); $memberId = $this->wpdb->insert_id;