diff options
| -rwxr-xr-x | add_xref.php | 8 | ||||
| -rwxr-xr-x | add_xref_address.php | 4 | ||||
| -rwxr-xr-x | admin/schema_inc.php | 159 | ||||
| -rw-r--r-- | admin/upgrades/5.0.1.php | 10 | ||||
| -rwxr-xr-x | includes/bit_setup_inc.php | 1 | ||||
| -rwxr-xr-x | includes/classes/Contact.php | 44 | ||||
| -rwxr-xr-x | includes/classes/ContactType.php | 16 | ||||
| -rwxr-xr-x | templates/add_xref.tpl | 8 | ||||
| -rwxr-xr-x | templates/add_xref_address.tpl | 6 | ||||
| -rwxr-xr-x | templates/contact_date_bar.tpl | 2 | ||||
| -rwxr-xr-x | templates/display_contact.tpl | 2 | ||||
| -rwxr-xr-x | templates/list_xref_generic.tpl | 2 | ||||
| -rwxr-xr-x | templates/view_xref_address_record.tpl | 2 | ||||
| -rwxr-xr-x | templates/view_xref_contact_record.tpl | 4 | ||||
| -rwxr-xr-x | templates/view_xref_text_record.tpl | 4 |
15 files changed, 149 insertions, 123 deletions
diff --git a/add_xref.php b/add_xref.php index 749d6f4..6674768 100755 --- a/add_xref.php +++ b/add_xref.php @@ -28,7 +28,7 @@ if (isset($_REQUEST["fCancel"])) { } die; } elseif (isset($_REQUEST["fAddXref"])) { - $source = $_REQUEST["source"]; + $source = $_REQUEST["item"]; $format = $_REQUEST["format-".$source]; if ( $format != 'generic' ) { if ( isset( $_REQUEST[$format."xref"] ) ) { $_REQUEST["xref"] = $_REQUEST[$format."xref"]; } @@ -44,7 +44,7 @@ if (isset($_REQUEST["fCancel"])) { } -if( !isset( $_REQUEST['xref_type'] ) ) $_REQUEST['xref_type'] = 0; +if( !isset( $_REQUEST['group'] ) ) $_REQUEST['group'] = 0; $gBitSystem->setOnloadScript( 'updateContactXrefFormat();' ); @@ -52,9 +52,9 @@ $gBitSystem->setOnloadScript( 'updateContactXrefFormat();' ); if( empty( $xrefInfo ) ) { $xrefInfo = &$gContent->mInfo['xref_store']; $xrefInfo['content_id'] = $gContent->mContentId; - $xrefInfo['xref_type'] = $_REQUEST['xref_type']; + $xrefInfo['group'] = $_REQUEST['group']; } -$xrefInfo['xref_type_list'] = $gContent->getXrefTypeList( $xrefInfo['xref_type'] ); +$xrefInfo['xref_type_list'] = $gContent->getXrefTypeList( $xrefInfo['group'] ); $xrefInfo['xref_format_list'] = $gContent->getXrefFormatList(); // Don't use ckeditor for text fields ' diff --git a/add_xref_address.php b/add_xref_address.php index bc9e471..0ea548d 100755 --- a/add_xref_address.php +++ b/add_xref_address.php @@ -36,13 +36,13 @@ if (isset($_REQUEST["fCancel"])) { } } -$_REQUEST['xref_type'] = 10; +$_REQUEST['group'] = 10; // formInfo might be set due to a error on submit if( empty( $xrefInfo ) ) { $xrefInfo = &$gContent->mInfo['xref_store']; $xrefInfo['content_id'] = $gContent->mContentId; - $xrefInfo['xref_type'] = $_REQUEST['xref_type']; + $xrefInfo['group'] = $_REQUEST['group']; } $xrefInfo['xref_type_list'] = $gContent->getXrefTypeList( 0, 'address' ); // Don't use ckeditor for text fields ' diff --git a/admin/schema_inc.php b/admin/schema_inc.php index 7868f90..2e6391c 100755 --- a/admin/schema_inc.php +++ b/admin/schema_inc.php @@ -1,7 +1,7 @@ <?php $tables = [ - 'contact' => " + 'contact' => " content_id I8 PRIMARY, parent_id I8 DEFAULT 0, address_id I8 DEFAULT 0, @@ -9,7 +9,7 @@ $tables = [ xkey C(32) ", - 'contact_address' => " + 'contact_address' => " content_id I8 PRIMARY, address_id I8, uprn I8, @@ -28,6 +28,27 @@ $tables = [ cltype I2 ", + 'address_postcode' => " + postcode C(10) NOTNULL PRIMARY, + add1 C(32) DEFAULT '', + add2 C(32) DEFAULT '', + add3 C(32) DEFAULT '', + add4 C(32) DEFAULT '', + town C(20) DEFAULT '', + county C(20) DEFAULT '', + grideast C(6) DEFAULT '00000', + gridnorth C(6) DEFAULT '00000', + wcd C(6) DEFAULT '', + nhs C(3) DEFAULT '', + pcg C(5) DEFAULT '', + wnw C(32) DEFAULT '', + wna C(32) DEFAULT '', + pnp C(32) DEFAULT '', + pnh C(32) DEFAULT '', + nnh C(32) DEFAULT '', + nnr C(32) DEFAULT '' +", + ]; global $gBitInstaller; @@ -37,9 +58,10 @@ foreach( array_keys( $tables ) AS $tableName ) { } $gBitInstaller->registerPackageInfo( CONTACT_PKG_NAME, [ - 'description' => "Base Contact management package with contact xref and address books + 'description' => "Base Contact management package with contact xref and address books designed to be expanded with additional plugins.", - 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>', + 'license' => '<a href="http://www.gnu.org/licenses/licenses.html#LGPL">LGPL</a>', + 'dependencies' => 'liberty', ] ); // ### Indexes @@ -50,79 +72,82 @@ $indices = [ $gBitInstaller->registerSchemaIndexes( CONTACT_PKG_NAME, $indices ); // ### Sequences -$sequences = []; -$gBitInstaller->registerSchemaSequences( CONTACT_PKG_NAME, $sequences ); +$gBitInstaller->registerSchemaSequences( CONTACT_PKG_NAME, [] ); // ### Defaults +// xref configuration now lives in liberty_xref_group and liberty_xref_item (content_type_guid='contact'). +// These replace the old contact_xref_type and contact_xref_source table defaults. +$gBitInstaller->registerSchemaDefault( CONTACT_PKG_NAME, [ + + // --- liberty_xref_group (formerly contact_xref_type: integer xref_type → sort_order, source text → x_group) --- + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('type', 'contact','Contact Type List', 0,3,'')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('contact','contact','General Contact Details', 1,3,'')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('links', 'contact','Linked Contact Items', 2,3,'')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('alarm', 'contact','Security System Links', 3,3,'')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('council','contact','Council reference links', 4,3,'')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('account','contact','Account Details', 5,4,'')", + + // --- liberty_xref_item (formerly contact_xref_source) --- + // group: type + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('\$00','contact','type','Personal', 0,3,'/contact/?type=0', NULL)", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('\$01','contact','type','Business', 0,3,'/contact/?type=1', NULL)", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('\$02','contact','type','Manufacturer', 0,3,'/contact/?type=2', NULL)", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('\$03','contact','type','Distributor', 0,3,'/contact/?type=3', NULL)", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('\$04','contact','type','Supplier', 0,3,'/contact/?type=4', NULL)", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('\$05','contact','type','Record Company', 0,3,'/contact/?type=5', NULL)", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('\$06','contact','type','Record Artist', 0,3,'/contact/?type=6', NULL)", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('\$07','contact','type','Cartographer', 0,3,'/contact/?type=7', NULL)", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('\$08','contact','type','PHX Client', 0,3,'/contact/?type=8', NULL)", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('\$09','contact','type','LSCES Supplier', 0,3,'/contact/?type=9', NULL)", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('\$10','contact','type','Paypal Client', 0,3,'/contact/?type=10',NULL)", + // group: contact + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('#C','contact','contact','Contact Address', 0,3,'../nlpg/?uprn=', 'address')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('#E','contact','contact','eMail Address', 1,3,'../contact/?contact_id=','text' )", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('#F','contact','contact','Fax', 1,3,'../contact/?contact_id=','text' )", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('#I','contact','contact','Invoice Address', 0,3,'../nlpg/?uprn=', 'address')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('#P','contact','contact','Telephone', 1,3,'../contact/?contact_id=','phone' )", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('#R','contact','contact','Residential Address', 0,3,'../nlpg/?uprn=', 'address')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('#S','contact','contact','Service Address', 0,3,'../nlpg/?uprn=', 'address')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('#T','contact','contact','Tenant Address', 0,3,'../nlpg/?uprn=', 'address')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('#W','contact','contact','Web Site Url', 1,3,'../contact/?contact_id=','text' )", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('0', 'contact','contact','Free format information', 1,3,'../contact/?xref=', 'text' )", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('CON','contact','contact','Contact', 1,3,'../nlpg/?uprn=', 'text' )", + // group: alarm + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('#A', 'contact','alarm','Alarm Maintainer', 0,3,'../nlpg/?uprn=','text' )", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('#K', 'contact','alarm','Keyholder', 1,3,'../nlpg/?uprn=','phone')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('ALARM','contact','alarm','Alarm System', 0,3,'../nlpg/?uprn=','text' )", + // group: council + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('CTAX','contact','council','Council Tax', 0,3,'../nlpg/?uprn=','text')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('ER', 'contact','council','Electoral Roll', 0,3,'../nlpg/?uprn=','text')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('HBEN','contact','council','Housing Benefit', 0,3,'../nlpg/?uprn=','text')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('NNDR','contact','council','National Non-domestic Rates',0,3,'../nlpg/?uprn=','text')", + // group: account + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('ACC_TO','contact','account','Account Turnover', 0,3,'../vat/?vat=', 'text')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('SAGEID','contact','account','SAGE Account Reference', 0,3,'''sage''', 'text')", + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` (`item`,`content_type_guid`,`x_group`,`cross_ref_title`,`multiple`,`role_id`,`cross_ref_href`,`template`) VALUES ('VAT_NO','contact','account','VAT Number', 0,3,'../vat/?vat=', 'text')", + +] ); // ### Default User Permissions $gBitInstaller->registerUserPermissions( CONTACT_PKG_NAME, [ - [ 'p_contact_view', 'Can browse the Contact List', 'basic', CONTACT_PKG_NAME ], - [ 'p_contact_update', 'Can update the Contact List content', 'registered', CONTACT_PKG_NAME ], - [ 'p_contact_create', 'Can create a new Contact List entry', 'registered', CONTACT_PKG_NAME ], - [ 'p_contact_admin', 'Can admin Contact List', 'admin', CONTACT_PKG_NAME ], - [ 'p_contact_expunge', 'Can remove a Contact entry', 'editors', CONTACT_PKG_NAME ], + [ 'p_contact_view', 'Can browse the Contact List', 'basic', CONTACT_PKG_NAME ], + [ 'p_contact_update', 'Can update the Contact List content','registered', CONTACT_PKG_NAME ], + [ 'p_contact_create', 'Can create a new Contact List entry','registered', CONTACT_PKG_NAME ], + [ 'p_contact_admin', 'Can admin Contact List', 'admin', CONTACT_PKG_NAME ], + [ 'p_contact_expunge', 'Can remove a Contact entry', 'editors', CONTACT_PKG_NAME ], ] ); // ### Default Preferences $gBitInstaller->registerPreferences( CONTACT_PKG_NAME, [ [ CONTACT_PKG_NAME, 'contact_default_ordering', 'title_desc' ], - [ CONTACT_PKG_NAME, 'contact_list_created', 'y' ], - [ CONTACT_PKG_NAME, 'contact_list_lastmodif', 'y' ], - [ CONTACT_PKG_NAME, 'contact_list_notes', 'y' ], - [ CONTACT_PKG_NAME, 'contact_list_title', 'y' ], - [ CONTACT_PKG_NAME, 'contact_list_user', 'y' ], -] ); - -// liberty_xref_type columns: xref_type, content_type_guid, title, sort_order, role_id, type_href -// liberty_xref_source columns: source, content_type_guid, xref_type, cross_ref_title, multi, role_id, cross_ref_href, template, data -$gBitInstaller->registerSchemaDefault( CONTACT_PKG_NAME, [ - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_type` (`xref_type`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('type', 'contact','Contact Type List', 0,3,'')", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_type` (`xref_type`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('contact','contact','General Contact Details', 1,3,'')", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_type` (`xref_type`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('links', 'contact','Linked Contact Items', 2,3,'')", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_type` (`xref_type`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('alarm', 'contact','Security System Links', 3,3,'')", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_type` (`xref_type`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('council','contact','Council reference links', 4,3,'')", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_type` (`xref_type`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES ('account','contact','Account Details', 5,4,'')", - - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('\$00','contact','type','Personal', 0,3,'/contact/?type=0', NULL,NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('\$01','contact','type','Business', 0,3,'/contact/?type=1', NULL,NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('\$02','contact','type','Manufacturer', 0,3,'/contact/?type=2', NULL,NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('\$03','contact','type','Distributor', 0,3,'/contact/?type=3', NULL,NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('\$04','contact','type','Supplier', 0,3,'/contact/?type=4', NULL,NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('\$05','contact','type','Record Company', 0,3,'/contact/?type=5', NULL,NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('\$06','contact','type','Record Artist', 0,3,'/contact/?type=6', NULL,NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('\$07','contact','type','Cartographer', 0,3,'/contact/?type=7', NULL,NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('\$08','contact','type','PHX Client', 0,3,'/contact/?type=8', NULL,NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('\$09','contact','type','LSCES Supplier', 0,3,'/contact/?type=9', NULL,NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('\$10','contact','type','Paypal Client', 0,3,'/contact/?type=10',NULL,NULL)", - - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#C','contact','contact','Contact Address', 0,3,'../nlpg/?uprn=', 'address',NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#E','contact','contact','eMail Address', 1,3,'../contact/?contact_id=', 'text', NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#F','contact','contact','Fax', 1,3,'../contact/?contact_id=', 'text', NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#I','contact','contact','Invoice Address', 0,3,'../nlpg/?uprn=', 'address',NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#P','contact','contact','Telephone', 1,3,'../contact/?contact_id=', 'phone', NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#R','contact','contact','Residential Address', 0,3,'../nlpg/?uprn=', 'address',NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#S','contact','contact','Service Address', 0,3,'../nlpg/?uprn=', 'address',NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#T','contact','contact','Tenant Address', 0,3,'../nlpg/?uprn=', 'address',NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#W','contact','contact','Web Site Url', 1,3,'../contact/?contact_id=', 'text', NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('0', 'contact','contact','Free format information',1,3,'../contact/?xref=', 'text', NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('CON','contact','links', 'Contact', 1,3,'../nlpg/?uprn=', 'text', NULL)", - - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#A', 'contact','alarm', 'Alarm Maintainer', 0,3,'../nlpg/?uprn=','text', NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('#K', 'contact','alarm', 'Keyholder', 1,3,'../nlpg/?uprn=','phone',NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('ALARM','contact','alarm', 'Alarm System', 0,3,'../nlpg/?uprn=','text', NULL)", - - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('CTAX','contact','council','Council Tax', 0,3,'../nlpg/?uprn=','text',NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('ER', 'contact','council','Electoral Roll', 0,3,'../nlpg/?uprn=','text',NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('HBEN','contact','council','Housing Benefit', 0,3,'../nlpg/?uprn=','text',NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('NNDR','contact','council','National Non-domestic Rates', 0,3,'../nlpg/?uprn=','text',NULL)", - - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('ACC_TO','contact','account','Account Turnover', 0,3,'../vat/?vat=', 'text',NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('SAGEID','contact','account','SAGE Account Reference', 0,3,'''sage''', 'text',NULL)", - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` (`source`,`content_type_guid`,`xref_type`,`cross_ref_title`,`multi`,`role_id`,`cross_ref_href`,`template`,`data`) VALUES ('VAT_NO','contact','account','VAT Number', 0,3,'../vat/?vat=', 'text',NULL)", + [ CONTACT_PKG_NAME, 'contact_list_created', 'y' ], + [ CONTACT_PKG_NAME, 'contact_list_lastmodif', 'y' ], + [ CONTACT_PKG_NAME, 'contact_list_notes', 'y' ], + [ CONTACT_PKG_NAME, 'contact_list_title', 'y' ], + [ CONTACT_PKG_NAME, 'contact_list_user', 'y' ], ] ); -// Requirements +// ### Requirements $gBitInstaller->registerRequirements( CONTACT_PKG_NAME, [ - 'liberty' => [ 'min' => '5.0.0' ], -] );
\ No newline at end of file + 'liberty' => [ 'min' => '5.0.1' ], +] ); diff --git a/admin/upgrades/5.0.1.php b/admin/upgrades/5.0.1.php index 538e498..b40ddc9 100644 --- a/admin/upgrades/5.0.1.php +++ b/admin/upgrades/5.0.1.php @@ -15,15 +15,15 @@ $gBitInstaller->registerPackageUpgrade( [ 'QUERY' => [ 'SQL92' => [ // contact_xref_type: integer xref_type becomes sort_order; text source becomes the xref_type key - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_type` - (`xref_type`, `content_type_guid`, `title`, `sort_order`, `role_id`, `type_href`) + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_group` + (`x_group`, `content_type_guid`, `title`, `sort_order`, `role_id`, `type_href`) SELECT `source`, 'contact', `title`, `xref_type`, `role_id`, `type_href` FROM `" . BIT_DB_PREFIX . "contact_xref_type`", // contact_xref_source: integer xref_type joined to get the text key - "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_source` - (`source`, `content_type_guid`, `xref_type`, `cross_ref_title`, `multi`, `role_id`, `cross_ref_href`, `template`, `data`) + "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref_item` + (`item`, `content_type_guid`, `x_group`, `cross_ref_title`, `multiple`, `role_id`, `cross_ref_href`, `template`, `data`) SELECT cs.`source`, 'contact', ct.`source`, cs.`cross_ref_title`, cs.`multi`, cs.`role_id`, cs.`cross_ref_href`, cs.`template`, cs.`data` FROM `" . BIT_DB_PREFIX . "contact_xref_source` cs @@ -31,7 +31,7 @@ $gBitInstaller->registerPackageUpgrade( // contact_xref: direct column mapping, xref_id preserved "INSERT INTO `" . BIT_DB_PREFIX . "liberty_xref` - (`xref_id`, `content_id`, `source`, `xorder`, `xref`, `xkey`, `xkey_ext`, `data`, `start_date`, `last_update_date`, `entry_date`, `end_date`) + (`xref_id`, `content_id`, `item`, `xorder`, `xref`, `xkey`, `xkey_ext`, `data`, `start_date`, `last_update_date`, `entry_date`, `end_date`) SELECT `xref_id`, `content_id`, `source`, `xorder`, `xref`, `xkey`, `xkey_ext`, `data`, `start_date`, `last_update_date`, `entry_date`, `end_date` FROM `" . BIT_DB_PREFIX . "contact_xref`", diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index 45f7742..a8e53e2 100755 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -15,6 +15,7 @@ define( 'CONTACT_PKG_NAME', $pRegisterHash['package_name'] ); define( 'CONTACT_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' ); define( 'CONTACT_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/' ); define( 'CONTACT_PKG_INCLUDE_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); +define( 'CONTACT_PKG_ADMIN_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/admin/'); $gBitSystem->registerPackage( $pRegisterHash ); if( $gBitSystem->isPackageActive( 'contact' ) ) { diff --git a/includes/classes/Contact.php b/includes/classes/Contact.php index 3fdbee5..c6ed102 100755 --- a/includes/classes/Contact.php +++ b/includes/classes/Contact.php @@ -86,10 +86,10 @@ class Contact extends LibertyContent { LEFT JOIN `".BIT_DB_PREFIX."liberty_content` lc ON lc.content_id = con.content_id LEFT JOIN `".BIT_DB_PREFIX."users_users` uue ON (uue.`user_id` = lc.`modifier_user_id`) LEFT JOIN `".BIT_DB_PREFIX."users_users` uuc ON (uuc.`user_id` = lc.`user_id`) - LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` img ON img.`content_id` = con.`content_id` AND img.`source` = 'IMG' - LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` x00 ON x00.`content_id` = con.`content_id` AND x00.`source` = '$00' - LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhA ON xhA.`content_id` = con.`content_id` AND xhA.`source` = '#S' AND ( xhA.`end_date` IS NULL OR xhA.`end_date` > CURRENT_TIMESTAMP ) - LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhL ON xhL.`content_id` = con.`content_id` AND xhL.`source` = '#L' AND ( xhL.`end_date` IS NULL OR xhL.`end_date` > CURRENT_TIMESTAMP ) + LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` img ON img.`content_id` = con.`content_id` AND img.`item` = 'IMG' + LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` x00 ON x00.`content_id` = con.`content_id` AND x00.`item` = '$00' + LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhA ON xhA.`content_id` = con.`content_id` AND xhA.`item` = '#S' AND ( xhA.`end_date` IS NULL OR xhA.`end_date` > CURRENT_TIMESTAMP ) + LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhL ON xhL.`content_id` = con.`content_id` AND xhL.`item` = '#L' AND ( xhL.`end_date` IS NULL OR xhL.`end_date` > CURRENT_TIMESTAMP ) LEFT JOIN `".BIT_DB_PREFIX."address_postcode` ap ON ap.`postcode` = xhA.`xkey` WHERE con.`content_id`=?"; $result = $this->mDb->query( $query, [ $this->mContentId ] ); @@ -209,17 +209,17 @@ class Contact extends LibertyContent { $result = $this->mDb->associateInsert( $atable, $pParamHash['contact_store'] ); } if( !empty( $pParamHash['contact_types'] ) ) { - $query = "DELETE FROM `".BIT_DB_PREFIX."liberty_xref` WHERE `content_id` = ? AND `source` LIKE '$%'"; + $query = "DELETE FROM `".BIT_DB_PREFIX."liberty_xref` WHERE `content_id` = ? AND `item` LIKE '$%'"; $result = $this->mDb->query($query, [$this->mContentId ] ); foreach ( $pParamHash['contact_types'] as $key => $source ) { if ( $source == '$00' ) { - $query = "INSERT INTO `".BIT_DB_PREFIX."liberty_xref` (`content_id`, `source`, `xkey_ext`, `last_update_date`) VALUES ( ?, ?, ?, NULL )"; + $query = "INSERT INTO `".BIT_DB_PREFIX."liberty_xref` (`content_id`, `item`, `xkey_ext`, `last_update_date`) VALUES ( ?, ?, ?, NULL )"; $result = $this->mDb->query($query, [ $this->mContentId, $source, $pParamHash['name'] ] ); } else if ( $source == '$01' ) { - $query = "INSERT INTO `".BIT_DB_PREFIX."liberty_xref` (`content_id`, `source`, `xkey_ext`, `last_update_date`) VALUES ( ?, ?, ?, NULL )"; + $query = "INSERT INTO `".BIT_DB_PREFIX."liberty_xref` (`content_id`, `item`, `xkey_ext`, `last_update_date`) VALUES ( ?, ?, ?, NULL )"; $result = $this->mDb->query($query, [ $this->mContentId, $source, $pParamHash['organisation'] ] ); } else { - $query = "INSERT INTO `".BIT_DB_PREFIX."liberty_xref` (`content_id`, `source`, `last_update_date`) VALUES ( ?, ?, NULL )"; + $query = "INSERT INTO `".BIT_DB_PREFIX."liberty_xref` (`content_id`, `item`, `last_update_date`) VALUES ( ?, ?, NULL )"; $result = $this->mDb->query($query, [ $this->mContentId, $source ] ); } } @@ -345,7 +345,7 @@ class Contact extends LibertyContent { } } elseif ( isset( $pParamHash['contact_type_guid'][0] ) ) { - $joinSql .= "JOIN `".BIT_DB_PREFIX."liberty_xref` cx ON cx.`content_id` = con.`content_id` AND cx.`source` = ? "; + $joinSql .= "JOIN `".BIT_DB_PREFIX."liberty_xref` cx ON cx.`content_id` = con.`content_id` AND cx.`item` = ? "; $bindVars[] = $pParamHash['contact_type_guid'][0]; } @@ -425,11 +425,11 @@ class Contact extends LibertyContent { $query = "SELECT con.`content_id` as content_id, con.*, lc.*, ap.*, xhA.`xkey_ext` AS house, xhL.`xkey` as x_coordinate, xhL.`xkey_ext` as y_coordinate, - (SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref` x WHERE x.`content_id` = con.`content_id` AND x.`source` NOT STARTING WITH '$' ) AS refs + (SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref` x WHERE x.`content_id` = con.`content_id` AND x.`item` NOT STARTING WITH '$' ) AS refs FROM `".BIT_DB_PREFIX."contact` con LEFT JOIN `".BIT_DB_PREFIX."liberty_content` lc ON lc.`content_id` = con.`content_id` - LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhA ON xhA.`content_id` = con.`content_id` AND ( xhA.`source` IN ( SELECT `source` FROM `".BIT_DB_PREFIX."liberty_xref_source` WHERE `template` = 'address' AND `content_type_guid` = 'contact' ) ) AND ( xhA.`end_date` IS NULL OR xhA.`end_date` > CURRENT_TIMESTAMP ) - LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhL ON xhL.`content_id` = con.`content_id` AND xhL.`source` = '#L' AND ( xhL.`end_date` IS NULL OR xhL.`end_date` > CURRENT_TIMESTAMP ) + LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhA ON xhA.`content_id` = con.`content_id` AND ( xhA.`item` IN ( SELECT `item` FROM `".BIT_DB_PREFIX."liberty_xref_item` WHERE `template` = 'address' AND `content_type_guid` = 'contact' ) ) AND ( xhA.`end_date` IS NULL OR xhA.`end_date` > CURRENT_TIMESTAMP ) + LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhL ON xhL.`content_id` = con.`content_id` AND xhL.`item` = '#L' AND ( xhL.`end_date` IS NULL OR xhL.`end_date` > CURRENT_TIMESTAMP ) LEFT JOIN `".BIT_DB_PREFIX."address_postcode` ap ON ap.`postcode` = xhA.`xkey` $findSql $joinSql @@ -440,7 +440,7 @@ class Contact extends LibertyContent { $query_cant = "SELECT COUNT( * ) FROM `".BIT_DB_PREFIX."contact` con LEFT JOIN `".BIT_DB_PREFIX."liberty_content` lc ON lc.content_id = con.content_id - LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhA ON xhA.`content_id` = con.`content_id` AND xhA.`source` = '#S' AND ( xhA.`end_date` IS NULL OR xhA.`end_date` > CURRENT_TIMESTAMP ) + LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhA ON xhA.`content_id` = con.`content_id` AND xhA.`item` = '#S' AND ( xhA.`end_date` IS NULL OR xhA.`end_date` > CURRENT_TIMESTAMP ) LEFT JOIN `".BIT_DB_PREFIX."address_postcode` ap ON ap.`postcode` = xhA.`xkey` $joinSql WHERE lc.`content_type_guid` = ? $whereSql "; $result = $this->mDb->query( $query, $bindVars, $max_records, $offset ); @@ -471,9 +471,9 @@ class Contact extends LibertyContent { ELSE CAST ( r.`xkey_ext` AS INTEGER ) END AS XORDERBY FROM `".BIT_DB_PREFIX."liberty_xref` r LEFT JOIN `".BIT_DB_PREFIX."liberty_content` lc ON lc.`content_id` = r.`content_id` - LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhA ON xhA.`content_id` = lc.`content_id` AND xhA.`source` = '#S' AND ( xhA.`end_date` IS NULL OR xhA.`end_date` > CURRENT_TIMESTAMP ) + LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` xhA ON xhA.`content_id` = lc.`content_id` AND xhA.`item` = '#S' AND ( xhA.`end_date` IS NULL OR xhA.`end_date` > CURRENT_TIMESTAMP ) LEFT JOIN `".BIT_DB_PREFIX."address_postcode` ap ON ap.`postcode` = xhA.`xkey` - WHERE r.`source` = 'KEY_S' AND r.`xref` = ? AND ( r.`end_date` IS NULL OR r.`end_date` > CURRENT_TIMESTAMP ) + WHERE r.`item` = 'KEY_S' AND r.`xref` = ? AND ( r.`end_date` IS NULL OR r.`end_date` > CURRENT_TIMESTAMP ) ORDER BY r.`xref`, XORDERBY"; $result = $this->mDb->query($query, [ $contract ] ); @@ -510,12 +510,12 @@ class Contact extends LibertyContent { $sql = "SELECT r.`xref_id`, r.`content_id`, r.`last_update_date`, c.`title`, CASE WHEN r.`end_date` < ? THEN 'history' - ELSE r.`source` END as type_source, + ELSE r.`item` END as type_source, r.`xkey`, r.`xkey_ext`, r.`data`, r.`start_date`, r.`end_date` FROM `".BIT_DB_PREFIX."liberty_xref` r JOIN `".BIT_DB_PREFIX."liberty_content` c ON c.`content_id` = r.`content_id` - WHERE r.`xref` = ? AND r.`source` = '#A' + WHERE r.`xref` = ? AND r.`item` = '#A' ORDER BY c.`title`"; // LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id` = s.`role_id` ) // AND (s.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?) @@ -542,10 +542,10 @@ class Contact extends LibertyContent { array_push( $bindVars, $this->mContentId ); $bindVars = array_merge( $bindVars, $roles, [ $gBitUser->mUserId ] ); - $sql = "SELECT s.xref_type, x.`xref_id`, x.`last_update_date`, x.`source`, t.`title` AS type_title, + $sql = "SELECT s.`x_group`, x.`xref_id`, x.`last_update_date`, x.`item`, t.`title` AS type_title, CASE WHEN x.`end_date` < ? THEN 'history' - ELSE t.`xref_type` END as type_source, + ELSE t.`x_group` END as type_source, CASE WHEN x.`xorder` = 0 THEN s.`cross_ref_title` ELSE s.`cross_ref_title` || '-' || x.`xorder` END @@ -553,12 +553,12 @@ class Contact extends LibertyContent { x.`xkey_ext` AS house, ap.`add1`, ap.`add2`, ap.`add3`, ap.`add4`, ap.`town`, ap.`county`, x.`xkey` AS postcode, ap.`grideast`, ap.`gridnorth`, x.`data`, x.`start_date`, x.`end_date` FROM `".BIT_DB_PREFIX."liberty_xref` x - JOIN `".BIT_DB_PREFIX."liberty_xref_source` s ON s.`source` = x.`source` AND s.`content_type_guid` = 'contact' - JOIN `".BIT_DB_PREFIX."liberty_xref_type` t ON t.`xref_type` = s.`xref_type` AND t.`content_type_guid` = 'contact' + JOIN `".BIT_DB_PREFIX."liberty_xref_item` s ON s.`item` = x.`item` AND s.`content_type_guid` = 'contact' + JOIN `".BIT_DB_PREFIX."liberty_xref_group` t ON t.`x_group` = s.`x_group` AND t.`content_type_guid` = 'contact' LEFT JOIN `".BIT_DB_PREFIX."address_postcode` ap ON ap.`postcode` = x.`xkey` LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id`=s.`role_id` ) WHERE x.content_id = ? AND s.`template` = 'address' AND (s.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?) - ORDER BY x.`source`, x.`xorder`"; + ORDER BY x.`item`, x.`xorder`"; $result = $this->mDb->query( $sql, $bindVars ); diff --git a/includes/classes/ContactType.php b/includes/classes/ContactType.php index 7a4e550..65c077d 100755 --- a/includes/classes/ContactType.php +++ b/includes/classes/ContactType.php @@ -36,17 +36,17 @@ class ContactType extends BitBase { $bindVars = []; $bindVars = array_merge( $bindVars, $roles, [ $gBitUser->mUserId ] ); - $sql = "SELECT r.`source`, r.`cross_ref_title` - FROM `".BIT_DB_PREFIX."liberty_xref_source` r - JOIN `".BIT_DB_PREFIX."liberty_xref_type` t ON t.`xref_type` = r.`xref_type` AND t.`content_type_guid` = r.`content_type_guid` + $sql = "SELECT r.`item`, r.`cross_ref_title` + FROM `".BIT_DB_PREFIX."liberty_xref_item` r + JOIN `".BIT_DB_PREFIX."liberty_xref_group` t ON t.`x_group` = r.`x_group` AND t.`content_type_guid` = r.`content_type_guid` LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id`=r.`role_id` ) WHERE r.`content_type_guid` = 'contact' AND t.`sort_order` = 0 AND (r.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?) - ORDER BY r.`source`"; + ORDER BY r.`item`"; $result = $this->mDb->query( $sql, $bindVars ); while( $res = $result->fetchRow() ) { - $this->mContactType[ $res['source']] = $res['cross_ref_title']; + $this->mContactType[ $res['item']] = $res['cross_ref_title']; } // asort($this->mContactType); @@ -91,7 +91,7 @@ class ContactType extends BitBase { $where = $where ? $where . " AND $guidWhere" : " WHERE $guidWhere"; $query = "SELECT cxt.* - FROM `".BIT_DB_PREFIX."liberty_xref_type` cxt + FROM `".BIT_DB_PREFIX."liberty_xref_group` cxt $where ORDER BY cxt.`sort_order`"; $result = $gBitSystem->mDb->query( $query, $bindVars ); @@ -100,8 +100,8 @@ class ContactType extends BitBase { while( $res = $result->fetchRow() ) { $res["num_types"] = $gBitSystem->mDb->getOne( - "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref_source` WHERE `xref_type` = ? AND `content_type_guid` = 'contact'", - [ $res["xref_type"] ] + "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref_item` WHERE `x_group` = ? AND `content_type_guid` = 'contact'", + [ $res["x_group"] ] ); $ret[] = $res; } diff --git a/templates/add_xref.tpl b/templates/add_xref.tpl index 6b07030..fa99ca7 100755 --- a/templates/add_xref.tpl +++ b/templates/add_xref.tpl @@ -5,7 +5,7 @@ function updateContactXrefFormat() { {/literal} document.getElementById('{$output}-format').style.display = 'none'; {/foreach} {literal} var form = document.getElementById('editContactXrefForm'); - var input = form.source; + var input = form.item; var i = input.selectedIndex; var select = document.getElementById('format-'+input.options[i].value).value; document.getElementById(select+'-format').style.display = 'block'; @@ -25,7 +25,7 @@ function updateContactXrefFormat() { {/literal} <div class="body"> {form enctype="multipart/form-data" id="editContactXrefForm"} <input type="hidden" name="content_id" value="{$xrefInfo.content_id}" /> - <input type="hidden" name="xref_type" value="{$xrefInfo.xref_type}" /> + <input type="hidden" name="group" value="{$xrefInfo.group}" /> {foreach from=$xrefInfo.xref_type_list.type key=feature item=output} <input type="hidden" id="format-{$feature}" name="format-{$feature}" value="{$output}" /> {/foreach} @@ -36,9 +36,9 @@ function updateContactXrefFormat() { {/literal} {formfeedback error=$errors warning=$contactWarnings success=$contactSuccess} <div class="form-group"> - {formlabel label="Reference Type" for="source"} + {formlabel label="Reference Type" for="item"} {forminput} - {html_options name="source" id="source" options=$xrefInfo.xref_type_list.list selected=$smarty.const.CONTACT_FORMAT_GENERIC onchange="updateContactXrefFormat();"} + {html_options name="item" id="item" options=$xrefInfo.xref_type_list.list selected=$smarty.const.CONTACT_FORMAT_GENERIC onchange="updateContactXrefFormat();"} {formhelp note="Select type of reference information to add"} {/forminput} </div> diff --git a/templates/add_xref_address.tpl b/templates/add_xref_address.tpl index 67374cd..51dc2ad 100755 --- a/templates/add_xref_address.tpl +++ b/templates/add_xref_address.tpl @@ -11,15 +11,15 @@ <div class="body"> {form enctype="multipart/form-data" id="writexref"} <input type="hidden" name="content_id" value="{$xrefInfo.content_id}" /> - <input type="hidden" name="xref_type" value="{$xrefInfo.xref_type}" /> + <input type="hidden" name="group" value="{$xrefInfo.group}" /> {jstabs} {jstab title="Address Details"} {legend legend="Contents"} <div class="form-group"> - {formlabel label="Address Type" for="source"} + {formlabel label="Address Type" for="item"} {forminput} - {html_options name="$xrefInfo.xref_type_list[$xrefInfo.source]" options=$xrefInfo.xref_type_list selected=$xrefInfo.source} + {html_options name="$xrefInfo.xref_type_list[$xrefInfo.item]" options=$xrefInfo.xref_type_list selected=$xrefInfo.item} {formhelp note="Type of cross link reference to add."} {/forminput} </div> diff --git a/templates/contact_date_bar.tpl b/templates/contact_date_bar.tpl index 0ab0290..883a597 100755 --- a/templates/contact_date_bar.tpl +++ b/templates/contact_date_bar.tpl @@ -5,7 +5,7 @@ {if $print_page ne 'y'} {if !$lock} {if $gBitUser->hasPermission('p_edit_contact')} - {smartlink ititle='Add additional crossref record' ifile="add_xref.php" booticon="icon-note-add" content_id=$gContent->mInfo.content_id xref_type=-1} + {smartlink ititle='Add additional crossref record' ifile="add_xref.php" booticon="icon-note-add" content_id=$gContent->mInfo.content_id group=-1} {smartlink ititle="Edit Contact" ifile="edit.php" booticon="icon-user-edit" content_id=$gContent->mInfo.content_id} {/if} {/if} diff --git a/templates/display_contact.tpl b/templates/display_contact.tpl index 5cb4901..0db300c 100755 --- a/templates/display_contact.tpl +++ b/templates/display_contact.tpl @@ -65,6 +65,6 @@ {jstabs} {section name=type loop=$gContent->mInfo.type} - {include file="bitpackage:liberty/list_xref.tpl" source=$gContent->mInfo.type[type].source source_title=$gContent->mInfo.type[type].title xref_type=$gContent->mInfo.type[type].sort_order allow_add=true} + {include file="bitpackage:liberty/list_xref.tpl" source=$gContent->mInfo.type[type].source source_title=$gContent->mInfo.type[type].title group=$gContent->mInfo.type[type].sort_order allow_add=true} {/section} {/jstabs} diff --git a/templates/list_xref_generic.tpl b/templates/list_xref_generic.tpl index dcd9f40..7104449 100755 --- a/templates/list_xref_generic.tpl +++ b/templates/list_xref_generic.tpl @@ -40,7 +40,7 @@ {if $gBitUser->hasPermission('p_contact_update')} <div> {if $source ne 'history' } - {smartlink ititle="Add additional detail record" ifile="add_xref.php" booticon="icon-note-add" content_id=$gContent->mInfo.content_id xref_type=$xref_type} + {smartlink ititle="Add additional detail record" ifile="add_xref.php" booticon="icon-note-add" content_id=$gContent->mInfo.content_id group=$group} {/if} </div> {/if} diff --git a/templates/view_xref_address_record.tpl b/templates/view_xref_address_record.tpl index 9750938..f8a217c 100755 --- a/templates/view_xref_address_record.tpl +++ b/templates/view_xref_address_record.tpl @@ -31,7 +31,7 @@ {if $gBitUser->hasPermission( 'p_contact_update' ) && $source ne 'history' } {smartlink ititle="Edit" ifile="edit_xref.php" booticon="icon-note-edit" content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id} {/if} - {if $gBitUser->hasPermission( 'p_contact_expunge' ) && $gContent->mInfo.$source[xref].source ne 'KEY_B' } + {if $gBitUser->hasPermission( 'p_contact_expunge' ) && $gContent->mInfo.$source[xref].item ne 'KEY_B' } {if $source eq 'history' } {smartlink ititle="Restore" ifile="edit_xref.php" booticon="icon-note-edit" content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id expunge=-1} {else} diff --git a/templates/view_xref_contact_record.tpl b/templates/view_xref_contact_record.tpl index 77df1f7..01a7095 100755 --- a/templates/view_xref_contact_record.tpl +++ b/templates/view_xref_contact_record.tpl @@ -31,14 +31,14 @@ <td> <span class="actionicon"> {if $gBitUser->hasPermission( 'p_contact_update' ) && $source ne 'history' } - {if $gContent->mInfo.$source[xref].source eq 'KEY_B' } + {if $gContent->mInfo.$source[xref].item eq 'KEY_B' } {smartlink ititle="Callout" ifile="edit_key_break.php" booticon="icon-redo" expunge=0 content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id} {smartlink ititle="Reseal" ifile="edit_key_break.php" booticon="icon-undo" expunge=2 content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id} {else} {smartlink ititle="Edit" ifile="edit_xref.php" booticon="icon-note-edit" content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id} {/if} {/if} - {if $gBitUser->hasPermission( 'p_contact_expunge' ) && $gContent->mInfo.$source[xref].source ne 'KEY_B' } + {if $gBitUser->hasPermission( 'p_contact_expunge' ) && $gContent->mInfo.$source[xref].item ne 'KEY_B' } {if $source eq 'history' } {smartlink ititle="Restore" ifile="edit_xref.php" booticon="icon-note-edit" content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id expunge=-1} {else} diff --git a/templates/view_xref_text_record.tpl b/templates/view_xref_text_record.tpl index 77df1f7..01a7095 100755 --- a/templates/view_xref_text_record.tpl +++ b/templates/view_xref_text_record.tpl @@ -31,14 +31,14 @@ <td> <span class="actionicon"> {if $gBitUser->hasPermission( 'p_contact_update' ) && $source ne 'history' } - {if $gContent->mInfo.$source[xref].source eq 'KEY_B' } + {if $gContent->mInfo.$source[xref].item eq 'KEY_B' } {smartlink ititle="Callout" ifile="edit_key_break.php" booticon="icon-redo" expunge=0 content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id} {smartlink ititle="Reseal" ifile="edit_key_break.php" booticon="icon-undo" expunge=2 content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id} {else} {smartlink ititle="Edit" ifile="edit_xref.php" booticon="icon-note-edit" content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id} {/if} {/if} - {if $gBitUser->hasPermission( 'p_contact_expunge' ) && $gContent->mInfo.$source[xref].source ne 'KEY_B' } + {if $gBitUser->hasPermission( 'p_contact_expunge' ) && $gContent->mInfo.$source[xref].item ne 'KEY_B' } {if $source eq 'history' } {smartlink ititle="Restore" ifile="edit_xref.php" booticon="icon-note-edit" content_id=$gContent->mInfo.content_id xref_id=$gContent->mInfo.$source[xref].xref_id expunge=-1} {else} |
