summaryrefslogtreecommitdiff
path: root/topic_move.php
blob: 26fb1c9d42b18c2af3c4f490f2d94dfd422c0d15 (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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
 * @package boards
 * @subpackage functions
 */

/**
 * required setup
 */
require_once( '../kernel/setup_inc.php' );

// Is package installed and enabled
$gBitSystem->verifyPackage( 'boards' );

// Look up Topic (lookup_inc is universal, gContent == BitBoardTopic)
require_once( BOARDS_PKG_PATH.'lookup_inc.php' );

// Make sure topic exists since we only run through here for existing topics. New topics are created via comment system.
if( !$gContent->isValid() ){
	$gBitSystem->fatalError( 'No topic specified' );
}

// Load up the Topic's board - we'll respect its permissions
$board = new BitBoard( $gContent->mInfo['board_id'] );
$board->load();
$board->verifyAdminPermission();

if( isset( $_REQUEST["target"] ) ) {
	// Check the user's ticket
	$gBitUser->verifyTicket();

	$targetBoard = new BitBoard( null, $_REQUEST["target"] );
	$targetBoard->load();
	if( !$targetBoard->hasAdminPermission() ){
		$gBitSystem->fatalError( 'You do not have permission to move topics to the Board' . $targetBoard->mInfo['title'] );
	}
	
	if( isset( $_REQUEST["confirm"] ) ) {
		if( $gContent->moveTo($_REQUEST["target"]) ) {
			header ("location: ".$gContent-getDisplayUrl() );
			die;
		} else {
			$gBitSystem->fatalError( "There was an error moving the topic: ".vc( $gContent->mErrors ));
		}
	}else{
		$gBitSystem->setBrowserTitle( tra( 'Confirm moving' ).' "' .$gContent->mInfo['title'] .'" '. tra("to Board"). ' "'.$targetBoard->mInfo['title'].'"');
		$formHash=array();
		if (empty($_REQUEST["ref"])) {
			$_REQUEST["ref"]=$_SERVER['HTTP_REFERER'];
		} elseif ($_REQUEST["ref"]=="-") {
			$_REQUEST["ref"]=$gContent->getDisplayUrl();
		}
		$formHash["ref"]=$_REQUEST["ref"];
		$formHash["target"]=$_REQUEST["target"];
		$formHash["t"]=$_REQUEST["t"];
		$msgHash = array(
			'label' => tra( "Move Thread" ).": ".$gContent->mInfo['title']  ,
// redundant to title in tpl
//			'confirm_item' => $gContent->mInfo['title'] ,
			'warning' => tra( "Move ".' "' .$gContent->mInfo['title'] .'" '. tra("to Board"). ' "'.$targetBoard->mInfo['title'].'"'."<br />This cannot be undone!" ),
		);
		$gBitSystem->confirmDialog( $formHash,$msgHash );
	}
}

// get list of boards we can move the topic to
$boards = $board->getBoardSelectList();
$gBitSmarty->assign_by_ref('boards', $boards);

$gBitSmarty->assign('fromBoardId', $board->mContentId);

$gBitSystem->display( 'bitpackage:boards/topic_move.tpl', tra('Category') , array( 'display_mode' => 'display' ));
?>