Adding secondary membergroup information to Top Posters block

Started by Biology Forums, March 07, 2015, 02:14:11 AM

Previous topic - Next topic

Biology Forums

The following code produces the top posters on my forum:

$request = db_query("
      SELECT IFNULL(a.ID_ATTACH, 0) AS ID_ATTACH, a.filename, a.attachmentType, me.ID_MEMBER, avatar, me.avatar, me.realName, COUNT(*) as count_posts
      FROM {$db_prefix}messages AS m
         LEFT JOIN {$db_prefix}members AS me ON (me.ID_MEMBER = m.ID_MEMBER)
         LEFT JOIN {$db_prefix}attachments AS a ON (a.ID_MEMBER = me.ID_MEMBER)
      WHERE m.posterTime > " . $starttime . "
         AND m.ID_MEMBER != 0
      GROUP BY me.ID_MEMBER
      ORDER BY count_posts DESC
      LIMIT $topNumber", __FILE__, __LINE__);
         
   $context['top_posters_week'] = array();
   $max_num_posts = 1;
   $first_poster_flag = true;
   while ($row_members = mysql_fetch_assoc($request))
   {
        if($first_poster_flag) {
$style = '" style="width: 30px; height: 30px;';
            $first_poster_flag = false;
        } else {
        // Height and width of avatar
$style = ' avatar_small';
        }
      $context['top_posters_week'][] = array(
         'name' => $row_members['realName'],
         'id' => $row_members['ID_MEMBER'],
         'num_posts' => $row_members['count_posts'],
         'href' => $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'],
'avatar' => array(
            'image' => $row_members['avatar'] == '' ? ($row_members['ID_ATTACH'] > 0 ? '<img onerror="imgError(this);" class="avatarfriends'.$style.'" src="' . (empty($row_members['attachmentType']) ? $scripturl . '?action=dlattach;attach=' . $row_members['ID_ATTACH'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row_members['filename']) . '" alt="" title="'.$txt[92].' '.$row_members['realName'].'" />' : '<img onerror="imgError(this);" class="avatarfriends'.$style.'" src="'.$settings['images_url'].'/noavatar.gif" alt="" title="'.$txt[92].' '.$row_members['realName'].'" />') : (stristr($row_members['avatar'], 'http://') ? '<img onerror="imgError(this);" src="' . $row_members['avatar'] . '" alt="" class="avatarfriends'.$style.'" border="0" />' : '<img onerror="imgError(this);" src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row_members['avatar']) . '" alt="" class="avatarfriends'.$style.'" title="'.$txt[92].' '.$row_members['realName'].'" />'),
            ),

                'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row_members['ID_MEMBER'] . '" title="'.$txt[92].' '.$row_members['realName'].'">' . $row_members['realName'] . '</a>'
      );

      if ($max_num_posts < $row_members['count_posts'])
         $max_num_posts = $row_members['count_posts'];

   }
   mysql_free_result($request);


What I would like to do is, if the member is in membergroup 5, for example, show [M] beside the name. If the member is in membergroup 2, show . If the member possesses two secondary membergroups, like 2 and 5, show [M].

How do you suppose I can accomplish this on SMF 1.x?

Advertisement: