vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.6 Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=194)
-   -   Mini Mods - Users posts (https://vborg.vbsupport.ru/showthread.php?t=133636)

becafuel 12-09-2006 10:00 PM

Users posts
 
This small mod will tell you some small stats about where a member is posting : in which forums and what it represents against his total number of messages (see screenshot below. sorry it's a french screenshot ).
It respects your forums ordering and groups them by category, with a total by category.

Php code to place in the "modcp" dir, filename "usermess.php" :
PHP Code:

<?php
// ######################## usermess.php ###########################
//
// Quick stats for member's number of messages.
//
// Auteur : Bec ? Fuel
// Date   : December, 10 2006
// Version : 1.2

// ######################## SET PHP ENVIRONMENT ###########################
error_reporting(E_ALL & ~E_NOTICE);
@
set_time_limit(0);
 
// #################### PRE-CACHE TEMPLATES AND DATA ######################
$phrasegroups = array('style','cpuser','user','forum','search');
$specialtemplates = array('products');

// ########################## REQUIRE BACK-END ############################
require_once('./global.php');
require_once(
DIR '/includes/functions.php');

$phrase_percentage "Par rapport au total";

print_cp_header($vbphrase['user_manager']);
print_form_header('usermess','usermess',false,true);
print_table_header($vbphrase['search_users']);
print_input_row($vbphrase['username'],'membre',$membre,true);
print_submit_row($vbphrase['find']);  

if (
$_REQUEST['do'] == 'usermess')
  {
    
$membre $vbulletin->input->clean_gpc('p''membre'TYPE_STR);
    
$result $db->query_read("SELECT userid, username FROM "TABLE_PREFIX ."user WHERE username='".$membre."'");
    if (!
$db->num_rows($result) > 0)
      {
        
define('CP_REDIRECT''usermess.php');
        
print_stop_message('no_users_matched_your_query');
      }
    else
      {
        
print_table_footer();
        
print_form_header('usermess','usermess',false,true);
        
$r $db->fetch_array($result);
        
$userid $r['userid'];
        
print_table_break();
        
print_table_header($vbphrase['posts_made_by'].' '.$r['username'].' (id:'.$userid.')',4);
        
$total = array();
        
$tabparent = array();
        
$totalstr = array();
        
$result $db->query_read ("SELECT parentlist,title_clean,forumid FROM "TABLE_PREFIX ."forum WHERE parentid=-1 ORDER BY forumid");
        while (
$r $db->fetch_array($result))
          {
            
$tabparent[] = '%,'.$r['parentlist'];
            
$totalstr[] = $r['title_clean'];
          }
        
$totalgen 0;
        
$result $db->query_read ("SELECT COUNT(postid) AS nbmess FROM "TABLE_PREFIX ."post WHERE visible=1 AND userid=".$userid." GROUP BY userid");
        
$r $db->fetch_array($result);
        
$totalcalc $r['nbmess'] ? $r['nbmess'] : 1;
        
        
$forums = array();
        foreach (
$vbulletin->forumcache AS $forumid => $forum)
          {
            
$forums["$forum[forumid]"] = construct_depth_mark($forum['depth']-1'- - ') . ' ' $forum['title'];
          }
        
$tab2 = array();
        foreach (
$vbulletin->forumcache AS $key => $forum)
          {
            if (
$forum['parentid'] == -1) { $tab2[] = $forum['title']; }
          }
        
$i 0;
        foreach (
$vbulletin->forumcache AS $key => $forum)
          {
            if (
$forum['parentid'] == -1)
              {
                if (
$i 0) { print_cells_row(array('',$vbphrase['category']." : <q>".$tab2[$i-1]."</q>".$last,vb_number_format($total[$i-1],0,false,',',' ')."</span>",vb_number_format($total[$i-1]/$totalcalc*100,2,false,',',' ')." %"),true);  }
                
print_table_break();
                
$totalgen += $total[$i-1];
                
$i++;
                
$total[$i] = 0;
                
print_cells_row(array($vbphrase['forum'],'',$vbphrase['messages'],$phrase_percentage),1);
              }
            else
              {
                
$result $db->query_read ("SELECT "TABLE_PREFIX ."forum.parentid,"TABLE_PREFIX ."forum.title, COUNT("TABLE_PREFIX ."post.postid) AS nbmess
                                    FROM "
TABLE_PREFIX ."post
                                    LEFT JOIN "
TABLE_PREFIX ."thread ON ("TABLE_PREFIX ."post.threadid="TABLE_PREFIX ."thread.threadid)
                                    LEFT JOIN "
TABLE_PREFIX ."forum ON ("TABLE_PREFIX ."forum.forumid="TABLE_PREFIX ."thread.forumid)
                                    WHERE "
TABLE_PREFIX ."post.visible=1 and userid=".$userid." AND "TABLE_PREFIX ."forum.forumid=".$forum['forumid']."
                                    GROUP BY "
TABLE_PREFIX ."thread.forumid");
                
$r $db->fetch_array($result);
                if (
$r['parentid'] == -1) {  $last $forum['title']; }
                
$total[$i-1] += $r['nbmess'];         

                
$cell = array();
                
$cell[] = construct_depth_mark($forum['depth']-1'- - ') . $forum[title];
                
$cell[] = '';
                
$cell[] = vb_number_format($r['nbmess'],0,false,',',' ');
                
$cell[] = vb_number_format($r['nbmess']/$totalcalc*100,2,false,',',' ')." %";

                
print_cells_row($cell,false,false,0,'top',false,true);
              }
          }
        
print_cells_row(array('',$vbphrase['category']." : <q>".$tab2[$i-1]."</q>",vb_number_format($total[$i-1],0,false,',',' '),vb_number_format($total[$i-1]/$totalcalc*100,2,false,',',' ')." %"),true);
        
print_table_break();
        
$totalgen += $total[$i-1];
        
print_table_header($vbphrase['total_posts'].' : '.vb_number_format($totalgen,0,false,',',' '),4);     
        
        
print_cp_footer();
      }
  }
?>

Module to create using "mod_index_navigation" hook (choose a name you like for this module) :
PHP Code:

construct_nav_spacer();
construct_nav_option('Number of messages''usermess.php?');
construct_nav_group('Menu title'); 

I hope you will enjoy this. It's not a great mod, but I think it can be useful or at least handy, though.

Last changes :
v1.2
  • Forum list correctly ordered to reflect layout order
  • Now showing forum with no messages
  • Added new variable for a non-translated text


v1.1
  • Replace some hardcoded string with vbphrases
  • Correct division by 0 for forums with no posts
  • Added cosmetics to display categories headers & footers

ragtek 12-10-2006 08:40 AM

thx
looks fine
the only thing i would change is on the picture because i dont know how to say it



this i changed but the sum isnt right

PHP Code:

            $total[$i] = 0;
             while (
$r $db->fetch_array($result))
              {
                
print_cells_row (array($r['title'],$parent,vb_number_format($r['nbmess'],0,false,',',' '),vb_number_format($r['nbmess']/$totalcalc*100,2,false,',',' ')." %"),false,false,0,'top',false,true);
                
$total[$i] += $r['nbmess'];
              }
 
print_cells_row(array("","Total in <q>".$totalstr[$i]."</q>",vb_number_format($total[$i],0,false,',',' '),vb_number_format($total[$i]/$totalcalc*100,2,false,',',' ')." %"),true);          
            
$totalgen += $total[$i];
          } 

into:

PHP Code:

            $total[$i] = 0;
             
print_cells_row(array("","Total in <q>".$totalstr[$i]."</q>",vb_number_format($total[$i],0,false,',',' '),vb_number_format($total[$i]/$totalcalc*100,2,false,',',' ')." %"),true);
            while (
$r $db->fetch_array($result))
              {
                
print_cells_row (array($r['title'],$parent,vb_number_format($r['nbmess'],0,false,',',' '),vb_number_format($r['nbmess']/$totalcalc*100,2,false,',',' ')." %"),false,false,0,'top',false,true);
                
$total[$i] += $r['nbmess'];
              }
           
            
$totalgen += $total[$i];
          } 


