// 'MODERATORS' => $moderator_list, // // 'L_MODERATOR' => $l_moderators, // 'L_FORUM_FOLDER_ALT' => $folder_alt, // // 'U_VIEWFORUM' => append_sid("viewforum.$phpEx?" . POST_FORUM_URL . "=$forum_id")) // ); // } // } // } // } // } // } // for ... categories $max_depth = !$sub_forum ? get_max_depth($viewcat) : 0; $template->assign_vars(array('INC_SPAN' => $max_depth + 2)); enhance_cat($viewcat); // display the index $found = false; for ($i = 0; $i < $total_categories && !$found; $i++) { if ($viewcat == -1 && $category_rows[$i]['cat_main'] == 0 || $viewcat > 0 && $category_rows[$i]['cat_id'] == $viewcat) { display_index_cat($category_rows[$i], $sub_forum, true); $found = $viewcat > 0; } } // End PNphpBB2 Categories Hierarchie Mod } else { message_die(GENERAL_MESSAGE, $lang['No_forums']); } // // Generate the page //
function enhance_cat($cat_id) { //-- fix v 1.0.6 global $category_rows, $forum_data, $is_auth_ary, $tracking_forums, $tracking_topics, $new_topic_data, $images, $lang, $board_config, $userdata, $phpEx; //-- if ($cat_id < 0) { $cat_id = 0; } // default values $ind = -1; //-- v 1.0.5 $categories_desc = ''; // all the sub-cat titles $forums_desc = ''; // all the sub-forum titles //-- $cat_display = false; $cat_locked = true; $cat_unread_topics = false; $cat_posts = 0; $cat_topics = 0; $cat_post_time = 0; $cat_last_post = ''; // look up for sub-categories for ($i = 0; $i < count($category_rows); $i++) { // let's fix the cat_main : attached to index : lvl 0 if ($category_rows[$i]['cat_main'] == $category_rows[$i]['cat_id']) { $category_rows[$i]['cat_main'] = 0; } // get the tab index for $cat_id if ($cat_id > 0 && $category_rows[$i]['cat_id'] == $cat_id) { $ind = $i; } // identify category which are daughters of the one running if ($category_rows[$i]['cat_main'] == $cat_id && $category_rows[$i]['cat_id'] > 0) { // enhance sub-categories enhance_cat($category_rows[$i]['cat_id']); // get the result //-- v 1.0.5 $categories_desc .= empty($categories_desc) ? '' : ', '; $categories_desc .= $category_rows[$i]['cat_title']; //-- if ($category_rows[$i]['cat_display']) { $cat_display = true; } if (!$category_rows[$i]['cat_locked']) { $cat_locked = false; } if ($category_rows[$i]['unread_topics']) { $cat_unread_topics = true; } $cat_posts = $cat_posts + $category_rows[$i]['posts']; $cat_topics = $cat_topics + $category_rows[$i]['topics']; if ($cat_post_time < $category_rows[$i]['post_time']) { $cat_post_time = $category_rows[$i]['post_time']; $cat_last_post = $category_rows[$i]['last_post']; } } // if ($category_rows[$i]['cat_main']==$cat_id) || ( ($cat_id==0) && ($category_rows[$i]['cat_main']==$category_rows[$i]['cat_id']) ) } // for ($i=0; $i < count($category_rows); $i++) // deal with the forums of the category if ($ind > -1) { // Raz $category_rows[$ind]['cat_display'] = false; $category_rows[$ind]['cat_locked'] = true; $category_rows[$ind]['unread_topics'] = false; $category_rows[$ind]['posts'] = 0; $category_rows[$ind]['topics'] = 0; $category_rows[$ind]['post_time'] = 0; $category_rows[$ind]['last_post'] = ''; // look up for the forums of the category for ($j = 0; $j < count($forum_data); $j++) { if ($forum_data[$j]['cat_id'] == $cat_id) { $forum_id = $forum_data[$j]['forum_id']; // valeur par défaut $display_forum = false; $unread_topics = false; $last_post = ""; // forum visible ? if ($display_forum = $is_auth_ary[$forum_id]['auth_view']) { if ($forum_data[$j]['forum_status'] != FORUM_LOCKED) { if ($userdata['session_logged_in'] && !empty($new_topic_data[$forum_id])) { $forum_last_post_time = 0; while (list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id])) { if (empty($tracking_topics[$check_topic_id])) { $unread_topics = true; $forum_last_post_time = max($check_post_time, $forum_last_post_time); } else { if ($tracking_topics[$check_topic_id] < $check_post_time) { $unread_topics = true; $forum_last_post_time = max($check_post_time, $forum_last_post_time); } } } // end while( list($check_topic_id, $check_post_time) = @each($new_topic_data[$forum_id]) ) if (!empty($tracking_forums[$forum_id])) { if ($tracking_forums[$forum_id] > $forum_last_post_time) { $unread_topics = false; } } if (isset($_COOKIE[$board_config['cookie_name'] . '_f_all'])) { if ($_COOKIE[$board_config['cookie_name'] . '_f_all'] > $forum_last_post_time) { $unread_topics = false; } } } // if ( $userdata['session_logged_in'] && !empty($new_topic_data[$forum_id]) ) } // if ($forum_data[$j]['forum_status'] != FORUM_LOCKED) $posts = $forum_data[$j]['forum_posts']; $topics = $forum_data[$j]['forum_topics']; $last_post = $lang['No_Posts']; if ($forum_data[$j]['forum_last_post_id']) { $last_post_time = create_date($board_config['default_dateformat'], $forum_data[$j]['post_time'], $board_config['board_timezone']); $last_post = $last_post_time . '<br />'; // Begin PNphpBB2 Module $last_post .= $forum_data[$j]['user_id'] == ANONYMOUS ? $forum_data[$j]['post_username'] != '' ? DataUtil::formatForDisplay($forum_data[$j]['post_username']) . ' ' : $lang['Guest'] . ' ' : '<a href="' . append_sid("profile.{$phpEx}?mode=viewprofile&" . POST_USERS_URL . '=' . $forum_data[$j]['user_id']) . '">' . DataUtil::formatForDisplay($forum_data[$j]['username']) . '</a> '; // End PNphpBB2 Module $last_post .= '<a href="' . append_sid("viewtopic.{$phpEx}?" . POST_POST_URL . '=' . $forum_data[$j]['forum_last_post_id']) . '#' . $forum_data[$j]['forum_last_post_id'] . '"><img src="' . $images['icon_latest_reply'] . '" border="0" alt="' . $lang['View_latest_post'] . '" title="' . $lang['View_latest_post'] . '" /></a>'; } } // if ($display_forums = $is_auth_ary[$forum_data[$j]['forum_id']]['auth_view']) // enhanced forum row $forum_data[$j]['display_forum'] = $display_forum; $forum_data[$j]['unread_topics'] = $unread_topics; $forum_data[$j]['last_post'] = $last_post; // ok : add forum informations to the category if ($forum_data[$j]['display_forum']) { //-- v 1.0.5 $forums_desc .= empty($forums_desc) ? '' : ', '; // Begin PNphpBB2 Module $forums_desc .= '<a href="' . append_sid("viewforum.{$phpEx}?" . POST_FORUM_URL . "={$forum_id}") . '">' . $forum_data[$j]['forum_name'] . '</a>'; // End PNphpBB2 Module //-- $category_rows[$ind]['cat_display'] = true; if ($forum_data[$j]['forum_status'] != FORUM_LOCKED) { $category_rows[$ind]['cat_locked'] = false; } if ($forum_data[$j]['unread_topics']) { $category_rows[$ind]['unread_topics'] = true; } $category_rows[$ind]['posts'] = $category_rows[$ind]['posts'] + $forum_data[$j]['forum_posts']; $category_rows[$ind]['topics'] = $category_rows[$ind]['topics'] + $forum_data[$j]['forum_topics']; if ($forum_data[$j]['post_time'] > $category_rows[$ind]['post_time']) { $category_rows[$ind]['post_time'] = $forum_data[$j]['post_time']; $category_rows[$ind]['last_post'] = $forum_data[$j]['last_post']; } } // if ($display_forum) } // if ($forum_data['cat_id'] == $cat_id) } // for ($j=0;$j<count($forum_data);$j++) // all is done for the forums : add the sub-categories informations //-- v 1.0.5 if (empty($category_rows[$ind]['cat_desc'])) { $category_rows[$ind]['cat_desc'] = $forums_desc; $category_rows[$ind]['cat_desc'] .= empty($forums_desc) || empty($categories_desc) ? '' : ', '; $category_rows[$ind]['cat_desc'] .= $categories_desc; } //-- if ($cat_display) { $category_rows[$ind]['cat_display'] = true; } if (!$cat_locked) { $category_rows[$ind]['cat_locked'] = false; } if ($cat_unread_topics) { $category_rows[$ind]['unread_topics'] = true; } $category_rows[$ind]['posts'] = $category_rows[$ind]['posts'] + $cat_posts; $category_rows[$ind]['topics'] = $category_rows[$ind]['topics'] + $cat_topics; if ($cat_post_time > $category_rows[$ind]['post_time']) { $category_rows[$ind]['post_time'] = $cat_post_time; $category_rows[$ind]['last_post'] = $cat_last_post; } } // if ($ind > -1) }