コード例 #1
0
/**
* Display Forums
*/
function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
{
    global $db, $auth, $user, $template;
    global $phpbb_root_path, $phpEx, $config;
    $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
    $parent_id = $visible_forums = 0;
    $sql_from = '';
    // Mark forums read?
    $mark_read = request_var('mark', '');
    if ($mark_read == 'all') {
        $mark_read = '';
    }
    if (!$root_data) {
        if ($mark_read == 'forums') {
            $mark_read = 'all';
        }
        $root_data = array('forum_id' => 0);
        $sql_where = '';
    } else {
        $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
    }
    // Display list of active topics for this category?
    $show_active = isset($root_data['forum_flags']) && $root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS ? true : false;
    $sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_TABLE => 'f'), 'LEFT_JOIN' => array());
    if ($config['load_db_lastread'] && $user->data['is_registered']) {
        $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id');
        $sql_array['SELECT'] .= ', ft.mark_time';
    } else {
        if ($config['load_anon_lastread'] || $user->data['is_registered']) {
            $tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_track']) ? STRIP ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track'] : '';
            $tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
            if (!$user->data['is_registered']) {
                $user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
            }
        }
    }
    if ($show_active) {
        $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_ACCESS_TABLE => 'fa'), 'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'");
        $sql_array['SELECT'] .= ', fa.user_id';
    }
    $sql = $db->sql_build_query('SELECT', array('SELECT' => $sql_array['SELECT'], 'FROM' => $sql_array['FROM'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'WHERE' => $sql_where, 'ORDER_BY' => 'f.left_id'));
    $result = $db->sql_query($sql);
    $forum_tracking_info = array();
    $branch_root_id = $root_data['forum_id'];
    // Check for unread global announcements (index page only)
    $ga_unread = false;
    if ($root_data['forum_id'] == 0) {
        $unread_ga_list = get_unread_topics($user->data['user_id'], 'AND t.forum_id = 0', '', 1);
        if (!empty($unread_ga_list)) {
            $ga_unread = true;
        }
    }
    while ($row = $db->sql_fetchrow($result)) {
        $forum_id = $row['forum_id'];
        // Mark forums read?
        if ($mark_read == 'forums' || $mark_read == 'all') {
            if ($auth->acl_get('f_list', $forum_id)) {
                $forum_ids[] = $forum_id;
                continue;
            }
        }
        // Category with no members
        if ($row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id']) {
            continue;
        }
        // Skip branch
        if (isset($right_id)) {
            if ($row['left_id'] < $right_id) {
                continue;
            }
            unset($right_id);
        }
        if (!$auth->acl_get('f_list', $forum_id)) {
            // if the user does not have permissions to list this forum, skip everything until next branch
            $right_id = $row['right_id'];
            continue;
        }
        $forum_ids[] = $forum_id;
        if ($config['load_db_lastread'] && $user->data['is_registered']) {
            $forum_tracking_info[$forum_id] = !empty($row['mark_time']) ? $row['mark_time'] : $user->data['user_lastmark'];
        } else {
            if ($config['load_anon_lastread'] || $user->data['is_registered']) {
                if (!$user->data['is_registered']) {
                    $user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
                }
                $forum_tracking_info[$forum_id] = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
            }
        }
        // Count the difference of real to public topics, so we can display an information to moderators
        $row['forum_id_unapproved_topics'] = $auth->acl_get('m_approve', $forum_id) && $row['forum_topics_real'] != $row['forum_topics'] ? $forum_id : 0;
        $row['forum_topics'] = $auth->acl_get('m_approve', $forum_id) ? $row['forum_topics_real'] : $row['forum_topics'];
        // Display active topics from this forum?
        if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && $row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) {
            if (!isset($active_forum_ary['forum_topics'])) {
                $active_forum_ary['forum_topics'] = 0;
            }
            if (!isset($active_forum_ary['forum_posts'])) {
                $active_forum_ary['forum_posts'] = 0;
            }
            $active_forum_ary['forum_id'][] = $forum_id;
            $active_forum_ary['enable_icons'][] = $row['enable_icons'];
            $active_forum_ary['forum_topics'] += $row['forum_topics'];
            $active_forum_ary['forum_posts'] += $row['forum_posts'];
            // If this is a passworded forum we do not show active topics from it if the user is not authorised to view it...
            if ($row['forum_password'] && $row['user_id'] != $user->data['user_id']) {
                $active_forum_ary['exclude_forum_id'][] = $forum_id;
            }
        }
        //
        if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id) {
            if ($row['forum_type'] != FORUM_CAT) {
                $forum_ids_moderator[] = (int) $forum_id;
            }
            // Direct child of current branch
            $parent_id = $forum_id;
            $forum_rows[$forum_id] = $row;
            if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id']) {
                $branch_root_id = $forum_id;
            }
            $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
            $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
        } else {
            if ($row['forum_type'] != FORUM_CAT) {
                $subforums[$parent_id][$forum_id]['display'] = $row['display_on_index'] ? true : false;
                $subforums[$parent_id][$forum_id]['name'] = $row['forum_name'];
                $subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
                $subforums[$parent_id][$forum_id]['children'] = array();
                if (isset($subforums[$parent_id][$row['parent_id']]) && !$row['display_on_index']) {
                    $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id;
                }
                if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics']) {
                    $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id;
                }
                $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics'];
                // Do not list redirects in LINK Forums as Posts.
                if ($row['forum_type'] != FORUM_LINK) {
                    $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts'];
                }
                if ($row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time']) {
                    $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id'];
                    $forum_rows[$parent_id]['forum_last_post_subject'] = $row['forum_last_post_subject'];
                    $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time'];
                    $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id'];
                    $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name'];
                    $forum_rows[$parent_id]['forum_last_poster_colour'] = $row['forum_last_poster_colour'];
                    $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
                }
            }
        }
    }
    $db->sql_freeresult($result);
    // Handle marking posts
    if ($mark_read == 'forums' || $mark_read == 'all') {
        $redirect = build_url(array('mark', 'hash'));
        $token = request_var('hash', '');
        if (check_link_hash($token, 'global')) {
            if ($mark_read == 'all') {
                markread('all');
                $message = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>');
            } else {
                // Add 0 to forums array to mark global announcements correctly
                $forum_ids[] = 0;
                markread('topics', $forum_ids);
                $message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>');
            }
            meta_refresh(3, $redirect);
            trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message);
        } else {
            $message = sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
            meta_refresh(3, $redirect);
            trigger_error($message);
        }
    }
    // Grab moderators ... if necessary
    if ($display_moderators) {
        if ($return_moderators) {
            $forum_ids_moderator[] = $root_data['forum_id'];
        }
        get_moderators($forum_moderators, $forum_ids_moderator);
    }
    // Used to tell whatever we have to create a dummy category or not.
    $last_catless = true;
    foreach ($forum_rows as $row) {
        // Empty category
        if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT) {
            $template->assign_block_vars('forumrow', array('S_IS_CAT' => true, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'FORUM_FOLDER_IMG' => '', 'FORUM_FOLDER_IMG_SRC' => '', 'FORUM_IMAGE' => $row['forum_image'] ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['FORUM_CAT'] . '" />' : '', 'FORUM_IMAGE_SRC' => $row['forum_image'] ? $phpbb_root_path . $row['forum_image'] : '', 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id'])));
            continue;
        }
        $visible_forums++;
        $forum_id = $row['forum_id'];
        $forum_unread = isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id] ? true : false;
        // Mark the first visible forum on index as unread if there's any unread global announcement
        if ($ga_unread && !empty($forum_ids_moderator) && $forum_id == $forum_ids_moderator[0]) {
            $forum_unread = true;
        }
        $folder_image = $folder_alt = $l_subforums = '';
        $subforums_list = array();
        // Generate list of subforums if we need to
        if (isset($subforums[$forum_id])) {
            foreach ($subforums[$forum_id] as $subforum_id => $subforum_row) {
                $subforum_unread = isset($forum_tracking_info[$subforum_id]) && $subforum_row['orig_forum_last_post_time'] > $forum_tracking_info[$subforum_id] ? true : false;
                if (!$subforum_unread && !empty($subforum_row['children'])) {
                    foreach ($subforum_row['children'] as $child_id) {
                        if (isset($forum_tracking_info[$child_id]) && $subforums[$forum_id][$child_id]['orig_forum_last_post_time'] > $forum_tracking_info[$child_id]) {
                            // Once we found an unread child forum, we can drop out of this loop
                            $subforum_unread = true;
                            break;
                        }
                    }
                }
                if ($subforum_row['display'] && $subforum_row['name']) {
                    $subforums_list[] = array('link' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $subforum_id), 'name' => $subforum_row['name'], 'unread' => $subforum_unread);
                } else {
                    unset($subforums[$forum_id][$subforum_id]);
                }
                // If one subforum is unread the forum gets unread too...
                if ($subforum_unread) {
                    $forum_unread = true;
                }
            }
            $l_subforums = sizeof($subforums[$forum_id]) == 1 ? $user->lang['SUBFORUM'] . ': ' : $user->lang['SUBFORUMS'] . ': ';
            $folder_image = $forum_unread ? 'forum_unread_subforum' : 'forum_read_subforum';
        } else {
            switch ($row['forum_type']) {
                case FORUM_POST:
                    $folder_image = $forum_unread ? 'forum_unread' : 'forum_read';
                    break;
                case FORUM_LINK:
                    $folder_image = 'forum_link';
                    break;
            }
        }
        // Which folder should we display?
        if ($row['forum_status'] == ITEM_LOCKED) {
            $folder_image = $forum_unread ? 'forum_unread_locked' : 'forum_read_locked';
            $folder_alt = 'FORUM_LOCKED';
        } else {
            $folder_alt = $forum_unread ? 'NEW_POSTS' : 'NO_NEW_POSTS';
        }
        // Create last post link information, if appropriate
        if ($row['forum_last_post_id']) {
            $last_post_subject = $row['forum_last_post_subject'];
            $last_post_time = $user->format_date($row['forum_last_post_time']);
            $last_post_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id_last_post'] . '&amp;p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];
        } else {
            $last_post_subject = $last_post_time = $last_post_url = '';
        }
        // Output moderator listing ... if applicable
        $l_moderator = $moderators_list = '';
        if ($display_moderators && !empty($forum_moderators[$forum_id])) {
            $l_moderator = sizeof($forum_moderators[$forum_id]) == 1 ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
            $moderators_list = implode(', ', $forum_moderators[$forum_id]);
        }
        $l_post_click_count = $row['forum_type'] == FORUM_LINK ? 'CLICKS' : 'POSTS';
        $post_click_count = $row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK ? $row['forum_posts'] : '';
        $s_subforums_list = array();
        foreach ($subforums_list as $subforum) {
            $s_subforums_list[] = '<a href="' . $subforum['link'] . '" class="subforum ' . ($subforum['unread'] ? 'unread' : 'read') . '" title="' . ($subforum['unread'] ? $user->lang['NEW_POSTS'] : $user->lang['NO_NEW_POSTS']) . '">' . $subforum['name'] . '</a>';
        }
        $s_subforums_list = (string) implode(', ', $s_subforums_list);
        $catless = $row['parent_id'] == $root_data['forum_id'] ? true : false;
        if ($row['forum_type'] != FORUM_LINK) {
            $u_viewforum = append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']);
        } else {
            // If the forum is a link and we count redirects we need to visit it
            // If the forum is having a password or no read access we do not expose the link, but instead handle it in viewforum
            if ($row['forum_flags'] & FORUM_FLAG_LINK_TRACK || $row['forum_password'] || !$auth->acl_get('f_read', $forum_id)) {
                $u_viewforum = append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']);
            } else {
                $u_viewforum = $row['forum_link'];
            }
        }
        $template->assign_block_vars('forumrow', array('S_IS_CAT' => false, 'S_NO_CAT' => $catless && !$last_catless, 'S_IS_LINK' => $row['forum_type'] == FORUM_LINK ? true : false, 'S_UNREAD_FORUM' => $forum_unread, 'S_LOCKED_FORUM' => $row['forum_status'] == ITEM_LOCKED ? true : false, 'S_LIST_SUBFORUMS' => $row['display_subforum_list'] ? true : false, 'S_SUBFORUMS' => sizeof($subforums_list) ? true : false, 'S_FEED_ENABLED' => $config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options']) ? true : false, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'TOPICS' => $row['forum_topics'], $l_post_click_count => $post_click_count, 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 'FORUM_FOLDER_IMG_SRC' => $user->img($folder_image, $folder_alt, false, '', 'src'), 'FORUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '', 'FORUM_IMAGE' => $row['forum_image'] ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '', 'FORUM_IMAGE_SRC' => $row['forum_image'] ? $phpbb_root_path . $row['forum_image'] : '', 'LAST_POST_SUBJECT' => censor_text($last_post_subject), 'LAST_POST_TIME' => $last_post_time, 'LAST_POSTER' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'LAST_POSTER_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'LAST_POSTER_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'MODERATORS' => $moderators_list, 'SUBFORUMS' => $s_subforums_list, 'L_SUBFORUM_STR' => $l_subforums, 'L_FORUM_FOLDER_ALT' => $folder_alt, 'L_MODERATOR_STR' => $l_moderator, 'U_UNAPPROVED_TOPICS' => $row['forum_id_unapproved_topics'] ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=unapproved_topics&amp;f=' . $row['forum_id_unapproved_topics']) : '', 'U_VIEWFORUM' => $u_viewforum, 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'U_LAST_POST' => $last_post_url));
        // Assign subforums loop for style authors
        foreach ($subforums_list as $subforum) {
            $template->assign_block_vars('forumrow.subforum', array('U_SUBFORUM' => $subforum['link'], 'SUBFORUM_NAME' => $subforum['name'], 'S_UNREAD' => $subforum['unread']));
        }
        $last_catless = $catless;
    }
    $template->assign_vars(array('U_MARK_FORUMS' => $user->data['is_registered'] || $config['load_anon_lastread'] ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'hash=' . generate_link_hash('global') . '&amp;f=' . $root_data['forum_id'] . '&amp;mark=forums') : '', 'S_HAS_SUBFORUM' => $visible_forums ? true : false, 'L_SUBFORUM' => $visible_forums == 1 ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED')));
    if ($return_moderators) {
        return array($active_forum_ary, $forum_moderators);
    }
    return array($active_forum_ary, array());
}
コード例 #2
0
ファイル: viewforum.php プロジェクト: ZerGabriel/phpbb
    return;
}
// Build navigation links
generate_forum_nav($forum_data);
// Forum Rules
if ($auth->acl_get('f_read', $forum_id)) {
    generate_forum_rules($forum_data);
}
// Do we have subforums?
$active_forum_ary = $moderators = array();
if ($forum_data['left_id'] != $forum_data['right_id'] - 1) {
    list($active_forum_ary, $moderators) = display_forums($forum_data, $config['load_moderators'], $config['load_moderators']);
} else {
    $template->assign_var('S_HAS_SUBFORUM', false);
    if ($config['load_moderators']) {
        get_moderators($moderators, $forum_id);
    }
}
/* @var $phpbb_content_visibility \phpbb\content_visibility */
$phpbb_content_visibility = $phpbb_container->get('content.visibility');
// Dump out the page header and load viewforum template
$topics_count = $phpbb_content_visibility->get_count('forum_topics', $forum_data, $forum_id);
$start = $pagination->validate_start($start, $config['topics_per_page'], $topics_count);
page_header($forum_data['forum_name'] . ($start ? ' - ' . $user->lang('PAGE_TITLE_NUMBER', $pagination->get_on_page($config['topics_per_page'], $start)) : ''), true, $forum_id);
$template->set_filenames(array('body' => 'viewforum_body.html'));
make_jumpbox(append_sid("{$phpbb_root_path}viewforum.{$phpEx}"), $forum_id);
$template->assign_vars(array('U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", "f={$forum_id}" . ($start == 0 ? '' : "&amp;start={$start}"))));
// Not postable forum or showing active topics?
if (!($forum_data['forum_type'] == FORUM_POST || $forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS && $forum_data['forum_type'] == FORUM_CAT)) {
    page_footer();
}
コード例 #3
0
function display_forums($root_data = '', $display_moderators = true)
{
    global $config, $_CLASS, $_CORE_CONFIG;
    // Get posted/get info
    $mark_read = request_var('mark', '');
    $forum_id_ary = $active_forum_ary = $forum_rows = $subforums = $forum_moderators = $mark_forums = array();
    $visible_forums = 0;
    if (!$root_data) {
        $root_data = array('forum_id' => 0);
        $sql_where = '';
    } else {
        $sql_where = 'AND left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
    }
    // Display list of active topics for this category?
    $show_active = isset($root_data['forum_flags']) && $root_data['forum_flags'] & 16 ? true : false;
    if ($_CLASS['core_user']->is_user && $config['load_db_lastread']) {
        $sql_from = ' LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $_CLASS['core_user']->data['user_id'] . ' 
				AND ft.forum_id = f.forum_id AND ft.topic_id = 0)';
        $lastread_select = ', ft.mark_time ';
    } else {
        $sql_from = $lastread_select = $sql_lastread = '';
        $tracking_topics = @unserialize(get_variable($_CORE_CONFIG['server']['cookie_name'] . '_track', 'COOKIE'));
    }
    $sql = "SELECT f.* {$lastread_select} \n\t\tFROM " . FORUMS_FORUMS_TABLE . " f {$sql_from}\n\t\tWHERE forum_status <> " . ITEM_DELETING . "\n\t\t{$sql_where}\n\t\tORDER BY f.left_id";
    $result = $_CLASS['core_db']->query($sql);
    $branch_root_id = $root_data['forum_id'];
    $forum_ids = array($root_data['forum_id']);
    while ($row = $_CLASS['core_db']->fetch_row_assoc($result)) {
        if ($mark_read == 'forums' && $_CLASS['core_user']->is_user) {
            if ($_CLASS['auth']->acl_get('f_list', $row['forum_id'])) {
                $forum_id_ary[] = $row['forum_id'];
            }
            continue;
        }
        if (isset($right_id)) {
            if ($row['left_id'] < $right_id) {
                continue;
            }
            unset($right_id);
        }
        if ($row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id']) {
            // Non-postable forum with no subforums: don't display
            continue;
        }
        $forum_id = $row['forum_id'];
        if (!$_CLASS['auth']->acl_get('f_list', $forum_id)) {
            // if the user does not have permissions to list this forum, skip everything until next branch
            $right_id = $row['right_id'];
            continue;
        }
        // Display active topics from this forum?
        if ($show_active && $row['forum_type'] == FORUM_POST && $_CLASS['auth']->acl_get('f_read', $forum_id) && $row['forum_flags'] & 16) {
            $active_forum_ary['forum_id'][] = $forum_id;
            $active_forum_ary['enable_icons'][] = $row['enable_icons'];
            $active_forum_ary['forum_topics'] += $_CLASS['auth']->acl_get('m_approve', $forum_id) ? $row['forum_topics_real'] : $row['forum_topics'];
            $active_forum_ary['forum_posts'] += $row['forum_posts'];
        }
        if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id) {
            // Direct child
            $parent_id = $forum_id;
            $forum_rows[$forum_id] = $row;
            $forum_ids[] = $forum_id;
            if (!$row['parent_id'] && $row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id']) {
                $branch_root_id = $forum_id;
            }
            $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
        } elseif ($row['forum_type'] != FORUM_CAT) {
            $subforums[$parent_id]['display'] = $row['display_on_index'] ? true : false;
            $subforums[$parent_id]['name'][$forum_id] = $row['forum_name'];
            $forum_rows[$parent_id]['forum_topics'] += $_CLASS['auth']->acl_get('m_approve', $forum_id) ? $row['forum_topics_real'] : $row['forum_topics'];
            // Do not list redirects in LINK Forums as Posts.
            if ($row['forum_type'] != FORUM_LINK) {
                $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts'];
            }
            if (isset($forum_rows[$parent_id]) && $row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time']) {
                $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id'];
                $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time'];
                $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id'];
                $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name'];
                $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
            } else {
                $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
            }
        }
        if (!$_CLASS['core_user']->is_user || !$config['load_db_lastread']) {
            $forum_id36 = base_convert($forum_id, 10, 36);
            $row['mark_time'] = isset($tracking_topics[$forum_id36][0]) ? (int) base_convert($tracking_topics[$forum_id36][0], 36, 10) : 0;
        }
        if ($row['mark_time'] < $row['forum_last_post_time']) {
            $forum_unread[$parent_id] = true;
        }
    }
    $_CLASS['core_db']->free_result($result);
    // Handle marking posts
    if ($mark_read == 'forums') {
        markread('mark', $forum_id_ary);
        $redirect = generate_link('Forums');
        $_CLASS['core_display']->meta_refresh(3, $redirect);
        $message = strpos($redirect, 'viewforum') !== false ? 'RETURN_FORUM' : 'RETURN_INDEX';
        $message = $_CLASS['core_user']->lang['FORUMS_MARKED'] . '<br /><br />' . sprintf($_CLASS['core_user']->lang[$message], '<a href="' . $redirect . '">', '</a> ');
        trigger_error($message);
    }
    // Grab moderators ... if necessary
    if ($display_moderators) {
        $forum_moderators = get_moderators($forum_ids);
    }
    // Loop through the forums
    $root_id = $root_data['forum_id'];
    foreach ($forum_rows as $row) {
        if ($row['parent_id'] == $root_id && !$row['parent_id']) {
            if ($row['forum_type'] == FORUM_CAT) {
                $hold = $row;
                continue;
            } else {
                unset($hold);
            }
        } else {
            if (!empty($hold)) {
                $_CLASS['core_template']->assign_vars_array('forumrow', array('S_IS_CAT' => TRUE, 'FORUM_ID' => $hold['forum_id'], 'FORUM_NAME' => $hold['forum_name'], 'FORUM_DESC' => $hold['forum_desc'], 'U_VIEWFORUM' => generate_link('Forums&amp;file=viewforum&amp;f=' . $hold['forum_id'])));
                unset($hold);
            }
        }
        $visible_forums++;
        $forum_id = $row['forum_id'];
        $subforums_list = $l_subforums = '';
        // Generate list of subforums if we need to
        if (isset($subforums[$forum_id])) {
            if ($subforums[$forum_id]['display']) {
                $links = array();
                foreach ($subforums[$forum_id]['name'] as $subforum_id => $subforum_name) {
                    if (!empty($subforum_name)) {
                        $links[] = '<a href="' . generate_link('Forums&amp;file=viewforum&amp;f=' . $subforum_id) . '">' . $subforum_name . '</a>';
                    }
                }
                if (!empty($links)) {
                    $subforums_list = implode(', ', $links);
                    $l_subforums = count($subforums[$forum_id]) == 1 ? $_CLASS['core_user']->lang['SUBFORUM'] . ': ' : $_CLASS['core_user']->lang['SUBFORUMS'] . ': ';
                }
                unset($links);
            }
            $folder_image = !empty($forum_unread[$forum_id]) ? 'sub_forum_new' : 'sub_forum';
        } else {
            switch ($row['forum_type']) {
                case FORUM_POST:
                    $folder_image = !empty($forum_unread[$forum_id]) ? 'forum_new' : 'forum';
                    break;
                case FORUM_LINK:
                    $folder_image = 'forum_link';
                    break;
            }
        }
        // Which folder should we display?
        if ($row['forum_status'] == ITEM_LOCKED) {
            // forum_locked_new , need an image for this one
            $folder_image = empty($forum_unread[$forum_id]) ? 'forum_locked' : 'folder_locked_new';
            $folder_alt = 'FORUM_LOCKED';
        } else {
            $folder_alt = empty($forum_unread[$forum_id]) ? 'NO_NEW_POSTS' : 'NEW_POSTS';
        }
        // Create last post link information, if appropriate
        if ($row['forum_last_post_id']) {
            $last_post_time = $_CLASS['core_user']->format_date($row['forum_last_post_time']);
            $last_poster = $row['forum_last_poster_name'] != '' ? $row['forum_last_poster_name'] : $_CLASS['core_user']->lang['GUEST'];
            $last_poster_url = $row['forum_last_poster_id'] == ANONYMOUS ? '' : generate_link('Members_List&amp;mode=viewprofile&amp;u=' . $row['forum_last_poster_id']);
            $last_post_url = generate_link('Forums&amp;file=viewtopic&amp;f=' . $row['forum_id_last_post'] . '&amp;p=' . $row['forum_last_post_id'] . '#' . $row['forum_last_post_id'], false, false, false);
        } else {
            $last_post_time = $last_poster = $last_poster_url = $last_post_url = '';
        }
        // Output moderator listing ... if applicable
        $l_moderator = $moderators_list = '';
        if ($display_moderators && !empty($forum_moderators[$forum_id])) {
            $l_moderator = count($forum_moderators[$forum_id]) == 1 ? $_CLASS['core_user']->lang['MODERATOR'] : $_CLASS['core_user']->lang['MODERATORS'];
            $moderators_list = implode(', ', $forum_moderators[$forum_id]);
        }
        $l_post_click_count = $row['forum_type'] == FORUM_LINK ? 'CLICKS' : 'POSTS';
        $post_click_count = $row['forum_type'] != FORUM_LINK || $row['forum_flags'] & 1 ? $row['forum_posts'] : '';
        $_CLASS['core_template']->assign_vars_array('forumrow', array('S_IS_CAT' => false, 'S_IS_LINK' => $row['forum_type'] == FORUM_LINK, 'LAST_POST_IMG' => $_CLASS['core_user']->img('icon_post_latest', 'VIEW_LATEST_POST'), 'FORUM_ID' => $row['forum_id'], 'FORUM_FOLDER_IMG' => $row['forum_image'] ? '<img src="' . $row['forum_image'] . '" alt="' . $folder_alt . '" />' : $_CLASS['core_user']->img($folder_image, $folder_alt), 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => $row['forum_desc'], 'FORUM_LOCKED' => $row['forum_status'] == ITEM_LOCKED ? 1 : 0, $l_post_click_count => $post_click_count, 'TOPICS' => $row['forum_topics'], 'LAST_POST_TIME' => $last_post_time, 'LAST_POSTER' => $last_poster, 'MODERATORS' => $moderators_list, 'SUBFORUMS' => $subforums_list, 'L_SUBFORUM_STR' => $l_subforums, 'L_MODERATOR_STR' => $l_moderator, 'L_FORUM_FOLDER_ALT' => $folder_alt, 'U_LAST_POSTER' => $last_poster_url, 'U_LAST_POST' => $last_post_url, 'U_VIEWFORUM' => $row['forum_type'] != FORUM_LINK || $row['forum_flags'] & 1 ? generate_link('Forums&amp;file=viewforum&amp;f=' . $row['forum_id']) : $row['forum_link']));
    }
    $_CLASS['core_template']->assign_array(array('MODIFY_FORUM' => $_CLASS['auth']->acl_get('a_forum'), 'U_MARK_FORUMS' => generate_link('Forums&amp;file=viewforum&amp;f=' . $root_data['forum_id'] . '&amp;mark=Forums'), 'S_HAS_SUBFORUM' => $visible_forums ? true : false, 'L_SUBFORUM' => $visible_forums == 1 ? $_CLASS['core_user']->lang['SUBFORUM'] : $_CLASS['core_user']->lang['SUBFORUMS']));
    return $active_forum_ary;
}
コード例 #4
0
/**
* Display Forums
*/
function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
{
    global $db, $auth, $user, $template;
    global $phpbb_root_path, $phpEx, $config;
    $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
    $parent_id = $visible_forums = 0;
    $sql_from = $lastread_select = '';
    // Mark forums read?
    $mark_read = request_var('mark', '');
    if ($mark_read == 'all') {
        $mark_read = '';
    }
    if (!$root_data) {
        if ($mark_read == 'forums') {
            $mark_read = 'all';
        }
        $root_data = array('forum_id' => 0);
        $sql_where = '';
    } else {
        $sql_where = ' WHERE left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
    }
    // Display list of active topics for this category?
    $show_active = isset($root_data['forum_flags']) && $root_data['forum_flags'] & 16 ? true : false;
    if ($config['load_db_lastread'] && $user->data['is_registered']) {
        $sql_from = FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id)';
        $lastread_select = ', ft.mark_time ';
    } else {
        $sql_from = FORUMS_TABLE . ' f ';
        $lastread_select = $sql_lastread = '';
        $tracking_topics = isset($_COOKIE[$config['cookie_name'] . '_track']) ? STRIP ? stripslashes($_COOKIE[$config['cookie_name'] . '_track']) : $_COOKIE[$config['cookie_name'] . '_track'] : '';
        $tracking_topics = $tracking_topics ? unserialize($tracking_topics) : array();
        if (!$user->data['is_registered']) {
            $user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
        }
    }
    $sql = "SELECT f.* {$lastread_select}\n\t\tFROM {$sql_from}\n\t\t{$sql_where}\n\t\tORDER BY f.left_id";
    $result = $db->sql_query($sql);
    $forum_tracking_info = array();
    $branch_root_id = $root_data['forum_id'];
    while ($row = $db->sql_fetchrow($result)) {
        $forum_id = $row['forum_id'];
        // Mark forums read?
        if ($mark_read == 'forums' || $mark_read == 'all') {
            if ($auth->acl_get('f_list', $forum_id)) {
                $forum_ids[] = $forum_id;
                continue;
            }
        }
        // Category with no members
        if ($row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id']) {
            continue;
        }
        // Skip branch
        if (isset($right_id)) {
            if ($row['left_id'] < $right_id) {
                continue;
            }
            unset($right_id);
        }
        if (!$auth->acl_get('f_list', $forum_id)) {
            // if the user does not have permissions to list this forum, skip everything until next branch
            $right_id = $row['right_id'];
            continue;
        }
        $forum_ids[] = $forum_id;
        if ($config['load_db_lastread'] && $user->data['is_registered']) {
            $forum_tracking_info[$forum_id] = !empty($row['mark_time']) ? $row['mark_time'] : $user->data['user_lastmark'];
        } else {
            if (!$user->data['is_registered']) {
                $user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
            }
            $forum_tracking_info[$forum_id] = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
        }
        // Display active topics from this forum?
        if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && $row['forum_flags'] & 16) {
            if (!isset($active_forum_ary['forum_topics'])) {
                $active_forum_ary['forum_topics'] = 0;
            }
            if (!isset($active_forum_ary['forum_posts'])) {
                $active_forum_ary['forum_posts'] = 0;
            }
            $active_forum_ary['forum_id'][] = $forum_id;
            $active_forum_ary['enable_icons'][] = $row['enable_icons'];
            $active_forum_ary['forum_topics'] += $auth->acl_get('m_approve', $forum_id) ? $row['forum_topics_real'] : $row['forum_topics'];
            $active_forum_ary['forum_posts'] += $row['forum_posts'];
        }
        //
        if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id) {
            if ($row['forum_type'] != FORUM_CAT) {
                $forum_ids_moderator[] = $forum_id;
            }
            // Direct child of current branch
            $parent_id = $forum_id;
            $forum_rows[$forum_id] = $row;
            if (!$row['parent_id'] && $row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id']) {
                $branch_root_id = $forum_id;
            }
            $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
            $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
        } else {
            if ($row['forum_type'] != FORUM_CAT) {
                $subforums[$parent_id][$forum_id]['display'] = $row['display_on_index'] ? true : false;
                $subforums[$parent_id][$forum_id]['name'] = $row['forum_name'];
                $subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
                $forum_rows[$parent_id]['forum_topics'] += $auth->acl_get('m_approve', $forum_id) ? $row['forum_topics_real'] : $row['forum_topics'];
                // Do not list redirects in LINK Forums as Posts.
                if ($row['forum_type'] != FORUM_LINK) {
                    $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts'];
                }
                if ($row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time']) {
                    $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id'];
                    $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time'];
                    $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id'];
                    $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name'];
                    $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
                } else {
                    $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
                }
            }
        }
    }
    $db->sql_freeresult($result);
    // Handle marking posts
    if ($mark_read == 'forums' || $mark_read == 'all') {
        $redirect = build_url('mark');
        if ($mark_read == 'all') {
            markread('all');
            $message = sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>');
        } else {
            markread('topics', $forum_ids);
            $message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>');
        }
        meta_refresh(3, $redirect);
        trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message);
    }
    // Grab moderators ... if necessary
    if ($display_moderators) {
        if ($return_moderators) {
            $forum_ids_moderator[] = $root_data['forum_id'];
        }
        get_moderators($forum_moderators, $forum_ids_moderator);
    }
    foreach ($forum_rows as $row) {
        // Empty category
        if (!$row['parent_id'] && $row['forum_type'] == FORUM_CAT) {
            $template->assign_block_vars('forumrow', array('S_IS_CAT' => true, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield']), 'FORUM_FOLDER_IMG' => $row['forum_image'] ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['FORUM_CAT'] . '" />' : '', 'FORUM_FOLDER_IMG_SRC' => $row['forum_image'] ? $phpbb_root_path . $row['forum_image'] : '', 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id'])));
            continue;
        }
        $visible_forums++;
        $forum_id = $row['forum_id'];
        $forum_unread = isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id] ? true : false;
        $folder_image = $folder_alt = $subforums_list = $l_subforums = '';
        // Generate list of subforums if we need to
        if (isset($subforums[$forum_id])) {
            foreach ($subforums[$forum_id] as $subforum_id => $subforum_row) {
                // Update unread information if needed
                if (!$forum_unread) {
                    $forum_unread = isset($forum_tracking_info[$subforum_id]) && $subforum_row['orig_forum_last_post_time'] > $forum_tracking_info[$subforum_id] ? true : false;
                }
                if ($subforum_row['display'] && $subforum_row['name']) {
                    $subforums_list .= $subforums_list == '' ? '' : ', ';
                    $subforums_list .= '<a href="' . append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $subforum_id) . '">' . $subforum_row['name'] . '</a>';
                } else {
                    unset($subforums[$forum_id][$subforum_id]);
                }
            }
            $l_subforums = sizeof($subforums[$forum_id]) == 1 ? $user->lang['SUBFORUM'] . ': ' : $user->lang['SUBFORUMS'] . ': ';
            $folder_image = $forum_unread ? 'sub_forum_new' : 'sub_forum';
        } else {
            switch ($row['forum_type']) {
                case FORUM_POST:
                    $folder_image = $forum_unread ? 'forum_new' : 'forum';
                    break;
                case FORUM_LINK:
                    $folder_image = 'forum_link';
                    break;
            }
        }
        // Which folder should we display?
        if ($row['forum_status'] == ITEM_LOCKED) {
            $folder_image = 'forum_locked';
            $folder_alt = 'FORUM_LOCKED';
        } else {
            $folder_alt = $forum_unread ? 'NEW_POSTS' : 'NO_NEW_POSTS';
        }
        // Create last post link information, if appropriate
        if ($row['forum_last_post_id']) {
            $last_post_time = $user->format_date($row['forum_last_post_time']);
            $last_poster = $row['forum_last_poster_name'] != '' ? $row['forum_last_poster_name'] : $user->lang['GUEST'];
            $last_poster_url = $row['forum_last_poster_id'] == ANONYMOUS ? '' : append_sid("{$phpbb_root_path}memberlist.{$phpEx}", 'mode=viewprofile&amp;u=' . $row['forum_last_poster_id']);
            $last_post_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id_last_post'] . '&amp;p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];
        } else {
            $last_post_time = $last_poster = $last_poster_url = $last_post_url = '';
        }
        // Output moderator listing ... if applicable
        $l_moderator = $moderators_list = '';
        if ($display_moderators && !empty($forum_moderators[$forum_id])) {
            $l_moderator = sizeof($forum_moderators[$forum_id]) == 1 ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
            $moderators_list = implode(', ', $forum_moderators[$forum_id]);
        }
        $l_post_click_count = $row['forum_type'] == FORUM_LINK ? 'CLICKS' : 'POSTS';
        $post_click_count = $row['forum_type'] != FORUM_LINK || $row['forum_flags'] & 1 ? $row['forum_posts'] : '';
        $template->assign_block_vars('forumrow', array('S_IS_CAT' => false, 'S_IS_LINK' => $row['forum_type'] == FORUM_LINK ? true : false, 'S_UNREAD_FORUM' => $forum_unread, 'S_LOCKED_FORUM' => $row['forum_status'] == ITEM_LOCKED ? true : false, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield']), 'TOPICS' => $row['forum_topics'], $l_post_click_count => $post_click_count, 'FORUM_FOLDER_IMG' => $row['forum_image'] ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : $user->img($folder_image, $folder_alt), 'FORUM_FOLDER_IMG_SRC' => $row['forum_image'] ? $phpbb_root_path . $row['forum_image'] : $user->img($folder_image, $folder_alt, false, '', 'src'), 'SUBFORUMS' => $subforums_list, 'LAST_POST_TIME' => $last_post_time, 'LAST_POSTER' => $last_poster, 'MODERATORS' => $moderators_list, 'L_SUBFORUM_STR' => $l_subforums, 'L_FORUM_FOLDER_ALT' => $folder_alt, 'L_MODERATOR_STR' => $l_moderator, 'U_VIEWFORUM' => $row['forum_type'] != FORUM_LINK || $row['forum_flags'] & 1 ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']) : $row['forum_link'], 'U_LAST_POSTER' => $last_poster_url, 'U_LAST_POST' => $last_post_url));
    }
    $template->assign_vars(array('U_MARK_FORUMS' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $root_data['forum_id'] . '&amp;mark=forums'), 'S_HAS_SUBFORUM' => $visible_forums ? true : false, 'L_SUBFORUM' => $visible_forums == 1 ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], 'LAST_POST_IMG' => $user->img('icon_post_latest', 'VIEW_LATEST_POST')));
    if ($return_moderators) {
        return array($active_forum_ary, $forum_moderators);
    }
    return array($active_forum_ary, array());
}
コード例 #5
0
         if (!$i) {
             $output .= clean('Subforums') . $delims[1];
         } else {
             $output .= $delims[1];
         }
         $output .= clean($forum['FORUM_NAME']) . $delims[1];
         $output .= clean(sprintf($strings[0], $forum['LAST_POSTER'], $forum['LAST_POST_TIME'])) . $delims[1];
         if ($forum['POSTS'] > 0 && $forum['TOPICS'] > 0) {
             $output .= clean(sprintf($strings[1], $forum['POSTS'], $forum['POSTS'] != 1 ? 's' : '', $forum['TOPICS'], $forum['TOPICS'] != 1 ? 's' : ''));
         } else {
             $output .= clean($strings[2]);
         }
     }
 } else {
     $template->assign_var('S_HAS_SUBFORUM', false);
     get_moderators($moderators, $id);
 }
 // Not postable forum or showing active topics?
 if (!($forum_data['forum_type'] == FORUM_POST || $forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS && $forum_data['forum_type'] == FORUM_CAT)) {
     if ($debug) {
         page_footer();
     } else {
         exit;
     }
 }
 // Ok, if someone has only list-access, we only display the forum list.
 // We also make this circumstance available to the template in case we want to display a notice. ;)
 if (!$auth->acl_get('f_read', $id)) {
     if ($debug) {
         $template->assign_vars(array('S_NO_READ_ACCESS' => true, 'S_AUTOLOGIN_ENABLED' => $config['allow_autologin'] ? true : false, 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.{$phpEx}", 'mode=login') . '&amp;redirect=' . urlencode(str_replace('&amp;', '&', build_url()))));
         page_footer();
コード例 #6
0
$attachment_data = $message_parser->attachment_data;
$filename_data = $message_parser->filename_data;
$post_text = $message_parser->message;
if (sizeof($poll_options) && $poll_title) {
    $message_parser->message = $poll_title;
    $message_parser->bbcode_uid = $bbcode_uid;
    $message_parser->decode_message();
    $poll_title = $message_parser->message;
    $message_parser->message = implode("\n", $poll_options);
    $message_parser->decode_message();
    $poll_options = explode("\n", $message_parser->message);
}
unset($message_parser);
// MAIN POSTING PAGE BEGINS HERE
// Forum moderators?
$moderators = get_moderators($forum_id);
// Generate smiley listing
generate_smilies('inline', $forum_id);
// Generate inline attachment select box
posting_gen_inline_attachments($attachment_data);
// Do show topic type selection only in first post.
$topic_type_toggle = false;
if ($mode == 'post' || $mode == 'edit' && $post_id == $topic_first_post_id) {
    $topic_type_toggle = posting_gen_topic_types($forum_id, $posting_data['topic_type']);
}
$s_topic_icons = false;
if ($enable_icons) {
    $s_topic_icons = posting_gen_topic_icons($mode, $icon_id);
}
$html_checked = isset($enable_html) ? !$enable_html : ($config['allow_html'] ? !$_CLASS['core_user']->user_data_get('html') : 1);
$bbcode_checked = isset($enable_bbcode) ? !$enable_bbcode : ($config['allow_bbcode'] ? !$_CLASS['core_user']->user_data_get('bbcode') : 1);
コード例 #7
0
ファイル: functions_display.php プロジェクト: hgchen/phpbb
/**
* Display Forums
*/
function display_forums($root_data = '', $display_moderators = true, $return_moderators = false)
{
    global $db, $auth, $user, $template;
    global $phpbb_root_path, $phpEx, $config;
    global $request, $phpbb_dispatcher, $phpbb_container;
    $forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
    $parent_id = $visible_forums = 0;
    $sql_from = '';
    // Mark forums read?
    $mark_read = $request->variable('mark', '');
    if ($mark_read == 'all') {
        $mark_read = '';
    }
    if (!$root_data) {
        if ($mark_read == 'forums') {
            $mark_read = 'all';
        }
        $root_data = array('forum_id' => 0);
        $sql_where = '';
    } else {
        $sql_where = 'left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
    }
    // Handle marking everything read
    if ($mark_read == 'all') {
        $redirect = build_url(array('mark', 'hash', 'mark_time'));
        meta_refresh(3, $redirect);
        if (check_link_hash($request->variable('hash', ''), 'global')) {
            markread('all', false, false, $request->variable('mark_time', 0));
            if ($request->is_ajax()) {
                // Tell the ajax script what language vars and URL need to be replaced
                $data = array('NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], 'U_MARK_FORUMS' => $user->data['is_registered'] || $config['load_anon_lastread'] ? append_sid("{$phpbb_root_path}index.{$phpEx}", 'hash=' . generate_link_hash('global') . '&mark=forums&mark_time=' . time()) : '', 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED']);
                $json_response = new \phpbb\json_response();
                $json_response->send($data);
            }
            trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . sprintf($user->lang['RETURN_INDEX'], '<a href="' . $redirect . '">', '</a>'));
        } else {
            trigger_error(sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>'));
        }
    }
    // Display list of active topics for this category?
    $show_active = isset($root_data['forum_flags']) && $root_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS ? true : false;
    $sql_array = array('SELECT' => 'f.*', 'FROM' => array(FORUMS_TABLE => 'f'), 'LEFT_JOIN' => array());
    if ($config['load_db_lastread'] && $user->data['is_registered']) {
        $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_TRACK_TABLE => 'ft'), 'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id');
        $sql_array['SELECT'] .= ', ft.mark_time';
    } else {
        if ($config['load_anon_lastread'] || $user->data['is_registered']) {
            $tracking_topics = $request->variable($config['cookie_name'] . '_track', '', true, \phpbb\request\request_interface::COOKIE);
            $tracking_topics = $tracking_topics ? tracking_unserialize($tracking_topics) : array();
            if (!$user->data['is_registered']) {
                $user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
            }
        }
    }
    if ($show_active) {
        $sql_array['LEFT_JOIN'][] = array('FROM' => array(FORUMS_ACCESS_TABLE => 'fa'), 'ON' => "fa.forum_id = f.forum_id AND fa.session_id = '" . $db->sql_escape($user->session_id) . "'");
        $sql_array['SELECT'] .= ', fa.user_id';
    }
    $sql_ary = array('SELECT' => $sql_array['SELECT'], 'FROM' => $sql_array['FROM'], 'LEFT_JOIN' => $sql_array['LEFT_JOIN'], 'WHERE' => $sql_where, 'ORDER_BY' => 'f.left_id');
    /**
     * Event to modify the SQL query before the forum data is queried
     *
     * @event core.display_forums_modify_sql
     * @var	array	sql_ary		The SQL array to get the data of the forums
     * @since 3.1.0-a1
     */
    $vars = array('sql_ary');
    extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_sql', compact($vars)));
    $sql = $db->sql_build_query('SELECT', $sql_ary);
    $result = $db->sql_query($sql);
    $forum_tracking_info = $valid_categories = array();
    $branch_root_id = $root_data['forum_id'];
    /* @var $phpbb_content_visibility \phpbb\content_visibility */
    $phpbb_content_visibility = $phpbb_container->get('content.visibility');
    while ($row = $db->sql_fetchrow($result)) {
        /**
         * Event to modify the data set of a forum
         *
         * This event is triggered once per forum
         *
         * @event core.display_forums_modify_row
         * @var	int		branch_root_id	Last top-level forum
         * @var	array	row				The data of the forum
         * @since 3.1.0-a1
         */
        $vars = array('branch_root_id', 'row');
        extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_row', compact($vars)));
        $forum_id = $row['forum_id'];
        // Mark forums read?
        if ($mark_read == 'forums') {
            if ($auth->acl_get('f_list', $forum_id)) {
                $forum_ids[] = $forum_id;
            }
            continue;
        }
        // Category with no members
        if ($row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id']) {
            continue;
        }
        // Skip branch
        if (isset($right_id)) {
            if ($row['left_id'] < $right_id) {
                continue;
            }
            unset($right_id);
        }
        if (!$auth->acl_get('f_list', $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 ($config['load_db_lastread'] && $user->data['is_registered']) {
            $forum_tracking_info[$forum_id] = !empty($row['mark_time']) ? $row['mark_time'] : $user->data['user_lastmark'];
        } else {
            if ($config['load_anon_lastread'] || $user->data['is_registered']) {
                if (!$user->data['is_registered']) {
                    $user->data['user_lastmark'] = isset($tracking_topics['l']) ? (int) (base_convert($tracking_topics['l'], 36, 10) + $config['board_startdate']) : 0;
                }
                $forum_tracking_info[$forum_id] = isset($tracking_topics['f'][$forum_id]) ? (int) (base_convert($tracking_topics['f'][$forum_id], 36, 10) + $config['board_startdate']) : $user->data['user_lastmark'];
            }
        }
        // Lets check whether there are unapproved topics/posts, so we can display an information to moderators
        $row['forum_id_unapproved_topics'] = $auth->acl_get('m_approve', $forum_id) && $row['forum_topics_unapproved'] ? $forum_id : 0;
        $row['forum_id_unapproved_posts'] = $auth->acl_get('m_approve', $forum_id) && $row['forum_posts_unapproved'] ? $forum_id : 0;
        $row['forum_posts'] = $phpbb_content_visibility->get_count('forum_posts', $row, $forum_id);
        $row['forum_topics'] = $phpbb_content_visibility->get_count('forum_topics', $row, $forum_id);
        // Display active topics from this forum?
        if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && $row['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) {
            if (!isset($active_forum_ary['forum_topics'])) {
                $active_forum_ary['forum_topics'] = 0;
            }
            if (!isset($active_forum_ary['forum_posts'])) {
                $active_forum_ary['forum_posts'] = 0;
            }
            $active_forum_ary['forum_id'][] = $forum_id;
            $active_forum_ary['enable_icons'][] = $row['enable_icons'];
            $active_forum_ary['forum_topics'] += $row['forum_topics'];
            $active_forum_ary['forum_posts'] += $row['forum_posts'];
            // If this is a passworded forum we do not show active topics from it if the user is not authorised to view it...
            if ($row['forum_password'] && $row['user_id'] != $user->data['user_id']) {
                $active_forum_ary['exclude_forum_id'][] = $forum_id;
            }
        }
        // Fill list of categories with forums
        if (isset($forum_rows[$row['parent_id']])) {
            $valid_categories[$row['parent_id']] = true;
        }
        //
        if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id) {
            if ($row['forum_type'] != FORUM_CAT) {
                $forum_ids_moderator[] = (int) $forum_id;
            }
            // Direct child of current branch
            $parent_id = $forum_id;
            $forum_rows[$forum_id] = $row;
            if ($row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id']) {
                $branch_root_id = $forum_id;
            }
            $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
            $forum_rows[$parent_id]['forum_password_last_post'] = $row['forum_password'];
            $forum_rows[$parent_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
        } else {
            if ($row['forum_type'] != FORUM_CAT) {
                $subforums[$parent_id][$forum_id]['display'] = $row['display_on_index'] ? true : false;
                $subforums[$parent_id][$forum_id]['name'] = $row['forum_name'];
                $subforums[$parent_id][$forum_id]['orig_forum_last_post_time'] = $row['forum_last_post_time'];
                $subforums[$parent_id][$forum_id]['children'] = array();
                if (isset($subforums[$parent_id][$row['parent_id']]) && !$row['display_on_index']) {
                    $subforums[$parent_id][$row['parent_id']]['children'][] = $forum_id;
                }
                if (!$forum_rows[$parent_id]['forum_id_unapproved_topics'] && $row['forum_id_unapproved_topics']) {
                    $forum_rows[$parent_id]['forum_id_unapproved_topics'] = $forum_id;
                }
                if (!$forum_rows[$parent_id]['forum_id_unapproved_posts'] && $row['forum_id_unapproved_posts']) {
                    $forum_rows[$parent_id]['forum_id_unapproved_posts'] = $forum_id;
                }
                $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics'];
                // Do not list redirects in LINK Forums as Posts.
                if ($row['forum_type'] != FORUM_LINK) {
                    $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts'];
                }
                if ($row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time']) {
                    $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id'];
                    $forum_rows[$parent_id]['forum_last_post_subject'] = $row['forum_last_post_subject'];
                    $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time'];
                    $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id'];
                    $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name'];
                    $forum_rows[$parent_id]['forum_last_poster_colour'] = $row['forum_last_poster_colour'];
                    $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
                    $forum_rows[$parent_id]['forum_password_last_post'] = $row['forum_password'];
                }
            }
        }
        /**
         * Event to modify the forum rows data set
         *
         * This event is triggered once per forum
         *
         * @event core.display_forums_modify_forum_rows
         * @var	array	forum_rows		Data array of all forums we display
         * @var	array	subforums		Data array of all subforums we display
         * @var	int		branch_root_id	Current top-level forum
         * @var	int		parent_id		Current parent forum
         * @var	array	row				The data of the forum
         * @since 3.1.0-a1
         */
        $vars = array('forum_rows', 'subforums', 'branch_root_id', 'parent_id', 'row');
        extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_forum_rows', compact($vars)));
    }
    $db->sql_freeresult($result);
    // Handle marking posts
    if ($mark_read == 'forums') {
        $redirect = build_url(array('mark', 'hash', 'mark_time'));
        $token = $request->variable('hash', '');
        if (check_link_hash($token, 'global')) {
            markread('topics', $forum_ids, false, $request->variable('mark_time', 0));
            $message = sprintf($user->lang['RETURN_FORUM'], '<a href="' . $redirect . '">', '</a>');
            meta_refresh(3, $redirect);
            if ($request->is_ajax()) {
                // Tell the ajax script what language vars and URL need to be replaced
                $data = array('NO_UNREAD_POSTS' => $user->lang['NO_UNREAD_POSTS'], 'UNREAD_POSTS' => $user->lang['UNREAD_POSTS'], 'U_MARK_FORUMS' => $user->data['is_registered'] || $config['load_anon_lastread'] ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'hash=' . generate_link_hash('global') . '&f=' . $root_data['forum_id'] . '&mark=forums&mark_time=' . time()) : '', 'MESSAGE_TITLE' => $user->lang['INFORMATION'], 'MESSAGE_TEXT' => $user->lang['FORUMS_MARKED']);
                $json_response = new \phpbb\json_response();
                $json_response->send($data);
            }
            trigger_error($user->lang['FORUMS_MARKED'] . '<br /><br />' . $message);
        } else {
            $message = sprintf($user->lang['RETURN_PAGE'], '<a href="' . $redirect . '">', '</a>');
            meta_refresh(3, $redirect);
            trigger_error($message);
        }
    }
    // Grab moderators ... if necessary
    if ($display_moderators) {
        if ($return_moderators) {
            $forum_ids_moderator[] = $root_data['forum_id'];
        }
        get_moderators($forum_moderators, $forum_ids_moderator);
    }
    /**
     * Event to perform additional actions before the forum list is being generated
     *
     * @event core.display_forums_before
     * @var	array	active_forum_ary	Array with forum data to display active topics
     * @var	bool	display_moderators	Flag indicating if we display forum moderators
     * @var	array	forum_moderators	Array with forum moderators list
     * @var	array	forum_rows			Data array of all forums we display
     * @var	bool	return_moderators	Flag indicating if moderators list should be returned
     * @var	array	root_data			Array with the root forum data
     * @since 3.1.4-RC1
     */
    $vars = array('active_forum_ary', 'display_moderators', 'forum_moderators', 'forum_rows', 'return_moderators', 'root_data');
    extract($phpbb_dispatcher->trigger_event('core.display_forums_before', compact($vars)));
    // Used to tell whatever we have to create a dummy category or not.
    $last_catless = true;
    foreach ($forum_rows as $row) {
        // Category
        if ($row['parent_id'] == $root_data['forum_id'] && $row['forum_type'] == FORUM_CAT) {
            // Do not display categories without any forums to display
            if (!isset($valid_categories[$row['forum_id']])) {
                continue;
            }
            $cat_row = array('S_IS_CAT' => true, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'FORUM_FOLDER_IMG' => '', 'FORUM_FOLDER_IMG_SRC' => '', 'FORUM_IMAGE' => $row['forum_image'] ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang['FORUM_CAT'] . '" />' : '', 'FORUM_IMAGE_SRC' => $row['forum_image'] ? $phpbb_root_path . $row['forum_image'] : '', 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']));
            /**
             * Modify the template data block of the 'category'
             *
             * This event is triggered once per 'category'
             *
             * @event core.display_forums_modify_category_template_vars
             * @var	array	cat_row			Template data of the 'category'
             * @var	bool	catless			The flag indicating whether the 'category' has a parent category
             * @var	bool	last_catless	The flag indicating whether the last forum had a parent category
             * @var	array	root_data		Array with the root forum data
             * @var	array	row				The data of the 'category'
             * @since 3.1.0-RC4
             */
            $vars = array('cat_row', 'catless', 'last_catless', 'root_data', 'row');
            extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_category_template_vars', compact($vars)));
            $template->assign_block_vars('forumrow', $cat_row);
            continue;
        }
        $visible_forums++;
        $forum_id = $row['forum_id'];
        $forum_unread = isset($forum_tracking_info[$forum_id]) && $row['orig_forum_last_post_time'] > $forum_tracking_info[$forum_id] ? true : false;
        $folder_image = $folder_alt = $l_subforums = '';
        $subforums_list = array();
        // Generate list of subforums if we need to
        if (isset($subforums[$forum_id])) {
            foreach ($subforums[$forum_id] as $subforum_id => $subforum_row) {
                $subforum_unread = isset($forum_tracking_info[$subforum_id]) && $subforum_row['orig_forum_last_post_time'] > $forum_tracking_info[$subforum_id] ? true : false;
                if (!$subforum_unread && !empty($subforum_row['children'])) {
                    foreach ($subforum_row['children'] as $child_id) {
                        if (isset($forum_tracking_info[$child_id]) && $subforums[$forum_id][$child_id]['orig_forum_last_post_time'] > $forum_tracking_info[$child_id]) {
                            // Once we found an unread child forum, we can drop out of this loop
                            $subforum_unread = true;
                            break;
                        }
                    }
                }
                if ($subforum_row['display'] && $subforum_row['name']) {
                    $subforums_list[] = array('link' => append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $subforum_id), 'name' => $subforum_row['name'], 'unread' => $subforum_unread);
                } else {
                    unset($subforums[$forum_id][$subforum_id]);
                }
                // If one subforum is unread the forum gets unread too...
                if ($subforum_unread) {
                    $forum_unread = true;
                }
            }
            $l_subforums = sizeof($subforums[$forum_id]) == 1 ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'];
            $folder_image = $forum_unread ? 'forum_unread_subforum' : 'forum_read_subforum';
        } else {
            switch ($row['forum_type']) {
                case FORUM_POST:
                    $folder_image = $forum_unread ? 'forum_unread' : 'forum_read';
                    break;
                case FORUM_LINK:
                    $folder_image = 'forum_link';
                    break;
            }
        }
        // Which folder should we display?
        if ($row['forum_status'] == ITEM_LOCKED) {
            $folder_image = $forum_unread ? 'forum_unread_locked' : 'forum_read_locked';
            $folder_alt = 'FORUM_LOCKED';
        } else {
            $folder_alt = $forum_unread ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS';
        }
        // Create last post link information, if appropriate
        if ($row['forum_last_post_id']) {
            if ($row['forum_password_last_post'] === '' && $auth->acl_get('f_read', $row['forum_id_last_post'])) {
                $last_post_subject = censor_text($row['forum_last_post_subject']);
                $last_post_subject_truncated = truncate_string($last_post_subject, 30, 255, false, $user->lang['ELLIPSIS']);
            } else {
                $last_post_subject = $last_post_subject_truncated = '';
            }
            $last_post_time = $user->format_date($row['forum_last_post_time']);
            $last_post_url = append_sid("{$phpbb_root_path}viewtopic.{$phpEx}", 'f=' . $row['forum_id_last_post'] . '&amp;p=' . $row['forum_last_post_id']) . '#p' . $row['forum_last_post_id'];
        } else {
            $last_post_subject = $last_post_time = $last_post_url = $last_post_subject_truncated = '';
        }
        // Output moderator listing ... if applicable
        $l_moderator = $moderators_list = '';
        if ($display_moderators && !empty($forum_moderators[$forum_id])) {
            $l_moderator = sizeof($forum_moderators[$forum_id]) == 1 ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
            $moderators_list = implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]);
        }
        $l_post_click_count = $row['forum_type'] == FORUM_LINK ? 'CLICKS' : 'POSTS';
        $post_click_count = $row['forum_type'] != FORUM_LINK || $row['forum_flags'] & FORUM_FLAG_LINK_TRACK ? $row['forum_posts'] : '';
        $s_subforums_list = $subforums_row = array();
        foreach ($subforums_list as $subforum) {
            $s_subforums_list[] = '<a href="' . $subforum['link'] . '" class="subforum ' . ($subforum['unread'] ? 'unread' : 'read') . '" title="' . ($subforum['unread'] ? $user->lang['UNREAD_POSTS'] : $user->lang['NO_UNREAD_POSTS']) . '">' . $subforum['name'] . '</a>';
            $subforums_row[] = array('U_SUBFORUM' => $subforum['link'], 'SUBFORUM_NAME' => $subforum['name'], 'S_UNREAD' => $subforum['unread']);
        }
        $s_subforums_list = (string) implode($user->lang['COMMA_SEPARATOR'], $s_subforums_list);
        $catless = $row['parent_id'] == $root_data['forum_id'] ? true : false;
        if ($row['forum_type'] != FORUM_LINK) {
            $u_viewforum = append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']);
        } else {
            // If the forum is a link and we count redirects we need to visit it
            // If the forum is having a password or no read access we do not expose the link, but instead handle it in viewforum
            if ($row['forum_flags'] & FORUM_FLAG_LINK_TRACK || $row['forum_password'] || !$auth->acl_get('f_read', $forum_id)) {
                $u_viewforum = append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'f=' . $row['forum_id']);
            } else {
                $u_viewforum = $row['forum_link'];
            }
        }
        $forum_row = array('S_IS_CAT' => false, 'S_NO_CAT' => $catless && !$last_catless, 'S_IS_LINK' => $row['forum_type'] == FORUM_LINK ? true : false, 'S_UNREAD_FORUM' => $forum_unread, 'S_AUTH_READ' => $auth->acl_get('f_read', $row['forum_id']), 'S_LOCKED_FORUM' => $row['forum_status'] == ITEM_LOCKED ? true : false, 'S_LIST_SUBFORUMS' => $row['display_subforum_list'] ? true : false, 'S_SUBFORUMS' => sizeof($subforums_list) ? true : false, 'S_DISPLAY_SUBJECT' => $last_post_subject !== '' && $config['display_last_subject'] ? true : false, 'S_FEED_ENABLED' => $config['feed_forum'] && !phpbb_optionget(FORUM_OPTION_FEED_EXCLUDE, $row['forum_options']) && $row['forum_type'] == FORUM_POST ? true : false, 'FORUM_ID' => $row['forum_id'], 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => generate_text_for_display($row['forum_desc'], $row['forum_desc_uid'], $row['forum_desc_bitfield'], $row['forum_desc_options']), 'TOPICS' => $row['forum_topics'], $l_post_click_count => $post_click_count, 'FORUM_IMG_STYLE' => $folder_image, 'FORUM_FOLDER_IMG' => $user->img($folder_image, $folder_alt), 'FORUM_FOLDER_IMG_ALT' => isset($user->lang[$folder_alt]) ? $user->lang[$folder_alt] : '', 'FORUM_IMAGE' => $row['forum_image'] ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $user->lang[$folder_alt] . '" />' : '', 'FORUM_IMAGE_SRC' => $row['forum_image'] ? $phpbb_root_path . $row['forum_image'] : '', 'LAST_POST_SUBJECT' => $last_post_subject, 'LAST_POST_SUBJECT_TRUNCATED' => $last_post_subject_truncated, 'LAST_POST_TIME' => $last_post_time, 'LAST_POSTER' => get_username_string('username', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'LAST_POSTER_COLOUR' => get_username_string('colour', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'LAST_POSTER_FULL' => get_username_string('full', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'MODERATORS' => $moderators_list, 'SUBFORUMS' => $s_subforums_list, 'L_SUBFORUM_STR' => $l_subforums, 'L_MODERATOR_STR' => $l_moderator, 'U_UNAPPROVED_TOPICS' => $row['forum_id_unapproved_topics'] ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=unapproved_topics&amp;f=' . $row['forum_id_unapproved_topics']) : '', 'U_UNAPPROVED_POSTS' => $row['forum_id_unapproved_posts'] ? append_sid("{$phpbb_root_path}mcp.{$phpEx}", 'i=queue&amp;mode=unapproved_posts&amp;f=' . $row['forum_id_unapproved_posts']) : '', 'U_VIEWFORUM' => $u_viewforum, 'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']), 'U_LAST_POST' => $last_post_url);
        /**
         * Modify the template data block of the forum
         *
         * This event is triggered once per forum
         *
         * @event core.display_forums_modify_template_vars
         * @var	array	forum_row		Template data of the forum
         * @var	array	row				The data of the forum
         * @var	array	subforums_row	Template data of subforums
         * @since 3.1.0-a1
         * @change 3.1.0-b5 Added var subforums_row
         */
        $vars = array('forum_row', 'row', 'subforums_row');
        extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_template_vars', compact($vars)));
        $template->assign_block_vars('forumrow', $forum_row);
        // Assign subforums loop for style authors
        $template->assign_block_vars_array('forumrow.subforum', $subforums_row);
        /**
         * Modify and/or assign additional template data for the forum
         * after forumrow loop has been assigned. This can be used
         * to create additional forumrow subloops in extensions.
         *
         * This event is triggered once per forum
         *
         * @event core.display_forums_add_template_data
         * @var	array	forum_row		Template data of the forum
         * @var	array	row				The data of the forum
         * @var	array	subforums_list	The data of subforums
         * @var	array	subforums_row	Template data of subforums
         * @var	bool	catless			The flag indicating whether a forum has a parent category
         * @since 3.1.0-b5
         */
        $vars = array('forum_row', 'row', 'subforums_list', 'subforums_row', 'catless');
        extract($phpbb_dispatcher->trigger_event('core.display_forums_add_template_data', compact($vars)));
        $last_catless = $catless;
    }
    $template->assign_vars(array('U_MARK_FORUMS' => $user->data['is_registered'] || $config['load_anon_lastread'] ? append_sid("{$phpbb_root_path}viewforum.{$phpEx}", 'hash=' . generate_link_hash('global') . '&amp;f=' . $root_data['forum_id'] . '&amp;mark=forums&amp;mark_time=' . time()) : '', 'S_HAS_SUBFORUM' => $visible_forums ? true : false, 'L_SUBFORUM' => $visible_forums == 1 ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS'], 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPICS_UNAPPROVED'), 'UNAPPROVED_POST_IMG' => $user->img('icon_topic_unapproved', 'POSTS_UNAPPROVED_FORUM')));
    /**
     * Event to perform additional actions after the forum list has been generated
     *
     * @event core.display_forums_after
     * @var	array	active_forum_ary	Array with forum data to display active topics
     * @var	bool	display_moderators	Flag indicating if we display forum moderators
     * @var	array	forum_moderators	Array with forum moderators list
     * @var	array	forum_rows			Data array of all forums we display
     * @var	bool	return_moderators	Flag indicating if moderators list should be returned
     * @var	array	root_data			Array with the root forum data
     * @since 3.1.0-RC5
     */
    $vars = array('active_forum_ary', 'display_moderators', 'forum_moderators', 'forum_rows', 'return_moderators', 'root_data');
    extract($phpbb_dispatcher->trigger_event('core.display_forums_after', compact($vars)));
    if ($return_moderators) {
        return array($active_forum_ary, $forum_moderators);
    }
    return array($active_forum_ary, array());
}
コード例 #8
0
ファイル: viewforum.php プロジェクト: koki-h/xoops_utf8
} else {
    $xoopsTpl->assign('viewer_can_post', false);
    if ($show_reg == 1) {
        $xoopsTpl->assign('forum_post_or_register', '<a href="' . XOOPS_URL . '/user.php?xoops_redirect=' . htmlspecialchars($xoopsRequestUri) . '">' . _MD_REGTOPOST . '</a>');
    } else {
        $xoopsTpl->assign('forum_post_or_register', "");
    }
}
$xoopsTpl->assign('forum_index_title', sprintf(_MD_FORUMINDEX, $xoopsConfig['sitename']));
$xoopsTpl->assign('forum_image_folder', $bbImage['folder_topic']);
$myts =& MyTextSanitizer::getInstance();
$xoopsTpl->assign('forum_name', $myts->makeTboxData4Show($forumdata['forum_name']));
$xoopsTpl->assign('lang_moderatedby', _MD_MODERATEDBY);
$forum_moderators = "";
$count = 0;
$moderators = get_moderators($forum);
foreach ($moderators as $mods) {
    foreach ($mods as $mod_id => $mod_name) {
        if ($count > 0) {
            $forum_moderators .= ", ";
        }
        $forum_moderators .= '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $mod_id . '">' . $myts->makeTboxData4Show($mod_name) . '</a>';
        $count = 1;
    }
}
$xoopsTpl->assign('forum_moderators', $forum_moderators);
$sel_sort_array = array("t.topic_title" => _MD_TOPICTITLE, "t.topic_replies" => _MD_NUMBERREPLIES, "u.uname" => _MD_TOPICPOSTER, "t.topic_views" => _MD_VIEWS, "p.post_time" => _MD_LASTPOSTTIME);
if (!isset($_GET['sortname']) || !in_array($_GET['sortname'], array_keys($sel_sort_array))) {
    $sortname = "p.post_time";
} else {
    $sortname = $_GET['sortname'];
コード例 #9
0
function display_forums($root_data = '', $display_moderators = TRUE)
{
    global $board_config, $db, $template, $user, $auth, $phpEx, $forum_moderators, $phpbb_root_path, $user;
    // Get posted/get info
    $mark_read = request_var('mark', '');
    $forum_id_ary = $active_forum_ary = $forum_rows = $subforums = $forum_moderators = $mark_forums = array();
    $visible_forums = 0;
    if (!$root_data) {
        $root_data = array('forum_id' => 0);
        $sql_where = '';
    } else {
        $sql_where = ' WHERE left_id > ' . $root_data['left_id'] . ' AND left_id < ' . $root_data['right_id'];
    }
    // Display list of active topics for this category?
    $show_active = isset($root_data['forum_flags']) && $root_data['forum_flags'] & 16 ? true : false;
    if ($board_config['load_db_lastread'] && $user->data['user_id'] != ANONYMOUS) {
        switch (SQL_LAYER) {
            case 'oracle':
                break;
            default:
                $sql_from = '(' . FORUMS_TABLE . ' f LEFT JOIN ' . FORUMS_TRACK_TABLE . ' ft ON (ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id))';
                break;
        }
        $lastread_select = ', ft.mark_time ';
    } else {
        $sql_from = "(( " . FORUMS_TABLE . " f\n\t\t\t\tLEFT JOIN " . POSTS_TABLE . " p ON p.post_id = f.forum_last_post_id )\n\t\t\t\tLEFT JOIN " . USERS_TABLE . " u ON u.user_id = p.poster_id )\n\t\t\t\tORDER BY f.cat_id, f.forum_order";
        $lastread_select = ', p.post_time, p.post_username, u.username, u.user_id';
        $sql_lastread = '';
        $tracking_topics = isset($_COOKIE[$board_config['cookie_name'] . '_track']) ? unserialize(stripslashes($_COOKIE[$board_config['cookie_name'] . '_track'])) : array();
    }
    $sql = "SELECT f.* {$lastread_select} \n\t\tFROM {$sql_from} \n\t\t{$sql_where}\n\t\t";
    //ORDER BY f.left_id";
    $result = $db->sql_query($sql);
    print_r($db->sql_error());
    $branch_root_id = $root_data['forum_id'];
    $forum_ids = array($root_data['forum_id']);
    while ($row = $db->sql_fetchrow($result)) {
        if ($mark_read == 'forums' && $user->data['user_id'] != ANONYMOUS) {
            //if ($auth->acl_get('f_list', $row['forum_id']))
            //{
            $forum_id_ary[] = $row['forum_id'];
            //}
            continue;
        }
        if (isset($right_id)) {
            if ($row['left_id'] < $right_id) {
                continue;
            }
            unset($right_id);
        }
        if ($row['forum_type'] == FORUM_CAT && $row['left_id'] + 1 == $row['right_id']) {
            // Non-postable forum with no subforums: don't display
            continue;
        }
        $forum_id = $row['forum_id'];
        //if (!$auth->acl_get('f_list', $forum_id))
        //{
        // if the user does not have permissions to list this forum, skip everything until next branch
        //$right_id = $row['right_id'];
        //continue;
        //}
        // Display active topics from this forum?
        if ($show_active && $row['forum_type'] == FORUM_POST && $auth->acl_get('f_read', $forum_id) && $row['forum_flags'] & 16) {
            $active_forum_ary['forum_id'][] = $forum_id;
            $active_forum_ary['enable_icons'][] = $row['enable_icons'];
            $active_forum_ary['forum_topics'] += $row['forum_topics'];
            $active_forum_ary['forum_posts'] += $row['forum_posts'];
        }
        if ($row['parent_id'] == $root_data['forum_id'] || $row['parent_id'] == $branch_root_id) {
            // Direct child
            $parent_id = $forum_id;
            $forum_rows[$forum_id] = $row;
            $forum_ids[] = $forum_id;
            if (!$row['parent_id'] && $row['forum_type'] == FORUM_CAT && $row['parent_id'] == $root_data['forum_id']) {
                $branch_root_id = $forum_id;
            }
            $forum_rows[$parent_id]['forum_id_last_post'] = $row['forum_id'];
        } elseif ($row['forum_type'] != FORUM_CAT) {
            $subforums[$parent_id]['display'] = $row['display_on_index'] ? true : false;
            $subforums[$parent_id]['name'][$forum_id] = $row['forum_name'];
            // Include subforum topic/post counts in parent counts
            $forum_rows[$parent_id]['forum_topics'] += $row['forum_topics'];
            // Do not list redirects in LINK Forums as Posts.
            if ($row['forum_type'] != FORUM_LINK) {
                $forum_rows[$parent_id]['forum_posts'] += $row['forum_posts'];
            }
            if (isset($forum_rows[$parent_id]) && $row['forum_last_post_time'] > $forum_rows[$parent_id]['forum_last_post_time']) {
                $forum_rows[$parent_id]['forum_last_post_id'] = $row['forum_last_post_id'];
                $forum_rows[$parent_id]['forum_last_post_time'] = $row['forum_last_post_time'];
                $forum_rows[$parent_id]['forum_last_poster_id'] = $row['forum_last_poster_id'];
                $forum_rows[$parent_id]['forum_last_poster_name'] = $row['forum_last_poster_name'];
                $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
            } else {
                $forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
            }
        }
        if (!isset($row['mark_time'])) {
            $row['mark_time'] = 0;
        }
        $mark_time_forum = $board_config['load_db_lastread'] ? $row['mark_time'] : (isset($tracking_topics[$forum_id][0]) ? base_convert($tracking_topics[$forum_id][0], 36, 10) + $board_config['board_startdate'] : 0);
        if ($mark_time_forum < $row['forum_last_post_time'] && $user->data['user_id'] != ANONYMOUS) {
            $forum_unread[$parent_id] = true;
        }
    }
    $db->sql_freeresult($result);
    // Handle marking posts
    if ($mark_read == 'forums') {
        markread('mark', $forum_id_ary);
        $redirect = !empty($_SERVER['REQUEST_URI']) ? preg_replace('#^(.*?)&(amp;)?mark=.*$#', '\\1', htmlspecialchars($_SERVER['REQUEST_URI'])) : append_sid("index.{$phpEx}");
        meta_refresh(3, $redirect);
        $message = strstr($redirect, 'viewforum') ? 'RETURN_FORUM' : 'RETURN_INDEX';
        $message = $user->lang['FORUMS_MARKED'] . '<br /><br />' . sprintf($user->lang[$message], '<a href="' . $redirect . '">', '</a> ');
        trigger_error($message);
    }
    // Grab moderators ... if necessary
    if ($display_moderators) {
        get_moderators($forum_moderators, $forum_ids);
    }
    // Loop through the forums
    $root_id = $root_data['forum_id'];
    foreach ($forum_rows as $row) {
        if ($row['parent_id'] == $root_id && !$row['parent_id']) {
            if ($row['forum_type'] == FORUM_CAT) {
                $hold = $row;
                continue;
            } else {
                unset($hold);
            }
        } else {
            if (!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' => append_sid("viewforum.{$phpEx}?f=" . $hold['forum_id'])));
                unset($hold);
            }
        }
        $visible_forums++;
        $forum_id = $row['forum_id'];
        // Generate list of subforums if we need to
        if (isset($subforums[$forum_id])) {
            if ($subforums[$forum_id]['display']) {
                $alist = array();
                foreach ($subforums[$forum_id]['name'] as $sub_forum_id => $subforum_name) {
                    if (!empty($subforum_name)) {
                        $alist[$sub_forum_id] = $subforum_name;
                    }
                }
                if (sizeof($alist)) {
                    $links = array();
                    foreach ($alist as $subforum_id => $subforum_name) {
                        $links[] = '<a href="' . append_sid('viewforum.' . $phpEx . '?f=' . $subforum_id) . '">' . $subforum_name . '</a>';
                    }
                    $subforums_list = implode(', ', $links);
                    $l_subforums = count($subforums[$forum_id]) == 1 ? $user->lang['SUBFORUM'] . ': ' : $user->lang['SUBFORUMS'] . ': ';
                }
            }
            $folder_image = !empty($forum_unread[$forum_id]) ? 'sub_forum_new' : 'sub_forum';
        } else {
            switch ($row['forum_type']) {
                case FORUM_POST:
                    $folder_image = !empty($forum_unread[$forum_id]) ? 'forum_new' : 'forum';
                    break;
                case FORUM_LINK:
                    $folder_image = 'forum_link';
                    break;
            }
            $subforums_list = '';
            $l_subforums = '';
        }
        // Which folder should we display?
        if ($row['forum_status'] == ITEM_LOCKED) {
            $folder_image = 'forum_locked';
            $folder_alt = 'FORUM_LOCKED';
        } else {
            $folder_alt = !empty($forum_unread[$forum_id]) ? 'NEW_POSTS' : 'NO_NEW_POSTS';
        }
        // Create last post link information, if appropriate
        if ($row['forum_last_post_id']) {
            $last_post_time = $user->format_date($row['post_time']);
            $last_poster = $row['username'] != '' ? $row['username'] : $user->lang['GUEST'];
            $last_poster_url = $row['user_id'] == ANONYMOUS ? '' : append_sid("profile.{$phpEx}?mode=viewprofile&amp;u=" . $row['user_id']);
            $last_post_url = append_sid("viewtopic.{$phpEx}?f=" . $row['forum_id_last_post'] . '&amp;p=' . $row['forum_last_post_id'] . '#' . $row['forum_last_post_id']);
        } else {
            $last_post_time = $last_poster = $last_poster_url = $last_post_url = '';
        }
        // Output moderator listing ... if applicable
        $l_moderator = $moderators_list = '';
        if ($display_moderators && !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]);
        }
        $l_post_click_count = $row['forum_type'] == FORUM_LINK ? 'CLICKS' : 'POSTS';
        $post_click_count = $row['forum_type'] != FORUM_LINK || $row['forum_flags'] & 1 ? $row['forum_posts'] : '';
        $template->assign_block_vars('forumrow', array('S_IS_CAT' => false, 'S_IS_LINK' => $row['forum_type'] != FORUM_LINK ? false : true, 'LAST_POST_IMG' => $user->img('icon_latest_reply', 'VIEW_LATEST_POST'), 'FORUM_ID' => $row['forum_id'], 'FORUM_FOLDER_IMG' => $row['forum_image'] ? '<img src="' . $phpbb_root_path . $row['forum_image'] . '" alt="' . $folder_alt . '" border="0" />' : $user->img($folder_image, $folder_alt), 'FORUM_NAME' => $row['forum_name'], 'FORUM_DESC' => $row['forum_desc'], $l_post_click_count => $post_click_count, 'TOPICS' => $row['forum_topics'], 'LAST_POST_TIME' => $last_post_time, 'LAST_POSTER' => $last_poster, 'MODERATORS' => $moderators_list, 'SUBFORUMS' => $subforums_list, 'L_SUBFORUM_STR' => $l_subforums, 'L_MODERATOR_STR' => $l_moderator, 'L_FORUM_FOLDER_ALT' => $folder_alt, 'U_LAST_POSTER' => $last_poster_url, 'U_LAST_POST' => $last_post_url, 'U_VIEWFORUM' => $row['forum_type'] != FORUM_LINK || $row['forum_flags'] & 1 ? append_sid("viewforum.{$phpEx}?f=" . $row['forum_id']) : $row['forum_link']));
    }
    $template->assign_vars(array('U_MARK_FORUMS' => append_sid("viewforum.{$phpEx}?f=" . $root_data['forum_id'] . '&amp;mark=forums'), 'L_LAST_POST' => $user->lang['Last_Post'], 'S_HAS_SUBFORUM' => $visible_forums ? true : false, 'L_SUBFORUM' => $visible_forums == 1 ? $user->lang['SUBFORUM'] : $user->lang['SUBFORUMS']));
    return $active_forum_ary;
}
コード例 #10
0
ファイル: send_to.php プロジェクト: Eugen1985/stalker_portal
        <input type="text" size="32" readonly value="<?php 
