how to ignore the topic for this query and keep messages

Started by Dhayzon, August 29, 2016, 05:44:49 PM

Previous topic - Next topic

Dhayzon


as ignoring the issues and keep only the answers
I have this query


global $smcFunc, $scripturl, $sourcedir, $modSettings, $user_info, $settings, $context;
global $vpb_start, $vpb_total;

$posts_result = $smcFunc['db_query']('', '
   SELECT u.real_name, m.poster_time, m.id_msg, t.id_member_updated, m.subject, m.body, m.id_topic, b.name,
    t.id_last_msg, t.id_board, u.avatar,g.group_name, g.online_color,' . ($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') . '
FROM {db_prefix}topics AS t
LEFT JOIN {db_prefix}boards AS b ON (t.id_board = b.id_board)
LEFT JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_last_msg)
LEFT JOIN {db_prefix}members AS u ON (t.id_member_updated = u.id_member)
LEFT JOIN {db_prefix}membergroups AS g ON (g.id_group = CASE WHEN u.id_group = 0 THEN u.id_post_group ELSE u.id_group END)
' . (!$user_info['is_guest'] ? '
LEFT JOIN {db_prefix}log_topics AS lt ON (lt.id_topic = m.id_topic AND lt.id_member = ' . $user_info['id'] . ')
LEFT JOIN {db_prefix}log_mark_read AS lmr ON (lmr.id_board = b.id_board AND lmr.id_member = ' . $user_info['id'] . ')' : '') . '     
WHERE m.approved=1 AND m.poster_time > 0
AND b.id_board  AND {query_see_board}
ORDER BY t.id_last_msg DESC
   LIMIT  '.$vpb_total.'
   OFFSET '.$vpb_start
   );

$posts = array();

while ($row_posts = $smcFunc['db_fetch_assoc']($posts_result))
{

      global $memberContext;
      loadMemberData($row_posts['id_member_updated']);
      loadMemberContext($row_posts['id_member_updated']);
      $memberContext[0] = array( 'id' => '0','avatar' =>  array('href' =>'0'),);


   $posts[] = array(
  'id' => $row_posts['id_member_updated'],
  //'rango' => $row_posts['id_member_updated']['post_group'],
      'username' => '<a style="color: ' . $row_posts['online_color'] . ';"  href="' . $scripturl . '?action=profile;u=' . $row_posts['id_member_updated'] . '">' . $row_posts['real_name'] . '</a>',
      'subject' => '<a href="' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new">' . $row_posts['subject'] . '</a>',
      'body' => $row_posts['body'],
      'coment' => '' . $scripturl . '?topic=' . $row_posts['id_topic'] . '.msg' . $row_posts['id_last_msg'] . ';topicseen#new',
  'avatar' => $row_posts['avatar'] == '' ? $memberContext[$row_posts['id_member_updated']]['avatar']['href'] : (stristr($row_posts['avatar'], 'http://') ? $row_posts['avatar'] : $modSettings['avatar_url'] . '/' . $row_posts['avatar']),
  'board' => $row_posts['name'],
  'online_color' => $row_posts['online_color'],
  'group_name' => '<span  class="label" style="background: ' . $row_posts['online_color'] . ';">'.$row_posts['group_name'].'</span>',
  'board_id' => $row_posts['id_board'],
  'time' => timeformat($row_posts['poster_time']),
  'new' => !empty($row_posts['is_read']),
    );
}
$smcFunc['db_free_result']($posts_result);

return $posts;



Matthew K.

Hey there,

Sorry that your question still has not been addressed. Can you explain what exactly (more clearly) you're wanting to do?

Cheers.

Dhayzon

show the latest comments from the community, and ignore the topics?

:'(

Advertisement: