TinyPortal

Development => Support => Topic started by: darkangel on April 20, 2012, 01:22:56 AM

Title: top posters block problem
Post by: darkangel on April 20, 2012, 01:22:56 AM
I entered this code (from a post which I can not find at mo) into a php block. It is mainly for another admn to be able to see and encourage the top posters to get to a certain goal or egg a lagger on...prely for amusement of the members....lol

He noticed that when looking for one of our newer member count total, she does not appear and although we have it set for 29 to show in listing....hers is not there. Those that are there are having their posts counts increasing...as they should

how to get this gals count to show in the box, is there a setting I forgot to set in admin/tp? I ran upgrade.php to see if that would help with the ongoing problems too...lol

global $smcFunc, $scripturl, $modSettings;

// Height and width of avatar
$width = '40px';
$height = '40px';
// Number of top posters displayed
$topPoster = 29;

// Find the latest poster.
$request = $smcFunc['db_query']('', '
SELECT mem.id_member, mem.show_online, mem.real_name, mem.posts, mem.avatar, a.id_attach, a.attachment_type, a.filename
FROM ({db_prefix}members as mem)
LEFT JOIN {db_prefix}attachments AS a ON (a.id_member = mem.id_member)
WHERE show_online = 1
ORDER BY posts DESC
LIMIT {int:limit}',
array('limit' => $topPoster)
);

$users = array();

while ($row = $smcFunc['db_fetch_assoc']($request))
{
$users[] = array(
'id' => $row['id_member'],
'name' => $row['real_name'],
'href' => $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['real_name'] . '</a>',
'posts' => $row['posts'],
'show' => $row['show_online'],
'avatar' => array(
    'image' => empty($row['avatar']) ? ($row['id_attach'] > 0 ? 'src="' . (empty($row['attachment_type']) ? $scripturl . '?action=dlattach;attach=' . $row['id_attach'] . ';type=avatar' : $modSettings['custom_avatar_url'] . '/' . $row['filename']) . '" alt="" border="0" width="'.$width.'" height="'.$height.'" title="'.$row['real_name'].'" />' : '') : (stristr($row['avatar'], 'http://') ? 'src="' . $row['avatar'] . '" alt="" border="0" width="'.$width.'" height="'.$height.'" title="'.$row['real_name'].'" />' : 'src="' . $modSettings['avatar_url'] . '/' . htmlspecialchars($row['avatar']) . '" alt="" border="0" width="'.$width.'" height="'.$height.'" title="'.$row['real_name'].'" />'),
    ),
);
}

$smcFunc['db_free_result']($request);

// Output our array of users with avatar, posts, and name
echo '
<table cellpadding="0" cellspacing="8">';

foreach ($users as $user)
{
echo '
<tr>
<td>',empty($user['avatar']['image']) ? '<a href="'.$user['href'].'"><img src="'.$settings['images_url'].'/noavatar.gif" width="'.$width.'" height="'.$height.'" alt="" title="'.$user['name'].'" /></a>' : '<a href="'.$user['href'].'"><img '.$user['avatar']['image'].'</a>';
echo '
</td>
<td><h5 style="margin: 4px;">'.$user['link'].'</h5><h5 style="margin: 4px;">'. $user['posts'] .'</h5></td>
</tr>';
}

echo '
</table>';
Title: Re: top posters block problem
Post by: IchBin on April 20, 2012, 04:06:34 AM
Sorry, your explanation is very hard to follow. Does the member have their online status as hidden?
Title: Re: top posters block problem
Post by: darkangel on April 20, 2012, 06:02:35 AM
1. when you go to my site and look near bottom left at the posters block you will see that Wenchie does not appear in the listing with her 345 posts.

Me being admin I can see when she is online but looking at her profile I see that the checkbox for online status is not ticked...does that mean she appears not to others and only to admin?

if so then is that why she does not appear in the block to anyone incuding admins?


http://thefantasiesattic.net/attic/index.php?action=forum
Title: Re: top posters block problem
Post by: ZarPrime on April 20, 2012, 06:39:43 AM
That's probably why she doesn't appear in the Top Posters block but I'm not sure.  If her online status is hidden in her profile account settings, Admins will see her in the "Users Online" section of the Stats block but her name will be in italics.  Try setting your Online Status to hidden as well and see if you disappear from the Top Posters block.

ZarPrime
Title: Re: top posters block problem
Post by: darkangel on April 20, 2012, 06:47:36 AM
I did just that and yup poof it went...lol

I have sent her a pm asking if I may set her to visible so she can appear in the block but left it totally up to her for yes or no.

thanks
Title: Re: top posters block problem
Post by: ZarPrime on April 20, 2012, 06:53:56 AM
I kind of figured that's what it was. ;)

ZarPrime
Title: Re: top posters block problem
Post by: IchBin on April 20, 2012, 04:17:07 PM
You can show users online (even if they are set not to show), but only for admins.

Add $context to the global line. And then change the WHERE section of the query to this:
WHERE ' .($context['user']['is_admin'] ? '1' : 'show_online = 1') . '

Title: Re: top posters block problem
Post by: darkangel on April 20, 2012, 06:22:36 PM
Thanks that will help alot. You are so kind to me love you all here. :-*

change this:          WHERE show_online = 1


to your line above?

of course you know this is going to appease that admin but eventually he is gonna have to face the fact....unless he wants to have an entire loooooong block --- once the ones showing get higher in posts the newer ones probably won't show cause the highest ones will be in the top slots...they are set to show 29 users posts...lol
Title: Re: top posters block problem
Post by: IchBin on April 20, 2012, 08:03:17 PM
Yes just change that line and it should. Don't forget to add the $context variable to the top global line though.
Title: Re: top posters block problem
Post by: darkangel on April 20, 2012, 09:45:36 PM
ok will do, thanks