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:
<?php
if (!defined('SMF'))
die('No direct access...');
function getBoardList($boardListOptions = array())
{
global $smcFunc, $sourcedir;
if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards']))
trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR);
$where = array();
$where_parameters = array();
if (isset($boardListOptions['excluded_boards']))
{
$where[] = 'b.id_board NOT IN ({array_int:excluded_boards})';
$where_parameters['excluded_boards'] = $boardListOptions['excluded_boards'];
}
if (isset($boardListOptions['included_boards']))
{
$where[] = 'b.id_board IN ({array_int:included_boards})';
$where_parameters['included_boards'] = $boardListOptions['included_boards'];
}
if (!empty($boardListOptions['ignore_boards']))
$where[] = '{query_wanna_see_board}';
elseif (!empty($boardListOptions['use_permissions']))
$where[] = '{query_see_board}';
if (!empty($boardListOptions['not_redirection']))
{
$where[] = 'b.redirect = {string:blank_redirect}';
$where_parameters['blank_redirect'] = '';
}
$request = $smcFunc['db_query']('order_by_board_order', '
SELECT c.name AS cat_name, c.id_cat, b.id_board, b.name AS board_name, b.child_level
FROM {db_prefix}boards AS b
LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)' . (empty($where) ? '' : '
WHERE ' . implode('
AND ', $where)),
$where_parameters
);
$return_value = array();
if ($smcFunc['db_num_rows']($request) !== 0)
{
while ($row = $smcFunc['db_fetch_assoc']($request))
{
if (!isset($return_value[$row['id_cat']]))
$return_value[$row['id_cat']] = array(
'id' => $row['id_cat'],
'name' => $row['cat_name'],
'boards' => array(),
);
$return_value[$row['id_cat']]['boards'][$row['id_board']] = array(
'id' => $row['id_board'],
'name' => $row['board_name'],
'child_level' => $row['child_level'],
'selected' => isset($boardListOptions['selected_board']) && $boardListOptions['selected_board'] == $row['id_board'],
);
}
}
$smcFunc['db_free_result']($request);
require_once($sourcedir . '/Subs-Boards.php');
sortCategories($return_value);
return $return_value;
}
?>