See: http://drupal.org/node/571100

I have the standard Flags installed (nodes and comments), and was wondering which of the patches I would have to apply in order for me to have "Flag Reset" functionality on nodes and/or comments on my site. I was also wondering what the interface would look like (if any) for the reset. Is it an action? Or would I have to create my own interface for this functionality?

CommentFileSizeAuthor
#40 flag-reset_flags-823314-40.patch4.85 KBrooby
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

Title: Flag Reset Patches? » Flag Reset Links/UI
Version: 6.x-1.3 » 6.x-2.x-dev
Category: support » feature

There currently is no UI for flag resetting, so I'll move this to a feature request and we can track that request here. The issue that you linked to is closed because it's already included in the 2.x development version. The best way forward is to continue improving Flag and put a UI to this functionality.

As I see it, this UI really simply consists of a new field handler for Views. We may also need to consider a new permission for "reseting" of flags. Or for now we can just add the permission directly to the field handler.

SpikeX’s picture

Well, a Views field may work for you (what would this field even look like?), but personally I would like to see an Action (of the Actions module) included, as I use Views Bulk Operations to list my flagged nodes/comments, and the ability to use an Action to select multiple nodes to reset/clear would be extremely helpful to me.

We could also optionally include a link on the node and/or comment in the Links section for Administrators to "Reset All Flags" if they have the permission to, and flags exist on the content.

quicksketch’s picture

Ah, yeah an action of course is a good idea also. The Views field I was suggesting would be just like the existing "Flag link" field, only it would be "Reset link".

SpikeX’s picture

Oh, yes, that would work well, as well, though of course you may have to then code an additional confirmation screen if needed, something like "Are you sure you want to clear all flags on node [title]?". I think it would be a good idea to have something like that, since I remember people getting jumpy just hearing about a "clear" option for flags (since a lot of people use it for bookmarks/favorites, a clear options isn't needed, and could potentially be dangerous).

Anyway, I'm sure an action wouldn't be too hard to code (just a few lines, right?), as opposed to an entire Views field, so if we could knock that out first that would be awesome. :)

x106’s picture

Bump

Resetting flags only makes sense. I can publish an article with a flag action but if the article is unpublished I can't un-flag it.

I need to be able to unflag a node from all users or users from role.

quicksketch’s picture

Please do not "bump" issues. Karma--

Shadlington’s picture

Would such a reset action apply to all flags on a particular node or all flags of a particular type on a particular node?
Personally, I think it should be the latter.
As said in #4 most people won't want to reset bookmark flags. However, if you have both bookmark and abuse flags on a particular content type, then you may still want the reset function, albeit only for the abuse flag.

SpikeX’s picture

Yes, the script should be conscious of the type of flag it's clearing (but there should also be the option to remove all flags, so I guess both?).

mooffie’s picture

(Meanwhile, people looking for this functionality can use this module.)

SpikeX’s picture

@9: Requires -dev branch, and isn't on drupal.org officially... I think I'll pass on this with my production site. :/

Shadlington’s picture

Hmmm... I like the sound of #9. Any chance this might see its way into Flag proper rather than as a separate module?

ressa’s picture

It's kinda tedious to remove the flags one by one via VBO, so a "reset flags" functionality would be greatly appreciated 8o)

mooffie’s picture

News:

- The module I mentioned (at #9) now has a Drupal.Org homepage: Flag Clear.

- You no longer have to use Flag's 'dev'. But you need Flag 2.x (Flag 1.x won't work).

ressa’s picture

Great! I appreciate your work on the Flag Clear module, but I think I'll wait until it's "officially" in drupal.org as a module...

mooffie’s picture

Issue tags: +flag reset

Tagging.

chuckbar77’s picture

subscribing

funature’s picture

subscribing

jeff.k’s picture

+1

Looking for something similar. I am using a flag as a way for users to temporarily mark some items. When done I would like to have a way for the user to clear their temp bookmarks

<?php
$flag = flag_get_flag('temp_bookmark') or die('no "temp_bookmark" flag defined');

// Unflag all users 'temp_bookmark nodes':
$flag->flag('unflag', 'all'); 
?>

mooffie’s picture

@jeff.k: I think your request is a duplicate of: #935056: Add uid as optional parameter to flag_reset_flag().

jeff.k’s picture

@mooffie: thanks. I will keep an eye on that patch there.

mototribe’s picture

I'm interested in the flag reset - will this be available in future versions?

thanks

partyp’s picture

subscribing

westie’s picture

This functionality would be greatly useful for resetting flags per node. For example you might have an "important change" which everyone need to mark read. However if this is updated they need to mark it read again - resetting this would make that scenario possible.

BigMike’s picture

subscribed

MacaroniDuck’s picture

I'm astonished that this has never happened. I can imagine many use cases where a mass reset of flags would be useful. My particular case is for a yearly event where people flag particular items (in our case board games) that they are interested in playing that year. The same database of games can be used year after year with some additions for new games. The most useful approach would be for an admin to reset the flags after each year's event. For now, we are stuck with exporting the games and re-importing them as new records so that they are no longer flagged. Meh.

mrweiner’s picture

Version: 6.x-2.x-dev » 7.x-2.0-beta7

