TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

May 17, 2024, 10:44:34 AM

Login with username, password and session length
Members
  • Total Members: 3,886
  • Latest: Grendor
Stats
  • Total Posts: 195,189
  • Total Topics: 21,220
  • Online today: 59
  • Online ever: 3,540 (September 03, 2022, 01:38:54 AM)
Users Online
  • Users: 0
  • Guests: 66
  • Total: 66

"recent topics" in SMF style

Started by Lesmond, August 17, 2005, 12:01:38 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

jacortina

The code in this message:
http://www.tinyportal.net/index.php?topic=596.msg105580#msg105580

will use less calls (and potentially fewer DB queries). It also allows the specification of boards to be unconditionally excluded.

But no other enhanced capabilties or extra options have been added.

mrbean17

Not sure if it's simply the time of day in which I'm testing my site (due to shared resources) but it seems to load a bit quicker with this new code.

Thanks!

mrbean17

#342
Hmmm, I'm having the same problem I did before ... If a page spans multiple pages, it shows up as "Ã,« 1 2 Ã,»". I just removed the three instances of Ã, in the code. What is the purpose of that character?

jacortina

There is none. It snuck into the posted code at some point.

I've gone back and edited them out of the posted code (which I swear, I've done before).

dannbass

Hi J.A.Cortina!
I have a question that I think might not be appropriate here... I posted it a couple of days ago here, but I realized the problem is not the multi-tabs, because today I was trying the same thing with the accordion style menu and it worked up to three times...

Any idea why I'm not able to have multiple blocks or more than three blocks?
Anything will be very appreciated!

jacortina

Hold on for a few days. I'm looking at implementing a version of this as a separate function. While not as 'convenient' as having it in a block/article, it makes a LOT more sense when its functionality will be called in more than one place/circumstance.