ragtek 12-10-2006 08:57 AM

then we change the hook into admin_index_navigation and sim sala bim its here*g*

sorry my changes wount work so don't do the change*g*

ragtek 12-10-2006 09:25 AM

Quote:

Originally Posted by Mike-D (Post 1135582)
German Moin Daniel ;)
ich kapier das nicht!!! Hooks? Warum? Wieso kann ich den Hack denn nicht direkt in die "cpnav_vbulletin.xml" einbinden? Kl?r mich doch bitte mal auf, da ich von den Hooks Ged?ns ?berhaupt keine Ahnung habe https://vborg.vbsupport.ru/external/2010/01/19.gif

also
direkt wird dort nichts eingebunden ;)
die cpnav_vbulletin greifen wir NICHT AN ;)
sondern du erstellst eine cpnav_mike.xml im includes/xml verzeichniss und schreiben folgendes rein

Code:

<navgroups master="false">

        <navgroup phrase="users" permissions="canadminusers" displayorder="110">


                <navoption displayorder="100">
                        <text>text der du hier habn willst</text>
                        <link>der link dazu</link>
                </navoption>

        </navgroup>

</navgroups>

so dsa wars :)

becafuel 12-10-2006 09:48 AM

Two main reasons for putting it in modcp :
  • I think it should be available to moderators
  • It's easier to put in there ;) I mean in terms of manipulations. But either way has its own pro & con.
