summaryrefslogtreecommitdiff
path: root/add_xref.php
diff options
context:
space:
mode:
authorLester Caine <lester@lsces.co.uk>2026-05-25 15:39:34 +0100
committerLester Caine <lester@lsces.co.uk>2026-05-25 15:39:34 +0100
commitfb30cd3317e01ebe8e748e4bcf1482e4c324b9b9 (patch)
tree2a263ad27d6a78b4fe5f78e30134b5edc5aa618b /add_xref.php
parent80d56ac6a0b704c1b480157422227626f63df67d (diff)
downloadliberty-fb30cd3317e01ebe8e748e4bcf1482e4c324b9b9.tar.gz
liberty-fb30cd3317e01ebe8e748e4bcf1482e4c324b9b9.tar.bz2
liberty-fb30cd3317e01ebe8e748e4bcf1482e4c324b9b9.zip
Add generic xref controllers and templates to liberty
Moves add/edit xref pages out of stock into liberty so any content type can use them. list_xref.tpl uses hasUpdatePermission() instead of a stock-specific permission check. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'add_xref.php')
-rw-r--r--add_xref.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/add_xref.php b/add_xref.php
new file mode 100644
index 0000000..56ba6d5
--- /dev/null
+++ b/add_xref.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * @package liberty
+ * @subpackage functions
+ */
+
+namespace Bitweaver\Liberty;
+
+require_once '../kernel/includes/setup_inc.php';
+
+global $gBitSystem, $gBitSmarty, $gBitUser, $gContent;
+
+if( empty( $_REQUEST['content_id'] ) || !is_numeric( $_REQUEST['content_id'] ) ) {
+ $gBitSystem->fatalError( 'No content ID specified.' );
+}
+
+$gContent = LibertyContent::getLibertyObject( (int)$_REQUEST['content_id'] );
+
+if( !$gContent || !$gContent->isValid() ) {
+ $gBitSystem->fatalError( 'Content not found.' );
+}
+
+$gContent->verifyUpdatePermission();
+
+if( !empty( $_REQUEST['fCancel'] ) ) {
+ header( 'Location: '.$gContent->getDisplayUrl() );
+ die;
+}
+
+if( !empty( $_REQUEST['fAddXref'] ) ) {
+ if( $gContent->storeXref( $_REQUEST ) ) {
+ header( 'Location: '.$gContent->getDisplayUrl() );
+ die;
+ }
+}
+
+$xref_type = (int)( $_REQUEST['xref_type'] ?? 1 );
+$xrefTypeList = $gContent->getXrefTypeList( $xref_type );
+
+$gBitSmarty->assign( 'gContent', $gContent );
+$gBitSmarty->assign( 'xref_type', $xref_type );
+$gBitSmarty->assign( 'xrefTypeList', $xrefTypeList );
+$gBitSmarty->assign( 'errors', $gContent->mErrors );
+
+$gBitSystem->display( 'bitpackage:liberty/add_xref.tpl', 'Add Detail', [ 'display_mode' => 'edit' ] );