The module currently deducts or grants userpoints when any flag is set, no matter which flag it is.

This isn't very useful because on a node we have 3 flags - bookmark, report abuse, or say thanks. We would like bookmarking to have no effect on userpoints, perhaps an abuse report could deduct a point from the author and/or grant one to the reporter, and saying thanks could add a point to the author.

So the userpoints settings for this module really need to be flag-specific instead of global.

Comments

gilgabar’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new12.7 KB

Here is a patch that rewrites the module to allow per flag type points. It includes separate points and categories for the flagging user and flagged content author (or flagged user if it is a user flag). It also includes the daily threshold and moderation options per flag type.

Status: Needs review » Needs work

The last submitted patch, userpoints_contrib-935504.patch, failed testing.

gilgabar’s picture

Status: Needs work » Needs review
StatusFileSize
new12.74 KB

Maybe the testbot will like this better.

mr.j’s picture

Thanks gilgabar - will try it out and let you know how it goes.

lobo235’s picture

Thanks for the patch, gilgabar. I have userpoints_contrib-6.x-1.0-beta1 and the patch from #3 applied without any issues and I was able to test it with a few different flags that we use. After applying the patch I had to clear the cache to get the settings page to show the Flag settings section correctly but after that it worked like a charm. Great work!

berdir’s picture

Status: Needs review » Needs work
+++ userpoints_flag/userpoints_flag.module
@@ -1,123 +1,214 @@
+//$Id$

There should be a space before $Id$ but it doesn't matter as it will be removed anyway once we migrated to git (and that is soon!)

+++ userpoints_flag/userpoints_flag.module
@@ -1,123 +1,214 @@
+    // Load the category list.
+    $tree = taxonomy_get_tree(userpoints_get_vid());
+    $category_options = array();
+    $category_options[0] = t('!Uncategorized', userpoints_translation());
+    if (!empty($tree)) {
+      foreach ($tree as $term) {
+        $category_options[$term->tid] = str_repeat('--', $term->depth) . $term->name;
+      }
+    }

We usually don't indicate the term depth when displaying them in userpoints. You should also use the userpoints_get_categories() helper function.

+++ userpoints_flag/userpoints_flag.module
@@ -1,123 +1,214 @@
+            'operation' => 'flag_'. $flag->name,
+            'description' => t('Flag: !content_type !content_id.',array('!content_type'=> $flag->content_type, '!content_id'=> $content_id)),

- In Drupal 6, the operation is publicly shown. So it should probably use one or two "propper" words. In D7, that has changed. Is $flag->name the user facing name or is there something else that could be used instead?

- This needs to use @content_type/id.

Very nice work on this patch, will commit once you did a re-roll of the few minor things above.

Powered by Dreditor.

gilgabar’s picture

Status: Needs work » Needs review
StatusFileSize
new12.51 KB

Thanks for the review Berdir. Rerolled patch fixes the space, implements userpoints_get_categories(), replaces $flag->name with $flag-title to be more human readable in the operation field as well as in the points settings form, and updates the text replacement with '@'.

The categories snippet is straight from userpoints_nc, so it looks like that should be patched as well.

Status: Needs review » Needs work

The last submitted patch, userpoints_contrib-935504-2.patch, failed testing.

gilgabar’s picture

Status: Needs work » Needs review
StatusFileSize
new12.54 KB

Patch path was relative to userpoints_flag instead of userpoints_contrib.

BenK’s picture

Subscribing

berdir’s picture

Status: Needs review » Fixed

Only did some brief testing, but this a huge improvement, thanks for the fast re-roll.

I was thinking about an upgrade path but that doesn't make much sense, chances are that all sites will want to re-visit their settings anyway. So all that could possibly be done is print a warning that the settings need to be re-visited, probably with a link point to those.

You're welcome to write a patch for that but I went ahead and commited this.

BenK’s picture

Is there any way to incorporate this patch into the D7 port of userpoints_flag that is underway on the following thread?

http://drupal.org/node/871116

--Ben

madeinfr’s picture

This patch works very well and saves my Web site.
All my congratulations !

Status: Fixed » Closed (fixed)

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