diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-25 15:39:34 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-25 15:39:34 +0100 |
| commit | fb30cd3317e01ebe8e748e4bcf1482e4c324b9b9 (patch) | |
| tree | 2a263ad27d6a78b4fe5f78e30134b5edc5aa618b /edit_xref.php | |
| parent | 80d56ac6a0b704c1b480157422227626f63df67d (diff) | |
| download | liberty-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 'edit_xref.php')
| -rw-r--r-- | edit_xref.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/edit_xref.php b/edit_xref.php new file mode 100644 index 0000000..323b4db --- /dev/null +++ b/edit_xref.php @@ -0,0 +1,49 @@ +<?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.' ); +} + +if( !empty( $_REQUEST['xref_id'] ) ) { + $gContent->loadXref( $_REQUEST['xref_id'] ); +} + +$gContent->verifyUpdatePermission(); + +if( !empty( $_REQUEST['fCancel'] ) ) { + header( 'Location: '.$gContent->getDisplayUrl() ); + die; +} + +if( !empty( $_REQUEST['fSaveXref'] ) ) { + if( $gContent->storeXref( $_REQUEST ) ) { + header( 'Location: '.$gContent->getDisplayUrl() ); + die; + } + $xrefInfo = $_REQUEST; + $xrefInfo['data'] = $_REQUEST['edit'] ?? ''; +} else { + $xrefInfo = $gContent->mInfo['xref_store']['data'] ?? []; +} + +$gBitSmarty->assign( 'gContent', $gContent ); +$gBitSmarty->assign( 'xrefInfo', $xrefInfo ); +$gBitSmarty->assign( 'errors', $gContent->mErrors ); + +$gBitSystem->display( 'bitpackage:liberty/edit_xref.tpl', 'Edit Detail', [ 'display_mode' => 'edit' ] ); |
