*/
public $processingComplete = false;
+ public $totalVideos = 0;
+
+ public $videosProcessed = 0;
+
/**
* Constructor
*
$fileData = '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
$clearData = ( filter_var( $_REQUEST['clear_data'], FILTER_VALIDATE_BOOLEAN ) );
+ break;
+
+ case 'videosValidate':
+ if ( isset( $_FILES ) ) {
+ move_uploaded_file( $_FILES['files_file']['tmp_name'], $uploadPath . '/videosData.csv' );
+ }
+ if ( is_file( $uploadPath . '/videosData.csv' ) ) {
+ $fileExists = true;
+ }
+ // validate the header line
+ $fData = $this->readCSVFileHeaders( $uploadPath . '/videosData.csv' );
+ $validate = array( 'member_id', 'member_name', 'video_url' );
+ $isValid = ( $fData == $validate );
+ // If the file validates then we're ready to process
+ $readyToProcess = $isValid;
+ // Set the view file
+ $view = 'videosValidate.html';
+ $fileData = '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
+ $clearData = ( filter_var( $_REQUEST['clear_data'], FILTER_VALIDATE_BOOLEAN ) );
+ break;
+
+ case 'videosProcess':
+ $view = 'videosProcess.html';
+ // 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 . '/videosData.csv' ) ) {
+ $videoData = $this->readCSVFile( $uploadPath . '/videosData.csv' );
+ $this->totalVideos = count( $videoData );
+
+ foreach ( $videoData as $video ) {
+ // Get the member id for this video
+ $memberId = $this->wpdb->get_var(
+ $this->wpdb->prepare(
+ "SELECT id
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members
+ WHERE old_member_id = %s",
+ $video['member_id']
+ )
+ );
+ 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 '<pre>$memberInfoId: ' . print_r( $memberInfoId, true ) . '</pre>';
+ if ( !$memberInfoId ) {
+ var_dump( 'no member info id' );
+ continue;
+ }
+
+ // check the video url to make sure it is valid
+ if ( $video_url = filter_var( $video['video_url'], FILTER_VALIDATE_URL ) ) {
+ $this->videosProcessed++;
+ $this->wpdb->update(
+ GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_info',
+ array( 'video_url' => $video_url ),
+ array( 'id' => $memberInfoId ),
+ array( '%s' ),
+ array( '%d' )
+ );
+ // echo '<pre>' . $video['member_name'] . ': ' . htmlspecialchars( $video['video_url'] ) .'</pre>';
+ }
+ }
+
+ }
+
+
break;
case 'photosProcess':
}
break;
+ case 'videos':
+ // Set the view file
+ $view = 'videos.html';
+ unset( $fileData );
+ if ( is_file( $uploadPath . '/videosData.csv' ) ) {
+ $fileExists = true;
+ $fileData['Videos'] = array(
+ 'field' => 'videos_file',
+ 'name' => 'videosData.csv',
+ 'exists' => true,
+ 'mtime' => filemtime( $uploadPath . '/videosData.csv' ),
+ );
+ } else {
+ $fileData['Videos'] = array(
+ 'field' => 'videos_file',
+ 'name' => 'videosData.csv',
+ 'exists' => false,
+ );
+ }
+ break;
+
case 'default':
default:
// Set the view file
'totalFiles' => $this->totalFiles,
'photosProcessed' => $this->photosProcessed,
'filesProcessed' => $this->filesProcessed,
+ 'totalVideos' => $this->totalVideos,
+ 'videosProcessed' => $this->videosProcessed,
'completed' => $this->processingComplete,
'data' => false,
'fileData' => $fileData,
--- /dev/null
+{include file='admin/import/header.html'}
+
+ <h2>Data Import: Videos</h2>
+ <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="glm_action" value="index" />
+ <input type="hidden" name="option" value="videosValidate" />
+
+ <table class="glm-admin-table">
+ <tr>
+ <th>File Type</th>
+ <th>New File</th>
+ <th>Sample File</th>
+ <th>Current File</th>
+ <th>Updated</th>
+ </tr>
+ {foreach $fileData as $fileHeader => $file}
+ <tr>
+ <td class="glm-import-td">
+ {$fileHeader}
+ </td>
+ <td class="glm-import-td">
+ <input type="file" name="files_file">
+ </td>
+ <td class="glm-import-td">
+ <a href="{$sampleFileUrl}{$file.name}">Sample {$fileHeader} File</a>
+ </td>
+ <td class="glm-import-td">
+ {if $file.exists}
+ {$fileHeader} File
+ {/if}
+ </td>
+ <td class="glm-import-td">
+ {if $file.exists}
+ {$file.mtime|date_format:"%D %I:%M %p"}
+ {/if}
+ </td>
+ {/foreach}
+ </tr>
+
+ </table>
+
+ <input type="submit" value="Continue" class="button button-primary submit-import">
+ </form>
+
+{include file='admin/footer.html'}