diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-06-11 19:26:25 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-06-11 19:26:25 +0100 |
| commit | 64aae1e41d9288a6d9709781af29b06fe6adb5ca (patch) | |
| tree | d5d5e74420cee938d7e8ff90b9e6792d5f44cc77 /import | |
| parent | 27c615a0a26edb985543e520587e3043d91489f6 (diff) | |
| download | contact-64aae1e41d9288a6d9709781af29b06fe6adb5ca.tar.gz contact-64aae1e41d9288a6d9709781af29b06fe6adb5ca.tar.bz2 contact-64aae1e41d9288a6d9709781af29b06fe6adb5ca.zip | |
Introduce ContactPerson and ContactBusiness subclasses
Splits the Contact class into ContactPerson (content_type_guid='contactperson')
and ContactBusiness (content_type_guid='contactbusiness'), each using 'contact'
as the shared package-level xref schema. Replaces the $isPerson/$00 xref hack
with proper class identity via instanceof.
- ContactPerson.php, ContactBusiness.php: new subclasses
- Contact.php: loadXrefTypeList() reads type tags directly from liberty_xref;
getAvailableTypeItems() for edit form (schema-driven with pre-upgrade fallback);
getDisplayUrl() now points to display_contact.php
- Type item codes: P01/P02 (person), B01-B04 (business, B01=Service new)
- list_people.php, list_businesses.php: separate list pages per type
- list_contacts.php: combined display-layer merge of both types
- 5.0.3.php: upgrade script migrating existing data to new content types and codes
- Templates: isPerson flag from instanceof; horizontal type checkboxes; list.tpl
accepts $listTitle; menu adds People/Businesses entries
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'import')
| -rw-r--r-- | import/ImportContactCSV.php | 12 | ||||
| -rw-r--r-- | import/load_contacts_csv.php | 2 |
2 files changed, 9 insertions, 5 deletions
diff --git a/import/ImportContactCSV.php b/import/ImportContactCSV.php index ada5732..a6e6b1d 100644 --- a/import/ImportContactCSV.php +++ b/import/ImportContactCSV.php @@ -24,6 +24,8 @@ namespace Bitweaver\Liberty; use Bitweaver\Contact\Contact; +use Bitweaver\Contact\ContactPerson; +use Bitweaver\Contact\ContactBusiness; /** * Delete any existing xref for ($contentId, $item) then re-insert if either $xkey or @@ -95,14 +97,16 @@ function contactCsvImportRow( array $row, int $rowNum ): array { return $result; } - // --- Find existing or create new via Contact class --- + // --- Find existing or create new via Contact subclass --- + $isPerson = ( $type === '$00' ); + $contentId = $gBitDb->getOne( "SELECT `content_id` FROM `" . BIT_DB_PREFIX . "liberty_content` - WHERE `content_type_guid` = 'contact' AND `title` = ?", + WHERE `content_type_guid` IN ('contactperson','contactbusiness','contact') AND `title` = ?", [ $title ] ); - $contact = new Contact( null, $contentId ?: null ); + $contact = $isPerson ? new ContactPerson( null, $contentId ?: null ) : new ContactBusiness( null, $contentId ?: null ); if( $contentId ) { $contact->load(); } @@ -118,7 +122,7 @@ function contactCsvImportRow( array $row, int $rowNum ): array { if( !empty( $type ) && $type[0] === '$' ) { $pHash['contact_types'] = [ $type ]; - if( $type === '$00' ) { + if( $isPerson ) { $pHash['name'] = $personName; } } diff --git a/import/load_contacts_csv.php b/import/load_contacts_csv.php index 3a75030..4e8adc7 100644 --- a/import/load_contacts_csv.php +++ b/import/load_contacts_csv.php @@ -52,7 +52,7 @@ if( !file_exists( $csvFile ) ) { if( empty( $title ) ) continue; $contentId = $gBitDb->getOne( "SELECT `content_id` FROM `" . BIT_DB_PREFIX . "liberty_content` - WHERE `content_type_guid` = 'contact' AND `title` = ?", + WHERE `content_type_guid` IN ('contactperson','contactbusiness') AND `title` = ?", [ $title ] ); if( $contentId ) { |
