summaryrefslogtreecommitdiff
path: root/list_contacts.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-06-11 19:26:25 +0100
committerLester Caine <lester@lsces.co.uk>2026-06-11 19:26:25 +0100
commit64aae1e41d9288a6d9709781af29b06fe6adb5ca (patch)
treed5d5e74420cee938d7e8ff90b9e6792d5f44cc77 /list_contacts.php
parent27c615a0a26edb985543e520587e3043d91489f6 (diff)
downloadcontact-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 'list_contacts.php')
-rwxr-xr-xlist_contacts.php27
1 files changed, 21 insertions, 6 deletions
diff --git a/list_contacts.php b/list_contacts.php
index 9aa8ca9..0d1899e 100755
--- a/list_contacts.php
+++ b/list_contacts.php
@@ -6,19 +6,34 @@
require_once '../kernel/includes/setup_inc.php';
-use Bitweaver\Contact\Contact;
+use Bitweaver\Contact\ContactPerson;
+use Bitweaver\Contact\ContactBusiness;
use Bitweaver\KernelTools;
$gBitSystem->verifyPackage( 'contact' );
$gBitSystem->verifyPermission( 'p_contact_view' );
-$gContent = new Contact();
-$gContent->invokeServices( 'content_list_function', $_REQUEST );
+// Persons and businesses are separate types — each has its own getList().
+// The combined display is a view-layer concern: merge, sort, and let the
+// template select the row template by content_type_guid.
+$personContent = new ContactPerson();
+$businessContent = new ContactBusiness();
-$listHash = $_REQUEST;
-$listcontacts = $gContent->getList( $listHash );
+$personHash = $_REQUEST;
+$businessHash = $_REQUEST;
-if( $listHash['listInfo']['count'] == 1 ) {
+$persons = $personContent->getList( $personHash );
+$businesses = $businessContent->getList( $businessHash );
+
+$listcontacts = array_merge( $persons, $businesses );
+usort( $listcontacts, fn( $a, $b ) => strcasecmp( $a['title'] ?? '', $b['title'] ?? '' ) );
+
+// listInfo: sum the two counts; use personHash's pagination metadata as base
+$listHash = $personHash;
+$listHash['cant'] = ( $personHash['cant'] ?? 0 ) + ( $businessHash['cant'] ?? 0 );
+$listHash['listInfo']['count'] = $listHash['cant'];
+
+if( $listHash['cant'] == 1 ) {
KernelTools::bit_redirect( CONTACT_PKG_URL."display_contact.php?content_id=".$listcontacts[0]['content_id'] );
}