News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

View forum statistics - Guests

Started by SnowWidow, March 03, 2011, 10:42:15 AM

Previous topic - Next topic

SnowWidow

I've done searches on this and found threads about this, but still can't understand why.

In Guest permissions why is it that when View forum statistics and View Who's Online is unchecked, guests are still able to see it? Checking/Unchecking doesn't change anything.

I'm running RC4.

Arantor

It doesn't change the front panel, but the icons on the front panel link to more complex pages, specifically view forum statistics goes to a page like http://www.simplemachines.org/community/index.php?action=stats and view who's online goes to a page like http://www.simplemachines.org/community/index.php?action=who

It is these more detailed pages that are disabled.


SnowWidow

Ok that makes sense and now I understand what that does  :laugh: Seem sorta like an idiot now.

I'm trying to figure out how to stop guests from seeing the "View the most recent posts on the forum" link.

Arantor

There's actually no direct way to do that without a code modification - but the posts in there will be ones only visible to guests anyway; it's not like guests will be able to see things they're not supposed to.

SnowWidow

Could you point me to that code modification? I would love to have guests not be able to use that link.

Arantor

Themes/default/BoardIndex.template.php (and something similar for any BoardIndex.template.php files in any custom themes you might have)

Code (find) Select
<span class="ie6_header floatleft">
<a href="', $scripturl, '?action=recent"><img class="icon" src="', $settings['images_url'], '/post/xx.gif" alt="', $txt['recent_posts'], '" /></a>
', $txt['recent_posts'], '
</span>


Code (replace) Select
<span class="ie6_header floatleft">
<img class="icon" src="', $settings['images_url'], '/post/xx.gif" alt="', $txt['recent_posts'], '" />
', $txt['recent_posts'], '
</span>


Note that it won't stop them going there if they already knew about the link, it just hides the fact it's there. To fix that, edit Sources/Recent.php and find this code:
function RecentPosts()
{
global $txt, $scripturl, $user_info, $context, $modSettings, $sourcedir, $board, $smcFunc;


After it, on the next line add:
is_not_guest();

This will make it so guests can't use that page.

SnowWidow

That was it. Thank you VERY much for your help!

pxwee5

Sorry for reviving dead thread.

I'm on 2.0.8

I'm not sure this has been fixed or not, but I tested it by setting Guest, unchecking the "View Board Statistics", in "Permission".

It still shows the board statistic when I entered
http://www.simplemachines.org/community/index.php?action=stats

By default unchecking the "View Board Statistics" should disable
- http://www.simplemachines.org/community/index.php?action=stats
- Forum Stats at the bottom of the page
(I know it doesn't matter, but I'm just sharing common sense)

Arantor

From the standard code in 2.0.8 it would appear to do that very thing. Internally the permission to view stats is called 'view_stats'.

Early in Stats.php where the stats page is built, we see a permissions check on it - line 43.

As for the board index, line 90 of the main board index handler sets $context['show_stats'] with a permissions check, and line 398 of the board index template has a conditional to only display the link is $context['show_stats'] is true.

If it is not functioning that way for you, something else is wrong.

Advertisement: