Quote from: Spuds – Quote from: Ruth – Maybe Spuds can help us with this code and transform it for ElkArte?   I don't know, if this is possible and how much work it would be. I think, such block is a very needful thing and I would be very glad to use it.
  I don't know, if this is possible and how much work it would be. I think, such block is a very needful thing and I would be very glad to use it.
Give this a try and let me know if its what you want.
 global $context, $settings, $scripturl, $txt, $user_info, $modSettings, $posts, $color_profile;
 $db = database();
 $exclude_boards = null;
 $num_recent = !empty($parameters[0]) ? $parameters[0] : (isset($_GET['limit']) ? (int) $_GET['limit'] : 20);
 $show_body = !empty($parameters[1]) ? $parameters[1] : false;
 if ($exclude_boards === null && !empty($modSettings['recycle_enable']) && $modSettings['recycle_board'] > 0)
 $exclude_boards = array($modSettings['recycle_board']);
 else
 $exclude_boards = empty($exclude_boards) ? array() : $exclude_boards;
 $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';
 // Find all the posts in distinct topics.  Newer ones will have higher IDs.
 $request = $db->query('', '
 SELECT
 m.poster_time, ms.subject, m.id_topic, m.id_member, m.id_msg, b.id_board, t.num_replies, t.num_views, b.name AS bName,
 IFNULL(mem.real_name, m.poster_name) AS poster_name, ' . ($user_info['is_guest'] ? '1 AS is_read, 0 AS new_from' : '
 IFNULL(lt.id_msg, IFNULL(lmr.ID_MSG, 0)) >= m.id_msg_modified AS is_read,
 IFNULL(lt.id_msg, IFNULL(lmr.ID_MSG, -1)) + 1 AS new_from') . ', LEFT(m.body, 384) AS body, m.smileys_enabled, mf.icon
 FROM ({db_prefix}messages AS m, {db_prefix}topics AS t, {db_prefix}boards AS b, {db_prefix}messages AS ms)
 INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
 LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)' . (!$user_info['is_guest'] ? '
 LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = t.id_topic AND lt.id_member = {int:id_member})
 LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = {int:id_member})' : '') . '
 WHERE t.id_last_msg >= ' . ($modSettings['maxMsgID'] - 35 * min($num_recent, 5)) . '
 AND t.id_last_msg = m.id_msg
 AND b.id_board = t.id_board' . (empty($exclude_boards) ? '' : '
 AND b.id_board NOT IN ({array_int:exclude_boards})') . '
 AND {raw:query_see_board}
 AND ms.id_msg = t.id_last_msg
 ORDER BY t.id_last_msg DESC
 LIMIT {int:limit}',
 array(
 'id_member' => $user_info['id'],
 'exclude_boards' => $exclude_boards,
 'query_see_board' => $user_info['query_wanna_see_board'],
 'limit' => (int) $num_recent,
 )
 );
 $posts = array();
 $color_ids = array();
 while ($row = $db->fetch_assoc($request))
 {
 // Shorten the body if needed
 if ($show_body)
 {
 $ellip = '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.0" title="' . $row['subject'] . '">…</a>';
 $row['body'] = Util::shorten_html(parse_bbc($row['body'], $row['smileys_enabled'], $row['id_msg']), 128, $ellip, false);
 censorText($row['body']);
 }
 // Censor the subject.
 $row['subject'] = preg_replace('/^' . preg_quote($txt['response_prefix']) . '/', '', $row['subject']);
 censorText($row['subject']);
 // Collect the color ids :)
 $color_ids[$row['id_member']] = $row['id_member'];
 if (empty($modSettings['messageIconChecks_disable']) && !isset($icon_sources[$row['icon']]))
 $icon_sources[$row['icon']] = file_exists($settings['theme_dir'] . '/images/post/' . $row['icon'] . '.png') ? 'images_url' : 'default_images_url';
 // Build the array.
 $posts[] = array(
 '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>'
 ),
 'topic' => $row['id_topic'],
 'poster' => array(
 'id' => $row['id_member'],
 'name' => $row['poster_name'],
 'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
 'link' => empty($row['id_member']) ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_name'] . '</a>'
 ),
 'subject' => $row['subject'],
 'short_subject' => Util::shorten_text($row['subject'], 25),
 'preview' => $show_body ? $row['body'] : '',
 'time' => standardTime($row['poster_time']),
 'timestamp' => forum_time(true, $row['poster_time']),
 'href' => $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . ';topicseen#new',
 'link' => '<a href="' . $scripturl . '?topic=' . $row['id_topic'] . '.msg' . $row['id_msg'] . '#new">' . $row['subject'] . '</a>',
 'new' => !empty($row['is_read']),
 'new_from' => $row['new_from'],
 'icon' => '<img src="' . $settings[$icon_sources[$row['icon']]] . '/post/' . $row['icon'] . '.png" style="vertical-align: middle;" alt="' . $row['icon'] . '" />',
 'views' => $row['num_views'],
 'replies' => $row['num_replies'],
 );
 }
 $db->free_result($request);
 // Colorization
 if (!empty($color_ids) && sp_loadColors($color_ids) !== false)
 {
 foreach ($posts as $key => $value)
 {
 if (!empty($color_profile[$value['poster']['id']]['link']))
 $posts[$key]['poster']['link'] = $color_profile[$value['poster']['id']]['link'];
 }
 }
 $context['recent_topics'] = $posts;
 // Just return if we have no results
 if (empty($posts))
 return $txt['error_sp_no_posts_found'];
 echo '
 <div>';
 foreach ($posts as $post)
 {
 echo '
 <div style="display: table-cell; padding: 0 8px" class="centericon">
 ', $post['icon'], '
 </div>
 <div class="" style="display: table-cell">
 <a href="', $post['href'], '">', $post['subject'], '</a>
 ', $post['new'] ? '' : '<a href="' . $scripturl . '?topic=' . $post['topic'] . '.msg' . $post['new_from'] . ';topicseen#new" rel="nofollow"><span class="new_posts"> ' . $txt['new'] . '</span></a>';
 echo '
 <div class="middletext">
 ', $txt['by'], ' ', $post['poster']['link'], ' ', $txt['in'], ' ', $post['board']['link'], '
 </br />
 ', $post['time'], ' | ', $txt['views'], ': ', $post['views'], ' | ', $txt['replies'], ': ', $post['replies'], '
 </div>';
 
 if ($show_body)
 echo '
 <div class="middletext">
 ', $post['preview'], '
 </div>';
 
 echo '
 </div>
 <hr>';
 }
 echo '
 </div>';