/** * Mark all recent topics in a certain forum as unread for the current member. * * @param AUTO_LINK The ID of the forum. */ function ocf_ping_forum_unread_all($forum_id) { $or_list = ocf_get_all_subordinate_forums($forum_id, 't_forum_id'); $topics = $GLOBALS['FORUM_DB']->query('SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE (' . $or_list . ') AND t_cache_last_time>' . strval(time() - 60 * 60 * 24 * intval(get_option('post_history_days')))); $or_list_2 = ''; foreach ($topics as $topic) { if ($or_list_2 != '') { $or_list_2 .= ' OR '; } $or_list_2 .= 'l_topic_id=' . strval((int) $topic['id']); } if ($or_list_2 == '') { return; } $GLOBALS['FORUM_DB']->query('DELETE FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_read_logs WHERE ' . $or_list_2); }
/** * Update a forums cached details. * * @param AUTO_LINK The ID of the forum to update the cached details of. * @param ?integer How much to increment the topic count by (NULL: It has to be completely recalculated). * @param ?integer How much to increment the post count by (NULL: It has to be completely recalculated). * @param ?AUTO_LINK The ID of the last topic (NULL: Unknown, it will have to be looked up). * @param ?string The title of the last topic (NULL: Unknown, it will have to be looked up). * @param ?TIME The last post time of the last topic (NULL: Unknown, it will have to be looked up). * @param ?string The last post username of the last topic (NULL: Unknown, it will have to be looked up). * @param ?MEMBER The last post member of the last topic (NULL: Unknown, it will have to be looked up). * @param ?AUTO_LINK The forum the last post was in (note this makes sense, because there may be subforums under this forum that we have to take into account). (NULL: Unknown, it will have to be looked up). */ function ocf_force_update_forum_cacheing($forum_id, $num_topics_increment = NULL, $num_posts_increment = NULL, $last_topic_id = NULL, $last_title = NULL, $last_time = NULL, $last_username = NULL, $last_member_id = NULL, $last_forum_id = NULL) { if (is_null($num_topics_increment) && !is_null($num_posts_increment)) { $num_topics_increment = 0; } if (!is_null($num_topics_increment) && is_null($num_posts_increment)) { $num_posts_increment = 0; } if (is_null($last_topic_id)) { require_code('ocf_forums'); $or_list = ocf_get_all_subordinate_forums($forum_id, 't_forum_id', NULL, true); $last_topic = $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE (' . $or_list . ') AND t_validated=1 ORDER BY t_cache_last_time DESC', 1); if (!array_key_exists(0, $last_topic)) { $last_topic_id = NULL; $last_title = ''; $last_time = NULL; $last_username = ''; $last_member_id = NULL; $last_forum_id = NULL; } else { $last_topic_id = $last_topic[0]['id']; $last_title = $last_topic[0]['t_cache_first_title']; // Actually, the first title of the last topic $last_time = $last_topic[0]['t_cache_last_time']; $last_username = $last_topic[0]['t_cache_last_username']; $last_member_id = $last_topic[0]['t_cache_last_member_id']; $last_forum_id = $last_topic[0]['t_forum_id']; } } else { if (is_null($num_topics_increment)) { $or_list = ocf_get_all_subordinate_forums($forum_id, 't_forum_id', NULL, true); } } if (is_null($num_topics_increment)) { $_num_topics = $GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS topic_count FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE ' . $or_list); $num_topics = $_num_topics[0]['topic_count']; $or_list_2 = str_replace('t_forum_id', 'p_cache_forum_id', $or_list); $_num_posts = $GLOBALS['FORUM_DB']->query('SELECT COUNT(*) AS post_count FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE p_intended_solely_for IS NULL AND (' . $or_list_2 . ')'); $num_posts = $_num_posts[0]['post_count']; } $GLOBALS['FORUM_DB']->query('UPDATE ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums SET ' . (!is_null($num_posts_increment) ? ' f_cache_num_topics=(f_cache_num_topics+' . strval((int) $num_topics_increment) . '), f_cache_num_posts=(f_cache_num_posts+' . strval((int) $num_posts_increment) . '),' : ' f_cache_num_topics=' . strval((int) $num_topics) . ', f_cache_num_posts=' . strval((int) $num_posts) . ', ') . 'f_cache_last_topic_id=' . (!is_null($last_topic_id) ? strval($last_topic_id) : 'NULL') . ', f_cache_last_title=\'' . db_escape_string($last_title) . '\', f_cache_last_time=' . (!is_null($last_time) ? strval($last_time) : 'NULL') . ', f_cache_last_username=\'' . db_escape_string($last_username) . '\', f_cache_last_member_id=' . (!is_null($last_member_id) ? strval($last_member_id) : 'NULL') . ', f_cache_last_forum_id=' . (!is_null($last_forum_id) ? strval($last_forum_id) : 'NULL') . ' WHERE id=' . strval((int) $forum_id), 1); // Now, are there any parents who need updating? if (!is_null($forum_id)) { $parent_forum = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forums', 'f_parent_forum', array('id' => $forum_id)); if (!is_null($parent_forum) && $parent_forum != db_get_first_id()) { ocf_force_update_forum_cacheing($parent_forum, $num_topics_increment, $num_posts_increment); } } }
/** * Get an array of tickets for the given member and ticket type. If the member has permission to see others' tickets, it will be a list of all tickets * in the system, restricted by ticket type as appropriate. Otherwise, it will be a list of that member's tickets, as restricted by ticket type. * * @param AUTO_LINK The member ID * @param ?AUTO_LINK The ticket type (NULL: all ticket types) * @param boolean Don't view others' tickets, even if the member has permission to * @param boolean Whether to skip showing errors, returning NULL instead * @param boolean Whether to include first posts * @return array Array of tickets, empty on failure */ function get_tickets($member, $ticket_type = NULL, $override_view_others_tickets = false, $silent_error_handling = false, $include_first_posts = false) { $restrict = ''; $restrict_description = ''; $view_others_tickets = !$override_view_others_tickets && has_specific_permission($member, 'view_others_tickets'); if (!$view_others_tickets) { $restrict = strval($member) . '\\_%'; $restrict_description = do_lang('SUPPORT_TICKET') . ': #' . $restrict; } else { if (!is_null($ticket_type) && !has_category_access(get_member(), 'tickets', get_translated_text($ticket_type))) { return array(); } } if (get_option('ticket_member_forums') == '1' || get_option('ticket_type_forums') == '1') { if (get_forum_type() == 'ocf') { $fid = $view_others_tickets ? get_ticket_forum_id(NULL, NULL, false, $silent_error_handling) : get_ticket_forum_id(get_member(), NULL, false, $silent_error_handling); if (is_null($fid)) { return array(); } if (is_null($ticket_type)) { require_code('ocf_forums'); $forums = ocf_get_all_subordinate_forums($fid, NULL, NULL, true); } else { $query = 'SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE ' . db_string_equal_to('f_name', get_translated_text($ticket_type)) . ' AND '; if ($view_others_tickets) { $query .= 'f_parent_forum IN (SELECT id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE f_parent_forum=' . strval((int) $fid) . ')'; } else { $query .= 'f_parent_forum=' . strval((int) $fid); } $rows = $GLOBALS['FORUM_DB']->query($query); $forums = collapse_2d_complexity('id', 'id', $rows); } } else { $forums = array(get_ticket_forum_id($member, $ticket_type, false, $silent_error_handling)); } } else { $forums = array(get_ticket_forum_id(NULL, NULL, false, $silent_error_handling)); } if (count($forums) == 1 && array_key_exists(0, $forums) && is_null($forums[0])) { return array(); } $max_rows = 0; $topics = $GLOBALS['FORUM_DRIVER']->show_forum_topics(array_flip($forums), $view_others_tickets ? 100 : 500, 0, $max_rows, $restrict, true, 'lasttime', false, $restrict_description); if (is_null($topics)) { return array(); } $filtered_topics = array(); foreach ($topics as $topic) { $fp = $topic['firstpost']; if (!$include_first_posts) { unset($topic['firstpost']); // To stop Tempcode randomly making serialization sometimes change such that the refresh_if_changed is triggered } if (is_null($ticket_type) || strpos($fp->evaluate(), do_lang('TICKET_TYPE') . ': ' . get_translated_text($ticket_type)) !== false) { $filtered_topics[] = $topic; } } return $filtered_topics; }
/** * Get a map of details relating to the view of a certain forum of a certain member. * * @param integer The start row for getting details of topics in the forum (i.e. 0 is newest, higher is starting further back in time). * @param ?integer The maximum number of topics to get detail of (NULL: default). * @param ?MEMBER The member viewing (NULL: current member). * @return array The details. */ function ocf_get_forum_view($start = 0, $max = NULL, $forum_id = NULL) { if (is_null($max)) { $max = intval(get_option('forum_topics_per_page')); } $member_id = get_member(); load_up_all_module_category_permissions($member_id, 'forums'); if (is_null($forum_id)) { /*$forum_info[0]['f_name']=do_lang('ROOT_FORUM'); This optimisation was more trouble that it was worth, and constraining $forum_info[0]['f_description']=''; $forum_info[0]['f_parent_forum']=NULL;*/ $forum_id = db_get_first_id(); } $forum_info = $GLOBALS['FORUM_DB']->query_select('f_forums f', array('f_redirection', 'f_intro_question', 'f_intro_answer', 'f_order_sub_alpha', 'f_parent_forum', 'f_name', 'f_description', 'f_order'), array('f.id' => $forum_id), '', 1, NULL, false, array('f_description', 'f_intro_question')); if (!array_key_exists(0, $forum_info)) { warn_exit(do_lang_tempcode('MISSING_RESOURCE')); } if ($forum_info[0]['f_redirection'] != '' && looks_like_url($forum_info[0]['f_redirection'])) { header('Location: ' . $forum_info[0]['f_redirection']); exit; } if (!is_null($forum_id)) { if (!has_category_access($member_id, 'forums', strval($forum_id))) { access_denied('CATEGORY_ACCESS_LEVEL'); } // We're only allowed to view it existing from a parent forum, or nothing at all -- so access denied brother! } // Find our subforums first $order = $forum_info[0]['f_order_sub_alpha'] ? 'f_name' : 'f_position'; $_max_forum_detail = get_value('max_forum_detail'); $max_forum_detail = is_null($_max_forum_detail) ? 100 : intval($_max_forum_detail); $huge_forums = $GLOBALS['FORUM_DB']->query_value('f_forums', 'COUNT(*)') > $max_forum_detail; if ($huge_forums) { $_max_forum_inspect = get_value('max_forum_inspect'); $max_forum_inspect = is_null($_max_forum_inspect) ? 300 : intval($_max_forum_inspect); $subforum_rows = $GLOBALS['FORUM_DB']->query('SELECT f.* FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums f WHERE f.id=' . strval($forum_id) . ' OR f_parent_forum=' . strval($forum_id) . ' ORDER BY f_parent_forum,' . $order, $max_forum_inspect, NULL, false, false, array('f_description', 'f_intro_question')); if (count($subforum_rows) == $max_forum_inspect) { $subforum_rows = array(); } // Will cause performance breakage } else { $subforum_rows = $GLOBALS['FORUM_DB']->query_select('f_forums f', array('f.*'), NULL, 'ORDER BY f_parent_forum,' . $order, NULL, NULL, false, array('f_description', 'f_intro_question')); } $unread_forums = array(); if (!is_null($forum_id) && get_member() != $GLOBALS['OCF_DRIVER']->get_guest_id()) { // Where are there unread topics in subforums? $tree = array(); $subforum_rows_copy = $subforum_rows; $tree = ocf_organise_into_tree($subforum_rows_copy, $forum_id); if ($forum_id != db_get_first_id()) { $child_or_list = ocf_get_all_subordinate_forums($forum_id, 't_forum_id', $tree); } else { $child_or_list = ''; } if ($child_or_list != '') { $child_or_list .= ' AND '; } $query = 'SELECT DISTINCT t_forum_id,t.id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics t LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_read_logs l ON (t.id=l_topic_id AND l_member_id=' . strval((int) get_member()) . ') WHERE ' . $child_or_list . 't_cache_last_time>' . strval(time() - 60 * 60 * 24 * intval(get_option('post_history_days'))) . ' AND (l_time<t_cache_last_time OR l_time IS NULL)'; if (!has_specific_permission(get_member(), 'jump_to_unvalidated')) { $query .= ' AND t_validated=1'; } $unread_forums = collapse_2d_complexity('t_forum_id', 'id', $GLOBALS['FORUM_DB']->query($query)); } // Find all the categories that are used $categories = array(); $or_list = ''; foreach ($subforum_rows as $tmp_key => $subforum_row) { if ($subforum_row['f_parent_forum'] != $forum_id) { continue; } if (!has_category_access($member_id, 'forums', strval($subforum_row['id']))) { unset($subforum_rows[$tmp_key]); continue; } $category_id = $subforum_row['f_category_id']; if (!array_key_exists($category_id, $categories)) { $categories[$category_id] = array('subforums' => array()); if ($or_list != '') { $or_list .= ' OR '; } $or_list .= 'id=' . strval((int) $category_id); } } if ($or_list != '') { $category_rows = $GLOBALS['FORUM_DB']->query('SELECT * FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_categories WHERE ' . $or_list); foreach ($category_rows as $category_row) { $category_id = $category_row['id']; $title = $category_row['c_title']; $description = $category_row['c_description']; $expanded_by_default = $category_row['c_expanded_by_default']; $categories[$category_id]['title'] = $title; $categories[$category_id]['description'] = $description; $categories[$category_id]['expanded_by_default'] = $expanded_by_default; } $categories[NULL]['title'] = ''; $categories[NULL]['description'] = ''; $categories[NULL]['expanded_by_default'] = true; foreach ($subforum_rows as $subforum_row) { if ($subforum_row['f_parent_forum'] != $forum_id) { continue; } $category_id = $subforum_row['f_category_id']; // if (!array_key_exists('position',$categories[$category_id])) $categories[$category_id]['position']=$subforum_row['f_position']; $subforum = array(); $subforum['id'] = $subforum_row['id']; $subforum['name'] = $subforum_row['f_name']; $subforum['description'] = get_translated_tempcode($subforum_row['f_description'], $GLOBALS['FORUM_DB']); $subforum['redirection'] = $subforum_row['f_redirection']; $subforum['intro_question'] = get_translated_tempcode($subforum_row['f_intro_question'], $GLOBALS['FORUM_DB']); $subforum['intro_answer'] = $subforum_row['f_intro_answer']; if (is_numeric($subforum_row['f_redirection'])) { $subforum_row = $GLOBALS['FORUM_DB']->query_select('f_forums', array('*'), array('id' => intval($subforum_row['f_redirection'])), '', 1); $subforum_row = $subforum_row[0]; } if ($subforum_row['f_redirection'] == '' || is_numeric($subforum_row['f_redirection'])) { $subforum['num_topics'] = $subforum_row['f_cache_num_topics']; $subforum['num_posts'] = $subforum_row['f_cache_num_posts']; $subforum['has_new'] = false; if (get_member() != $GLOBALS['OCF_DRIVER']->get_guest_id()) { $subforums_recurse = ocf_get_all_subordinate_forums($subforum['id'], NULL, $tree[$subforum['id']]['children']); foreach ($subforums_recurse as $subforum_potential) { if (array_key_exists($subforum_potential, $unread_forums)) { $subforum['has_new'] = true; } } } if (is_null($subforum_row['f_cache_last_forum_id']) || has_category_access($member_id, 'forums', strval($subforum_row['f_cache_last_forum_id']))) { $subforum['last_topic_id'] = $subforum_row['f_cache_last_topic_id']; $subforum['last_title'] = $subforum_row['f_cache_last_title']; $subforum['last_time'] = $subforum_row['f_cache_last_time']; $subforum['last_username'] = $subforum_row['f_cache_last_username']; $subforum['last_member_id'] = $subforum_row['f_cache_last_member_id']; $subforum['last_forum_id'] = $subforum_row['f_cache_last_forum_id']; } else { $subforum['protected_last_post'] = true; } // Subsubforums $subforum['children'] = array(); foreach ($subforum_rows as $tmp_key_2 => $subforum_row2) { if ($subforum_row2['f_parent_forum'] == $subforum_row['id'] && has_category_access($member_id, 'forums', strval($subforum_row2['id']))) { $subforum['children'][$subforum_row2['f_name'] . '__' . strval($subforum_row2['id'])] = array('id' => $subforum_row2['id'], 'name' => $subforum_row2['f_name'], 'redirection' => $subforum_row2['f_redirection']); } } global $M_SORT_KEY; $M_SORT_KEY = 'name'; uasort($subforum['children'], 'multi_sort'); } $categories[$category_id]['subforums'][] = $subforum; } } // Find topics $extra = ''; if (!has_specific_permission(get_member(), 'see_unvalidated') && !ocf_may_moderate_forum($forum_id, $member_id)) { $extra = 't_validated=1 AND '; } if (is_null($forum_info[0]['f_parent_forum'])) { $where = $extra . ' (t_forum_id=' . strval((int) $forum_id) . ')'; } else { $extra2 = ''; $parent_or_list = ocf_get_forum_parent_or_list($forum_id, $forum_info[0]['f_parent_forum']); if ($parent_or_list != '') { $extra2 = 'AND (' . $parent_or_list . ')'; } $where = $extra . ' (t_forum_id=' . strval((int) $forum_id) . ' OR (t_cascading=1 ' . $extra2 . '))'; } $order = get_param('order', $forum_info[0]['f_order']); $order2 = 't_cache_last_time DESC'; if ($order == 'first_post') { $order2 = 't_cache_first_time DESC'; } elseif ($order == 'title') { $order2 = 't_cache_first_title ASC'; } if (get_value('disable_sunk') !== '1') { $order2 = 't_sunk ASC,' . $order2; } if (is_guest()) { $query = 'SELECT ttop.*,t.text_parsed AS _trans_post,NULL AS l_time FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics ttop LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND ttop.t_cache_first_post=t.id WHERE ' . $where . ' ORDER BY t_cascading DESC,t_pinned DESC,' . $order2; } else { $query = 'SELECT ttop.*,t.text_parsed AS _trans_post,l_time FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics ttop LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_read_logs l ON (ttop.id=l.l_topic_id AND l.l_member_id=' . strval((int) get_member()) . ') LEFT JOIN ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'translate t ON ' . db_string_equal_to('language', user_lang()) . ' AND ttop.t_cache_first_post=t.id WHERE ' . $where . ' ORDER BY t_cascading DESC,t_pinned DESC,' . $order2; } $topic_rows = $GLOBALS['FORUM_DB']->query($query, $max, $start); if ($start == 0 && count($topic_rows) < $max) { $max_rows = $max; } else { $max_rows = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT COUNT(*) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_topics WHERE ' . $where); } $topics = array(); $hot_topic_definition = intval(get_option('hot_topic_definition')); $or_list = ''; foreach ($topic_rows as $topic_row) { if ($or_list != '') { $or_list .= ' OR '; } $or_list .= 'p_topic_id=' . strval((int) $topic_row['id']); } if ($or_list != '' && !is_guest()) { $involved = $GLOBALS['FORUM_DB']->query('SELECT DISTINCT p_topic_id FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_posts WHERE (' . $or_list . ') AND p_poster=' . strval((int) get_member())); $involved = collapse_1d_complexity('p_topic_id', $involved); } else { $involved = array(); } foreach ($topic_rows as $topic_row) { $topics[] = ocf_get_topic_array($topic_row, $member_id, $hot_topic_definition, in_array($topic_row['id'], $involved)); } $description = get_translated_tempcode($forum_info[0]['f_description'], $GLOBALS['FORUM_DB']); $description_text = get_translated_text($forum_info[0]['f_description'], $GLOBALS['FORUM_DB']); $out = array('name' => $forum_info[0]['f_name'], 'description' => $description, 'categories' => $categories, 'topics' => $topics, 'max_rows' => $max_rows, 'order' => $order, 'parent_forum' => $forum_info[0]['f_parent_forum']); $GLOBALS['META_DATA'] += array('created' => '', 'creator' => '', 'publisher' => '', 'modified' => '', 'type' => 'Forum', 'title' => $forum_info[0]['f_name'], 'identifier' => '_SEARCH:forumview:misc:' . strval($forum_id), 'description' => $description_text, 'image' => find_theme_image('bigicons/forums')); // Is there a question/answer situation? $question = get_translated_tempcode($forum_info[0]['f_intro_question'], $GLOBALS['FORUM_DB']); if (!$question->is_empty()) { $is_guest = $member_id == $GLOBALS['OCF_DRIVER']->get_guest_id(); $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forum_intro_ip', 'i_ip', array('i_forum_id' => $forum_id, 'i_ip' => get_ip_address(3))); if (is_null($test) && !$is_guest) { $test = $GLOBALS['FORUM_DB']->query_value_null_ok('f_forum_intro_member', 'i_member_id', array('i_forum_id' => $forum_id, 'i_member_id' => $member_id)); } if (is_null($test)) { $out['question'] = $question; $out['answer'] = $forum_info[0]['f_intro_answer']; } } if (ocf_may_post_topic($forum_id, $member_id)) { $out['may_post_topic'] = 1; } if (ocf_may_moderate_forum($forum_id, $member_id)) { $out['may_change_max'] = 1; $out['may_move_topics'] = 1; if (has_specific_permission(get_member(), 'multi_delete_topics')) { $out['may_delete_topics'] = 1; } // Only super admins can casually delete topics - other staff are expected to trash them. At least deleted posts or trashed topics can be restored! } return $out; }
/** * Gets a list of subordinate forums of a certain forum. * * @param AUTO_LINK The ID of the forum we are finding subordinate forums of. * @param ?string The field name to use in the OR list (NULL: do not make an OR list, return an array). * @param ?array The forum tree structure (NULL: unknown, it will be found using ocf_organise_into_tree). * @param boolean Whether to ignore permissions in this. * @return mixed The list (is either a true list, or an OR list). */ function ocf_get_all_subordinate_forums($forum_id, $create_or_list = NULL, $tree = NULL, $ignore_permissions = false) { if (is_null($forum_id)) { if (is_null($create_or_list)) { return array($forum_id); } else { return '(' . $create_or_list . ' IS NULL)'; } } if (is_null($tree)) { global $ALL_FORUMS_STRUCT; if (is_null($ALL_FORUMS_STRUCT)) { $_max_forum_detail = get_value('max_forum_detail'); $max_forum_detail = is_null($_max_forum_detail) ? 100 : intval($_max_forum_detail); $huge_forums = $GLOBALS['FORUM_DB']->query_value('f_forums', 'COUNT(*)') > $max_forum_detail; if ($huge_forums) { $_max_forum_inspect = get_value('max_forum_inspect'); $max_forum_inspect = is_null($_max_forum_inspect) ? 300 : intval($_max_forum_inspect); $all_descendant = $GLOBALS['FORUM_DB']->query('SELECT id,f_parent_forum FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_forums WHERE id=' . strval($forum_id) . ' OR f_parent_forum=' . strval($forum_id), $max_forum_inspect); if (count($all_descendant) == $max_forum_inspect) { if (is_null($create_or_list)) { return array($forum_id); } else { return '(' . $create_or_list . '=' . strval($forum_id) . ')'; } } $tree = ocf_organise_into_tree($all_descendant, $forum_id); } else { $ALL_FORUMS_STRUCT = $GLOBALS['FORUM_DB']->query_select('f_forums'); $all_forum_struct_copy = $ALL_FORUMS_STRUCT; $tree = ocf_organise_into_tree($all_forum_struct_copy, $forum_id); } } else { $all_forum_struct_copy = $ALL_FORUMS_STRUCT; $tree = ocf_organise_into_tree($all_forum_struct_copy, $forum_id); } } // $subordinates=$direct_subordinates; $subordinates = array(); foreach ($tree as $subordinate) { $subordinates = $subordinates + ocf_get_all_subordinate_forums($subordinate['id'], NULL, $subordinate['children'], $ignore_permissions); } load_up_all_module_category_permissions(get_member(), 'forums'); if ($ignore_permissions || has_category_access(get_member(), 'forums', strval($forum_id))) { $subordinates[$forum_id] = $forum_id; } if (!is_null($create_or_list)) { $or_list = ''; foreach ($subordinates as $subordinate) { if ($or_list != '') { $or_list .= ' OR '; } $or_list .= $create_or_list . '=' . strval($subordinate); } if ($or_list == '') { return $or_list; } return '(' . $or_list . ')'; } return $subordinates; }