And when your block is down to a few arguments assignments and a function call for each iteration, it might be easier to  track down problems (if that alone doesn't clear it up).

dannbass

Thanks a lot!! As always I'm very grateful!! I'll wait as long as it takes!

mrbean17

Is it possible to add a message stating that you need to register if a guest is viewing?

Thanks

catchpen

Sorry if this already been covered - long thread here.

I have this code on my front page, but I'm kinda doing a workaround for what I really need. 

I created a board with duplicate posts from around the forum just so I can show the selected posts with this code on the front page and still have the RSS available (workaround for me not being a coder). 

Well I installed the mod that added "Return a single post <?php ssi_grabMessage(); ?>" on my SSI.php 1.1 allows me to select select only certain posts.

How hard is it or even possible to use this "ssi_grabMessage();" with this code to select around 15 single posts instead of selecting whole boards?

here's the version I'm using:

lobal $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

//////////////////////////////////////////// ---------- Unconditional Exclude
//
       $exclude_boards = array('1','2','3','4','5','6','7','8','9','10','11','12','13','14','15','16','18','19','20','22','23','24');      // KEEP (to preserve variable declaration)
//      $exclude_boards = array(5);     //  Exclude single board
//      $exclude_boards = array(5, 8);  //  Exclude multiple boards
       $ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
//
//


       $do_query = 1;

//////////////////////////////////////////// ---------- Boardindex Most Recent Topics Arguments
//
//      Comment out the Info Center's Most Recent Posts Code and Insert this
//      to show Most Recent Topics in full detail style instead
//
      $list_count = 15;
      $heading = 'Latest 15  Picks';
      $where_clause = 't.ID_LAST_MSG >= ' . ($modSettings['maxMsgID'] - 90 * max($list_count, 5));
      $limit_clause = 'LIMIT ' . $list_count;
      $order_clause = 't.ID_LAST_MSG DESC';
////////////////////////////////////////////


       $stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
       $icon_sources = array();
       foreach ($stable_icons as $icon)
               $icon_sources[$icon] = 'images_url';

       $groupcolors = array();
       $request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
       while ($row = mysql_fetch_assoc($request))
               $groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
       mysql_free_result($request);

       $topics = array();

       if ($do_query == 1)
       {
       $request = db_query("
               SELECT
                               ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
                               t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
                               ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
                               IFNULL(meml.realName, ml.posterName) AS lastPosterName,
                               mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group,
                               ml.subject AS lastSubject, b.memberGroups,
                               ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
                               LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
                               ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
                               . ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
                               IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
                               IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
                       FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
                               LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
                               LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
                               LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
                               LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
                       WHERE " . $where_clause . $ex_board_clause . "
                               AND t.ID_TOPIC = ms.ID_TOPIC
                               AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
                               AND ms.ID_MSG = t.ID_FIRST_MSG
                               AND ml.ID_MSG = t.ID_LAST_MSG
                               AND " . $user_info['query_see_board'] . "
                       ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


       $topic_ids = array();
       while ($row = mysql_fetch_assoc($request))
       {
               if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
                       continue;

               $topic_ids[] = $row['ID_TOPIC'];

               // Clip the strings first because censoring is slow :/. (for some reason?)
               $row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
               if (strlen($row['firstBody']) > 128)
                       $row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
               $row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
               if (strlen($row['lastBody']) > 128)
                       $row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

                       $row['lastSubject'] = $row['firstSubject'];
                       $row['lastBody'] = $row['firstBody'];

               // Decide how many pages the topic should have.
               $topic_length = $row['numReplies'] + 1;
               if ($topic_length > $modSettings['defaultMaxMessages'])
               {
                       $tmppages = array();
                       $tmpa = 1;
                       for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
                       {
                               $tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
                               $tmpa++;
                       }
                       // Show links to all the pages?
                       if (count($tmppages) <= 5)
                               $pages = 'ÂÃ,« ' . implode(' ', $tmppages);
                       // Or skip a few?
                       else
                               $pages = 'ÂÃ,« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

                       if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
                               $pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
                       $pages .= ' ÂÃ,»';
               }
               else
                       $pages = '';

               // We need to check the topic icons exist... you can never be too sure!
               if (empty($modSettings['messageIconChecks_disable']))
               {
                       // First icon first... as you'd expect.
                       if (!isset($icon_sources[$row['firstIcon']]))
                               $icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
                       // Last icon... last... duh.
                       if (!isset($icon_sources[$row['lastIcon']]))
                               $icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
               }

               $color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
               $color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

               // And build the array.
               $topics[$row['ID_TOPIC']] = array(
                       'id' => $row['ID_TOPIC'],
                       'first_post' => array(
                               'id' => $row['ID_FIRST_MSG'],
                               'member' => array(
                                       'name' => $row['firstPosterName'],
                                       'id' => $row['ID_FIRST_MEMBER'],
                                       'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
                                       'link' => !empty($row['ID_FIRST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . '<font color="' . $color_start . '">' . $row['firstPosterName'] . '</font>' . '</a>' : $row['firstPosterName']
                               ),
                               'time' => timeformat($row['firstPosterTime']),
                               'timestamp' => forum_time(true, $row['firstPosterTime']),
                               'subject' => $row['firstSubject'],
                               'preview' => $row['firstBody'],
                               'icon' => $row['firstIcon'],
                               'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
                               'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
                               'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
                       ),
                       'last_post' => array(
                               'id' => $row['ID_LAST_MSG'],
                               'member' => array(
                                       'name' => $row['lastPosterName'],
                                       'id' => $row['ID_LAST_MEMBER'],
                                       'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
                                       'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '">' . '<font color="' . $color_last . '">' . $row['lastPosterName'] . '</font>' . '</a>' : $row['lastPosterName']
                               ),
                               'time' => timeformat($row['lastPosterTime']),
                               'timestamp' => forum_time(true, $row['lastPosterTime']),
                               'subject' => $row['lastSubject'],
                               'preview' => $row['lastBody'],
                               'icon' => $row['lastIcon'],
                               'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
                               'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
                               'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
                       ),
                       'new' => $row['isRead'],
                       'new_from' => $row['new_from'],
                       'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
                       'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
                       'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
                       'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
                       'is_locked' => !empty($row['locked']),
                       'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
                       'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
                       'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
                       'is_posted_in' => false,
                       'icon' => $row['firstIcon'],
                       'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
                       'subject' => $row['firstSubject'],
                       'pages' => $pages,
                       'replies' => $row['numReplies'],
                       'views' => $row['numViews'],
                       'board' => array(
                               'id' => $row['ID_BOARD'],
                               'name' => $row['bname'],
                               'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
                               'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bname'] . '</a>'
                       )
               );

               determineTopicClass($topics[$row['ID_TOPIC']]);
       }
       mysql_free_result($request);

       if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
       {
               $result = db_query("
                       SELECT ID_TOPIC
                       FROM {$db_prefix}messages
                       WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
                               AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
               while ($row = mysql_fetch_assoc($result))
               {
                       if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
                       {
                               $topics[$row['ID_TOPIC']]['is_posted_in'] = true;
                               $topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
                       }
               }
               mysql_free_result($result);
       }

       }

if (!empty($topics))
   {
   echo '
       <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
           <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
               <tr>';

   echo '
                   <td class="titlebg" colspan="7">', $heading, '</td>';
   echo '
               </tr>';

   echo '
                               <tr class="titlebg">
                                       <td width="10%" colspan="2"> </td>
                                       <td>', $txt[70], '
                                       </td><td width="14%">', $txt[109], '
                                       </td><td width="4%" align="center">', $txt[110], '
                                       </td><td width="4%" align="center">', $txt[301], '
                                       </td><td width="24%">', $txt[111], '
                                       </td>
                               </tr>';

       foreach ($topics as $topic)
       {
               // Do we want to seperate the sticky and lock status out?
               if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
                       $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
               if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
                       $topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

               echo '
                               <tr>
                                       <td class="windowbg2" valign="middle" align="center" width="6%">
                                               <img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
                                       </td><td class="windowbg2" valign="middle" align="center" width="4%">
                                               <img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
                                       </td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
                                               <img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
                                               <img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '', $topic['first_post']['link'];
                                       if ($topic['new'] == 0)
                                               {
                                               echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
                                               }
                                       echo '
                                       <span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
                                       <td class="windowbg2" valign="middle" width="14%">
                                               ', $topic['first_post']['member']['link'], '</td>
                                       <td class="windowbg" valign="middle" width="4%" align="center">
                                               ', $topic['replies'], '</td>
                                       <td class="windowbg" valign="middle" width="4%" align="center">
                                               ', $topic['views'], '</td>
                                       <td class="windowbg2" valign="middle" width="22%">
                                               <a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
                                               <span class="smalltext">
                                                       ', $topic['last_post']['time'], '<br />
                                                       ', $txt[525], ' ', $topic['last_post']['member']['link'], '
                                               </span>
                                       </td>
                               </tr>';
       }

   echo '</table></div>';

   }
       else
           echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';


THanks for the help.
C.P.

jacortina

This can give you 15 specific Topics. This is just what's done when you use this for 'Global (Topic) Announcements'. I've taken the lates code and pared it down to what's need to use it that way.

Put the topic numbers you want in the $announce_topics array and put what you want for the $heading:
global $context, $settings, $scripturl, $txt, $db_prefix, $ID_MEMBER, $user_info, $modSettings, $user_profile;

$exclude_boards = array(); // KEEP (to preserve variable declaration)
$ex_board_clause = !empty($exclude_boards) ? ' AND b.ID_BOARD NOT IN (' . implode(', ', $exclude_boards) . ')' : '';
$do_query = 1;

$announce_topics = array(254, 568, 675, 678); // Topic ID's to be 'Announced'
$heading = '<center>Announcements<center>';

$where_clause = 't.ID_TOPIC IN (' . implode(', ', $announce_topics) . ')';
$limit_clause = '';
$order_clause = 't.ID_LAST_MSG DESC';


$stable_icons = array('xx', 'thumbup', 'thumbdown', 'exclamation', 'question', 'lamp', 'smiley', 'angry', 'cheesy', 'grin', 'sad', 'wink', 'moved', 'recycled', 'wireless');
$icon_sources = array();
foreach ($stable_icons as $icon)
$icon_sources[$icon] = 'images_url';

$groupcolors = array();
$request = db_query("SELECT ID_GROUP, onlineColor FROM {$db_prefix}membergroups", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($request))
$groupcolors[$row['ID_GROUP']] = $row['onlineColor'];
mysql_free_result($request);

$topics = array();

if ($do_query == 1)
{
$request = db_query("
SELECT
ms.subject AS firstSubject, ms.posterTime AS firstPosterTime, ms.ID_TOPIC, t.ID_BOARD, b.name AS bname,
t.numReplies, t.numViews, ms.ID_MEMBER AS ID_FIRST_MEMBER, ml.ID_MEMBER AS ID_LAST_MEMBER,
ml.posterTime AS lastPosterTime, IFNULL(mems.realName, ms.posterName) AS firstPosterName,
IFNULL(meml.realName, ml.posterName) AS lastPosterName,
mems.ID_GROUP as mems_group, meml.ID_GROUP as meml_group, mems.ID_POST_GROUP as mems_pgroup,
ml.subject AS lastSubject, b.memberGroups, meml.ID_POST_GROUP as meml_pgroup,
ml.icon AS lastIcon, ms.icon AS firstIcon, t.ID_POLL, t.isSticky, t.locked, ml.modifiedTime AS lastModifiedTime,
LEFT(ml.body, 384) AS lastBody, LEFT(ms.body, 384) AS firstBody,
ml.smileysEnabled AS lastSmileys, ms.smileysEnabled AS firstSmileys, t.ID_FIRST_MSG, t.ID_LAST_MSG,"
. ($user_info['is_guest'] ? '1 AS isRead, 0 AS new_from' : '
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, 0)) >= ml.ID_MSG_MODIFIED AS isRead,
IFNULL(lt.ID_MSG, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . "
FROM ({$db_prefix}messages AS ms, {$db_prefix}messages AS ml, {$db_prefix}topics AS t, {$db_prefix}boards AS b)
LEFT JOIN {$db_prefix}members AS mems ON (mems.ID_MEMBER = ms.ID_MEMBER)
LEFT JOIN {$db_prefix}members AS meml ON (meml.ID_MEMBER = ml.ID_MEMBER)
LEFT JOIN {$db_prefix}log_topics AS lt ON (lt.ID_TOPIC = t.ID_TOPIC AND lt.ID_MEMBER = $ID_MEMBER)
LEFT JOIN {$db_prefix}log_mark_read AS lmr ON (lmr.ID_BOARD = t.ID_BOARD AND lmr.ID_MEMBER = $ID_MEMBER)
WHERE " . $where_clause . $ex_board_clause . "
AND t.ID_TOPIC = ms.ID_TOPIC
AND b.ID_BOARD = t.ID_BOARD" . (!empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0 ? " AND b.ID_BOARD != $modSettings[recycle_board]" : '') . "
AND ms.ID_MSG = t.ID_FIRST_MSG
AND ml.ID_MSG = t.ID_LAST_MSG
AND " . $user_info['query_see_board'] . "
ORDER BY " . $order_clause . " " . $limit_clause, __FILE__, __LINE__);


$topic_ids = array();
while ($row = mysql_fetch_assoc($request))
{
if ($row['ID_POLL'] > 0 && $modSettings['pollMode'] == '0')
continue;

$topic_ids[] = $row['ID_TOPIC'];

// Clip the strings first because censoring is slow :/. (for some reason?)
$row['firstBody'] = strip_tags(strtr(parse_bbc($row['firstBody'], $row['firstSmileys'], $row['ID_FIRST_MSG']), array('<br />' => '
')));
if (strlen($row['firstBody']) > 128)
$row['firstBody'] = substr($row['firstBody'], 0, 128) . '...';
$row['lastBody'] = strip_tags(strtr(parse_bbc($row['lastBody'], $row['lastSmileys'], $row['ID_LAST_MSG']), array('<br />' => '
')));
if (strlen($row['lastBody']) > 128)
$row['lastBody'] = substr($row['lastBody'], 0, 128) . '...';

$row['lastSubject'] = $row['firstSubject'];
$row['lastBody'] = $row['firstBody'];

// Decide how many pages the topic should have.
$topic_length = $row['numReplies'] + 1;
if ($topic_length > $modSettings['defaultMaxMessages'])
{
$tmppages = array();
$tmpa = 1;
for ($tmpb = 0; $tmpb < $topic_length; $tmpb += $modSettings['defaultMaxMessages'])
{
$tmppages[] = '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.' . $tmpb . ';topicseen">' . $tmpa . '</a>';
$tmpa++;
}
// Show links to all the pages?
if (count($tmppages) <= 5)
$pages = '« ' . implode(' ', $tmppages);
// Or skip a few?
else
$pages = '« ' . $tmppages[0] . ' ' . $tmppages[1] . ' ... ' . $tmppages[count($tmppages) - 2] . ' ' . $tmppages[count($tmppages) - 1];

if (!empty($modSettings['enableAllMessages']) && $topic_length < $modSettings['enableAllMessages'])
$pages .= '  <a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;all">' . $txt[190] . '</a>';
$pages .= ' »';
}
else
$pages = '';

// We need to check the topic icons exist... you can never be too sure!
if (empty($modSettings['messageIconChecks_disable']))
{
// First icon first... as you'd expect.
if (!isset($icon_sources[$row['firstIcon']]))
$icon_sources[$row['firstIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['firstIcon'] . '.gif') ? 'images_url' : 'default_images_url';
// Last icon... last... duh.
if (!isset($icon_sources[$row['lastIcon']]))
$icon_sources[$row['lastIcon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['lastIcon'] . '.gif') ? 'images_url' : 'default_images_url';
}

$color_start = !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : '';
$color_last = !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : '';

// And build the array.
$topics[$row['ID_TOPIC']] = array(
'id' => $row['ID_TOPIC'],
'first_post' => array(
'id' => $row['ID_FIRST_MSG'],
'member' => array(
'name' => $row['firstPosterName'],
'id' => $row['ID_FIRST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'],
'link' => !empty($row['ID_FIRST_MEMBER']) ? ('<a href="' . $scripturl . '?action=profile;u=' . $row['ID_FIRST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['firstPosterName'] . '">' . ( !empty($modSettings['MemberColorLink']) ? ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']])  ? '<font color="'. ( !empty($groupcolors[$row['mems_group']]) ? $groupcolors[$row['mems_group']] : $groupcolors[$row['mems_pgroup']] ) . '">' : '' ) : '' )  . $row['firstPosterName'] . ((!empty($modSettings['MemberColorLink']) && ( !empty($groupcolors[$row['mems_group']]) || !empty($groupcolors[$row['mems_pgroup']]))) ? '</font>' : '' ) . '</a>' ) : $row['firstPosterName']
),
'time' => timeformat($row['firstPosterTime']),
'timestamp' => forum_time(true, $row['firstPosterTime']),
'subject' => $row['firstSubject'],
'preview' => $row['firstBody'],
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen',
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0;topicseen">' . $row['firstSubject'] . '</a>'
),
'last_post' => array(
'id' => $row['ID_LAST_MSG'],
'member' => array(
'name' => $row['lastPosterName'],
'id' => $row['ID_LAST_MEMBER'],
'href' => $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'],
'link' => !empty($row['ID_LAST_MEMBER']) ? '<a href="' . $scripturl . '?action=profile;u=' . $row['ID_LAST_MEMBER'] . '" title="' . $txt[92] . ' ' . $row['lastPosterName'] . '">' . (!empty($modSettings['MemberColorLink']) ? ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]) ? '<font color="'. ( !empty($groupcolors[$row['meml_group']]) ? $groupcolors[$row['meml_group']] : $groupcolors[$row['meml_pgroup']] ) .'">' : '' ) : '' ) . $row['lastPosterName'] . ((!empty($modSettings['MemberColorLink']) && ( !empty($groupcolors[$row['meml_group']]) || !empty($groupcolors[$row['meml_pgroup']]))) ? '</font>' : '' ) . '</a>' : $row['lastPosterName']
),
'time' => timeformat($row['lastPosterTime']),
'timestamp' => forum_time(true, $row['lastPosterTime']),
'subject' => $row['lastSubject'],
'preview' => $row['lastBody'],
'icon' => $row['lastIcon'],
'icon_url' => $settings[$icon_sources[$row['lastIcon']]] . '/post/' . $row['lastIcon'] . '.gif',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['ID_LAST_MSG']) . ';topicseen#msg' . $row['ID_LAST_MSG'] . '">' . $row['lastSubject'] . '</a>'
),
'new' => $row['isRead'],
'new_from' => $row['new_from'],
'new_href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . '.msg' . $row['new_from'] . ';topicseen#new',
'href' => $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen' . ($row['numReplies'] == 0 ? '' : 'new'),
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . ($row['numReplies'] == 0 ? '.0' : '.msg' . $row['new_from']) . ';topicseen#msg' . $row['new_from'] . '">' . $row['firstSubject'] . '</a>',
'is_sticky' => !empty($modSettings['enableStickyTopics']) && !empty($row['isSticky']),
'is_locked' => !empty($row['locked']),
'is_poll' => $modSettings['pollMode'] == '1' && $row['ID_POLL'] > 0,
'is_hot' => $row['numReplies'] >= $modSettings['hotTopicPosts'],
'is_very_hot' => $row['numReplies'] >= $modSettings['hotTopicVeryPosts'],
'is_posted_in' => false,
'icon' => $row['firstIcon'],
'icon_url' => $settings[$icon_sources[$row['firstIcon']]] . '/post/' . $row['firstIcon'] . '.gif',
'subject' => $row['firstSubject'],
'pages' => $pages,
'replies' => $row['numReplies'],
'views' => $row['numViews'],
'board' => array(
'id' => $row['ID_BOARD'],
'name' => $row['bname'],
'href' => $scripturl . '?board=' . $row['ID_BOARD'] . '.0',
'link' => '<a href="' . $scripturl . '?board=' . $row['ID_BOARD'] . '.0">' . $row['bname'] . '</a>'
)
);

determineTopicClass($topics[$row['ID_TOPIC']]);
}
mysql_free_result($request);

if (!empty($modSettings['enableParticipation']) && !empty($topic_ids))
{
$result = db_query("
SELECT ID_TOPIC
FROM {$db_prefix}messages
WHERE ID_TOPIC IN (" . implode(', ', $topic_ids) . ")
AND ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
while ($row = mysql_fetch_assoc($result))
{
if (empty($topics[$row['ID_TOPIC']]['is_posted_in']))
{
$topics[$row['ID_TOPIC']]['is_posted_in'] = true;
$topics[$row['ID_TOPIC']]['class'] = 'my_' . $topics[$row['ID_TOPIC']]['class'];
}
}
mysql_free_result($result);
}

}

if (!empty($topics))
    {
    echo '
        <div class="tborder" ', $context['browser']['needs_size_fix'] && !$context['browser']['is_ie6'] ? 'style="width: 100%;margin:0px;"' : 'style="margin:0px;"', '>
            <table border="0" width="100%" cellspacing="1" cellpadding="1" class="bordercolor">
                <tr>';

    echo '
                    <td class="titlebg" colspan="7">', $heading, '</td>';
    echo '
                </tr>';

    echo '
<tr class="titlebg">
<td width="10%" colspan="2"> </td>
<td>', $txt[70], '
</td><td width="14%">', $txt[109], '
</td><td width="4%" align="center">', $txt[110], '
</td><td width="4%" align="center">', $txt[301], '
</td><td width="24%">', $txt[111], '
</td>
</tr>';

foreach ($topics as $topic)
{
// Do we want to seperate the sticky and lock status out?
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'sticky') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_sticky'));
if (!empty($settings['seperate_sticky_lock']) && strpos($topic['class'], 'locked') !== false)
$topic['class'] = substr($topic['class'], 0, strrpos($topic['class'], '_locked'));

echo '
<tr>
<td class="windowbg2" valign="middle" align="center" width="6%">
<img src="' . $settings['images_url'] . '/topic/' . $topic['class'] . '.gif" alt="" />
</td><td class="windowbg2" valign="middle" align="center" width="4%">
<img src="' . $topic['first_post']['icon_url'] . '" alt="" align="middle" />
</td><td class="windowbg' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '3' : '' , '" width="48%" valign="middle">' , $topic['is_locked'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/quick_lock.gif" align="right" alt="" style="margin: 0;" />' : '' , $topic['is_sticky'] && !empty($settings['seperate_sticky_lock']) ? '
<img src="' . $settings['images_url'] . '/icons/show_sticky.gif" align="right" alt="" style="margin: 0;" />' : '';
if ($topic['new'] == 0)
{
echo '<b>',  $topic['first_post']['link'], '</b>';
echo '<a href="', $topic['new_href'], '"> <img src="', $settings['images_url'], '/', $context['user']['language'], '/new.gif" alt="', $txt[302], '" /></a>';
}
else
{
echo $topic['first_post']['link'];
}
echo '
<span class="smalltext">', $topic['pages'], '<br>', $txt['smf88'], ' ', $topic['board']['link'], '</span></td>
<td class="windowbg2" valign="middle" width="14%">
', $topic['first_post']['member']['link'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['replies'], '</td>
<td class="windowbg" valign="middle" width="4%" align="center">
', $topic['views'], '</td>
<td class="windowbg2" valign="middle" width="22%">
<a href="', $topic['last_post']['href'], '"><img src="', $settings['images_url'], '/icons/last_post.gif" alt="', $txt[111], '" title="', $txt[111], '" style="float: right;" /></a>
<span class="smalltext">
', $topic['last_post']['time'], '<br />
', $txt[525], ' ', $topic['last_post']['member']['link'], '
</span>
</td>
</tr>';
}

    echo '</table></div>';

    }
else
    echo '<b><u>'.$heading.'<br><br>No Topics Match Search Criteria</u></b>';