From: Chuck Scott Date: Tue, 26 Jan 2016 19:11:46 +0000 (-0500) Subject: Updated import and fixed issues with resetting database X-Git-Tag: v1.1.0^2~4 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=bb57d0770b57c5b9911d1507734760f1ee670bdf;p=WP-Plugins%2Fglm-member-db.git Updated import and fixed issues with resetting database --- diff --git a/models/admin/management/import.php b/models/admin/management/import.php index 20f15abd..31503cdc 100644 --- a/models/admin/management/import.php +++ b/models/admin/management/import.php @@ -390,6 +390,8 @@ class GlmMembersAdmin_management_import // Read in all member categories + $haveCatImportIssues = false; + $catImportIssues = ''; if (!$failure) { $sql = " SELECT * @@ -418,31 +420,59 @@ class GlmMembersAdmin_management_import // Process top level categories first foreach ($tmp as $x) { - // If this is a top level category - if ($x['parent_id'] == 0) { + // If this is a top level category - parent = 0 or points to itself + if ($x['parent_id'] == 0 || $x['parent_id'] == $x['category_id']) { + + foreach ($category as $y) { + if ($y['name'] == $x['name']) { + $haveCatImportIssues = true; + $catImportIssues .= '
  • Category '.$x['name'].' ('.$x['category_id'].') has the same name as another category at the same level. Added as duplicate.
  • '; + } + } + reset($category); + $category[$x['category_id']] = $x; $category[$x['category_id']]['subcat'] = array(); + + if ($x['parent_id'] == $x['category_id']) { + $haveCatImportIssues = true; + $catImportIssues .= '
  • Category '.$x['name'].' ('.$x['category_id'].') was pointing to itself as a parent. Now a top level category.
  • '; + } } } - // Now process all sub-categories + // Now look for sub-categories with bad parents and add them as a main category reset($tmp); foreach ($tmp as $x) { - // If this is NOT a top level category - if ($x['parent_id'] > 0) { + // If this is NOT a top level category - Parent not 0 and not pointing to itself + if ($x['parent_id'] > 0 && $x['parent_id'] != $x['category_id']) { - // Check if we have the requested parent as a top-level category - if (isset($category[$x['parent_id']])) { - $category[$x['parent_id']]['subcat'][$x['category_id']] = $x; - } else { + // Check if we don't have the requested parent as a top-level category + if (!isset($category[$x['parent_id']])) { // Since the parent doesn't exist, we're just going to make this one a parent. + $haveCatImportIssues = true; + $catImportIssues .= '
  • Category '.$x['name'].' ('.$x['category_id'].') had a bad parent ID ('.$x['parent_id'].'). Now a top level category.
  • '; $category[$x['category_id']] = $x; $category[$x['category_id']]['subcat'] = array(); } } } + + // Now process all supposedly good sub-categories + reset($tmp); + foreach ($tmp as $x) { + + // If this is NOT a top level category - Parent not 0 and not pointing to itself + if ($x['parent_id'] > 0 && $x['parent_id'] != $x['category_id']) { + + // Check if we have the requested parent as a top-level category + if (isset($category[$x['parent_id']])) { + $category[$x['parent_id']]['subcat'][$x['category_id']] = $x; + } + } + } } } } @@ -1019,6 +1049,8 @@ class GlmMembersAdmin_management_import $templateData['numbMembersActive'] = $numbMembersActive; $templateData['numbMembersInactive'] = $numbMembersInactive; $templateData['numbCategories'] = count($catTrans); + $templateData['haveCatImportIssues'] = $haveCatImportIssues; + $templateData['catImportIssues'] = $catImportIssues; $templateData['numbCategoryMembers'] = count($membCat); $templateData['numbAmenities'] = count($amenity); $templateData['numbAmenityMembers'] = $numbAmenityMembers; diff --git a/setup/databaseScripts/drop_database_V1.0.43.sql b/setup/databaseScripts/drop_database_V1.0.43.sql index 553101a3..d77cfee1 100644 --- a/setup/databaseScripts/drop_database_V1.0.43.sql +++ b/setup/databaseScripts/drop_database_V1.0.43.sql @@ -8,11 +8,10 @@ DROP TABLE IF EXISTS {prefix}accommodation_types, {prefix}accommodations, {prefix}accounts, - {prefix}activties, + {prefix}activities, {prefix}amenities, {prefix}amenity_ref, {prefix}category_member_info, - {prefix}categories, {prefix}cities, {prefix}contacts, {prefix}facilities, @@ -30,6 +29,7 @@ DROP TABLE IF EXISTS {prefix}settings_general, {prefix}settings_terms, {prefix}social_media, - {prefix}social_media_ref + {prefix}social_media_ref, + {prefix}categories ; diff --git a/views/admin/management/import/readDatabase.html b/views/admin/management/import/readDatabase.html index bce2721f..898a11a6 100644 --- a/views/admin/management/import/readDatabase.html +++ b/views/admin/management/import/readDatabase.html @@ -16,7 +16,15 @@ Members Active:{$numbMembersActive} Members Inactive:{$numbMembersInactive} Categories:{$numbCategories} - Member Category Entires:{$numbCategoryMembers} + + Member Category Entries: + + {$numbCategoryMembers} + {if $haveCatImportIssues} + + {/if} + + Amenities:{$numbAmenities} Member Amenity Entries:{$numbAmenityMembers} Credit Card Types:{$numbCcards}