summaryrefslogtreecommitdiff
path: root/add_xref.php
blob: 56ba6d5ed8cb14989bcfd4949261f7e0988d5409 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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' ] );