Hi,

I want to remove/delete a reminder with Rules but i don't find how... maybe i miss something.
I only find the possibilities to :
- set a reminder
- enable/disable reminder on a node

In my case when a registration is made on a node, i want to delete all the reminder set to this node.

Thanks in advance !

Comments

munchausen created an issue. See original summary.

dwillcox’s picture

@munchousen

Unfortunately, I'm not much of a Drupal guru. In particular not the rules API. I'm also not exactly sure what you want to do.

What do you mean by "when a registration is made?" Is that an action from another module? Registrations, perhaps?

And do you want to delete *all* reminders on the node? Or just the user that's doing the registration? I'm not sure why you'd want that, but OK.

Something like "delete all reminders for user X" might be possible, but you'd want to be sure that the current user had appropriate ability.

Or "delete all reminders on this node," but again, I think you'd want to ensure that the current user was able to write the node.

A bit more detail of just what you want to do would help.

dwillcox’s picture

Assigned: Unassigned » dwillcox
Status: Active » Postponed (maintainer needs more info)
munchausen’s picture

Hello and first, thx for your answer !

I use "date reminder" to remind user to register to an event (with node_registration module).
The administrator create the node and select a list of people to inform about the event.
At the same time, reminders are create (with Rules) to that list of person and 1 day before the event the reminders will be sent.
The reminder say "nobody is register yet, please go see the event and register if you can go to this event"

I want to sent the reminders to that list of person except if one person register to the node.
If just one person register to the node, all the reminders for that node have to be deleted (or disable...).

I like the idea of "delete all reminders for user X" AND "delete all reminders on this node" btw !

I hope my explanation is helping...

Thx in advanced !!

munchausen’s picture

Nobody have any tips for me ?

I'm not an expert but i need this feature for my site. If anybody have some links or advice for developing such a thing it would be so helping for me.

Thanks !

dwillcox’s picture

Sorry for not responding earlier. (1) I haven't been actively working on drupal for a while and (2) for some reason my email client tends to send drupal notices to the junk box, in spite of how many times I move messages back to my inbox.

That said...

Implementing deletes for "all for this node," "all for this user," or "all for this node and user" wouldn't be too hard to implement within the module. I'm a little concerned about permissions; I wouldn't want to open a back door that let a random user delete other users' reminders. It's been a while since I dealt with rules, so I'm not sure how to protect against that.

I'll be thinking about it, but can't guarantee any deadline.

dwillcox’s picture

Looking at how permissions work (at least as currently used in DateReminder), permissions are based on who is executing the action, not on who set up the rule.

My understanding is that, when an unprivileged user registers for an event, you want a rule to be triggered to delete all reminders for that event. So that user would be (indirectly) causing something to happen (deleting someone else's reminders) that shouldn't be permitted. If we could ensure that only a site administrator (or maybe someone with permission to modify a mode) could configure such a rule, that would probably be OK, but again, I'm not so sure about that. Is there a concept of "permission to even know about this rule?"

Maybe the clean-up could be done in a cron job (running as a privileged user) could do the cleanup, but that seems kludgy, too.

Some thought required.

dwillcox’s picture

Ah, I find that there is an ''access callback" option in hook_rules_action(), so yes, we could ensure that only suitably-privileged users could configure a given rule. That's probably secure enough.

munchausen’s picture

Thanks for your research, i'm back from my vacantions, sorry !

For me, this rule is only create by administrator user (me), so it's fine that only a site administrator is allowd to configure such a rules.

munchausen’s picture

Hello dwillcox,

Do you need more info for this improvement ? Is there a way that i can help you for the developpement ?
I be glad to help you in any ways.

Thanks !

dwillcox’s picture

Unfortunately, I have a pretty good understanding of what you want. What I'm lacking is the spare time to work on it. After being out of commission for a couple of months, I have a lot of catching up to do in "real life."

So this doesn't sound too hard. Just hasn't bubbled up on my list.

Now, if you're at all comfortable with PHP and Drupal, and wanted to submit a patch, I'd be happy to look at it. Basically, what's needed is one or more new action descriptions added to the list here, defining a new action datereminder_rules_action_delete_all_node_reminders. The new datereminder_rules_action_info entry would be similar to datereminder_rules_action_set_enable_reminder, but with only the first parameter. The added complication would be figuring out how to do the "access callback" to ensure only a user with the specified privilege could use that rule.

The code to delete reminders for a node should be fairly simple, basically a call to _datereminder_clean_node_reminders().

  • dwillcox committed 00916a6 on 7.x-1.x
    Issue #2962444 by dwillcox: Delete reminder with Rules
    

  • dwillcox committed 39dd41e on 7.x-1.x
    Issue #2962444 by dwillcox: Delete reminder with Rules
    

  • dwillcox committed 1df54c7 on 7.x-1.x
    Issue #2962444 by dwillcox: Delete reminder with Rules
    
dwillcox’s picture

OK, munchausen, I've made the change that I think will do what you want, basically created a rule action to delete all reminders for a node. It will only appear in the menu for users with permission to administer reminders. (We could define a separate permission for that, but I think that's overkill.)

It doesn't appear on the releases page (at least not at the moment) but here's a link: https://www.drupal.org/project/datereminder/releases/7.x-1.x-dev

I think that version has the new rule. (Drupal's version management has changed since I last was heavily into this, and I don't see how to control appearance of development releases in the list of releases.

Please try it out and see if it does what you want.

dwillcox’s picture

Status: Postponed (maintainer needs more info) » Needs review
munchausen’s picture

Hello dwillcox !

Thank you so much for taking time to help me :)

I have tried your contribution for the module and i have en error when the Rules "Delete all reminders for a node" trigger.

Recoverable fatal error : Object of class stdClass could not be converted to string dans DatabaseStatementBase->execute() (ligne 2227 dans /homepages/xx/xxxxxxxxx/htdocs/includes/database/database.inc).

And the reminders for the node aren't deletes from the list (admin/config/people/datereminder/view).

Do you have any idea ?

Thanks for your return !

  • dwillcox committed e6fa8e3 on 7.x-1.x
    Issue #2962444 by dwillcox: Delete reminder with Rules
    
dwillcox’s picture

Oops. Wrong parameter in a function call. Just checked in a fix. The dev release has the change. Give it a try.

munchausen’s picture

YES !!

You're awesome, this community is awesome !

As far as I tested your commit, it's work for me perfectly.

Thank you so much :) !

  • dwillcox committed a8baab8 on 7.x-1.x
    Issue #2962444 by dwillcox: Update CHANGELOG
    
dwillcox’s picture

Status: Needs review » Fixed

Fixed in release 7.x-1.14.

Status: Fixed » Closed (fixed)

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