From: Steve Sutton Date: Fri, 23 Jun 2017 20:07:04 +0000 (-0400) Subject: wip X-Git-Tag: v2.10.0^2~11^2~8 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=df3949aac90a4fda954a08cdb330607ee24fbad2;p=WP-Plugins%2Fglm-member-db.git wip --- diff --git a/models/admin/import/index.php b/models/admin/import/index.php index 8fac51df..443560d8 100644 --- a/models/admin/import/index.php +++ b/models/admin/import/index.php @@ -126,6 +126,14 @@ class GlmMembersAdmin_import_index */ public $totalPhotos = 0; + /** + * totalFiles + * + * @var float + * @access public + */ + public $totalFiles = 0; + /** * photosProcessed * @@ -525,6 +533,72 @@ class GlmMembersAdmin_import_index } break; + case 'filesProcess': + // Setup the file processing + require_once GLM_MEMBERS_PLUGIN_PATH . '/models/admin/ajax/fileUpload.php'; + $FileUpload = new GlmMembersAdmin_ajax_imageUpload($this->wpdb, $this->config); + + // Setup the member_info class + require_once GLM_MEMBERS_PLUGIN_PATH . '/classes/data/dataMemberInfo.php'; + $memberInfoObj = new GlmDataMemberInfo( $this->wpdb, $this->config ); + + if ( is_file( $uploadPath . '/filesData.csv' ) ) { + // Get the entire files file data + $filesData = $this->readCSVFile( $uploadPath . '/filesData.csv' ); + //echo '
$filesData: ' . print_r( $filesData, true ) . '
'; + $this->totalFiles = count( $filesData ); + $this->filesProcessed = count( $filesData ); + + $refType = $this->config['ref_type_numb']['MemberInfo']; + $refTable = $this->config['ref_type_table'][$refType]; + + // Loop through the filesData array + foreach ( $filesData as $file ) { + echo '
$file: ' . print_r( $file, true ) . '
'; + // If there's no url or the url is not valid then skip it. + if ( $fileUrl = filter_var( $file['image'], FILTER_VALIDATE_URL ) ) { + echo '
$fileUrl: ' . print_r( $fileUrl, true ) . '
'; + // Need to first get the member id from the database + // It will match from the old_member_id field + $memberId = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT id + FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members + WHERE old_member_id = %d", + $file['member_id'] + ) + ); + if ( !$memberId ) { + continue; + } + echo '
$memberId: ' . print_r( $memberId, true ) . '
'; + // Now that we have the member id we need to get the + // id for the active member info record + $memberInfoId = $memberInfoObj->getActiveInfoIdForMember( $memberId ); + if ( !$memberInfoId ) { + continue; + } + echo '
$memberInfoId: ' . print_r( $memberInfoId, true ) . '
'; + $res = $FileUpload->storeFile( + $fileUrl, + $refType, + $refTable, + $memberInfoId, + $file['caption'] + ); + } + + } + + // Set the view file + $view= 'filesProcess.html'; + } else { + // Set the view file + $view= 'filesValidate.html'; + } + $view= 'filesValidate.html'; + break; + case 'photos': // Set the view file $view= 'photos.html'; @@ -591,6 +665,7 @@ class GlmMembersAdmin_import_index 'numberProcessed' => $this->numberProcessed, 'totalMembers' => $this->totalMembers, 'totalPhotos' => $this->totalPhotos, + 'totalFiles' => $this->totalFiles, 'photosProcessed' => $this->photosProcessed, 'completed' => $this->processingComplete, 'data' => false, diff --git a/views/admin/import/filesValidate.html b/views/admin/import/filesValidate.html index 6a8acaae..1e2f502e 100644 --- a/views/admin/import/filesValidate.html +++ b/views/admin/import/filesValidate.html @@ -21,7 +21,7 @@ {if $readyToProcess} - Process Files + Process Files {/if}