1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
| <?php
################################################################################
########################### Sub Forum MOD (start) ##############################
################################################################################
if (file_exists(PUN_ROOT.'lang/'.$pun_user['language'].'/sub_forum.php'))
require PUN_ROOT.'lang/'.$pun_user['language'].'/sub_forum.php';
$sfdb = array();
$forums_info = $db->query('SELECT f.num_topics, f.num_posts, f.parent_forum_id, f.last_post_id, f.last_poster, f.last_post, f.id, f.forum_name FROM '.$db->prefix.'forums AS f LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND f.parent_forum_id <> 0 ORDER BY f.disp_position') or error('Unable to fetch subforum list', __FILE__, __LINE__, $db->error());
while ($current = $db->fetch_assoc($forums_info))
{
if (!isset($sfdb[$current['parent_forum_id']]))
$sfdb[$current['parent_forum_id']] = array();
$sfdb[$current['parent_forum_id']][] = $current;
}
################################################################################
########################### Sub Forum MOD ( end ) ##############################
################################################################################
// Print the categories and forums
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.redirect_url, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster, f.last_topic, f.last_topic_id, f.num_replies, u.id AS uid, f.parent_forum_id FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$pun_user['g_id'].') LEFT JOIN '.$db->prefix.'users AS u ON f.last_poster=u.username WHERE (fp.read_forum IS NULL OR fp.read_forum=1) AND (f.parent_forum_id IS NULL OR f.parent_forum_id=0) ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
$cur_category = 0;
$cat_count = 0;
$forum_count = 0;
while ($cur_forum = $db->fetch_assoc($result))
{
$moderators = '';
if ($cur_forum['cid'] != $cur_category) // A new category since last iteration?
{
if ($cur_category != 0)
echo "\t\t\t".'</tbody>'."\n\t\t\t".'</table>'."\n\t\t".'</div>'."\n\t".'</div>'."\n".'</div>'."\n\n";
++$cat_count;
$forum_count = 0;
?>
<div id="idx<?php echo $cat_count ?>" class="blocktable">
<h2><span><?php echo pun_htmlspecialchars($cur_forum['cat_name']) ?></span></h2>
<div class="box">
<div class="inbox">
<table>
<thead>
<tr>
<th class="tcl" scope="col"><?php echo $lang_common['Forum'] ?></th>
<th class="tc2" scope="col"><?php echo $lang_index['Topics'] ?></th>
<th class="tc3" scope="col"><?php echo $lang_common['Posts'] ?></th>
<th class="tcr" scope="col"><?php echo $lang_common['Last post'] ?></th>
</tr>
</thead>
<tbody>
<?php
$cur_category = $cur_forum['cid'];
}
++$forum_count;
$item_status = ($forum_count % 2 == 0) ? 'roweven' : 'rowodd';
$forum_field_new = '';
$icon_type = 'icon';
// Are there new posts since our last visit?
if (!$pun_user['is_guest'] && $cur_forum['last_post'] > $pun_user['last_visit'] && (empty($tracked_topics['forums'][$cur_forum['fid']]) || $cur_forum['last_post'] > $tracked_topics['forums'][$cur_forum['fid']]))
{
// There are new posts in this forum, but have we read all of them already?
foreach ($new_topics[$cur_forum['fid']] as $check_topic_id => $check_last_post)
{
if ((empty($tracked_topics['topics'][$check_topic_id]) || $tracked_topics['topics'][$check_topic_id] < $check_last_post) && (empty($tracked_topics['forums'][$cur_forum['fid']]) || $tracked_topics['forums'][$cur_forum['fid']] < $check_last_post))
{
$item_status .= ' inew';
$forum_field_new = '<span class="newtext">[ <a href="search.php?action=show_new&fid='.$cur_forum['fid'].'">'.$lang_common['New posts'].'</a> ]</span>';
$icon_type = 'icon icon-new';
break;
}
}
}
// Is this a redirect forum?
if ($cur_forum['redirect_url'] != '')
{
$forum_field = '<h3><span class="redirtext">'.$lang_index['Link to'].'</span> <a href="'.pun_htmlspecialchars($cur_forum['redirect_url']).'" title="'.$lang_index['Link to'].' '.pun_htmlspecialchars($cur_forum['redirect_url']).'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a></h3>';
$num_topics = $num_posts = '-';
$item_status .= ' iredirect';
$icon_type = 'icon';
}
else
{
$forum_field = '<h3><a href="'.fluxrewrite("forum-", $cur_forum['fid'], $cur_forum['forum_name'], 1, false, false).'">'.pun_htmlspecialchars($cur_forum['forum_name']).'</a>'.(!empty($forum_field_new) ? ' '.$forum_field_new : '').'</h3>';
$num_topics = $cur_forum['num_topics'];
$num_posts = $cur_forum['num_posts'];
################################################################################
########################### Sub Forum MOD (start) ##############################
################################################################################
if (isset($sfdb[$cur_forum['fid']]))
{
foreach ($sfdb[$cur_forum['fid']] as $cur_subforum)
{
$num_topics += $cur_subforum['num_topics'];
$num_posts += $cur_subforum['num_posts'];
if ($cur_forum['last_post'] < $cur_subforum['last_post'])
{
$cur_forum['last_post_id'] = $cur_subforum['last_post_id'];
$cur_forum['last_poster'] = $cur_subforum['last_poster'];
$cur_forum['uid'] = $cur_subforum['uid'];
$cur_forum['last_post'] = $cur_subforum['last_post'];
}
}
}
}
################################################################################
########################### Sub Forum MOD ( end ) ##############################
################################################################################
if ($cur_forum['forum_desc'] != '')
$forum_field .= "\n\t\t\t\t\t\t\t\t".'<div class="forumdesc">'.$cur_forum['forum_desc'].'</div>';
// If there is a last_post/last_poster
if ($pun_config['o_avatars'] == '1' && $pun_user['show_avatars'] != '0')
{
if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.gif'))
$user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.gif" class="maxavatar" alt="" />';
else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.jpg'))
$user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.jpg" class="maxavatar" alt="" />';
else if ($img_size = @getimagesize($pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.png'))
$user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/'.$cur_forum['uid'].'.png" class="maxavatar" alt="" />';
else
$user_avatar = '<img src="'.$pun_config['o_avatars_dir'].'/achoice/00_default.png" class="maxavatar" alt="" />';
}
else
$user_avatar = '';
if ($pun_user['g_view_users'] == '1' && $cur_forum['uid'] > 1)
{
$last_poster = '<a href="profile.php?id='.$cur_forum['uid'].'">'.pun_htmlspecialchars($cur_forum['last_poster']).'</a>';
}
else
{
$last_poster = pun_htmlspecialchars($cur_forum['last_poster']);
}
if ($cur_forum['last_post'] != '')
$last_post = $user_avatar.'<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.format_time($cur_forum['last_post']).'</a> <span class="byuser">'.$lang_common['by'].' '.pun_htmlspecialchars($cur_forum['last_poster']).'</span>';
else if ($cur_forum['redirect_url'] != '')
$last_post = '- - -';
else
$last_post = $lang_common['Never']; |
Partager