*/
public function modelAction ($actionData = false)
{
+ // Set the view file
$view = 'index.html';
$failure = false;
$option = 'default';
if ( isset( $_REQUEST['numberProcessed'] ) ) {
$this->numberProcessed = filter_var( $_REQUEST['numberProcessed'], FILTER_VALIDATE_INT );
}
+ // $fileData - The main files needed for the member import
+ // - field: input field name
+ // - name: file name
+ // - exists: Does file exists. Set to false at first.
+ // - validate: Validation array. Header line must match this.
+ // - type: Type of file. Used in the processing function.
$fileData = array(
'Amenity' => array(
'field' => 'amenity_file',
);
$readyToProcess = false;
+ // Set the $option if found in $_REQUEST array
if (isset($_REQUEST['option']) && $_REQUEST['option'] != '') {
$option = $_REQUEST['option'];
}
+ // Set the $option2 if found in $_REQUEST array
if (isset($_REQUEST['option2']) && $_REQUEST['option2'] != '') {
$option2 = $_REQUEST['option2'];
}
+ // Set variable for the upload directory
$wpUploadDir = wp_get_upload_dir();
- $uploadPath = $wpUploadDir['basedir'] . '/' . 'glm-member-import';
+
+ // Set the $uploadPath for import files
+ $uploadPath = $wpUploadDir['basedir'] . '/' . 'glm-member-import';
+
+ // If the folder for the upload import files doesn't exists create one.
if ( !is_dir( $uploadPath ) ) {
+ // Get old umask
$oldMask = umask(0);
+ // Set folder permission
mkdir( $uploadPath, 0770 );
+ // reset old umask
umask( $oldMask );
}
case 'validate';
$validFiles = 0;
+ // Set the view file
$view = 'validate.html';
$fileCount = count( $fileData );
// Move any files uploaded
case 'process':
$clearData = ( filter_var( $_REQUEST['clear_data'], FILTER_VALIDATE_BOOLEAN ) );
if ( $clearData ) {
- // empty tables
+ // Empty the tables for the member data.
+ // Not including the management options.
$this->wpdb->query('DELETE FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . 'amenity_ref');
$this->wpdb->query('DELETE FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . 'amenities');
$this->wpdb->query('DELETE FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . 'amenity_groups');
$this->wpdb->query('DELETE FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . 'member_info');
$this->wpdb->query('DELETE FROM ' . GLM_MEMBERS_PLUGIN_DB_PREFIX . 'members');
}
- //exit;
+
+ // Loop through the $fileData array.
+ // This will setup the wordpress options for each file.
foreach ( $fileData as $fileHeader => $file ) {
if ( is_file( $uploadPath . '/' . $file['name'] ) && $fileHeader != 'Member' ) {
- //$fileData[$fileHeader]['results']
$success = $this->processFile( $uploadPath . '/' . $file['name'], $file['type'] );
if ( $success ) {
$fileData[$fileHeader]['results'] = "<p>$fileHeader file processed successfully.</p>";
if ( count( $this->errors ) == 0 ) {
$readyToProcess = true;
}
+ // Set the view file
$view = 'process.html';
break;
if ( $this->numberProcessed == $this->totalMembers ) {
$this->processingComplete = true;
}
+ // Set the view file
$view = 'processMembers.html';
break;
$isValid = ( $fData == $validate );
// If the file validates then we're ready to process
$readyToProcess = $isValid;
+ // Set the view file
$view= 'photosValidate.html';
$fileData = '<pre>$_FILES: ' . print_r( $_FILES, true ) . '</pre>';
}
+ // Set the view file
$view= 'photosProcess.html';
} else {
+ // Set the view file
$view= 'photosValidate.html';
}
break;
case 'photos':
+ // Set the view file
$view= 'photos.html';
break;
case 'files':
+ // Set the view file
$view = 'files.html';
break;
case 'default':
default:
+ // Set the view file
$view = 'index.html';
// check upload dir to see if they have any files in yet
foreach ( $fileData as $fileHeader => $file ) {
'haveMembers' => $haveMembers,
'isValid' => $isValid,
);
+
// Return status, suggested view, and data to controller
return array(
'status' => true,
* Report errors in the $this->errors array.
*
* @param mixed $fileName File name for the csv file.
- * @param mixed $type Type (category,amenity,city)
+ * @param mixed $type Type (category,amenity,city...)
* @access public
* @return void