public function modelAction($actionData = false)
{
- $option = 'importSetup';
- $importResult = array(
- 'status' => false,
- 'exceptionTable' => false
- );
- $errorMsg = false;
- $db_host = false;
- $db_name = false;
- $db_user = false;
- $db_password = false;
- $db_schema = false;
- $content = '';
- $thisOption = '';
- $requestedView = 'contacts.html';
- $result = '';
- $resultData = array();
+ $option = 'importSetup';
+ $errorMsg = false;
+ $db_host = false;
+ $db_name = false;
+ $db_user = false;
+ $db_password = false;
+ $db_schema = false;
+ $content = '';
+ $thisOption = '';
+ $requestedView = 'contacts.html';
+ $result = '';
+ $resultData = array();
+ $importResult = array( 'status' => false, 'exceptionTable' => false );
$templateData = array(
- 'thisOption' => '',
+ 'thisOption' => '',
);
if ($actionData) {
switch ($option) {
+ case 'migrate':
+ $requestedView = 'migrate.html';
+ $option2 = isset( $_REQUEST['option2'] ) ? filter_var( $_REQUEST['option2'], FILTER_SANITIZE_STRING ): '';
+ $result = '';
+ $migrateCount = 0;
+
+ echo '<pre>$option2: ' . print_r( $option2, true ) . '</pre>';
+
+ switch ( $option2 ) {
+
+ case 'migrate':
+ // Update all contacts to move the address data from Contact Info to Organization
+ $updated = $this->wpdb->query(
+ "UPDATE " . GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts
+ SET business_addr1 = addr1,
+ business_addr2 = addr2,
+ business_city = city,
+ business_state = state,
+ business_zip = zip,
+ business_country = country"
+ );
+ $result .= '<p>Updated: ' . $updated . '</p>';
+ // Empty the Original Contact Info address fields
+ $cleared = $this->wpdb->query(
+ "UPDATE " . GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts
+ SET addr1 = '',
+ addr2 = '',
+ city = NULL,
+ state = '',
+ zip = '',
+ country = ''"
+ );
+ $result .= '<p>cleared: ' . $cleared . '</p>';
+ // Update the business_email and business_phone fields with the custom field data
+ $custom = $this->wpdb->query(
+ "UPDATE " . GLM_MEMBERS_CONTACTS_PLUGIN_DB_PREFIX . "contacts C
+ SET business_email = (
+ SELECT field_data
+ FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data
+ WHERE field_id = 14
+ AND entity_id = C.id
+ ),
+ business_phone = (
+ SELECT field_data
+ FROM " . GLM_MEMBERS_FIELDS_PLUGIN_DB_PREFIX . "custom_field_data
+ WHERE field_id = 16
+ AND entity_id = C.id
+ )"
+ );
+ $result .= '<p>custom: ' . $custom . '</p>';
+ break;
+
+ }
+
+ break;
+
case 'clean':
$requestedView = 'clean.html';
$option2 = isset( $_REQUEST['option2'] ) ? filter_var( $_REQUEST['option2'], FILTER_SANITIZE_STRING ): '';
$result = '';
$archiveCount = 0;
- // $result = '<pre>$option2: ' . print_r( $option2, true ) . '</pre>';
switch ( $option2 ) {
+
case 'nomember':
$sql = "
SELECT id,email
<h2 class="nav-tab-wrapper">
<a href="{$thisUrl}?page={$thisPage}&glm_action=contacts" class="nav-tab{if $thisOption == ''} nav-tab-active{/if}">Contact Options</a>
+ <a href="{$thisUrl}?page={$thisPage}&glm_action=contacts&option=migrate" class="nav-tab{if $thisOption == 'migrate'} nav-tab-active{/if}">Migrate Contact Data</a>
{if apply_filters( 'glm-members-customfields-active', false )}
<a href="{$thisUrl}?page={$thisPage}&glm_action=contacts&option=customfields" class="nav-tab{if $thisOption == 'customfields'} nav-tab-active{/if}">Custom Fields</a>
{/if}
--- /dev/null
+{include file='admin/management/header.html'}
+{include file='admin/management/contactHeader.html'}
+
+ <h2>Migrate Data from Contacts</h2>
+
+ <form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
+ <input type="hidden" name="page" value="{$thisPage}" />
+ <input type="hidden" name="glm_action" value="contacts" />
+ <input type="hidden" name="option" value="migrate" />
+ <input type="hidden" name="option2" value="migrate" />
+ <input type="submit" value="Migrate Data" />
+ </form>
+
+ {if $result}
+ {$result}
+ {/if}
+
+ <script>
+ </script>
+
+{include file='admin/footer.html'}
+