6 * @copyright (c) 2005 phpBB Group
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
14 define('IN_PHPBB', true);
15 $phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH
: './';
16 $phpEx = substr(strrchr(__FILE__
, '.'), 1);
17 include($phpbb_root_path . 'common.' . $phpEx);
18 include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
19 require($phpbb_root_path . 'includes/functions_module.' . $phpEx);
21 // Start session management
22 $user->session_begin();
23 $auth->acl($user->data
);
26 $module = new p_master();
28 // Setting a variable to let the style designer know where he is...
29 $template->assign_var('S_IN_MCP', true);
31 // Basic parameter data
32 $id = request_var('i', '');
34 if (isset($_REQUEST['mode']) && is_array($_REQUEST['mode']))
36 $mode = request_var('mode', array(''));
37 list($mode, ) = each($mode);
41 $mode = request_var('mode', '');
44 // Only Moderators can go beyond this point
45 if (!$user->data
['is_registered'])
47 if ($user->data
['is_bot'])
49 redirect(append_sid("{$phpbb_root_path}index.$phpEx"));
52 login_box('', $user->lang
['LOGIN_EXPLAIN_MCP']);
55 $quickmod = (isset($_REQUEST['quickmod'])) ?
true : false;
56 $action = request_var('action', '');
57 $action_ary = request_var('action', array('' => 0));
59 $forum_action = request_var('forum_action', '');
60 if ($forum_action !== '' && !empty($_POST['sort']))
62 $action = $forum_action;
65 if (sizeof($action_ary))
67 list($action, ) = each($action_ary);
71 if ($mode == 'topic_logs')
77 $post_id = request_var('p', 0);
78 $topic_id = request_var('t', 0);
79 $forum_id = request_var('f', 0);
80 $report_id = request_var('r', 0);
81 $user_id = request_var('u', 0);
82 $username = utf8_normalize_nfc(request_var('username', '', true));
86 // We determine the topic and forum id here, to make sure the moderator really has moderative rights on this post
87 $sql = 'SELECT topic_id, forum_id
88 FROM ' . POSTS_TABLE
. "
89 WHERE post_id = $post_id";
90 $result = $db->sql_query($sql);
91 $row = $db->sql_fetchrow($result);
92 $db->sql_freeresult($result);
94 $topic_id = (int) $row['topic_id'];
95 $forum_id = (int) ($row['forum_id']) ?
$row['forum_id'] : $forum_id;
99 $sql = 'SELECT forum_id
100 FROM ' . TOPICS_TABLE
. "
101 WHERE topic_id = $topic_id";
102 $result = $db->sql_query($sql);
103 $row = $db->sql_fetchrow($result);
104 $db->sql_freeresult($result);
106 $forum_id = (int) $row['forum_id'];
109 // If the user doesn't have any moderator powers (globally or locally) he can't access the mcp
110 if (!$auth->acl_getf_global('m_'))
112 // Except he is using one of the quickmod tools for users
113 $user_quickmod_actions = array(
114 'lock' => 'f_user_lock',
115 'make_sticky' => 'f_sticky',
116 'make_announce' => 'f_announce',
117 'make_global' => 'f_announce',
118 'make_normal' => array('f_announce', 'f_sticky')
122 if ($quickmod && isset($user_quickmod_actions[$action]) && $user->data
['is_registered'] && $auth->acl_gets($user_quickmod_actions[$action], $forum_id))
124 $topic_info = get_topic_data(array($topic_id));
125 if ($topic_info[$topic_id]['topic_poster'] == $user->data
['user_id'])
133 trigger_error('NOT_AUTHORISED');
137 // if the user cannot read the forum he tries to access then we won't allow mcp access either
138 if ($forum_id && !$auth->acl_get('f_read', $forum_id))
140 trigger_error('NOT_AUTHORISED');
145 $module->acl_forum_id
= $forum_id;
148 // Instantiate module system and generate list of available modules
149 $module->list_modules('mcp');
162 case 'make_announce':
169 $module->load('mcp', 'main', 'quickmod');
174 // Reset start parameter if we jumped from the quickmod dropdown
175 if (request_var('start', 0))
177 $_REQUEST['start'] = 0;
180 $module->set_active('logs', 'topic_logs');
184 $module->set_active('main', 'forum_view');
189 $module->set_active('main', 'topic_view');
193 trigger_error("$action not allowed as quickmod", E_USER_ERROR
);
199 // Select the active module
200 $module->set_active($id, $mode);
203 // Hide some of the options if we don't have the relevant information to use them
206 $module->set_display('main', 'post_details', false);
207 $module->set_display('warn', 'warn_post', false);
210 if ($mode == '' ||
$mode == 'unapproved_topics' ||
$mode == 'unapproved_posts')
212 $module->set_display('queue', 'approve_details', false);
215 if ($mode == '' ||
$mode == 'reports' ||
$mode == 'reports_closed' ||
$mode == 'pm_reports' ||
$mode == 'pm_reports_closed' ||
$mode == 'pm_report_details')
217 $module->set_display('reports', 'report_details', false);
220 if ($mode == '' ||
$mode == 'reports' ||
$mode == 'reports_closed' ||
$mode == 'pm_reports' ||
$mode == 'pm_reports_closed' ||
$mode == 'report_details')
222 $module->set_display('pm_reports', 'pm_report_details', false);
227 $module->set_display('main', 'topic_view', false);
228 $module->set_display('logs', 'topic_logs', false);
233 $module->set_display('main', 'forum_view', false);
234 $module->set_display('logs', 'forum_logs', false);
237 if (!$user_id && $username == '')
239 $module->set_display('notes', 'user_notes', false);
240 $module->set_display('warn', 'warn_user', false);
243 // Load and execute the relevant module
244 $module->load_active();
246 // Assign data to the template engine for the list of modules
247 $module->assign_tpl_vars(append_sid("{$phpbb_root_path}mcp.$phpEx"));
249 // Generate urls for letting the moderation control panel being accessed in different modes
250 $template->assign_vars(array(
251 'U_MCP' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main'),
252 'U_MCP_FORUM' => ($forum_id) ?
append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=forum_view&f=$forum_id") : '',
253 'U_MCP_TOPIC' => ($forum_id && $topic_id) ?
append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&t=$topic_id") : '',
254 'U_MCP_POST' => ($forum_id && $topic_id && $post_id) ?
append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=post_details&t=$topic_id&p=$post_id") : '',
257 // Generate the page, do not display/query online list
258 $module->display($module->get_page_title(), false);
261 * Functions used to generate additional URL paramters
263 function _module__url($mode, &$module_row)
268 function _module_notes_url($mode, &$module_row)
270 if ($mode == 'front')
276 return ($user_id) ?
"&u=$user_id" : '';
279 function _module_warn_url($mode, &$module_row)
281 if ($mode == 'front' ||
$mode == 'list')
285 return ($forum_id) ?
"&f=$forum_id" : '';
288 if ($mode == 'warn_post')
290 global $forum_id, $post_id;
292 $url_extra = ($forum_id) ?
"&f=$forum_id" : '';
293 $url_extra .= ($post_id) ?
"&p=$post_id" : '';
301 return ($user_id) ?
"&u=$user_id" : '';
305 function _module_main_url($mode, &$module_row)
310 function _module_logs_url($mode, &$module_row)
315 function _module_ban_url($mode, &$module_row)
320 function _module_queue_url($mode, &$module_row)
325 function _module_reports_url($mode, &$module_row)
332 global $forum_id, $topic_id, $post_id, $report_id, $user_id;
335 $url_extra .= ($forum_id) ?
"&f=$forum_id" : '';
336 $url_extra .= ($topic_id) ?
"&t=$topic_id" : '';
337 $url_extra .= ($post_id) ?
"&p=$post_id" : '';
338 $url_extra .= ($user_id) ?
"&u=$user_id" : '';
339 $url_extra .= ($report_id) ?
"&r=$report_id" : '';
345 * Get simple topic data
347 function get_topic_data($topic_ids, $acl_list = false, $read_tracking = false)
349 global $auth, $db, $config, $user;
350 static $rowset = array();
354 if (!sizeof($topic_ids))
359 // cache might not contain read tracking info, so we can't use it if read
360 // tracking information is requested
363 $cache_topic_ids = array_intersect($topic_ids, array_keys($rowset));
364 $topic_ids = array_diff($topic_ids, array_keys($rowset));
368 $cache_topic_ids = array();
371 if (sizeof($topic_ids))
374 'SELECT' => 't.*, f.*',
380 'LEFT_JOIN' => array(
382 'FROM' => array(FORUMS_TABLE
=> 'f'),
383 'ON' => 'f.forum_id = t.forum_id'
387 'WHERE' => $db->sql_in_set('t.topic_id', $topic_ids)
390 if ($read_tracking && $config['load_db_lastread'])
392 $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
394 $sql_array['LEFT_JOIN'][] = array(
395 'FROM' => array(TOPICS_TRACK_TABLE
=> 'tt'),
396 'ON' => 'tt.user_id = ' . $user->data
['user_id'] . ' AND t.topic_id = tt.topic_id'
399 $sql_array['LEFT_JOIN'][] = array(
400 'FROM' => array(FORUMS_TRACK_TABLE
=> 'ft'),
401 'ON' => 'ft.user_id = ' . $user->data
['user_id'] . ' AND t.forum_id = ft.forum_id'
405 $sql = $db->sql_build_query('SELECT', $sql_array);
406 $result = $db->sql_query($sql);
408 while ($row = $db->sql_fetchrow($result))
410 if (!$row['forum_id'])
412 // Global Announcement?
413 $row['forum_id'] = request_var('f', 0);
416 $rowset[$row['topic_id']] = $row;
418 if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
423 $topics[$row['topic_id']] = $row;
425 $db->sql_freeresult($result);
428 foreach ($cache_topic_ids as $id)
430 if (!$acl_list ||
$auth->acl_gets($acl_list, $rowset[$id]['forum_id']))
432 $topics[$id] = $rowset[$id];
440 * Get simple post data
442 function get_post_data($post_ids, $acl_list = false, $read_tracking = false)
444 global $db, $auth, $config, $user;
448 if (!sizeof($post_ids))
454 'SELECT' => 'p.*, u.*, t.*, f.*',
462 'LEFT_JOIN' => array(
464 'FROM' => array(FORUMS_TABLE
=> 'f'),
465 'ON' => 'f.forum_id = t.forum_id'
469 'WHERE' => $db->sql_in_set('p.post_id', $post_ids) . '
470 AND u.user_id = p.poster_id
471 AND t.topic_id = p.topic_id',
474 if ($read_tracking && $config['load_db_lastread'])
476 $sql_array['SELECT'] .= ', tt.mark_time, ft.mark_time as forum_mark_time';
478 $sql_array['LEFT_JOIN'][] = array(
479 'FROM' => array(TOPICS_TRACK_TABLE
=> 'tt'),
480 'ON' => 'tt.user_id = ' . $user->data
['user_id'] . ' AND t.topic_id = tt.topic_id'
483 $sql_array['LEFT_JOIN'][] = array(
484 'FROM' => array(FORUMS_TRACK_TABLE
=> 'ft'),
485 'ON' => 'ft.user_id = ' . $user->data
['user_id'] . ' AND t.forum_id = ft.forum_id'
489 $sql = $db->sql_build_query('SELECT', $sql_array);
490 $result = $db->sql_query($sql);
493 while ($row = $db->sql_fetchrow($result))
495 if (!$row['forum_id'])
497 // Global Announcement?
498 $row['forum_id'] = request_var('f', 0);
501 if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
506 if (!$row['post_approved'] && !$auth->acl_get('m_approve', $row['forum_id']))
508 // Moderators without the permission to approve post should at least not see them. ;)
512 $rowset[$row['post_id']] = $row;
514 $db->sql_freeresult($result);
520 * Get simple forum data
522 function get_forum_data($forum_id, $acl_list = 'f_list', $read_tracking = false)
524 global $auth, $db, $user, $config;
528 if (!is_array($forum_id))
530 $forum_id = array($forum_id);
533 if (!sizeof($forum_id))
538 if ($read_tracking && $config['load_db_lastread'])
540 $read_tracking_join = ' LEFT JOIN ' . FORUMS_TRACK_TABLE
. ' ft ON (ft.user_id = ' . $user->data
['user_id'] . '
541 AND ft.forum_id = f.forum_id)';
542 $read_tracking_select = ', ft.mark_time';
546 $read_tracking_join = $read_tracking_select = '';
549 $sql = "SELECT f.* $read_tracking_select
550 FROM " . FORUMS_TABLE
. " f$read_tracking_join
551 WHERE " . $db->sql_in_set('f.forum_id', $forum_id);
552 $result = $db->sql_query($sql);
554 while ($row = $db->sql_fetchrow($result))
556 if ($acl_list && !$auth->acl_gets($acl_list, $row['forum_id']))
561 if ($auth->acl_get('m_approve', $row['forum_id']))
563 $row['forum_topics'] = $row['forum_topics_real'];
566 $rowset[$row['forum_id']] = $row;
568 $db->sql_freeresult($result);
576 function get_pm_data($pm_ids)
578 global $db, $auth, $config, $user;
582 if (!sizeof($pm_ids))
588 'SELECT' => 'p.*, u.*',
592 PRIVMSGS_TABLE
=> 'p',
595 'WHERE' => $db->sql_in_set('p.msg_id', $pm_ids) . '
596 AND u.user_id = p.author_id',
599 $sql = $db->sql_build_query('SELECT', $sql_array);
600 $result = $db->sql_query($sql);
603 while ($row = $db->sql_fetchrow($result))
605 $rowset[$row['msg_id']] = $row;
607 $db->sql_freeresult($result);
615 * @param string $where_sql should either be WHERE (default if ommited) or end with AND or OR
617 * $mode reports and reports_closed: the $where parameters uses aliases p for posts table and r for report table
618 * $mode unapproved_posts: the $where parameters uses aliases p for posts table and t for topic table
620 function mcp_sorting($mode, &$sort_days, &$sort_key, &$sort_dir, &$sort_by_sql, &$sort_order_sql, &$total, $forum_id = 0, $topic_id = 0, $where_sql = 'WHERE')
622 global $db, $user, $auth, $template;
624 $sort_days = request_var('st', 0);
625 $min_time = ($sort_days) ?
time() - ($sort_days * 86400) : 0;
634 $sql = 'SELECT COUNT(topic_id) AS total
635 FROM ' . TOPICS_TABLE
. "
636 $where_sql forum_id = $forum_id
637 AND topic_type NOT IN (" . POST_ANNOUNCE
. ', ' . POST_GLOBAL
. ")
638 AND topic_last_post_time >= $min_time";
640 if (!$auth->acl_get('m_approve', $forum_id))
642 $sql .= 'AND topic_approved = 1';
651 $sql = 'SELECT COUNT(post_id) AS total
652 FROM ' . POSTS_TABLE
. "
653 $where_sql topic_id = $topic_id
654 AND post_time >= $min_time";
656 if (!$auth->acl_get('m_approve', $forum_id))
658 $sql .= 'AND post_approved = 1';
662 case 'unapproved_posts':
666 $where_sql .= ($topic_id) ?
' p.topic_id = ' . $topic_id . ' AND' : '';
668 $sql = 'SELECT COUNT(p.post_id) AS total
669 FROM ' . POSTS_TABLE
. ' p, ' . TOPICS_TABLE
. " t
670 $where_sql " . $db->sql_in_set('p.forum_id', ($forum_id) ?
array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
671 AND p.post_approved = 0
672 AND t.topic_id = p.topic_id
673 AND t.topic_first_post_id <> p.post_id';
677 $sql .= ' AND post_time >= ' . $min_time;
681 case 'unapproved_topics':
686 $sql = 'SELECT COUNT(topic_id) AS total
687 FROM ' . TOPICS_TABLE
. "
688 $where_sql " . $db->sql_in_set('forum_id', ($forum_id) ?
array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_approve'))) . '
689 AND topic_approved = 0';
693 $sql .= ' AND topic_time >= ' . $min_time;
698 case 'pm_reports_closed':
700 case 'reports_closed':
701 $pm = (strpos($mode, 'pm_') === 0) ?
true : false;
703 $type = ($pm) ?
'pm_reports' : 'reports';
706 $limit_time_sql = ($min_time) ?
"AND r.report_time >= $min_time" : '';
710 $where_sql .= ' p.topic_id = ' . $topic_id . ' AND ';
714 $where_sql .= ' p.forum_id = ' . $forum_id . ' AND ';
718 $where_sql .= ' ' . $db->sql_in_set('p.forum_id', get_forum_list(array('!f_read', '!m_report')), true, true) . ' AND ';
721 if ($mode == 'reports' ||
$mode == 'pm_reports')
723 $where_sql .= ' r.report_closed = 0 AND ';
727 $where_sql .= ' r.report_closed = 1 AND ';
732 $sql = 'SELECT COUNT(r.report_id) AS total
733 FROM ' . REPORTS_TABLE
. ' r, ' . PRIVMSGS_TABLE
. " p
734 $where_sql r.post_id = 0
735 AND p.msg_id = r.pm_id
740 $sql = 'SELECT COUNT(r.report_id) AS total
741 FROM ' . REPORTS_TABLE
. ' r, ' . POSTS_TABLE
. " p
742 $where_sql r.pm_id = 0
743 AND p.post_id = r.post_id
753 $sql = 'SELECT COUNT(log_id) AS total
754 FROM ' . LOG_TABLE
. "
755 $where_sql " . $db->sql_in_set('forum_id', ($forum_id) ?
array($forum_id) : array_intersect(get_forum_list('f_read'), get_forum_list('m_'))) . '
756 AND log_time >= ' . $min_time . '
757 AND log_type = ' . LOG_MOD
;
761 $sort_key = request_var('sk', $default_key);
762 $sort_dir = request_var('sd', $default_dir);
763 $sort_dir_text = array('a' => $user->lang
['ASCENDING'], 'd' => $user->lang
['DESCENDING']);
768 $limit_days = array(0 => $user->lang
['ALL_TOPICS'], 1 => $user->lang
['1_DAY'], 7 => $user->lang
['7_DAYS'], 14 => $user->lang
['2_WEEKS'], 30 => $user->lang
['1_MONTH'], 90 => $user->lang
['3_MONTHS'], 180 => $user->lang
['6_MONTHS'], 365 => $user->lang
['1_YEAR']);
769 $sort_by_text = array('a' => $user->lang
['AUTHOR'], 't' => $user->lang
['POST_TIME'], 'tt' => $user->lang
['TOPIC_TIME'], 'r' => $user->lang
['REPLIES'], 's' => $user->lang
['SUBJECT'], 'v' => $user->lang
['VIEWS']);
771 $sort_by_sql = array('a' => 't.topic_first_poster_name', 't' => 't.topic_last_post_time', 'tt' => 't.topic_time', 'r' => (($auth->acl_get('m_approve', $forum_id)) ?
't.topic_replies_real' : 't.topic_replies'), 's' => 't.topic_title', 'v' => 't.topic_views');
772 $limit_time_sql = ($min_time) ?
"AND t.topic_last_post_time >= $min_time" : '';
776 $limit_days = array(0 => $user->lang
['ALL_POSTS'], 1 => $user->lang
['1_DAY'], 7 => $user->lang
['7_DAYS'], 14 => $user->lang
['2_WEEKS'], 30 => $user->lang
['1_MONTH'], 90 => $user->lang
['3_MONTHS'], 180 => $user->lang
['6_MONTHS'], 365 => $user->lang
['1_YEAR']);
777 $sort_by_text = array('a' => $user->lang
['AUTHOR'], 't' => $user->lang
['POST_TIME'], 's' => $user->lang
['SUBJECT']);
778 $sort_by_sql = array('a' => 'u.username_clean', 't' => 'p.post_time', 's' => 'p.post_subject');
779 $limit_time_sql = ($min_time) ?
"AND p.post_time >= $min_time" : '';
783 $limit_days = array(0 => $user->lang
['ALL_REPORTS'], 1 => $user->lang
['1_DAY'], 7 => $user->lang
['7_DAYS'], 14 => $user->lang
['2_WEEKS'], 30 => $user->lang
['1_MONTH'], 90 => $user->lang
['3_MONTHS'], 180 => $user->lang
['6_MONTHS'], 365 => $user->lang
['1_YEAR']);
784 $sort_by_text = array('a' => $user->lang
['AUTHOR'], 'r' => $user->lang
['REPORTER'], 'p' => $user->lang
['POST_TIME'], 't' => $user->lang
['REPORT_TIME'], 's' => $user->lang
['SUBJECT']);
785 $sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.post_time', 't' => 'r.report_time', 's' => 'p.post_subject');
789 $limit_days = array(0 => $user->lang
['ALL_REPORTS'], 1 => $user->lang
['1_DAY'], 7 => $user->lang
['7_DAYS'], 14 => $user->lang
['2_WEEKS'], 30 => $user->lang
['1_MONTH'], 90 => $user->lang
['3_MONTHS'], 180 => $user->lang
['6_MONTHS'], 365 => $user->lang
['1_YEAR']);
790 $sort_by_text = array('a' => $user->lang
['AUTHOR'], 'r' => $user->lang
['REPORTER'], 'p' => $user->lang
['POST_TIME'], 't' => $user->lang
['REPORT_TIME'], 's' => $user->lang
['SUBJECT']);
791 $sort_by_sql = array('a' => 'u.username_clean', 'r' => 'ru.username', 'p' => 'p.message_time', 't' => 'r.report_time', 's' => 'p.message_subject');
795 $limit_days = array(0 => $user->lang
['ALL_ENTRIES'], 1 => $user->lang
['1_DAY'], 7 => $user->lang
['7_DAYS'], 14 => $user->lang
['2_WEEKS'], 30 => $user->lang
['1_MONTH'], 90 => $user->lang
['3_MONTHS'], 180 => $user->lang
['6_MONTHS'], 365 => $user->lang
['1_YEAR']);
796 $sort_by_text = array('u' => $user->lang
['SORT_USERNAME'], 't' => $user->lang
['SORT_DATE'], 'i' => $user->lang
['SORT_IP'], 'o' => $user->lang
['SORT_ACTION']);
798 $sort_by_sql = array('u' => 'u.username_clean', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
799 $limit_time_sql = ($min_time) ?
"AND l.log_time >= $min_time" : '';
803 if (!isset($sort_by_sql[$sort_key]))
805 $sort_key = $default_key;
808 $sort_order_sql = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ?
'DESC' : 'ASC');
810 $s_limit_days = $s_sort_key = $s_sort_dir = $sort_url = '';
811 gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $sort_url);
813 $template->assign_vars(array(
814 'S_SELECT_SORT_DIR' => $s_sort_dir,
815 'S_SELECT_SORT_KEY' => $s_sort_key,
816 'S_SELECT_SORT_DAYS' => $s_limit_days)
819 if (($sort_days && $mode != 'viewlogs') ||
in_array($mode, array('reports', 'unapproved_topics', 'unapproved_posts')) ||
$where_sql != 'WHERE')
821 $result = $db->sql_query($sql);
822 $total = (int) $db->sql_fetchfield('total');
823 $db->sql_freeresult($result);
834 * @param array &$ids The relevant ids to check
835 * @param string $table The table to find the ids in
836 * @param string $sql_id The ids relevant column name
837 * @param array $acl_list A list of permissions the user need to have
838 * @param mixed $singe_forum Limit to one forum id (int) or the first forum found (true)
840 * @return mixed False if no ids were able to be retrieved, true if at least one id left.
841 * Additionally, this value can be the forum_id assigned if $single_forum was set.
842 * Therefore checking the result for with !== false is the best method.
844 function check_ids(&$ids, $table, $sql_id, $acl_list = false, $single_forum = false)
848 if (!is_array($ids) ||
empty($ids))
853 $sql = "SELECT $sql_id, forum_id FROM $table
854 WHERE " . $db->sql_in_set($sql_id, $ids);
855 $result = $db->sql_query($sql);
860 while ($row = $db->sql_fetchrow($result))
862 if ($acl_list && $row['forum_id'] && !$auth->acl_gets($acl_list, $row['forum_id']))
867 if ($acl_list && !$row['forum_id'] && !$auth->acl_getf_global($acl_list))
872 // Limit forum? If not, just assign the id.
873 if ($single_forum === false)
875 $ids[] = $row[$sql_id];
879 // Limit forum to a specific forum id?
880 // This can get really tricky, because we do not want to create a failure on global topics. :)
881 if ($row['forum_id'])
883 if ($single_forum !== true && $row['forum_id'] == (int) $single_forum)
885 $forum_id = (int) $single_forum;
887 else if ($forum_id === false)
889 $forum_id = $row['forum_id'];
892 if ($row['forum_id'] == $forum_id)
894 $ids[] = $row[$sql_id];
899 // Always add a global topic
900 $ids[] = $row[$sql_id];
903 $db->sql_freeresult($result);
910 // If forum id is false and ids populated we may have only global announcements selected (returning 0 because of (int) $forum_id)
912 return ($single_forum === false) ?
true : (int) $forum_id;