Posts this month (Viewprofile)

All new MODs released in our MOD Database will be announced in here. All support for released MODs needs to take place in here. No new MODs will be accepted into the MOD Database for phpBB2
Forum rules
READ: phpBB.com Board-Wide Rules and Regulations

On February 1, 2009 this forum will be set to read only as part of retiring of phpBB2.

Rating:

Excellent!
1
50%
Very Good
1
50%
Good
0
No votes
Fair
0
No votes
Poor
0
No votes
 
Total votes: 2

User avatar
quahappy
Former Team Member
Posts: 1416
Joined: Tue Dec 12, 2006 8:19 pm
Location: South Yorkshire
Name: Andy Green

Re: Posts this month (Viewprofile)

Post by quahappy » Sun Jul 20, 2008 2:22 pm

quahappy wrote:I really appreciate that most are busy with phpBB3 but I would be grateful if anyone knows how I could display the "posts this month" in a column either the memberlist or, preferably, list of members in a User Group.

Many thanks!
I'm currently looking at the Statistics MOD which I believe will show me the top X monthly posters AND the actual number of posts done for the month...
wittykitty wrote:]Hi, I've run this, says it went through fine, but when I click on "profile" at the bottom of a topic, I get an error!

Fatal error: Call to undefined function display_online_offline() in /home/fordesco/public_html/phpBB2T/includes/usercp_viewprofile.php on line 184
Have you double-checked all your edits and additional code required by the MOD? Is the BEFORE, ADD code section below in the right place? It's common (done it myself!) to AFTER, ADD instead as so many MOD's use this frequently.

Code: Select all

#
#-----[ OPEN ]------------------------------------------
#
includes/usercp_viewprofile.php

#
#-----[ FIND ]------------------------------------------
#
$temp_url = append_sid("privmsg.$phpEx?mode=post&" . POST_USERS_URL . "=" . $profiledata['user_id']);