Btw, I'm currently modifying the code to reflect some changes :
  • Adding a header and a footer for each category, with some space between them
  • Replacing hard-coded string with vbphrases as much as possible (that was funny to see the mix of languages in your screenshot ;) )
I think this will be online very soon. And thank you for you reports.

Quote:

Originally Posted by Mike-D (Post 1135580)
I'm a lil bit confused about the "contruct_nav" things. Can you help me? -Mike

You add all your options then at the end the title. Not harder than that ;)
PHP Code:

construct_nav_spacer();
construct_nav_option('option 1''prog1.php?');
construct_nav_option('option 2''prog2.php?');
construct_nav_option('option 3''prog3.php?');
construct_nav_option('option 4''prog4.php?');
construct_nav_group('Title'); 


hurik 12-10-2006 10:28 AM

hi becafuel,

nice add on but i have two suggestions:
- he doesn't sort the forum the right way.
- i would show forum without post too. you could easier compare and find anything when every forum is always on his place.

hurik

becafuel 12-10-2006 10:54 AM

I have modified the code in the first post to accomodate with suggestions from feedback.

What do you think of it, now ?


Quote:

Originally Posted by hurik (Post 1135608)
- he doesn't sort the forum the right way.

Do you have any example or screenshot ?

Quote:

Originally Posted by hurik (Post 1135608)
- i would show forum without post too. you could easier compare and find anything when every forum is always on his place.

Ok for forum with 0 messages. What about an option for this : "Display forum without messages ? yes/no"

hurik 12-10-2006 02:48 PM

Quote:

Originally Posted by becafuel (Post 1135615)
Ok for forum with 0 messages. What about an option for this : "Display forum without messages ? yes/no"

tahat would be very nice.

Quote:

Originally Posted by becafuel (Post 1135615)
Do you have any example or screenshot ?

see my attachment.

and look at: http://www.portablegaming.de/forumdisplay.php?f=3

and the categorys are not soreted right tot.
gameboy advance should be the 3th category but it is the first.
http://www.portablegaming.de

ragtek 12-10-2006 04:11 PM

because the order
then someone must build the displayorder into the query ;)
i think that will not be enought...

becafuel 12-10-2006 04:40 PM

In fact, I am actually ordering by forumid, which is not the real display order (except on my forum, hence the confusion ;) )
I am working on it but it will take a little longer to code because it's not only a matter of query...


All times are GMT. The time now is 09:08 AM.

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.01374 seconds
  • Memory Usage 1,877KB
  • 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
  • (1)bbcode_code_printable
  • (5)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete