Mercurial > hg > vamp-website
comparison forum/Sources/Subs-MessageIndex.php @ 76:e3e11437ecea website
Add forum code
author | Chris Cannam |
---|---|
date | Sun, 07 Jul 2013 11:25:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
75:72f59aa7e503 | 76:e3e11437ecea |
---|---|
1 <?php | |
2 | |
3 /** | |
4 * Simple Machines Forum (SMF) | |
5 * | |
6 * @package SMF | |
7 * @author Simple Machines http://www.simplemachines.org | |
8 * @copyright 2011 Simple Machines | |
9 * @license http://www.simplemachines.org/about/smf/license.php BSD | |
10 * | |
11 * @version 2.0 | |
12 */ | |
13 | |
14 if (!defined('SMF')) | |
15 die('Hacking attempt...'); | |
16 | |
17 function getBoardList($boardListOptions = array()) | |
18 { | |
19 global $smcFunc, $user_info; | |
20 | |
21 if (isset($boardListOptions['excluded_boards']) && isset($boardListOptions['included_boards'])) | |
22 trigger_error('getBoardList(): Setting both excluded_boards and included_boards is not allowed.', E_USER_ERROR); | |
23 | |
24 $where = array(); | |
25 $where_parameters = array(); | |
26 if (isset($boardListOptions['excluded_boards'])) | |
27 { | |
28 $where[] = 'b.id_board NOT IN ({array_int:excluded_boards})'; | |
29 $where_parameters['excluded_boards'] = $boardListOptions['excluded_boards']; | |
30 } | |
31 | |
32 if (isset($boardListOptions['included_boards'])) | |
33 { | |
34 $where[] = 'b.id_board IN ({array_int:included_boards})'; | |
35 $where_parameters['included_boards'] = $boardListOptions['included_boards']; | |
36 } | |
37 | |
38 if (!empty($boardListOptions['ignore_boards'])) | |
39 $where[] = '{query_wanna_see_board}'; | |
40 | |
41 elseif (!empty($boardListOptions['use_permissions'])) | |
42 $where[] = '{query_see_board}'; | |
43 | |
44 if (!empty($boardListOptions['not_redirection'])) | |
45 { | |
46 $where[] = 'b.redirect = {string:blank_redirect}'; | |
47 $where_parameters['blank_redirect'] = ''; | |
48 } | |
49 | |
50 $request = $smcFunc['db_query']('messageindex_fetch_boards', ' | |
51 SELECT c.name AS cat_name, c.id_cat, b.id_board, b.name AS board_name, b.child_level | |
52 FROM {db_prefix}boards AS b | |
53 LEFT JOIN {db_prefix}categories AS c ON (c.id_cat = b.id_cat)' . (empty($where) ? '' : ' | |
54 WHERE ' . implode(' | |
55 AND ', $where)), | |
56 $where_parameters | |
57 ); | |
58 | |
59 $return_value = array(); | |
60 if ($smcFunc['db_num_rows']($request) !== 0) | |
61 { | |
62 while ($row = $smcFunc['db_fetch_assoc']($request)) | |
63 { | |
64 if (!isset($return_value[$row['id_cat']])) | |
65 $return_value[$row['id_cat']] = array( | |
66 'id' => $row['id_cat'], | |
67 'name' => $row['cat_name'], | |
68 'boards' => array(), | |
69 ); | |
70 | |
71 $return_value[$row['id_cat']]['boards'][] = array( | |
72 'id' => $row['id_board'], | |
73 'name' => $row['board_name'], | |
74 'child_level' => $row['child_level'], | |
75 'selected' => isset($boardListOptions['selected_board']) && $boardListOptions['selected_board'] == $row['id_board'], | |
76 ); | |
77 } | |
78 } | |
79 $smcFunc['db_free_result']($request); | |
80 | |
81 return $return_value; | |
82 } | |
83 | |
84 ?> |