Has there been any progress on this yet? It would be really nice to have some sort of reset functionality. I am using flags to allow users to "report" abusive content, and it would be awesome if I could unflag all (or individual) reported nodes to stop the View from displaying nodes after they have been reviewed. Currently, if the flag isn't set to global, I can't find a way to do this, as only the user who flagged the content can unflag it.

As others have stated, it seems like there are many use cases where this would be a welcome feature.

joachim’s picture

Version: 7.x-2.0-beta7 » 7.x-2.x-dev

Progress is really down to people who need this feature working on it :)

I would say this would be best implemented as an action, so it can be built into views with VBO.

joachim’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
warmth’s picture

Any news? Maybe here there is a solution: #1717672: Add flag/unflag tests to FlagTest

joachim’s picture

If there news, you would see it here ;)

I don't see how that other issue is relevant to this at all, as it's about writing tests for the module.

warmth’s picture

@joachim sometimes people find the answer but never publish it, that's what I mean. :P

Sorry but I'm kinda rookie about writing modules I just read the description (obviously it's what you say) and maybe there was some code there that it can be reused to the clear flags action, just trying to help.

BTW, I found a workaround here: #956902: Unflag all? but I prefer something official.

joachim’s picture

I am rather inclined to say this feature should continue to be developed in http://drupal.org/project/flag_clear -- and it's up so someone to step up and take that project on :)

warmth’s picture

That would be great but it will take longer, don't you think? And I still think it's a key missing feature of the main module, IMHO.

joachim’s picture

Status: Active » Closed (won't fix)

It could potentially be quicker, as it won't depend on my reviewing patches. It would also mean less work to maintain Flag, which is already big and complex. And since there's already a project... I reckon this functionality can best live over there.

WebmistressM’s picture

Subscribing. Checking out views in the meantime and see if I cant set something up for the admin to reset a flag once they have addressed the issue.

rooby’s picture

Issue summary: View changes
Status: Closed (won't fix) » Active

The module flag clear has not been a module for a long time now. There is no code there or anything.

Flag use to have this feature in the old days so it is sorely missed and would be great to have back.

I would have though a pretty high number of users would require this.

We have the function flag_reset_flag() so in theory it shouldn't be much of a stretch to make an action at least to begin with.

I can't say I'll work on it though unfortunately as that would probably end up being an empty promise.

shabana.navas’s picture

Hmm.. This is the second request for a flag_reset_flag() action this week. Considering the fact that the Flag Clear module was also created for this purpose, I take it as enough users really wanting this feature and this makes me want to commit to working on this. I am hoping that I can as soon as I get some time.

joachim’s picture

Maybe someone who wants this feature could adopt the Flag Clear module and bring it back to life?

I'd rather we keep less frequently used features in extension modules rather than make the main module harder to maintain.

shabana.navas’s picture

I agree.

rooby’s picture

Status: Active » Needs review
FileSize
4.85 KB

Here is a patch that adds actions.
It still probably needs rules support.

Also, I think it would be good to have an option where if there is only one flag type for an entity it will automatically be used instead of making the user select one.

Hopefully my project will give me a bit of time to work on the rules part soon too.

Personally, after seeing how this patch fits into this module I think it belongs here with the other actions stuff and I can't really see heaps of issues being opened in this queue as a result of these actions going in, but once I'm done and it gets some review I'm happy for maintainers to dictate (the code should be pretty portable) where it goes.

joachim’s picture

+++ b/includes/flag.actions.inc
@@ -58,6 +58,31 @@ function flag_action_info() {
+    'flag_node_reset_flag_action' => array(
+      'type' => 'node',
+      'label' => t('Reset flags for a node'),
+      'configurable' => TRUE,
+      'triggers' => array(
+        'node_presave', 'node_insert', 'node_update', 'node_delete', 'node_view',
+        'comment_insert', 'comment_update', 'comment_delete', 'comment_view',
+      ),
+    ),
+    'flag_comment_reset_flag_action' => array(
+      'type' => 'node',
+      'label' => t('Reset flags for a comment'),
+      'configurable' => TRUE,
+      'triggers' => array(
+        'comment_insert', 'comment_update', 'comment_delete', 'comment_view',
+      ),
+    ),
+    'flag_user_reset_flag_action' => array(
+      'type' => 'user',
+      'label' => t('Reset flags for a user'),
+      'configurable' => TRUE,
+      'triggers' => array(
+        'user_insert', 'user_update', 'user_delete', 'user_login', 'user_logout', 'user_view',
+      ),
+    ),

A huge problem with the D7 core action system is that the name of the action is also its callback function.

That means we can't define an action for each flag type and have a single common callback.

We already have these for the legacy actions we defined prior to 7x3x, but I'd rather we didn't add more.

Is there a more flexible way of defining these to Rules?

rooby’s picture

It looks like the Flag Clear module has had some work since my comment in #36.

Does anyone know off the top of their head what the status of that module is and does it cover the functionality requested in this issue?

eott’s picture

Rooby, this is a really slow reply to your question, but Flag Clear allows you to bulk clear all flags on a node, or unflag by a user. The problem is that the bulk clear does all flags of all types. So if you have flags for Bookmark and Vote, and you can clear both types, but not just the Vote flags or just the Bookmark flags. This functionality is still needed.