#
#-----[ BEFORE, ADD ]------------------------------------------
#
$current_time = time();
$this_months_posts = 0;
$year = date('Y', $current_time);
$month [0] = mktime (0,0,0,1,1, $year);
$month [1] = $month [0] + 2678400;
$month [2] = mktime (0,0,0,3,1, $year);
$month [3] = $month [2] + 2678400;
$month [4] = $month [3] + 2592000;
$month [5] = $month [4] + 2678400;
$month [6] = $month [5] + 2592000;
$month [7] = $month [6] + 2678400;
$month [8] = $month [7] + 2678400;
$month [9] = $month [8] + 2592000;
$month [10] = $month [9] + 2678400;
$month [11] = $month [10] + 2592000;
$month [12] = $month [11] + 2592000;
$arr_num = ( date('n')-1 );
$time_thismonth = $month[$arr_num];
$sql = "SELECT count(post_id) as monthly_posts
FROM " . POSTS_TABLE . "
WHERE poster_id = {$profiledata['user_id']}
AND post_time > '" . intval($time_thismonth) . "'";
if(! $result = $db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, 'Could not obtain last months postcount.', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$this_months_posts = $row['monthly_posts'];

$db->sql_freeresult($result);
Hope that helps.
If you don't ask.....

wittykitty
Registered User
Posts: 74
Joined: Sat Feb 16, 2008 11:09 am

Re: Posts this month (Viewprofile)

Post by wittykitty » Sun Jul 20, 2008 2:35 pm

Hi, not sure which file this script is in. I am very basic on amending script, but if I know exactly where to go and what to do I should be fine!

Thanks again,

User avatar
quahappy
Former Team Member
Posts: 1416
Joined: Tue Dec 12, 2006 8:19 pm
Location: South Yorkshire
Name: Andy Green

Re: Posts this month (Viewprofile)

Post by quahappy » Sun Jul 20, 2008 3:11 pm

wittykitty wrote:Hi, not sure which file this script is in. I am very basic on amending script, but if I know exactly where to go and what to do I should be fine!

Thanks again,
Any problems, PM me. :D
If you don't ask.....

User avatar
quahappy
Former Team Member
Posts: 1416
Joined: Tue Dec 12, 2006 8:19 pm
Location: South Yorkshire
Name: Andy Green

Re: Posts this month (Viewprofile)

Post by quahappy » Sat Jan 03, 2009 4:49 pm

I've hit a problem. I inserted some code for this MOD so it shows the present months post count and an extra field that shows LAST months post count. Now it's January - a new year, Last Months post count is showing the total number of posts for 2008 instead of just December 2008!!

Would be grateful if someone could enlighten me as to what I need to tweak:

File: ncludes/usercp_viewprofile.php

Code: Select all

// First, work how many posts they've made this month
$current_time = time();
$this_months_posts = 0;
$year = date('Y', $current_time);
$month [0] = mktime (0,0,0,1,1, $year);
$month [1] = $month [0] + 2678400;
$month [2] = mktime (0,0,0,3,1, $year);
$month [3] = $month [2] + 2678400;
$month [4] = $month [3] + 2592000;
$month [5] = $month [4] + 2678400;
$month [6] = $month [5] + 2592000;
$month [7] = $month [6] + 2678400;
$month [8] = $month [7] + 2678400;
$month [9] = $month [8] + 2592000;
$month [10] = $month [9] + 2678400;
$month [11] = $month [10] + 2592000;
$month [12] = $month [11] + 2592000;
$arr_num = ( date('n')-1);
$time_thismonth = $month[$arr_num];
$sql = "SELECT count(post_id) as monthly_posts
FROM " . POSTS_TABLE . "
WHERE poster_id = {$profiledata['user_id']}
AND post_time > '" . intval($time_thismonth) . "'";
if(! $result = $db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, 'Could not obtain last months postcount.', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);
$this_months_posts = $row['monthly_posts'];

$db->sql_freeresult($result);

// Now then, how many did they make last month?
$current_time = time();
$last_months_posts = 0;
$year = date('Y', $current_time);
$month [0] = mktime (0,0,0,1,1, $year);
$month [1] = $month [0] + 2678400;
$month [2] = mktime (0,0,0,3,1, $year);
$month [3] = $month [2] + 2678400;
$month [4] = $month [3] + 2592000;
$month [5] = $month [4] + 2678400;
$month [6] = $month [5] + 2592000;
$month [7] = $month [6] + 2678400;
$month [8] = $month [7] + 2678400;
$month [9] = $month [8] + 2592000;
$month [10] = $month [9] + 2678400;
$month [11] = $month [10] + 2592000;
$month [12] = $month [11] + 2592000;
$arr_num = ( date('n')-2);
$time_lastmonth = $month[$arr_num];
$sql = "SELECT count(post_id) as lastmonthly_posts
FROM " . POSTS_TABLE . "
WHERE poster_id = {$profiledata['user_id']}
AND post_time > '" . intval($time_lastmonth) . "'";
if(! $result = $db->sql_query($sql) )
{
	message_die(GENERAL_ERROR, 'Could not obtain last months postcount.', '', __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrow($result);

$last_months_posts = $row['lastmonthly_posts'] - $this_months_posts ;
if ( $time_lastmonth = 12 )
{
$last_months_posts = 'Temporarily unavailable';
}
if ( $last_months_posts <0 )
{
$last_months_posts = 0 ;
}

$db->sql_freeresult($result);
As you can see above, I've had to temporarily "disable" Last Months post count field and make it show "Temporarily unavailable" to users.

Look forward to any help and thanks in advance. :D
If you don't ask.....

User avatar
quahappy
Former Team Member
Posts: 1416
Joined: Tue Dec 12, 2006 8:19 pm
Location: South Yorkshire
Name: Andy Green

Re: Posts this month (Viewprofile)

Post by quahappy » Sun Jan 04, 2009 4:05 pm

My problem has been resolved. Big thanks to battye at CMX forum! Solution to correctly display a members previous months post count in view profile here: http://forums.cricketmx.com/viewtopic.php?f=43&t=4546
If you don't ask.....

Post Reply

Return to “[2.0.x] MOD Database Releases”

Who is online

Users browsing this forum: No registered users and 6 guests

cron