*/
public function modelAction ($actionData = false)
{
- $view = 'index.html';
- $failure = false;
- $option = 'default';
- $clearData = false;
+ $view = 'index.html';
+ $failure = false;
+ $option = 'default';
+ $clearData = false;
+ $haveMembers = false;
+ // Check to see if they have members
+ $haveMembers = $this->wpdb->get_var(
+ "SELECT count(id)
+ FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX . "members"
+ );
if ( isset( $_REQUEST['numberProcessed'] ) ) {
$this->numberProcessed = filter_var( $_REQUEST['numberProcessed'], FILTER_VALIDATE_INT );
}
case 'photosValidate':
if ( isset( $_FILES ) ) {
- move_uploaded_file( $_FILES['photos_file']['tmp_name'], $uploadPath . '/photoData.csv' );
+ move_uploaded_file( $_FILES['photos_file']['tmp_name'], $uploadPath . '/photoData.csv' );
}
// validate the header line
- $fData = $this->readCSVFileHeaders( $uploadPath . '/photoData.csv' );
+ $fData = $this->readCSVFileHeaders( $uploadPath . '/photoData.csv' );
+ $isValid = ( $fData == array( 'member_id', 'image', 'caption' ) );
+ // If the file validates then we're ready to process
+ $readyToProcess = $isValid;
+ $view= 'photos.html';
+ $fileData = '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
break;
case 'photos':
$view= 'photos.html';
- $fileData = '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
break;
case 'files':
}
+ // Setup the template data array
$templateData = array(
'option' => $option,
'errors' => $this->errors,
'fileData' => $fileData,
'clearData' => $clearData,
'csvData' => '<pre>$fileData: ' . print_r( $fileData, true ) . '</pre>',
- 'readyToProcess' => $readyToProcess
+ 'readyToProcess' => $readyToProcess,
+ 'haveMembers' => $haveMembers,
);
// Return status, suggested view, and data to controller
return array(
'menuItemRedirect' => false,
'modelRedirect' => false,
'view' => 'admin/import/' . $view,
- 'data' => $templateData
+ 'data' => $templateData,
);
}
<h2>Data Import: Photos</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="photos" />
+ <input type="hidden" name="option" value="photosValidate" />
<table class="glm-admin-table">
<tr>
<input type="submit" value="Continue" class="button button-primary submit-import">
</form>
- {if $fileData}
- {$fileData}
- {/if}
-
{include file='admin/footer.html'}