summaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-26 14:51:08 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-26 14:51:08 +0100
commitc4c48710f929286d4b799bcb6fb02bc8c04383a4 (patch)
tree54c70fb97bc8faaa4c5621dadb262b05f79d5350 /admin
parent2866cb7d576ae8c59137d0c7dbb8e9baf0e6e3f1 (diff)
downloadliberty-c4c48710f929286d4b799bcb6fb02bc8c04383a4.tar.gz
liberty-c4c48710f929286d4b799bcb6fb02bc8c04383a4.tar.bz2
liberty-c4c48710f929286d4b799bcb6fb02bc8c04383a4.zip
Add liberty_xref subsystem: package-agnostic typed cross-references
Replaces per-package xref tables with three shared liberty tables: liberty_xref_group (tab groups), liberty_xref_item (source definitions), liberty_xref (records). Column names: group→x_group (Firebird reserved word), source→item, multi→multiple throughout PHP classes and templates. - 5.0.1 upgrade creates the three tables + sequence + indexes for existing installs - schema_inc.php updated so fresh installs also get the tables - Admin UI: admin_xref_groups and admin_xref_sources pages with package filter - LibertyContent::loadXrefList / getXrefGroupList / getXrefTypeList updated - LibertyMime: skip attachment rendering during BIT_INSTALL Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'admin')
-rw-r--r--admin/admin_xref_groups.php12
-rw-r--r--admin/admin_xref_sources.php14
-rwxr-xr-xadmin/schema_inc.php28
-rw-r--r--admin/upgrades/5.0.1.php34
4 files changed, 44 insertions, 44 deletions
diff --git a/admin/admin_xref_groups.php b/admin/admin_xref_groups.php
index 8d4ae58..4f7740d 100644
--- a/admin/admin_xref_groups.php
+++ b/admin/admin_xref_groups.php
@@ -1,6 +1,6 @@
<?php
/**
- * Admin page for managing liberty_xref_type groups across all packages.
+ * Admin page for managing liberty_xref_group groups across all packages.
* @package liberty
*/
@@ -19,14 +19,14 @@ $activeGuid = $_SESSION['liberty_xref_admin_guid'] ?? '';
// Add a new group
if ( !empty( $_REQUEST['fAddGroup'] ) ) {
- $xrefType = trim( $_REQUEST['xref_type'] ?? '' );
+ $xrefType = trim( $_REQUEST["x_group"] ?? '' );
$guid = trim( $_REQUEST['new_content_type_guid'] ?? $activeGuid );
$title = trim( $_REQUEST['title'] ?? '' );
$sortOrder = (int)( $_REQUEST['sort_order'] ?? 0 );
$roleId = (int)( $_REQUEST['role_id'] ?? 3 );
if ( $xrefType && $guid && $title ) {
$gBitDb->query(
- "INSERT INTO `".BIT_DB_PREFIX."liberty_xref_type` (`xref_type`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES (?,?,?,?,?,'')",
+ "INSERT INTO `".BIT_DB_PREFIX."liberty_xref_group` (`x_group`,`content_type_guid`,`title`,`sort_order`,`role_id`,`type_href`) VALUES (?,?,?,?,?,'')",
[ $xrefType, $guid, $title, $sortOrder, $roleId ]
);
}
@@ -34,16 +34,16 @@ if ( !empty( $_REQUEST['fAddGroup'] ) ) {
// Delete a group (only if no sources are attached)
if ( !empty( $_REQUEST['fDeleteGroup'] ) ) {
- $xrefType = $_REQUEST['xref_type'] ?? '';
+ $xrefType = $_REQUEST["x_group"] ?? '';
$guid = $_REQUEST['del_content_type_guid'] ?? '';
if ( $xrefType && $guid ) {
$count = $gBitDb->getOne(
- "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref_source` WHERE `xref_type` = ? AND `content_type_guid` = ?",
+ "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref_item` WHERE `x_group` = ? AND `content_type_guid` = ?",
[ $xrefType, $guid ]
);
if ( $count == 0 ) {
$gBitDb->query(
- "DELETE FROM `".BIT_DB_PREFIX."liberty_xref_type` WHERE `xref_type` = ? AND `content_type_guid` = ?",
+ "DELETE FROM `".BIT_DB_PREFIX."liberty_xref_group` WHERE `x_group` = ? AND `content_type_guid` = ?",
[ $xrefType, $guid ]
);
} else {
diff --git a/admin/admin_xref_sources.php b/admin/admin_xref_sources.php
index c86b0d3..e78fd7a 100644
--- a/admin/admin_xref_sources.php
+++ b/admin/admin_xref_sources.php
@@ -1,6 +1,6 @@
<?php
/**
- * Admin page for managing liberty_xref_source entries across all packages.
+ * Admin page for managing liberty_xref_item entries across all packages.
* @package liberty
*/
@@ -21,16 +21,16 @@ $activeGuid = $_SESSION['liberty_xref_admin_guid'] ?? '';
if ( !empty( $_REQUEST['fAddSource'] ) ) {
$source = trim( $_REQUEST['source'] ?? '' );
$guid = trim( $_REQUEST['new_content_type_guid'] ?? $activeGuid );
- $xrefType = trim( $_REQUEST['xref_type'] ?? '' );
+ $xrefType = trim( $_REQUEST["x_group"] ?? '' );
$title = trim( $_REQUEST['cross_ref_title'] ?? '' );
$template = trim( $_REQUEST['template'] ?? '' );
$href = trim( $_REQUEST['cross_ref_href'] ?? '' );
- $multi = (int)( $_REQUEST['multi'] ?? 0 );
+ $multiple = (int)( $_REQUEST["multiple"] ?? 0 );
$roleId = (int)( $_REQUEST['role_id'] ?? 3 );
if ( $source && $guid && $xrefType && $title ) {
$gBitDb->query(
- "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 (?,?,?,?,?,?,?,?,NULL)",
- [ $source, $guid, $xrefType, $title, $multi, $roleId, $href, $template ]
+ "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`) VALUES (?,?,?,?,?,?,?,?,NULL)",
+ [ $source, $guid, $xrefType, $title, $multiple, $roleId, $href, $template ]
);
}
}
@@ -41,12 +41,12 @@ if ( !empty( $_REQUEST['fDeleteSource'] ) ) {
$guid = $_REQUEST['del_content_type_guid'] ?? '';
if ( $source && $guid ) {
$count = $gBitDb->getOne(
- "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref` WHERE `source` = ?",
+ "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref` WHERE `item` = ?",
[ $source ]
);
if ( $count == 0 ) {
$gBitDb->query(
- "DELETE FROM `".BIT_DB_PREFIX."liberty_xref_source` WHERE `source` = ? AND `content_type_guid` = ?",
+ "DELETE FROM `".BIT_DB_PREFIX."liberty_xref_item` WHERE `item` = ? AND `content_type_guid` = ?",
[ $source, $guid ]
);
} else {
diff --git a/admin/schema_inc.php b/admin/schema_inc.php
index a77678f..19d1182 100755
--- a/admin/schema_inc.php
+++ b/admin/schema_inc.php
@@ -218,21 +218,23 @@ $tables = [
, CONSTRAINT `lib_attachment_meta_title_ref` FOREIGN KEY (`meta_title_id`) REFERENCES `" . BIT_DB_PREFIX . "liberty_meta_titles` (`meta_title_id`) '
",
- 'liberty_xref_type' => "
- xref_type C(32) PRIMARY,
- package C(20) NOTNULL,
+ 'liberty_xref_group' => "
+ x_group C(32) PRIMARY,
+ content_type_guid C(32) PRIMARY,
title C(64),
sort_order I2,
role_id I4,
- type_href C(256)
+ type_href C(256),
+ multiple I2,
+ template C(32)
",
- 'liberty_xref_source' => "
- source C(20) PRIMARY,
- package C(20) NOTNULL,
- xref_type C(32),
+ 'liberty_xref_item' => "
+ item C(20) PRIMARY,
+ content_type_guid C(32) PRIMARY,
+ x_group C(32),
cross_ref_title C(64),
- multi I2,
+ multiple I2,
role_id I4,
cross_ref_href C(256),
template C(32),
@@ -242,7 +244,7 @@ $tables = [
'liberty_xref' => "
xref_id I8 PRIMARY,
content_id I8 NOTNULL,
- source C(20),
+ item C(20),
xorder I2,
xref I8,
xkey C(32),
@@ -294,9 +296,9 @@ $indices = [
'lib_attachment_meta_idx' => [ 'table' => 'liberty_attachment_meta_data', 'cols' => 'attachment_id', 'opts' => null ],
'lib_attachment_meta_type_idx' => [ 'table' => 'liberty_attachment_meta_data', 'cols' => 'meta_type_id', 'opts' => null ],
'lib_attachment_meta_title_idx' => [ 'table' => 'liberty_attachment_meta_data', 'cols' => 'meta_title_id', 'opts' => null ],
- 'liberty_xref_content_idx' => [ 'table' => 'liberty_xref', 'cols' => 'content_id', 'opts' => null ],
- 'liberty_xref_source_pkg_idx' => [ 'table' => 'liberty_xref_source', 'cols' => 'package', 'opts' => null ],
- 'liberty_xref_type_pkg_idx' => [ 'table' => 'liberty_xref_type', 'cols' => 'package', 'opts' => null ],
+ 'liberty_xref_content_idx' => [ 'table' => 'liberty_xref', 'cols' => 'content_id', 'opts' => null ],
+ 'liberty_xref_item_pkg_idx' => [ 'table' => 'liberty_xref_item', 'cols' => 'content_type_guid', 'opts' => null ],
+ 'liberty_xref_group_pkg_idx' => [ 'table' => 'liberty_xref_group', 'cols' => 'content_type_guid', 'opts' => null ],
];
foreach( array_keys($constraints) AS $tableName ) {
diff --git a/admin/upgrades/5.0.1.php b/admin/upgrades/5.0.1.php
index f20d190..3844be7 100644
--- a/admin/upgrades/5.0.1.php
+++ b/admin/upgrades/5.0.1.php
@@ -14,20 +14,22 @@ $gBitInstaller->registerPackageUpgrade(
[
[ 'DATADICT' => [
[ 'CREATE' => [
- 'liberty_xref_type' => "
- xref_type C(32) PRIMARY,
- package C(20) NOTNULL,
+ 'liberty_xref_group' => "
+ x_group C(32) PRIMARY,
+ content_type_guid C(32) PRIMARY,
title C(64),
sort_order I2,
role_id I4,
- type_href C(256)
+ type_href C(256),
+ multiple I2,
+ template C(32)
",
- 'liberty_xref_source' => "
- source C(20) PRIMARY,
- package C(20) NOTNULL,
- xref_type C(32),
+ 'liberty_xref_item' => "
+ item C(20) PRIMARY,
+ content_type_guid C(32) PRIMARY,
+ x_group C(32),
cross_ref_title C(64),
- multi I2,
+ multiple I2,
role_id I4,
cross_ref_href C(256),
template C(32),
@@ -36,7 +38,7 @@ $gBitInstaller->registerPackageUpgrade(
'liberty_xref' => "
xref_id I8 PRIMARY,
content_id I8 NOTNULL,
- source C(20),
+ item C(20),
xorder I2,
xref I8,
xkey C(32),
@@ -48,15 +50,11 @@ $gBitInstaller->registerPackageUpgrade(
end_date T
",
]],
- [ 'CREATESEQUENCE' => [
- [ 'liberty_xref_seq' ],
- ]],
+ [ 'CREATESEQUENCE' => [ 'liberty_xref_seq' ] ],
[ 'CREATEINDEX' => [
- [
- 'liberty_xref_content_idx' => [ 'liberty_xref', 'content_id', null ],
- 'liberty_xref_source_pkg_idx' => [ 'liberty_xref_source', 'package', null ],
- 'liberty_xref_type_pkg_idx' => [ 'liberty_xref_type', 'package', null ],
- ],
+ 'liberty_xref_content_idx' => [ 'liberty_xref', 'content_id', null ],
+ 'liberty_xref_item_pkg_idx' => [ 'liberty_xref_item', 'content_type_guid', null ],
+ 'liberty_xref_group_pkg_idx' => [ 'liberty_xref_group', 'content_type_guid', null ],
]],
]],
]