vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Ignoring private forum's post/thread count in statistics (https://vborg.vbsupport.ru/showthread.php?t=298338)

Cable_Player 05-20-2013 08:02 PM

Ignoring private forum's post/thread count in statistics
 
Hello,
I've used phpBB for some time now and have some code (which I now don't use as an actual modification has replaced it) which makes my private forum's post and topic count get ignored in the forum's overall statistics on the index page.

This is the code I was using for phpBB, I don't know if it'll be any use here at all:

Quote:

Open:
root/index.php

Find:
Code:

$l_total_user_s = ($total_users == 0) ? 'TOTAL_USERS_ZERO' : 'TOTAL_USERS_OTHER';
$l_total_post_s = ($total_posts == 0) ? 'TOTAL_POSTS_ZERO' : 'TOTAL_POSTS_OTHER';
$l_total_topic_s = ($total_topics == 0) ? 'TOTAL_TOPICS_ZERO' : 'TOTAL_TOPICS_OTHER';

After, Add:
Code:

$sql = 'SELECT forum_id, forum_posts, forum_topics
        FROM ' . FORUMS_TABLE . '
        WHERE ' . $db->sql_in_set('forum_id', array(FORUM_ID, FORUM_ID2));
$result = $db->sql_query($sql);
$hidden_posts = 0;
$hidden_topics = 0;
while ($row = $db->sql_fetchrow($result))
{
    $hidden_posts += $row['forum_posts'];
    $hidden_topics += $row['forum_topics'];
}
$db->sql_freeresult($result);
$total_posts  = $config['num_posts'] - $hidden_posts;
$total_topics  = $config['num_topics'] - $hidden_topics;

Now replace "FORUM_ID, FORUM_ID2" with the correct forum ID's
I was hoping somebody could help me replicate it's effects on vB 4.2.1
I have some private forums (my staff forums at the moment) and the post and thread count from those forums is being counted in the overall statistics. This isn't so bad for boards with hundreds of thousands of posts because it isn't really noticeable, but for a forum which is only just launching people are going to ask where all of these extra posts are!!

Thank you.

nerbert 05-21-2013 12:27 AM

If I understand correctly you just want to reduce your post count by the number of old posts. I see you can edit post counts in the user manager. As long as you don't rebuild the post count in the maintenance part it should just count up from whatever number you edit in

Cable_Player 05-21-2013 06:03 AM

Hello,
No, I'm wanting to have the board index's statistics update to ignore the private forums.
At the bottom of every forum you've got the <Board Name> Statistics.

"Threads x Posts xx Members x Active Members x
Welcome to our newest member,"

When you create a private forum (one that only selected members can see) you can set it so their posts do not count towards their post count.
What I want is that their posts do not count towards the site statistics.

I hope that's clearer :)

Lynne 05-21-2013 02:42 PM

The $totalthreads and $totalposts is totalled up around line 620 of the forum.php file. So, it's probably easier to just not add in the $totalthreads and $totalposts from that forum. Put a condition around the lines like this:

PHP Code:

        if ($forum['forumid'] != xx) {
        
$totalthreads += $forum['threadcount'];
        
$totalposts += $forum['replycount'];
        } 

Change xx to the forum you don't want to include in the thread/post count.

Cable_Player 05-21-2013 09:08 PM

Fantastic, thank you. And if I were to include multiple forums would it simply be a case of putting a comma ',' between forum ID's?

Lynne 05-22-2013 02:09 AM

You would use something more like this:

PHP Code:

        if (!in_array($forum['forumid'], array (xyz))) {
        
$totalthreads += $forum['threadcount'];
        
$totalposts += $forum['replycount'];
        } 


Cable_Player 05-22-2013 02:38 PM

Brilliant, thank you. I'll give it a go now.

--------------- Added [DATE]1369237493[/DATE] at [TIME]1369237493[/TIME] ---------------

Hmm, it doesn't seem to have worked. I've refreshed the statistics, post counts and topic counts as well as cleared the system cache but no changes.

This is what I've got line 618 - 628 of root/forum.php
PHP Code:

if (is_array($vbulletin->forumcache))
{
    foreach (
$vbulletin->forumcache AS $forum)
    {
        if (
in_array($forum['forumid'], array (1011121314)))
        {
        
$totalthreads += $forum['threadcount'];
        
$totalposts += $forum['replycount'];
        }  
    }



Cable_Player 05-26-2013 06:54 PM

Has there been any progress on this?
Thanks

Lynne 05-26-2013 08:13 PM

I put that exact code (only different forumids) into the forum.php file on my test site and it changed the stats on the forum.php page.

Simon Lloyd 05-26-2013 08:21 PM

I assume it's because the figures have already been consolidated in the database.

Cable_Player 05-29-2013 05:49 PM

I've double checked my edits but it won't update the stats unfortunately. Even after new posts are made in the forums I've listed to be ignored, the stats continue to update as normal.

Lynne 05-29-2013 08:21 PM

The stats under where it says Site Statistics? And you added in the forumids for the child forums, not just the parent forum?

Cable_Player 05-29-2013 10:21 PM

Yep, those statistics. I placed the category ID and all forum ID's within that category in the code.

Lynne 05-30-2013 01:44 AM

I honestly don't know why it wouldn't work for you as it works just fine on my test site with no modifications.

Cable_Player 05-30-2013 05:40 AM

I'll have a closer look, I might be able to spot if any modifications are getting in the way. Thank you for your help :)

--------------- Added [DATE]1369910733[/DATE] at [TIME]1369910733[/TIME] ---------------

Hello again,
What I've done is removed the private forum ID's and replaced them with forums I do wish to have shown in the statistics - this has now worked, the private forums are now excluded.

I think I may have just misunderstood the instruction. So, the forum ID's I need to enter are the forums I do want to be counted for the statistics, is it possible to change it so that the ID's I enter are the forums I do not wish to be counted for the statistics?
I'm going to have a lot more public forums than I would private forums if you understand what I mean.

Thanks

Lynne 05-30-2013 11:41 PM

It sounds like you forgot the ! at the beginning of the condition:

Code:

if (!in_array($forum['forumid'], array (x, y, z))) {

Zachery 05-31-2013 12:44 AM

Lynnes original code shows that you have to list each and every forum (and subforum) that you don't want to be counted.

Cable_Player 06-01-2013 02:17 AM

That's done the trick, I have no idea why the ! wasn't there, I copy/pasted the code you provided.

Having included exclamation mark it now works as I wanted it to.

Thank you very much for your help and time :)


All times are GMT. The time now is 05:50 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01824 seconds
  • Memory Usage 1,763KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (18)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete