Download & Extend

Radioactivity integration with Flags

Project:Radioactivity
Version:6.x-1.3
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:needs review

Issue Summary

As the title states, i propose this module works along with flags just as it does with votingapi. It should also include an admin dropdown option to choose which flag it should respond to, and in what way (+ or - radioactivity).

Comments

#1

Status:active» needs review

Well, I went ahead and did this. I've attached the necessary files (which belong in the radioactivity/plugins folder). I would like it to only appear in the respective content-types, but apart from that it seems to be working fine. Any feedback is welcome :)

AttachmentSize
radioactivity_flags.zip 1.21 KB

#2

Thanks. I'll look into this in a week or so before making the next official radioactivity release. If it looks ok, you can expect it to be included. Meanwhile, any feedback and test reports would be welcome.

#3

Version:6.x-1.2» 6.x-1.3-rc1

#4

Status:needs review» needs work

Quick code review:

For translation and security:
array('title_placeholder' => $node_flag . ' unflag');

Should be:
array('title_placeholder' => t('@flag unflag', array('@flag' => $node_flag));

The same pattern is repeated in the code and should be fixed in all cases.

I suggest also to decide whether this is just for node flags (the way the code works) or for all kinds of flags (the way the title/description make you think it works) and change the title/description accordingly.

#5

Status:needs work» needs review

I think I made the changes properly to vix8's code. Here it is. How does it look?

Is this code useable in its current state?

AttachmentSize
radioactivity_flags.zip 2.64 KB

#6

There were a few syntax errors: unexpected ';', expecting ')' in radioactivity_flags.module on lines 24, 25, 30 & 31, which I fixed by adding another ')', and now nodes have energy when you flag them! One small step for man.

AttachmentSize
radioactivity_flags.zip 3.52 KB

#7

Version:6.x-1.3-rc1» 6.x-1.3

I independently wrote this module before finding this thread. My version is rather more elegant I think -- at least, it's more compliant with Drupal coding standards -- and it also works with any flag type (not just nodes and comments).

I named it backwards I guess, but that's easy to change.

AttachmentSize
flag_radioactivity.tar_.gz 758 bytes

#8

IceCreamYou continues his reign of terror as my favorite Drupal contributor. Seriously man, you're unstoppable.

#9

Hahaha, there are plenty of other Drupal contributors who do more than me, but thanks.

#10

I put your plugin in the radioactivity/plugins folder and renamed the folder and files radioactivity_flag. Where do I determine how much energy to give for flagging? Does the plugin you made need a .install file?

#11

On a related issue: radioactivity will have integration with rules in the near future (there is a work-in-progress module in HEAD).

It will not remove the need for module specific plugins but it will make (almost) any kind of configuration possible - including adding or removing energy when a node gets flagged.

#12

FWIW, I'm currently at Acquia and we're considering whether to use Radioactivity in Commons. Committing this would be helpful in making that decision. We'd like to keep all the configuration related to Radioactivity (or whatever we choose) in one place instead of having some of it in Rules and some of it on the Radioactivity page.

#13

Status:needs review» needs work

Hi IceCreamYou, your employer and the potential use of this module in Commons is very exciting of course but the most important thing to getting a patch in is providing it as a patch ;)

Maybe you could re-roll as a git patch and fix the naming issue you mentioned? It's currently somewhat harder to review since it has to be download and then untarred.

#14

Will do.

After some work today, it turns out that this won't be strictly required for us (the way we're using Radioactivity is a little unorthodox) but I'll turn it into a patch anyway because I think it's a worthwhile addition.

#15

Having trouble creating a git patch (Windows...). Anyway, updated module attached as well as the module file in a format readable online without downloading.

AttachmentSize
radioactivity_flag.zip 1.08 KB
radioactivity_flag.module.txt 1.52 KB

#16

Status:needs work» needs review

Alright, let's see if this works.

AttachmentSize
radioactivity_flag.patch 2.38 KB

#17

Fantastic, I diff'd in the wrong direction. This should be right.

AttachmentSize
radioactivity_flag.patch 2.38 KB

#18

You could just use Rules.
Heres what i did:
1. new rule
2. name it, tag it, for the "react on event" choose "a node has been flagged under (your flag)"
3. Add condition: "content is of type"
4. choose the appropriate content type/types
5. Add another condition: " Entity has field"
6. choose your "radioactivity field"
7. Add an action: "calculate a value"
8. the "input value 1" should be your radioactivity field, the "input value 2" should be how much (a number) energy you want to add/subtract for flagging
9. Add an action: "set a data value"
10. the "data" should be your radioactivity field, and the "value" should be the result you get from the calculation (default label is "result")

and thats about it. now whenever someone flags that node, it will gain a set amount of energy. no need for a patch. Hope this helps :)

nobody click here