summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--add_xref.php6
-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
-rwxr-xr-xincludes/classes/LibertyContent.php54
-rwxr-xr-xincludes/classes/LibertyMime.php5
-rw-r--r--includes/classes/LibertyXref.php28
-rw-r--r--includes/classes/LibertyXrefType.php22
-rw-r--r--templates/add_xref.tpl6
-rw-r--r--templates/admin_xref_groups.tpl9
-rw-r--r--templates/admin_xref_sources.tpl20
-rw-r--r--templates/edit_xref.tpl2
-rw-r--r--templates/list_xref.tpl2
14 files changed, 124 insertions, 118 deletions
diff --git a/add_xref.php b/add_xref.php
index 56ba6d5..89c7908 100644
--- a/add_xref.php
+++ b/add_xref.php
@@ -34,11 +34,11 @@ if( !empty( $_REQUEST['fAddXref'] ) ) {
}
}
-$xref_type = (int)( $_REQUEST['xref_type'] ?? 1 );
-$xrefTypeList = $gContent->getXrefTypeList( $xref_type );
+$group = (int)( $_REQUEST['group'] ?? 1 );
+$xrefTypeList = $gContent->getXrefTypeList( $group );
$gBitSmarty->assign( 'gContent', $gContent );
-$gBitSmarty->assign( 'xref_type', $xref_type );
+$gBitSmarty->assign( 'group', $group );
$gBitSmarty->assign( 'xrefTypeList', $xrefTypeList );
$gBitSmarty->assign( 'errors', $gContent->mErrors );
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 ],
]],
]],
]
diff --git a/includes/classes/LibertyContent.php b/includes/classes/LibertyContent.php
index 6965788..f823236 100755
--- a/includes/classes/LibertyContent.php
+++ b/includes/classes/LibertyContent.php
@@ -3732,7 +3732,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
// =========================================================================
// Xref methods — generic for any LibertyContent subclass.
// Queries scope to $this->mContentTypeGuid so each package sees only its
- // own liberty_xref_type / liberty_xref_source / liberty_xref rows.
+ // own liberty_xref_group / liberty_xref_item / liberty_xref rows.
// =========================================================================
/**
@@ -3743,7 +3743,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
global $gBitUser;
$roles = array_keys( $gBitUser->mRoles );
$bindVars = array_merge( $roles, [ $gBitUser->mUserId ] );
- $query = "SELECT g.*, g.`xref_type` AS source FROM `".BIT_DB_PREFIX."liberty_xref_type` g
+ $query = "SELECT g.*, g.`x_group` AS source FROM `".BIT_DB_PREFIX."liberty_xref_group` g
LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id`=g.`role_id` )
WHERE g.`content_type_guid` = '".$this->mContentTypeGuid."' AND g.`sort_order` > 0 AND (g.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?)
ORDER BY g.`sort_order`";
@@ -3762,16 +3762,16 @@ class LibertyContent extends LibertyBase implements BitCacheable {
global $gBitUser;
$roles = array_keys( $gBitUser->mRoles );
$bindVars = array_merge( $roles, [ $gBitUser->mUserId ] );
- $query = "SELECT g.`cross_ref_title` AS `type_name`, g.`source` FROM `".BIT_DB_PREFIX."liberty_xref_source` g
- JOIN `".BIT_DB_PREFIX."liberty_xref_type` t ON t.`xref_type` = g.`xref_type` AND t.`content_type_guid` = '".$this->mContentTypeGuid."'
+ $query = "SELECT g.`cross_ref_title` AS `type_name`, g.`item` FROM `".BIT_DB_PREFIX."liberty_xref_item` g
+ JOIN `".BIT_DB_PREFIX."liberty_xref_group` t ON t.`x_group` = g.`x_group` AND t.`content_type_guid` = '".$this->mContentTypeGuid."'
LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id`=g.`role_id` )
WHERE g.`content_type_guid` = '".$this->mContentTypeGuid."' AND t.`sort_order` = 0 AND (g.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?)
- ORDER BY g.`source`";
+ ORDER BY g.`item`";
$result = $this->mDb->query( $query, $bindVars );
$ret = [];
$cnt = 0;
while ( $res = $result->fetchRow() ) {
- $ret[$cnt]['source'] = $res['source'];
+ $ret[$cnt]['item'] = $res['item'];
$ret[$cnt++]['name'] = trim( $res['type_name'] );
}
return $ret;
@@ -3783,29 +3783,29 @@ class LibertyContent extends LibertyBase implements BitCacheable {
*/
public function getXrefTypeList( $xrefGroup = 0, $xrefTemplate = NULL ): array {
if ( $xrefTemplate ) {
- $query = "SELECT s.`cross_ref_title` AS `type_name`, s.`source`, s.`template` FROM `".BIT_DB_PREFIX."liberty_xref_source` s
+ $query = "SELECT s.`cross_ref_title` AS `type_name`, s.`item`, s.`template` FROM `".BIT_DB_PREFIX."liberty_xref_item` s
WHERE s.`content_type_guid` = '".$this->mContentTypeGuid."' AND s.`template` = '$xrefTemplate'
ORDER BY s.`cross_ref_title`";
$result = $this->mDb->query( $query, [] );
} elseif ( $xrefGroup > -1 ) {
- $query = "SELECT s.`cross_ref_title` AS `type_name`, s.`source`, s.`template` FROM `".BIT_DB_PREFIX."liberty_xref_source` s
- JOIN `".BIT_DB_PREFIX."liberty_xref_type` t ON t.`xref_type` = s.`xref_type` AND t.`content_type_guid` = '".$this->mContentTypeGuid."'
- LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` x ON x.`source` = s.`source` AND x.`content_id` = ? AND ( x.`end_date` IS NULL OR x.`end_date` > CURRENT_TIMESTAMP )
+ $query = "SELECT s.`cross_ref_title` AS `type_name`, s.`item`, s.`template` FROM `".BIT_DB_PREFIX."liberty_xref_item` s
+ JOIN `".BIT_DB_PREFIX."liberty_xref_group` t ON t.`x_group` = s.`x_group` AND t.`content_type_guid` = '".$this->mContentTypeGuid."'
+ LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` x ON x.`item` = s.`item` AND x.`content_id` = ? AND ( x.`end_date` IS NULL OR x.`end_date` > CURRENT_TIMESTAMP )
WHERE s.`content_type_guid` = '".$this->mContentTypeGuid."' AND t.`sort_order` = ? AND ( x.`xref_id` IS NULL OR x.`xorder` > 0 )
ORDER BY s.`cross_ref_title`";
$result = $this->mDb->query( $query, [ $this->mContentId, $xrefGroup ] );
} else {
- $query = "SELECT s.`cross_ref_title` AS `type_name`, s.`source`, s.`template` FROM `".BIT_DB_PREFIX."liberty_xref_source` s
- JOIN `".BIT_DB_PREFIX."liberty_xref_type` t ON t.`xref_type` = s.`xref_type` AND t.`content_type_guid` = '".$this->mContentTypeGuid."'
- LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` x ON x.`source` = s.`source` AND x.`content_id` = ? AND ( x.`end_date` IS NULL OR x.`end_date` > CURRENT_TIMESTAMP )
+ $query = "SELECT s.`cross_ref_title` AS `type_name`, s.`item`, s.`template` FROM `".BIT_DB_PREFIX."liberty_xref_item` s
+ JOIN `".BIT_DB_PREFIX."liberty_xref_group` t ON t.`x_group` = s.`x_group` AND t.`content_type_guid` = '".$this->mContentTypeGuid."'
+ LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` x ON x.`item` = s.`item` AND x.`content_id` = ? AND ( x.`end_date` IS NULL OR x.`end_date` > CURRENT_TIMESTAMP )
WHERE s.`content_type_guid` = '".$this->mContentTypeGuid."' AND t.`sort_order` > 0 AND ( x.`xref_id` IS NULL OR x.`xorder` > 0 )
ORDER BY s.`cross_ref_title`";
$result = $this->mDb->query( $query, [ $this->mContentId ] );
}
$ret = [];
while ( $res = $result->fetchRow() ) {
- $ret['list'][$res['source']] = trim( $res['type_name'] );
- $ret['type'][$res['source']] = trim( $res['template'] ) !== '' ? trim( $res['template'] ) : 'generic';
+ $ret['list'][$res['item']] = trim( $res['type_name'] );
+ $ret['type'][$res['item']] = trim( $res['template'] ) !== '' ? trim( $res['template'] ) : 'generic';
}
return $ret;
}
@@ -3817,7 +3817,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
global $gBitUser;
$roles = array_keys( $gBitUser->mRoles );
$bindVars = array_merge( $roles, [ $gBitUser->mUserId ] );
- $query = "SELECT DISTINCT g.`template` FROM `".BIT_DB_PREFIX."liberty_xref_source` g
+ $query = "SELECT DISTINCT g.`template` FROM `".BIT_DB_PREFIX."liberty_xref_item` g
LEFT OUTER JOIN `".BIT_DB_PREFIX."users_roles_map` purm ON ( purm.`user_id`=".$gBitUser->mUserId." ) AND ( purm.`role_id`=g.`role_id` )
WHERE g.`content_type_guid` = '".$this->mContentTypeGuid."' AND (g.`role_id` IN(". implode(',', array_fill(0, count($roles), '?')) ." ) OR purm.`user_id`=?)
ORDER BY g.`template`";
@@ -3839,13 +3839,13 @@ class LibertyContent extends LibertyBase implements BitCacheable {
global $gBitUser;
$roles = array_keys( $gBitUser->mRoles );
$bindVars = array_merge( [ $this->mContentId ], $roles, [ $gBitUser->mUserId ] );
- $sql = "SELECT r.`source`, r.`cross_ref_title`, d.`content_id`
- 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` = '".$this->mContentTypeGuid."'
- LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` d ON d.`content_id` = ? AND d.`source` = r.`source`
+ $sql = "SELECT r.`item`, r.`cross_ref_title`, d.`content_id`
+ 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` = '".$this->mContentTypeGuid."'
+ LEFT JOIN `".BIT_DB_PREFIX."liberty_xref` d ON d.`content_id` = ? AND d.`item` = r.`item`
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` = '".$this->mContentTypeGuid."' 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->mInfo[$this->mXrefTypeKey][] = $res;
@@ -3855,17 +3855,17 @@ class LibertyContent extends LibertyBase implements BitCacheable {
/**
* Loads all xref records for this content item into mInfo keyed by type_source
- * (the liberty_xref_type.xref_type text key, or 'history' for expired records).
+ * (the liberty_xref_group.xref_type text key, or 'history' for expired records).
*/
public function loadXrefList(): void {
if ( $this->isValid() && empty( $this->mInfo['xref'] ) ) {
global $gBitUser;
$roles = array_keys( $gBitUser->mRoles );
$bindVars = array_merge( [ $this->mDb->NOW(), $this->mContentId ], $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
@@ -3874,12 +3874,12 @@ class LibertyContent extends LibertyBase implements BitCacheable {
x.`start_date`, x.`end_date`, s.`template`,
pc.`add1` || ',' || pc.`add2` || ',' || pc.`add4` || ',' || pc.`town` AS address
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` = '".$this->mContentTypeGuid."'
+ JOIN `".BIT_DB_PREFIX."liberty_xref_item` s ON s.`item` = x.`item` AND s.`content_type_guid` = '".$this->mContentTypeGuid."'
LEFT JOIN `".BIT_DB_PREFIX."address_postcode` pc ON pc.`postcode` = x.`xkey`
- JOIN `".BIT_DB_PREFIX."liberty_xref_type` t ON t.`xref_type` = s.`xref_type` AND t.`content_type_guid` = '".$this->mContentTypeGuid."'
+ JOIN `".BIT_DB_PREFIX."liberty_xref_group` t ON t.`x_group` = s.`x_group` AND t.`content_type_guid` = '".$this->mContentTypeGuid."'
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.`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 );
if ( $result ) {
while ( $res = $result->fetchRow() ) {
diff --git a/includes/classes/LibertyMime.php b/includes/classes/LibertyMime.php
index 7dce907..eaff998 100755
--- a/includes/classes/LibertyMime.php
+++ b/includes/classes/LibertyMime.php
@@ -48,6 +48,11 @@ class LibertyMime extends LibertyContent {
$this->loadAttachmentPreferences();
}
+ // mime plugins aren't loaded during BIT_INSTALL (active plugin list can't be read from DB), skip attachment rendering
+ if( defined( 'BIT_INSTALL' ) ) {
+ return true;
+ }
+
$query = "SELECT * FROM `".BIT_DB_PREFIX."liberty_attachments` la WHERE la.`content_id`=? ORDER BY la.`pos` ASC, la.`attachment_id` ASC";
if( $result = $this->mDb->query( $query,[ $this->mContentId ])) {
$this->mStorage = [];
diff --git a/includes/classes/LibertyXref.php b/includes/classes/LibertyXref.php
index 44e874c..1cd17f7 100644
--- a/includes/classes/LibertyXref.php
+++ b/includes/classes/LibertyXref.php
@@ -11,7 +11,7 @@ use Bitweaver\BitDate;
class LibertyXref extends LibertyBase {
public $mType;
- public $mSource;
+ public $mItem;
public $mXrefId;
public $mContentId;
public $mDate;
@@ -19,7 +19,7 @@ class LibertyXref extends LibertyBase {
public function __construct( $iXrefId = NULL ) {
$this->mXrefId = NULL;
- $this->mSource = NULL;
+ $this->mItem = NULL;
parent::__construct();
if( $iXrefId ) {
$this->load( $iXrefId );
@@ -40,20 +40,20 @@ class LibertyXref extends LibertyBase {
$sql = "SELECT x.*, CASE
WHEN x.`xorder` = 0 THEN s.`cross_ref_title`
ELSE s.`cross_ref_title` || '-' || x.`xorder` END
- AS source_title, s.`source`, s.`xref_type`,
+ AS source_title, s.`item`, s.`x_group`,
CASE WHEN x.`start_date` IS NULL THEN 'y' ELSE 'n' END AS `ignore_start_date`,
CASE WHEN x.`end_date` IS NULL THEN 'y' ELSE 'n' END AS `ignore_end_date`,
s.`cross_ref_title` AS `template_title`, s.`template`
FROM `".BIT_DB_PREFIX."liberty_xref` x
- JOIN `".BIT_DB_PREFIX."liberty_xref_source` s ON s.`source` = x.`source` $guidFilter
+ JOIN `".BIT_DB_PREFIX."liberty_xref_item` s ON s.`item` = x.`item` $guidFilter
WHERE x.`xref_id` = ?
ORDER BY x.`xorder`";
$result = $this->mDb->getRow( $sql, $bindVars );
if( $result['content_id'] ) {
$this->mXrefId = $pXrefId;
$this->mContentId = $result['content_id'];
- $this->mType = $result['xref_type'];
- $this->mSource = $result['source'];
+ $this->mType = $result["x_group"];
+ $this->mItem = $result['item'];
$this->mInfo['title'] = $result['source_title'];
$this->mInfo['format_guid'] = 'text';
unset( $result['source_title'] );
@@ -68,28 +68,28 @@ class LibertyXref extends LibertyBase {
if( isset( $pParamHash['content_id'] ) ) {
$pParamHash['xref_store']['content_id'] = $pParamHash['content_id'];
}
- if( isset( $pParamHash['source'] ) ) {
- $pParamHash['xref_store']['source'] = $pParamHash['source'];
+ if( isset( $pParamHash['item'] ) ) {
+ $pParamHash['xref_store']['item'] = $pParamHash['item'];
}
$pParamHash['xref_store']['xorder'] = 0;
if( isset( $pParamHash['fAddXref'] ) ) {
- $pParamHash['xref_store']['source'] = isset( $pParamHash['Array_xref_type_list'] ) ? $pParamHash['Array_xref_type_list']['Array.source'] : $pParamHash['source'];
+ $pParamHash['xref_store']['item'] = isset( $pParamHash['Array_xref_type_list'] ) ? $pParamHash['Array_xref_type_list']['Array.item'] : $pParamHash['item'];
$pParamHash['xref_store']['content_id'] = $pParamHash['content_id'];
$guidWhere = !empty( $this->mContentTypeGuid ) ? "AND x.`content_type_guid` = ?" : '';
- $guidBind = !empty( $this->mContentTypeGuid ) ? [ $pParamHash['xref_store']['source'], $this->mContentTypeGuid ] : [ $pParamHash['xref_store']['source'] ];
- $sql = "SELECT x.`multi` FROM `".BIT_DB_PREFIX."liberty_xref_source` x WHERE x.`source` = ? $guidWhere";
+ $guidBind = !empty( $this->mContentTypeGuid ) ? [ $pParamHash['xref_store']['item'], $this->mContentTypeGuid ] : [ $pParamHash['xref_store']['item'] ];
+ $sql = "SELECT x.`multiple` FROM `".BIT_DB_PREFIX."liberty_xref_item` x WHERE x.`item` = ? $guidWhere";
$next = $this->mDb->getOne( $sql, $guidBind );
if( $next > 0 ) {
- $sql = "SELECT COALESCE( MAX(x.`xorder`) + 1, 1 ) FROM `".BIT_DB_PREFIX."liberty_xref` x WHERE x.`content_id` = ? AND x.`source` = ?";
- $next = $this->mDb->getOne( $sql, [ $pParamHash['xref_store']['content_id'], $pParamHash['xref_store']['source'] ] );
+ $sql = "SELECT COALESCE( MAX(x.`xorder`) + 1, 1 ) FROM `".BIT_DB_PREFIX."liberty_xref` x WHERE x.`content_id` = ? AND x.`item` = ?";
+ $next = $this->mDb->getOne( $sql, [ $pParamHash['xref_store']['content_id'], $pParamHash['xref_store']['item'] ] );
}
$pParamHash['xref_store']['xorder'] = $next;
}
if( isset( $pParamHash['fStepXref'] ) ) {
- $pParamHash['xref_store']['source'] = $this->mSource;
+ $pParamHash['xref_store']['item'] = $this->mItem;
$pParamHash['xref_store']['xorder'] = $this->mInfo['data']['xorder'] + 1;
$pParamHash['xref_store']['content_id'] = $this->mContentId;
$pParamHash['start_date'] = $this->mDb->NOW();
diff --git a/includes/classes/LibertyXrefType.php b/includes/classes/LibertyXrefType.php
index 00f2cb2..2d64366 100644
--- a/includes/classes/LibertyXrefType.php
+++ b/includes/classes/LibertyXrefType.php
@@ -28,14 +28,14 @@ class LibertyXrefType extends LibertyBase {
$where = " WHERE cxs.`role_id` = ? ";
$bindVars[] = $pOptionHash['active_role'];
}
- if( !empty( $pOptionHash['source'] ) ) {
- $where = " WHERE cxs.`source` = ? ";
- $bindVars[] = $pOptionHash['source'];
+ if( !empty( $pOptionHash['item'] ) ) {
+ $where = " WHERE cxs.`item` = ? ";
+ $bindVars[] = $pOptionHash['item'];
}
$query = "SELECT cxs.*
- FROM `".BIT_DB_PREFIX."liberty_xref_source` cxs
- $where ORDER BY cxs.`xref_type`, cxs.`source`";
+ FROM `".BIT_DB_PREFIX."liberty_xref_item` cxs
+ $where ORDER BY cxs.`x_group`, cxs.`item`";
$result = $gBitSystem->mDb->query( $query, $bindVars );
@@ -52,12 +52,12 @@ class LibertyXrefType extends LibertyBase {
}
/**
- * Returns the distinct content_type_guid values present in liberty_xref_type.
+ * Returns the distinct content_type_guid values present in liberty_xref_group.
*/
public static function getContentTypeGuids(): array {
global $gBitSystem;
$result = $gBitSystem->mDb->query(
- "SELECT DISTINCT `content_type_guid` FROM `".BIT_DB_PREFIX."liberty_xref_type` ORDER BY `content_type_guid`",
+ "SELECT DISTINCT `content_type_guid` FROM `".BIT_DB_PREFIX."liberty_xref_group` ORDER BY `content_type_guid`",
[]
);
$ret = [];
@@ -68,7 +68,7 @@ class LibertyXrefType extends LibertyBase {
}
/**
- * Returns liberty_xref_type rows, optionally filtered by content_type_guid.
+ * Returns liberty_xref_group rows, optionally filtered by content_type_guid.
* Each row includes num_sources: count of sources defined for that group.
*/
public static function getGroupList( $pOptionHash = NULL ): array {
@@ -79,14 +79,14 @@ class LibertyXrefType extends LibertyBase {
$where = " WHERE cxt.`content_type_guid` = ?";
$bindVars[] = $pOptionHash['content_type_guid'];
}
- $query = "SELECT cxt.* FROM `".BIT_DB_PREFIX."liberty_xref_type` cxt
+ $query = "SELECT cxt.* FROM `".BIT_DB_PREFIX."liberty_xref_group` cxt
$where ORDER BY cxt.`content_type_guid`, cxt.`sort_order`";
$result = $gBitSystem->mDb->query( $query, $bindVars );
$ret = [];
while ( $res = $result->fetchRow() ) {
$res['num_sources'] = $gBitSystem->mDb->getOne(
- "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref_source` WHERE `xref_type` = ? AND `content_type_guid` = ?",
- [ $res['xref_type'], $res['content_type_guid'] ]
+ "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."liberty_xref_item` WHERE `x_group` = ? AND `content_type_guid` = ?",
+ [ $res["x_group"], $res['content_type_guid'] ]
);
$ret[] = $res;
}
diff --git a/templates/add_xref.tpl b/templates/add_xref.tpl
index 3be770f..990c1d5 100644
--- a/templates/add_xref.tpl
+++ b/templates/add_xref.tpl
@@ -9,12 +9,12 @@
{form id="addXrefForm"}
<input type="hidden" name="content_id" value="{$gContent->mContentId}" />
- <input type="hidden" name="xref_type" value="{$xref_type}" />
+ <input type="hidden" name="group" value="{$group}" />
<div class="form-group">
- {formlabel label="Type" for="source"}
+ {formlabel label="Type" for="item"}
{forminput}
- {html_options name="source" id="source" options=$xrefTypeList.list}
+ {html_options name="item" id="item" options=$xrefTypeList.list}
{/forminput}
</div>
diff --git a/templates/admin_xref_groups.tpl b/templates/admin_xref_groups.tpl
index 3618c79..8f3d580 100644
--- a/templates/admin_xref_groups.tpl
+++ b/templates/admin_xref_groups.tpl
@@ -36,8 +36,8 @@
<input type="hidden" name="new_content_type_guid" value="{$activeGuid|escape}" />
<input type="hidden" name="content_type_guid" value="{$activeGuid|escape}" />
<div class="form-group">
- {formlabel label="Key (xref_type)" for="xref_type"}
- {forminput}<input type="text" id="xref_type" name="xref_type" class="form-control" />{/forminput}
+ {formlabel label="Key (group)" for="x_group"}
+ {forminput}<input type="text" id="x_group" name="x_group" class="form-control" />{/forminput}
</div>
<div class="form-group">
{formlabel label="Title" for="title"}
@@ -75,7 +75,7 @@
{foreach from=$xref_groups item=grp}
<tr>
<td>{$grp.content_type_guid|escape}</td>
- <td><code>{$grp.xref_type|escape}</code></td>
+ <td><code>{$grp.x_group|escape}</code></td>
<td>{$grp.title|escape}</td>
<td>{$grp.sort_order}</td>
<td>{$grp.role_id}</td>
@@ -84,8 +84,9 @@
</td>
<td>
{if $grp.num_sources eq 0}
- <a href="{$smarty.const.LIBERTY_PKG_URL}admin/admin_xref_groups.php?fDeleteGroup=1&amp;xref_type={$grp.xref_type|escape}&amp;del_content_type_guid={$grp.content_type_guid|escape}&amp;content_type_guid={$activeGuid|escape}"
+ <a href="{$smarty.const.LIBERTY_PKG_URL}admin/admin_xref_groups.php?fDeleteGroup=1&amp;x_group={$grp.x_group|escape}&amp;del_content_type_guid={$grp.content_type_guid|escape}&amp;content_type_guid={$activeGuid|escape}"
onclick="return confirm('{tr}Delete this group?{/tr}')">{booticon iname="icon-trash" ipackage="icons" iforce=icon_text iexplain="Delete"}</a>
+
{/if}
</td>
</tr>
diff --git a/templates/admin_xref_sources.tpl b/templates/admin_xref_sources.tpl
index 58fddf6..9e9ec0a 100644
--- a/templates/admin_xref_sources.tpl
+++ b/templates/admin_xref_sources.tpl
@@ -40,11 +40,11 @@
{forminput}<input type="text" id="source" name="source" class="form-control" />{/forminput}
</div>
<div class="form-group">
- {formlabel label="Group" for="xref_type"}
+ {formlabel label="Group" for="x_group"}
{forminput}
- <select name="xref_type" id="xref_type" class="form-control">
+ <select name="x_group" id="x_group" class="form-control">
{foreach from=$xref_groups item=grp}
- <option value="{$grp.xref_type|escape}">{$grp.title|escape} ({$grp.xref_type|escape})</option>
+ <option value="{$grp.x_group|escape}">{$grp.title|escape} ({$grp.x_group|escape})</option>
{/foreach}
</select>
{/forminput}
@@ -62,8 +62,8 @@
{forminput}<input type="text" id="cross_ref_href" name="cross_ref_href" class="form-control" />{/forminput}
</div>
<div class="form-group">
- {formlabel label="Multi" for="multi"}
- {forminput}<input type="number" id="multi" name="multi" value="0" class="form-control" style="width:5em" />{/forminput}
+ {formlabel label="Multiple" for="multiple"}
+ {forminput}<input type="number" id="multiple" name="multiple" value="0" class="form-control" style="width:5em" />{/forminput}
</div>
<div class="form-group">
{formlabel label="Role ID" for="role_id"}
@@ -85,7 +85,7 @@
<th>{tr}Group{/tr}</th>
<th>{tr}Title{/tr}</th>
<th>{tr}Template{/tr}</th>
- <th>{tr}Multi{/tr}</th>
+ <th>{tr}Multiple{/tr}</th>
<th>{tr}Role{/tr}</th>
<th>{tr}Entries{/tr}</th>
<th>{tr}Actions{/tr}</th>
@@ -95,16 +95,16 @@
{foreach from=$xref_sources item=src}
<tr>
<td>{$src.content_type_guid|escape}</td>
- <td><code>{$src.source|escape}</code></td>
- <td><code>{$src.xref_type|escape}</code></td>
+ <td><code>{$src.item|escape}</code></td>
+ <td><code>{$src.x_group|escape}</code></td>
<td>{$src.cross_ref_title|escape}</td>
<td>{$src.template|escape}</td>
- <td>{$src.multi}</td>
+ <td>{$src.multiple}</td>
<td>{$src.role_id}</td>
<td>{$src.num_entries}</td>
<td>
{if $src.num_entries eq 0}
- <a href="{$smarty.const.LIBERTY_PKG_URL}admin/admin_xref_sources.php?fDeleteSource=1&amp;source={$src.source|escape}&amp;del_content_type_guid={$src.content_type_guid|escape}&amp;content_type_guid={$activeGuid|escape}"
+ <a href="{$smarty.const.LIBERTY_PKG_URL}admin/admin_xref_sources.php?fDeleteSource=1&amp;source={$src.item|escape}&amp;del_content_type_guid={$src.content_type_guid|escape}&amp;content_type_guid={$activeGuid|escape}"
onclick="return confirm('{tr}Delete this source?{/tr}')">{booticon iname="icon-trash" ipackage="icons" iforce=icon_text iexplain="Delete"}</a>
{/if}
</td>
diff --git a/templates/edit_xref.tpl b/templates/edit_xref.tpl
index 9dbb0d8..5261647 100644
--- a/templates/edit_xref.tpl
+++ b/templates/edit_xref.tpl
@@ -10,7 +10,7 @@
{form id="editXrefForm"}
<input type="hidden" name="content_id" value="{$xrefInfo.content_id}" />
<input type="hidden" name="xref_id" value="{$xrefInfo.xref_id}" />
- <input type="hidden" name="source" value="{$xrefInfo.source|escape}" />
+ <input type="hidden" name="item" value="{$xrefInfo.item|escape}" />
<div class="form-group">
{formlabel label="Type"}
diff --git a/templates/list_xref.tpl b/templates/list_xref.tpl
index 572cc34..e1a6bbc 100644
--- a/templates/list_xref.tpl
+++ b/templates/list_xref.tpl
@@ -33,7 +33,7 @@
</div>
{if $allow_add && $gContent->isValid() && $gContent->hasUpdatePermission() && $source ne 'history'}
<div>
- {smartlink ititle="Add record" ipackage="liberty" ifile="add_xref.php" booticon="icon-note-add" content_id=$gContent->mInfo.content_id xref_type=$xref_type}
+ {smartlink ititle="Add record" ipackage="liberty" ifile="add_xref.php" booticon="icon-note-add" content_id=$gContent->mInfo.content_id group=$group}
</div>
{/if}
{/legend}