2007-02-19, 05:33 PM
Hey everyone,
I am looking to make an alteration to minimize the amount of latest threads displayed in the sidebar over at :
http://www.wiiroom.net
Here is the relevant current PHP:
I am looking to make an alteration to minimize the amount of latest threads displayed in the sidebar over at :
http://www.wiiroom.net
Here is the relevant current PHP:
<?php
$lang->load("portal");
$unviewable = get_unviewable_forums();
if($unviewable)
{
$unviewwhere = " AND fid NOT IN ($unviewable)";
}
// If user is known, welcome them
if($mybb->settings['portal_showwelcome'] != "no")
{
if($mybb->user['uid'] != 0)
{
if($mybb->user['receivepms'] != "no" && $mybb->usergroup['canusepms'] != "no" && $mybb->settings['portal_showpms'] != "no")
{
$query = $db->query("SELECT COUNT(*) AS pms_total, SUM(IF(dateline>'".$mybb->user['lastvisit']."' AND folder='1','1','0')) AS pms_new, SUM(IF(status='0' AND folder='1','1','0')) AS pms_unread FROM ".TABLE_PREFIX."privatemessages WHERE uid='".$mybb->user['uid']."'");
$messages = $db->fetch_array($query);
if(!$messages['pms_new'])
{
$messages['pms_new'] = 0;
}
// the SUM() thing returns "" instead of 0
if($messages['pms_unread'] == "")
{
$messages['pms_unread'] = 0;
}
$lang->pms_received_new = sprintf($lang->pms_received_new, $mybb->user['username'], $messages['pms_new']);
eval("\$pms = \"".$templates->get("portal_pms")."\";");
}
// get number of new posts, threads, announcements
$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(pid) AS newposts", "dateline>'".$mybb->user['lastvisit']."' $unviewwhere");
$newposts = $db->fetch_field($query, "newposts");
if($newposts)
{ // if there aren't any new posts, there is no point in wasting two more queries
$query = $db->simple_select(TABLE_PREFIX."threads", "COUNT(tid) AS newthreads", "dateline>'".$mybb->user['lastvisit']."' $unviewwhere");
$newthreads = $db->fetch_field($query, "newthreads");
$query = $db->simple_select(TABLE_PREFIX."threads", "COUNT(tid) AS newann", "dateline>'".$mybb->user['lastvisit']."' AND fid IN (".$mybb->settings['portal_announcementsfid'].") $unviewwhere");
$newann = $db->fetch_field($query, "newann");
if(!$newthreads)
{
$newthreads = 0;
}
if(!$newann)
{
$newann = 0;
}
}
else
{
$newposts = 0;
$newthreads = 0;
$newann = 0;
}
// Make the text
if($newann == 1)
{
$lang->new_announcements = $lang->new_announcement;
}
else
{
$lang->new_announcements = sprintf($lang->new_announcements, $newann);
}
if($newthreads == 1)
{
$lang->new_threads = $lang->new_thread;
}
else
{
$lang->new_threads = sprintf($lang->new_threads, $newthreads);
}
if($newposts == 1)
{
$lang->new_posts = $lang->new_post;
}
else
{
$lang->new_posts = sprintf($lang->new_posts, $newposts);
}
eval("\$welcometext = \"".$templates->get("portal_welcome_membertext")."\";");
}
else
{
$lang->guest_welcome_registration = sprintf($lang->guest_welcome_registration, $mybb->settings['bburl'] . '/member.php?action=register');
$mybb->user['username'] = $lang->guest;
eval("\$welcometext = \"".$templates->get("portal_welcome_guesttext")."\";");
}
$lang->welcome = sprintf($lang->welcome, $mybb->user['username']);
eval("\$welcome = \"".$templates->get("portal_welcome")."\";");
if($mybb->user['uid'] == 0)
{
$mybb->user['username'] = "";
}
}
// Get Forum Statistics
if($mybb->settings['portal_showstats'] != "no")
{
$stats = $cache->read("stats");
$threadsnum = $stats['numthreads'];
$postsnum = $stats['numposts'];
$membersnum = $stats['numusers'];
if(!$stats['lastusername'])
{
$newestmember = "<b>" . $lang->no_one . "</b>";
}
else
{
$newestmember = "<a href=\"".$mybb->settings[bburl]."/member.php?action=profile&uid=$stats[lastuid]\">$stats[lastusername]</a>";
}
eval("\$stats = \"".$templates->get("portal_stats")."\";");
}
// Search box
if($mybb->settings['portal_showsearch'] != "no")
{
eval("\$search = \"".$templates->get("portal_search")."\";");
}
if($mybb->settings['portal_showdiscussions'] != "no" && $mybb->settings['portal_showdiscussionsnum'])
{
$altbg = "trow1";
$threadlist = '';
$query = $db->query("
SELECT t.*, u.username
FROM ".TABLE_PREFIX."threads t
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid)
WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
ORDER BY t.lastpost DESC
LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']
);
while($thread = $db->fetch_array($query))
{
$lastpostdate = my_date($mybb->settings['dateformat'], $thread['lastpost']);
$lastposttime = my_date($mybb->settings['timeformat'], $thread['lastpost']);
// Don't link to guest's profiles (they have no profile).
if($thread['lastposteruid'] == 0)
{
$lastposterlink = $thread['lastposter'];
}
else
{
$lastposterlink = build_profile_link($thread['lastposter'], $thread['lastposteruid']);
}
if(my_strlen($thread['subject']) > 25)
{
$thread['subject'] = my_substr($thread['subject'], 0, 25) . "...";
}
$thread['subject'] = htmlspecialchars_uni($thread['subject']);
eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
$altbg = alt_trow();
}
if($threadlist)
{ // show the table only if there are threads
eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
}
}
?>
Alex.