diff --git a/phpBB/includes/forums_display.php b/phpBB/includes/forums_display.php deleted file mode 100644 index ced439881c..0000000000 --- a/phpBB/includes/forums_display.php +++ /dev/null @@ -1,180 +0,0 @@ - $left_id AND left_id < $right_id" : ''; - $sql = 'SELECT * FROM ' . FORUMS_TABLE . $where_sql . ' ORDER BY left_id ASC'; - $result = $db->sql_query($sql); - - $cat_header = - while ($row = $db->sql_fetchrow($result)) - { - - } - -} - -foreach ($forum_rows as $row) -{ - extract($row); - if (!$auth->acl_get('f_list', $forum_id)) - { - continue; - } - - if ($parent_id == $root_id) - { - if ($forum_status == ITEM_CATEGORY) - { - $stored_cat = $row; - continue; - } - else - { - unset($stored_cat); - } - } - elseif (!empty($stored_cat)) - { - $template->assign_block_vars('forumrow', array( - 'S_IS_CAT' => TRUE, - 'CAT_ID' => $stored_cat['forum_id'], - 'CAT_NAME' => $stored_cat['forum_name'], - 'U_VIEWCAT' => 'index.' . $phpEx . $SID . '&c=' . $stored_cat['forum_id'] - )); - unset($stored_cat); - } - - switch ($forum_status) - { - case ITEM_CATEGORY: - $folder_image = 'sub_forum'; - $folder_alt = 'Category'; - break; - - case ITEM_LOCKED: - $folder_image = 'forum_locked'; - $folder_alt = 'Forum_locked'; - break; - - default: - $unread_topics = false; - if ($user->data['user_id'] && $forum_last_post_time > $user->data['user_lastvisit']) - { - $unread_topics = true; - } - - $folder_image = ($unread_topics) ? 'forum_new' : 'forum'; - $folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts'; - } - - if ($forum_last_post_id) - { - $last_post = $user->format_date($forum_last_post_time) . '
'; - - $last_post .= ($forum_last_poster_id == ANONYMOUS) ? (($forum_last_poster_name != '') ? $forum_last_poster_name . ' ' : $user->lang['Guest'] . ' ') : '' . $forum_last_poster_name . ' '; - - $last_post .= '' . $user->img('goto_post_latest', 'View_latest_post') . ''; - } - else - { - $last_post = $user->lang['No_Posts']; - } - - if (!empty($forum_moderators[$forum_id])) - { - $l_moderator = (count($forum_moderators[$forum_id]) == 1) ? $user->lang['Moderator'] . ': ' : $user->lang['Moderators'] . ': ' ; - $moderators_list = implode(', ', $forum_moderators[$forum_id]); - } - else - { - $l_moderator = ' '; - $moderators_list = ' '; - } - - if (isset($subforums[$forum_id])) - { - foreach ($subforums[$forum_id] as $row) - { - $alist[$row['forum_id']] = $row['forum_name']; - } - asort($alist); - - $links = array(); - foreach ($alist as $subforum_id => $subforum_name) - { - $links[] = '' . htmlspecialchars($subforum_name) . ''; - } - $subforums_list = implode(', ', $links); - - $l_subforums = (count($subforums[$forum_id]) == 1) ? $user->lang['Subforum'] . ': ' : $user->lang['Subforums'] . ': '; - } - else - { - $subforums_list = ''; - $l_subforums = ''; - } - - switch ($forum_status) - { - case ITEM_CATEGORY: - $forum_link = 'index.' . $phpEx . $SID . '&c=' . $forum_id; - $forum_type_switch = 'S_IS_SUBCAT'; - break; - - default: - $forum_link = 'viewforum.' . $phpEx . $SID . '&f=' . $forum_id; - if ($parent_id == $root_id) - { - $forum_type_switch = 'S_IS_ROOTFORUM'; - } - else - { - $forum_type_switch = 'S_IS_FORUM'; - } - } - - $template->assign_block_vars('forumrow', array( - $forum_type_switch => TRUE, - - 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), - 'FORUM_NAME' => $forum_name, - 'FORUM_DESC' => $forum_desc, - - 'POSTS' => $forum_posts, - 'TOPICS' => $forum_topics, - 'LAST_POST' => $last_post, - 'MODERATORS' => $moderators_list, - 'SUBFORUMS' => $subforums_list, - - 'FORUM_IMG' => $forum_image, - - 'L_SUBFORUM' => $l_subforums, - 'L_MODERATOR' => $l_moderator, - 'L_FORUM_FOLDER_ALT'=> $folder_alt, - - 'U_VIEWFORUM' => $forum_link - )); -} -?> \ No newline at end of file diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php new file mode 100644 index 0000000000..9a797c0e1d --- /dev/null +++ b/phpBB/includes/functions_display.php @@ -0,0 +1,258 @@ + ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'] : ''; + + $sql = 'SELECT * FROM ' . FORUMS_TABLE . $where_sql . ' ORDER BY left_id ASC'; + $result = $db->sql_query($sql); + + $branch_root_id = $total_posts = 0; + $forum_rows = $subforums = $alist = $forum_ids = $forum_moderators = array(); + + while ($row = $db->sql_fetchrow($result)) + { + if ($row['post_count_inc']) + { + $total_posts += $row['forum_posts']; + } + if (isset($right_id)) + { + if ($row['left_id'] < $right_id) + { + continue; + } + unset($right_id); + } + if (!$row['forum_postable'] && ($row['left_id'] + 1 == $row['right_id'])) + { + // Non-postable forum with no subforums: don't display + continue; + } + + if (!$auth->acl_get('f_list', $row['forum_id'])) + { + // if the user does not have permissions to list this forum, skip everything until next branch + + $right_id = $row['right_id']; + continue; + } + + if ($row['parent_id'] == $root_data['forum_id']) + { + // Direct child + $forum_rows[] = $row; + $parent_id = $row['forum_id']; + + if (!$row['forum_postable']) + { + $branch_root_id = $row['forum_id']; + } + else + { + $forum_ids[] = $row['forum_id']; + } + } + elseif ($row['parent_id'] == $branch_root_id) + { + // Forum directly under a category + $forum_rows[] = $row; + $parent_id = $row['forum_id']; + + if ($row['forum_postable']) + { + $forum_ids[] = $row['forum_id']; + } + } + elseif ($row['forum_postable']) + { + if ($row['display_on_index']) + { + // Subforum + $subforums[$parent_id][] = $row; + } + } + else + { + // what the heck is happening here?? + +// echo '
';print_r($row);echo'
'; + } + } + $db->sql_freeresult(); + + if ($display_moderators) + { + $forum_moderators = get_moderators($forum_moderators, $forum_ids); + } + + $root_id = $root_data['forum_id']; + foreach ($forum_rows as $row) + { + if ($row['parent_id'] == $root_id) + { + if (!$row['forum_postable']) + { + $hold = $row; + continue; + } + else + { + unset($hold); + } + } + elseif (!empty($hold)) + { + $template->assign_block_vars('forumrow', array( + 'S_IS_CAT' => TRUE, + 'FORUM_ID' => $hold['forum_id'], + 'FORUM_NAME' => $hold['forum_name'], + 'FORUM_DESC' => $hold['forum_desc'], + 'U_VIEWFORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $hold['forum_id'] + )); + unset($hold); + } + + $forum_id = $row['forum_id']; + $unread_topics = ($user->data['user_id'] && $row['forum_last_post_time'] > $user->data['user_lastvisit']) ? TRUE : FALSE; + + $folder_image = ($unread_topics) ? 'forum_new' : 'forum'; + $folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts'; + + if ($row['left_id'] + 1 < $row['right_id']) + { + $folder_image = ($unread_topics) ? 'sub_forum_new' : 'sub_forum'; + $folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts'; + } + elseif ($row['forum_status'] == ITEM_LOCKED) + { + $folder_image = 'forum_locked'; + $folder_alt = 'Forum_locked'; + } + else + { + $folder_image = ($unread_topics) ? 'forum_new' : 'forum'; + $folder_alt = ($unread_topics) ? 'New_posts' : 'No_new_posts'; + } + + if ($row['forum_last_post_id']) + { + $last_post = $user->format_date($row['forum_last_post_time']) . '
'; + + $last_post .= ($row['forum_last_poster_id'] == ANONYMOUS) ? (($row['forum_last_poster_name'] != '') ? $row['forum_last_poster_name'] . ' ' : $user->lang['Guest'] . ' ') : '' . $row['forum_last_poster_name'] . ' '; + + $last_post .= '' . $user->img('goto_post_latest', 'View_latest_post') . ''; + } + else + { + $last_post = $user->lang['No_Posts']; + } + + if (!empty($forum_moderators[$forum_id])) + { + $l_moderator = (count($forum_moderators[$forum_id]) == 1) ? $user->lang['Moderator'] . ': ' : $user->lang['Moderators'] . ': ' ; + $moderators_list = implode(', ', $forum_moderators[$forum_id]); + } + else + { + $l_moderator = ' '; + $moderators_list = ' '; + } + + if (isset($subforums[$forum_id])) + { + foreach ($subforums[$forum_id] as $subrow) + { + $alist[$subrow['forum_id']] = $subrow['forum_name']; + } + asort($alist); + + $links = array(); + foreach ($alist as $subforum_id => $subforum_name) + { + $links[] = '' . htmlspecialchars($subforum_name) . ''; + } + $subforums_list = implode(', ', $links); + + $l_subforums = (count($subforums[$forum_id]) == 1) ? $user->lang['Subforum'] . ': ' : $user->lang['Subforums'] . ': '; + } + else + { + $subforums_list = ''; + $l_subforums = ''; + } + + if ($display_moderators) + { + $l_moderator = $moderators_list = ''; + if (!empty($forum_moderators[$forum_id])) + { + $l_moderator = (count($forum_moderators[$forum_id]) == 1) ? $user->lang['Moderator'] : $user->lang['Moderators']; + $moderators_list = implode(', ', $forum_moderators); + } + } + else + { + $moderators_list = '' . $user->lang['View_moderators'] . ''; + } + + $template->assign_block_vars('forumrow', array( + 'S_IS_CAT' => FALSE, + + 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), + 'FORUM_NAME' => $row['forum_name'], + 'FORUM_DESC' => $row['forum_desc'], + + 'POSTS' => $row['forum_posts'], + 'TOPICS' => $row['forum_topics'], + 'LAST_POST' => $last_post, + 'MODERATORS' => $moderators_list, + 'SUBFORUMS' => $subforums_list, + + 'FORUM_IMG' => $forum_image, + + 'L_SUBFORUM' => $l_subforums, + 'L_MODERATOR' => $l_moderator, + 'L_FORUM_FOLDER_ALT'=> $folder_alt, + + 'U_VIEWFORUM' => 'viewforum.' . $phpEx . $SID . '&f=' . $row['forum_id'] + )); + } + + $template->assign_vars(array( + 'L_FORUM' => $user->lang['Forum'], + 'L_TOPICS' => $user->lang['Topics'], + 'L_REPLIES' => $user->lang['Replies'], + 'L_VIEWS' => $user->lang['Views'], + 'L_POSTS' => $user->lang['Posts'], + 'L_LASTPOST' => $user->lang['Last_Post'], + 'L_MODERATORS' => $user->lang['Moderators'], + 'L_NO_NEW_POSTS' => $user->lang['No_new_posts'], + 'L_NEW_POSTS' => $user->lang['New_posts'], + 'L_NO_NEW_POSTS_LOCKED' => $user->lang['No_new_posts_locked'], + 'L_NEW_POSTS_LOCKED' => $user->lang['New_posts_locked'] + )); +} +?> \ No newline at end of file