Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When dealing with non-global (per-user) flags, it would be really useful to reset flags per-user. Won't break any custom code, and I could really use it.
Also, unrelated to the patch, I was really confused by that module_invoke_all()
line. What does $rows
have to do with anything? And wouldn't the call be module_invoke_all('reset_flag')
?
Comment | File | Size | Author |
---|---|---|---|
#8 | flag_reset.zip | 1.13 KB | code-brighton |
#7 | flag_reset.zip | 1.13 KB | code-brighton |
flag-reset-uid.patch | 1.5 KB | tim.plunkett | |
Comments
Comment #1
tim.plunkettOh, I just realized the point of
$rows
. So maybe that line change would mess up any custom implementations. I'll leave as CNR, but I could use some insight on that part.Comment #2
jeff.k CreditAttribution: jeff.k commented+1 subscribing
Comment #3
Shadlington CreditAttribution: Shadlington commentedSubscribing
Comment #4
westie CreditAttribution: westie commentedWould be a great feature, we use flags to mark content as read, however when important changes are made to the content we want to reset the flags and force users to read it again.
Comment #5
BigMike CreditAttribution: BigMike commentedSubscribed
Comment #6
MacaroniDuck CreditAttribution: MacaroniDuck commentedYes, please.
Comment #7
code-brighton CreditAttribution: code-brighton commentedI've created this little module to reset all the flags for the current user (using session if not logged in). It could probably do with a bit of tidying up, but I thought I would upload it as it might prove useful for someone. This is for Drupal 7.
To add your link to your theme file:
<?php print(flag_reset_link('Clear flags')); ?>
Comment #8
code-brighton CreditAttribution: code-brighton commentedoops the line
$items['flags/remove/user/%user'] = array(
should have been:
$items['flags/remove/uid/%user'] = array(
updated file attached
Comment #9
joachim CreditAttribution: joachim commentedIt's changing the signature of hook_flag_reset()... which admittedly is undocumented. And we're in beta still.
Needs more pondering. Does anyone care to check whether our ecosystem modules make use of this hook?
Comment #10
warmth CreditAttribution: warmth commentedAny news?
Comment #11
joachim CreditAttribution: joachim commented> It's changing the signature of hook_flag_reset()... which admittedly is undocumented. And we're in beta still.
Bumping the version to 3.x, which is still in alpha, so we can change the hook signature without any problem.
(Though bear in mind that I hope to have a beta out in the next couple of months -- so if this patch is to get in for 3.x, we need someone to step up and work on it!)
Comment #12
alexweber CreditAttribution: alexweber commentedI've taken a look at the latest dev branches for the following modules:
These are the ones listed on the project page and documentation pages and NONE of them have a single mention of "hook_flag_reset", therefore my understanding is that this is safe to implement.
Where's that re-rolled patch now? :)
Comment #13
RAFA3L CreditAttribution: RAFA3L commentedThanks code-brighton, the #9 work perfect, but using the name flag_reset damage all the flag links, error 500 in a popup window after flag or unflag click. changing the name of the module to flag_flush work fine.
Comment #14
joachim CreditAttribution: joachim commented> using the name flag_reset damage all the flag links, error 500 in a popup window after flag
What was the text of the error?
Comment #15
RAFA3L CreditAttribution: RAFA3L commentedpage not found error 500 + the url of the link to flag and unflag, for example...
http://localhost/test/flag/flag/bookmarks/1?destination=node&token=chW1Q...
Comment #16
joachim CreditAttribution: joachim commentedAny log messages?
Comment #17
RAFA3L CreditAttribution: RAFA3L commentedNo, before rename the module and the error appear I opened the Terminal to check the logs with tail -f and did nothing.
I'll try this again today with "flag_reset"
Comment #18
RAFA3L CreditAttribution: RAFA3L commentedFinally today I did a test, installing Flag Reset I get this when flag something and after rename the module to Flag Flush the error disappear.
Comment #19
joachim CreditAttribution: joachim commented> Notice: Trying to get property of non-object en flag_reset_flag() (line 1272 of /Applications/MAMP/htdocs/test/sites/all/modules/flag/flag.module).
That looks nothing like my numbers. Can you use the latest from git, or tell me what is on that line?
BTW, there is this project: http://drupal.org/project/flag_clear which is abandoned, but the name could be taken over. There's also code at https://github.com/mooffie/flag_clear which could be worth looking at.
Comment #20
Stan.Ezersky CreditAttribution: Stan.Ezersky commentedRename module and you'll be glad-)