Back to vBulletin 3.6 Add-ons

Users posts
Mod Version: 1.2, by becafuel

This modification is in the archives.
vB Version: 3.6.2 Rating: (2 votes - 5.00 average) Installs: 28
Released: 10 Dec 2006 Last Update: Never Downloads: 8
Not Supported Uses Plugins Additional Files  

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

Download

No files for download.

Screenshots

Click image for larger version
Name:	ScreenShot152.jpg
Views:	1146
Size:	115.4 KB
ID:	57788  


vblts.ru supports vBulletin®, 2022-2024