Skip to content

Commit

Permalink
#956 Improve query to load index forums
Browse files Browse the repository at this point in the history
  • Loading branch information
Yannick committed Oct 31, 2014
1 parent 442fa88 commit edaf716
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@

require load_page('header.php');
// 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.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster, f.last_poster_id, f.last_topic, f.color 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='.$luna_user['g_id'].') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());
$result = $db->query('SELECT c.id AS cid, c.cat_name, f.id AS fid, f.forum_name, f.forum_desc, f.moderators, f.num_topics, f.num_posts, f.last_post, f.last_post_id, f.last_poster_id, f.color, u.username AS username, t.subject AS subject FROM '.$db->prefix.'categories AS c INNER JOIN '.$db->prefix.'forums AS f ON c.id=f.cat_id LEFT JOIN '.$db->prefix.'users AS u ON f.last_poster_id=u.id LEFT JOIN '.$db->prefix.'topics AS t ON t.last_post_id=f.last_post_id LEFT JOIN '.$db->prefix.'forum_perms AS fp ON (fp.forum_id=f.id AND fp.group_id='.$luna_user['g_id'].') WHERE fp.read_forum IS NULL OR fp.read_forum=1 ORDER BY c.disp_position, c.id, f.disp_position', true) or error('Unable to fetch category/forum list', __FILE__, __LINE__, $db->error());

require load_page('index.php');

Expand Down
4 changes: 2 additions & 2 deletions style/Sunrise/objects/forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
if (luna_strlen($cur_forum['last_topic']) > 43)
$cur_forum['last_topic'] = utf8_substr($cur_forum['last_topic'], 0, 40).'...';

$last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'" class="list-group-item" '.$group_style.'><span class="forum-newestitem">'.luna_htmlspecialchars($cur_forum['last_topic']).'<span class="help-block">by '.luna_htmlspecialchars($cur_forum['last_poster']).'</span></span></a>';
$last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'" class="list-group-item" '.$group_style.'><span class="forum-newestitem">'.luna_htmlspecialchars($cur_forum['subject']).'<span class="help-block">by '.luna_htmlspecialchars($cur_forum['username']).'</span></span></a>';
}

$forum_stats = '<span class="list-group-item" '.$group_style.'>'.$cur_forum['num_topics'].' topics and '.$cur_forum['num_posts'].' posts</span>';
Expand All @@ -34,7 +34,7 @@
if (luna_strlen($cur_forum['last_topic']) > 43)
$cur_forum['last_topic'] = utf8_substr($cur_forum['last_topic'], 0, 40).'...';

$last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.luna_htmlspecialchars($cur_forum['last_topic']).'</a><span class="help-block">by '.luna_htmlspecialchars($cur_forum['last_poster']).'</span>';
$last_post = '<a href="viewtopic.php?pid='.$cur_forum['last_post_id'].'#p'.$cur_forum['last_post_id'].'">'.luna_htmlspecialchars($cur_forum['subject']).'</a><span class="help-block">by '.luna_htmlspecialchars($cur_forum['username']).'</span>';
} else
$last_post = 'No posts yet';

Expand Down

0 comments on commit edaf716

Please sign in to comment.