echo get_sended_video();
?>
">
    </td>
</tr>
<tr>
    <td><?php 
echo _('To');
?>
:</td>
    <td>
    <select name="to_usr">
        <option>- - - - - - - - - - - - - 
        <?php 
echo get_moderators();
?>
    </select>
    <input type="hidden" name="id" value="<?php 
echo @$_GET['id'];
?>
">
    </td>
</tr>
<tr>
    <td valign="top"><?php 
echo _('Comment');
?>
:</td>
    <td>
        <textarea name="comment" cols="30" rows="8"></textarea>
コード例 #11
0
ファイル: index.php プロジェクト: amjadtbssm/website
             // no forums, so put empty values
             $categories[$i]['forums']['forum_lastpost_time'][] = "";
             $categories[$i]['forums']['forum_lastpost_icon'][] = "";
             $categories[$i]['forums']['forum_lastpost_user'][] = "";
             if ($forum_row['forum_type'] == 1) {
                 $categories[$i]['forums']['forum_folder'][] = $bbImage['locked_forum'];
             } else {
                 $categories[$i]['forums']['forum_folder'][] = $bbImage['folder_forum'];
             }
         }
         $categories[$i]['forums']['forum_id'][] = $forum_row['forum_id'];
         $categories[$i]['forums']['forum_name'][] = $myts->makeTboxData4Show($forum_row['forum_name']);
         $categories[$i]['forums']['forum_desc'][] = $myts->makeTareaData4Show($forum_row['forum_desc']);
         $categories[$i]['forums']['forum_topics'][] = $forum_row['forum_topics'];
         $categories[$i]['forums']['forum_posts'][] = $forum_row['forum_posts'];
         $all_moderators = get_moderators($forum_row['forum_id']);
         $count = 0;
         $forum_moderators = '';
         foreach ($all_moderators as $mods) {
             foreach ($mods as $mod_id => $mod_name) {
                 if ($count > 0) {
                     $forum_moderators .= ', ';
                 }
                 $forum_moderators .= '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $mod_id . '">' . $myts->makeTboxData4Show($mod_name) . '</a>';
                 $count = 1;
             }
         }
         $categories[$i]['forums']['forum_moderators'][] = $forum_moderators;
     }
 }
 $xoopsTpl->append("categories", $categories[$i]);