summaryrefslogtreecommitdiff
path: root/assign.php
blob: 8c3c602f8b662ab3fa7300b75ee7d7ea8512501a (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
<?php
/**
 * $Header$
 * Copyright (c) 2004 bitweaver Messageboards
 * All Rights Reserved. See below for details and a complete list of authors.
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details.
 * @package boards
 * @subpackage functions
 */

/**
 * required setup
 */
require_once '../kernel/includes/setup_inc.php';

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

require_once(BOARDS_PKG_INCLUDE_PATH.'lookup_inc.php' );

// verify minimal edit permission level
$gContent->verifyUpdatePermission();

if (!empty($_REQUEST['remove'])) {
	foreach ($_REQUEST['remove'] as $board_id => $content_ids) {
		$b = new BitBoard($board_id);
		$b->load();
		if ( $b->hasUpdatePermission() ){
			foreach ($content_ids as $content_id => $remove) {
				if ($remove) {
					$b->removeContent($content_id);
				}
			}
		}
			// @TODO assign error and report back to user which were not processed

	}
}

if( !empty( $_REQUEST['assign'] ) && BitBase::verifyId( $_REQUEST['to_board_id'] ?? 0 ) ) {
	$b = new BitBoard( $_REQUEST['to_board_id'] );
	$b->load();
	if ( $b->verifyUpdatePermission() ){
		foreach( $_REQUEST['assign'] as $content_id ) {
			$b->addContent( $content_id );
		}
	}
}

if (!empty($_REQUEST['integrity'])) {
	$board_id = $_REQUEST['integrity'];
	$b = new BitBoard($board_id);
	$b->load();
	if ( $b->verifyUpdatePermission() ){
		$b->fixContentMap();
	}
}

$data = BitBoard::getAllMap();
$gBitSmarty->assign('data',$data);

// Display the template
$gBitSystem->display( 'bitpackage:boards/board_assign.tpl', tra('Assign content to Board') , [ 'display_mode' => 'display' ]);
?>