Hi guys! Great freaking module... seriously. I'm going to use it to take over the world... or at least some of the custom modules in our platform. :P
Anywho, one replacement was the flag_content module. While it works great as a replacement, it would be really great to have a function that will delete all of the flags for a given node id.
Here's the use case:
We have a view that shows all flags of a certain type (flag_abuse). These are shown to a moderator who either deletes the node, or does not agree that a node should be flagged as abuse. If they do not agree with the flag, it would be nice to have a way to remove this from their list by removing all flags on that node.
Maybe an easier solution would be to create another flag for the admin to ignore this and then filter it out of the view... but I really think it would be more beneficial to just remove all flags from a node, at least in this case.
| Comment | File | Size | Author |
|---|---|---|---|
| #28 | flag_clear_all_patch.tar_.gz | 1.04 KB | Ingumsky |
| #21 | flag-add-clear-functionality.patch | 4.83 KB | erikwebb |
| #21 | flag_handler_field_ops_clear.inc_.zip | 1.72 KB | erikwebb |
Comments
Comment #1
mooffie commentedThis would entail:
- Having a "clear" URL, say q=flag/clear/FLAGNAME/CONTENT_ID.
- Having a "clear" link (field) for Views.
- Having a "Roles who may clear this flag" permission in the flag editing screen.
Nathan, is it worth the bother?
BTW, the Rules support has a 'trim' action that clears flaggings. But connecting it to a link in Views (preferably an ajax link) is perhaps a challenge. Or perhaps it isn't. It's worth investigating this.
Comment #2
mooffie commentedComment #3
mooffie commentedMaybe we could integrate this functionality in the existing flag/unflag link. For example, we could have a "Treat this flag as global" checkbox in the settings page of this link (in Views) that will cause an unflag action to clear all flaggings.
Comment #4
sirkitree commentedI started looking for a way to do this with flag_get_flags() or flag_get_flag() and it started bending my mind since it would require changes to those functions and there didn't seem to be a function that just handled this request outright. I also thought the "clear" link for Views would be necessary, didn't think of the role.
However, your second idea, "Treat this flag as global" as just a Views option on the Operator (if I understand that correctly) sounds like it might be much less work. I'd rather utilize existing functions then try to extend the current ones. If you can point me in the right direction on how to do this I'll write up a patch. Still getting to know the module API.
Comment #5
quicksketchI don't think this functionality is worth directly implementing just yet. A workaround for the time being would be to create a custom module that implements hook_flag(). If a user is a certain role and they unflag a piece of content, remove all the flags for that item. As Mooffie suggests, you'd also be able to do this without a custom module if Rules were fully implemented.
Then, once #322034: Have a $flag->access() method is implemented. You could even make it so that access to that flag would then be denied to all other users, since the administrator has already decided that individual piece of content is not offensive.
Comment #6
mooffie commentedTwo other places mentioning this problem ("this problem" being: The user interface doesn't have a "clear all flaggings" function):
http://drupal.org/node/315865#comment-1084702
http://drupal.org/node/368330
Comment #7
dnewkerk commentedI would love to see this functionality as well (as with a few others in the aforementioned issues, I also tried to setup a View for admin and moderator role use to list and act on flagged-as-offensive content... and ran into the same roadblock). I'd love to get this working with Flag so I can avoid going with Abuse module (or Flag Content module, though I've found that one currently too buggy in D6).
I'm not an excellent programmer (theming's my thing), however if you need testers once a patch is ready, please let me know (I'll keep an eye here). I'm using D6 in my case, though if the initial patch is for D5, I can test that too.
Comment #8
sirkitree commentedSo I'm doing a little more work on this and am running into a problem with Nate's suggestion in #5.
Now, I can preprocess the link for the appropriate user, but in the case of a confirmation box, that user is still presented with the 'flag_confirmation' message. Is there a way we can add some preprocessing for the whole flag so that anything about it can be changed dynamically?
Also, changing the
$vars['action']has no effect onhook_flag(). i.e. I would assume that it would change the$eventparameter.Here's what I have currently:
Comment #9
sirkitree commentedAlso, I've created a project for this as it seems like it will be useful to more than just me.
http://drupal.org/project/flag_abuse
Comment #10
sirkitree commentedgoing to mark this as fixed as there is a 'fix' for it now in the form of another module as suggest. Please reopen if you think I'm in error.
Comment #12
mitchell commented@sirkitree: What do you think about pushing this action upstream?
Marked #455616: Integration for non global flags as a duplicate of this issue.
Comment #13
mitchell commentedActually, the rules integration provides this functionality with the trim action.
Comment #14
Moonshine commentedDoes Rules actually allow for this w/ "trim" on *non-global flags though? Unless I've overlooked an option, I believe you have to choose what users flag you are clearing. I'd certainly find an action for clearing all flags on a node useful (global or non). Would you be open to a patch for an action like that?
Comment #16
elijah lynnAll there needs to be is a box next to the flag. That says "reset".
I accidentally did not check "global" when creating a flag and have had the hardest time figuring out how to reset the flags after I checked "global" It would make sense to just have a "reset" button/column next to the flag in the flag list.
If anyone knows how I can do this that would be great.
Comment #17
elijah lynnComment #18
sirkitree commentedA resolution to this problem would be handled by #571100: Add "reset" action and hooks to Flag. See quicksketch's concerns on it there. Since there is not really any code in this issue, there is nothing to really complete. The issue I referenced in this post is a continuation of this thought process (with code) and addresses the issue I mention in #8 where an inappropriate message is displayed. I'm going to mark this as duplicate since I think attention should be on the other thread instead, but will also check out how this is currently being handled with #547082: Make "Trim flag" an API function.
Comment #19
adam_c commentedI don't think the trim function is actually a solution to this problem, from the rules module, trim is described as:
"The trim action is used to restrict the number of objects that may be flagged. For example, you may wish your "Editor picks" queue (that is, flag) to contain a maximum of 3 nodes. The trim action is best understood when we think of a flag as a queue. The action works by discarding old flaggings; So newly flagged objects push older ones out of the queue."
Which just sounds like a '1-in-1-out' approach. Its not resetting at all.
After scanning all the relevant posts in this issue queue there dosn't actually appear to be a solution to this.
The reason I would like a reset (and not a trim) is because I have (or want) a rule which says:
After a flag has been flagged x number of times, do an action, then reset the number of flags to zero and start again.
Is there anyway of achieving this?
Comment #20
twistedindustries commentedI have solved this by using the flag modules integration in rules. I created a separate rule to clear all flags and it was easy. I modified two files:
flag.rules.inc
After (About line 183)
Add this:
After (About line 225)
Add this (taken from the flag abuse module):
Now on the file flag.rules_forms.inc
After
(About line 36)
Add this:
I hope this solves everyones issues like it solved mine. I know I should have put this all in a diff file but that is out of my league, if anyone wants to create a diff file please do.
Comment #21
erikwebb commentedI took a different approach and simply added the clear functionality directly to the Flag module. So far the new functionality is added to the content list page as well as in a new Views field. I'm attaching the patch as well as the new file created for Views (flag_handler_field_ops_clear.inc - in a ZIP file).
Comment #22
erikwebb commentedI am re-opening this issue as a patch for 6.x-1.1. This issue was marked as a duplicate despite the other ticket being assigned to version 6.x-2.x. These tickets can live beside one another, affecting different versions.
Comment #23
quicksketchNew functionality won't be added to the 1.x version of Flag.
Comment #24
erikwebb commentedThanks quicksketch. I'll leave this patch for other people on 6.x-1.1 to find.
Comment #25
mooffie commentedTagging.
Comment #26
Matt G commentedComment #20 worked for me.
I not have an action that clears all flags of one type from a node.
Very useful!
Thanks
Comment #27
notluap commented#20 also worked for me. Thanks!
Comment #28
Ingumsky commentedI've created a patch based on #20 (thank you twistedindustries!). It works with flag 6.x-2.0-beta5. To apply this patch extract archive to /sites/all/modules/flag/includes, go there and run "patch -p0 " for both of extracted fies (see documentation if you don't know how to apply patches properly).