blob: cce8a67fb39e05e46b5c16d2df67d801cd3f8996 (
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
<?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/setup_inc.php");
require_once( BOARDS_PKG_CLASS_PATH.'BitBoardTopic.php' );
require_once( BOARDS_PKG_CLASS_PATH.'BitBoardPost.php' );
require_once( BOARDS_PKG_CLASS_PATH.'BitBoard.php' );
// Is package installed and enabled
$gBitSystem->verifyPackage( 'boards' );
// Now check permissions to access this page
$gBitSystem->verifyPermission( 'p_boards_read' );
// Get a list of boards
$ns = array();
$board_all_cids =array();
// @TODO move pigeonholes to its own file library or something
if($gBitSystem->isPackageActive('pigeonholes')) {
require_once(PIGEONHOLES_PKG_PATH.'Pigeonholes.php');
$p = new Pigeonholes();
$s = new LibertyStructure();
$listHash = array('load_only_root'=> TRUE);
$l = $p->getList($listHash);
foreach ($l as $e) {
$d = $s->getSubTree( $e['structure_id'] );
$d_o = array();
foreach ($d as $c) {
$pos_var = &$d_o;
if($c['level']!=0) {
$pos = explode(".",$c['pos']);
$pos_var = &$d_o;
foreach ($pos as $pos_v) {
if (!isset($pos_var['children'])) {
$pos_var['children']=array();
}
if (!isset($pos_var['children'][$pos_v-1])) {
$pos_var['children'][$pos_v-1]=array();
}
$pos_var = &$pos_var['children'][$pos_v-1];
}
}
if (empty($pos_var['data'])) {
$pos_var['children']=array();
$pos_var['data']=$c;
$mlHash=array();
$mlHash['content_id']=$c['content_id'];
$mlHash['content_type_guid']=BITBOARD_CONTENT_TYPE_GUID;
$pos_var['members']=$p->getMemberList($mlHash);
$board_cids =array();
foreach ($pos_var['members'] as $boardKey) {
$board_cids[] = $boardKey['content_id'];
}
if (count($board_cids)>0) {
$listHash = array('boards'=>$board_cids,'paginationOff'=>'y');
$board = new BitBoard();
$pos_var['members'] = $board->getList($listHash);
$pos_var['pagination']=$listHash['listInfo'];
$board_all_cids = array_merge($board_all_cids,$board_cids);
}
}
}
$ns[]=$d_o;
}
}
// get our boards list
$ret =array();
if($gBitSystem->isPackageActive('pigeonholes')) {
// $ret['data']['title']="Uncategorised Boards";
} else {
// $ret['data']['title']="Board List";
}
$ret['children']=array();
$listHash = array('nboards'=>$board_all_cids,'paginationOff'=>'y');
$board = new BitBoard();
$ret['members'] = $board->getList($listHash);
if (count($ret['members']) == 1) {
$_REQUEST['b'] = $ret['members'][0]['board_id'];
require( BOARDS_PKG_INCLUDE_PATH.'view_board_inc.php' );
die;
} elseif (count($ret['members']) > 0) {
$ns[] = $ret;
}
$gBitSmarty->assignByRef('ns',$ns);
// this might be for getting a count of nested boards - not entirely sure, if you figure it out please clarify this comment.
function countBoards(&$a) {
$s = count($a['members']);
foreach ($a['children'] as $k=>$c) {
$n = countBoards($a['children'][$k]);
if ($n == 0) {
unset($a['children'][$k]);
}
else {
$a['children'][$k]['sub_count'] = $n;
$s += $n;
}
}
return $s;
}
foreach ($ns as $k=> $a) {
$n = countBoards($ns[$k]);
if ($n == 0) {
unset($ns[$k]);
}
else {
$ns[$k]['sub_count'] = $n;
}
}
//$gBitSmarty->display( 'bitpackage:boards/cat_display.tpl');
$gBitSystem->display( 'bitpackage:boards/list_boards.tpl', tra( 'Boards' ) , array( 'display_mode' => 'display' ));
?>
|