"Too bad it count every post count only if there is a way to make it only count for the forum post."

With this the forum can act as a real forums.

Comments

liam mcdermott’s picture

Title: Post count » Restrict post counts by content type

Just fleshing out the details.

Use cases

  • nainainai wants only nodes/comments in the forum to be included in post counts;
  • Dave needs all nodes/comments--irellevant of type--to contribute to a user's post count;
  • Alice only wants comments added to her blog to count towards a user's post count;

Deliverables

  • Administation page with a dynamic list of content types, by default none of the content types will be selected, meaning no post counts will be generated;
  • new permission: 'Administer user stats';
  • amendments made so only posts from content types selected on the administration page are added to a user's post count;

Limitations

  • Will not split counting of nodes and comments, will always count both;

Time/Cost

This should take around half a day, costing: EUR100. Payment can be from one, or many users: people can donate different amounts to get this work done. It'll take me around one week from the time pledges are made to fit the work in around the other things I have to do. So the work will be due one week from the time the full EUR100 is pledged.

Hope this makes sense. :)

liam mcdermott’s picture

One more thing: I can do Paypal, credit/debit card, or direct transfer to a UK bank account (direct transfer will probably cost though, unless you're in the UK).

:)

jaydub’s picture

I have taken a stab at implementing this feature. In the meantime there has been another release of user_stats so I will port my changes to the current release and post patch here.

liam mcdermott’s picture

Fantastic jaydub! The change that caused that release was very minor, just a couple of lines in hook_cron(). :)

jaydub’s picture

Status: Active » Needs review
StatusFileSize
new11.39 KB

Ok I've got a patch ready with this feature...although in desire to add a few more things I've perhaps added in some unrelated features to the patch. Feel free to take a look at the other things and if they are of value then they can go in as well. If not then I can do some extracting and re-roll the patch (but will be on holiday in 4 days).

In this patch:

  • Added in user_stats admin settings page.
    • Can specify which content types to include in post counts
    • Can reset all post counts (will be rebuilt on cron runs)
    • Can specify the number of users to rebuild per cron run
  • Added in optional parameter to user_stats_get_stats to provide profile fields. Since we have the user's profile field values due to loading up the user, might as well make them available. I punted on the case where the profile field returns an array such as for a date field so for now this is geared towards textfields
  • Rather than use user_load I wrote a user_stats_user_load function that pretty much does the same thing as the core user_load except that is does not result in the extra queries/work that would result from the 'load' operation from hook_user. I figure that this can be a minor performance boost.

Because I have a multisite setup with shared user tables, I've also modified user_stats to allow the selection of a previously created profile field to use as the post count field as in my case there would be different post counts per site for a single user. If you think that could be of value I can post another patch.

liam mcdermott’s picture

Status: Needs review » Needs work

This looks great. I've tested and read through the code pretty thoroughly. Thanks for adding this much-needed functionality! On the down-side there are a few changes (nothing major):

  1. capitalise the 'u' in the 'user stats settings' page title;
  2. change 'Post Count ...' to 'Post count ...';
  3. 'Reset post count' could be more descriptive, how about 'Reset all post counts';
  4. 'Reset post count' doesn't work as it's looking for variable_get('user_stats_postcount_profile_field', ''), this should be hardcoded to: 'user_post_count' for the moment (did some of your multi-site stuff creep in there? ;) );

The user_stats.install file needs updating too, I'll gladly sort that out after we've got this update committed though. :) Overall problems with getting this committed are very small, I'm enthusiastic about the added functionality. Should get a chance to write some documentation this weekend too!

Because I have a multisite setup with shared user tables, I've also modified user_stats to allow the selection of a previously created profile field to use as the post count field as in my case there would be different post counts per site for a single user. If you think that could be of value I can post another patch.

That does sound like a good idea, yes. Definitely a seperate patch (and new feature request).

jaydub’s picture

StatusFileSize
new12.16 KB

Ok, took care of #1-#4 although I didn't look too hard for the wording changes...

For user_stats.install file I am not sure what needs updating...I've separately uploaded a patch to the install file to enable PostgreSQL support (although untested with the module doh!). http://drupal.org/node/214040

For the ability to choose the profile field to use for post count, do you want me to try and patch against the current module or send that patch assuming the above patch is applied (easier) ?

liam mcdermott’s picture

For the ability to choose the profile field to use for post count, do you want me to try and patch against the current module or send that patch assuming the above patch is applied (easier) ?

Probably easier to just do things in sequence. Am going to get this patch committed within the next hour, so less work for you. :)

liam mcdermott’s picture

Status: Needs work » Fixed

Committed. Rock on. Am going to sort out the install file now. :)

jmai’s picture

I'm getting a blank settings page for the new committed file 1.2.2.6 user_stats.module.

liam mcdermott’s picture

I'm getting a blank settings page for the new committed file 1.2.2.6 user_stats.module.

That should have been fixed in the latest CVS version. Try it out and raise a bug if you still get problems. :)

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

amnion’s picture

How do I apply the above patch? I don't want to mess anything up.