Are there plans for Rules integration? specifically, we're looking for an event based on a user accepting an invite.
The use case is that we'd like to allow people to invite friends to the site, then using rules automatically flag those two users as friends. We're using Flag_friend for the friending side of things, so we can use rules to handle that side. It seems that the two things we would need via rules are:
1) an event based on one user accepting another user's invite
2) some way of accessing the uid of the person who issued the invite
That said, we can envision other scenarios where it might be useful to trigger off rules actions based on invites (like when invites expire, or when the invite limit for a user has been reached).
If this isn't planned, we can use some eval'd php code in rules to test whether a new user was invited. Is there something we can look for in the $user object at the point a new user is created that will indicate that he was invited to the site?
| Comment | File | Size | Author |
|---|---|---|---|
| #34 | invite-rules-622152-34.patch | 2.84 KB | ezeedub |
| #31 | invite-rules-7.x-2.x-622152-31.patch | 5.48 KB | jordojuice |
| #30 | invite-rules-7.x-2.x-622152-30.patch | 3.09 KB | jordojuice |
| #29 | invite-rules-7.x-2.x-622152-29.patch | 3.09 KB | jordojuice |
| #28 | invite-rules-622152-28.patch | 3.32 KB | jordojuice |
Comments
Comment #1
YK85 commentedsubscribing
Comment #2
Bilmar commented+1 subscribing
Comment #3
smk-ka commentedRules support would definitely be nice.
Comment #4
adub commented+1
Comment #5
codevoice commented+1
Comment #6
EmanueleQuinto commentedMaybe this could help for a patch.
Based on Developer Documentation Adding new events.
Add the event invoking creation in
invite_user()after the user save, before the latestunset($_SESSION[INVITE_SESSION]), around line 493 in invite.module.Then somewhere in the module implement the hook_rules_event_info to let Drupal acknowledge the new event with its payload (user invited and inviter).
Comment #7
YK85 commentedComment #8
robby.smith commentedthis feature would be very very helpful!
subscribing
Comment #9
YK85 commentedI tested this awhile ago and forgot to post back.
May the maintainer take a look and commit when possible?
Happy holidays!!
Comment #10
that0n3guy commentedSubscribing. This will also allow us to easily take care of the og_invites issues here: http://drupal.org/node/170332
Comment #11
chuckbar77 commentedGreat work! RTBC
Comment #12
paulap commentedYes!
Comment #13
YK85 commentedPlease please commit =) This is great!
Comment #14
rjbrown99 commentedGuys, this isn't RTBC because there is no patch attached to the issue. If #6 is the code change that solves this, the best bet would be to create a patch, attach it to this issue, and then mark it as "needs review". Once a few people have applied said patch, then move it to RTBC.
Comment #15
YK85 commentedCould someone please kindly provide the code as a patch?
Further development of the Invite module would be awesome =)
Comment #16
owen barton commentedComment #17
jordojuice commentedI like this idea and I think I'm going to work on this. I'm really into the Rules thing lately and I'm glad to contribute!
Comment #18
jordojuice commentedThis patch is not fully functional, but it is not dangerous.
I put some rules together, however not all are operable. I haven't been coding Drupal modules for long, and I think I'm likely having trouble with the invite objects. I doubt it accurately obtains the user data, but I have written rules modules before and a lot of the right framework is in place in this patch nevertheless.
There are a few events:
User accepted invitation
User canceled invitation
User sent invitation
One condition:
Inviter has role
This condition has an altered form that retrieves available roles from the database and compares the selected role against a query on the inviter
And a couple actions:
Load invited user (only applies if an invite was accepted and completed)
Load inviting user
These I seem to be having trouble with, but I thought it would be good to post the patch here in case anyone can give some valuable input.
If anyone has suggestions for any other events, conditions, or actions then I'll be glad to look into it.
Comment #19
jordojuice commentedComment #20
that0n3guy commentedjordojuice, thats a pretty rough patch. It just removes everything and then re-adds it. Can you try redoing the patch so that we can just see what was added?
Comment #21
jordojuice commentedYeah... so uhh that pretty much defeats the purpose! I'll get a good patch going when I'm back in town.
Comment #22
that0n3guy commentedLol, yeah. I'll be testing it when you get it up. I have a project coming my way where this would be handy.
Comment #23
mattcasey commentedsubscribing
Comment #24
brunorios1 commentedsubscribing...
Comment #25
isaac.niebeling commented@jordojuice - Have you had a chance to work on this any more? It looks like your patch is just to the invite.module file, so aside from it replacing everything, the actual rules integration is missing. I'd love to help test once the patch is fixed.
Comment #26
jordojuice commentedAlright, so I have indeed been working on it. This rules integration is really pretty simple, but more work may need to be done depending on whether anyone can think of more rules to add. Basically, the rules that exist deal with the inviter and invitee respectively. This is why it's quite easy. No conditions or actions were written because the core user conditions and actions are already available. The module simply loads the user and passes it to rules when an invite is sent, accepted, or cancelled. Accepted invites can have the inviter or invitee as arguments, while the other two only concern the inviter. Do let me know if you have any ideas for other rules.
I don't know why, but every time I try to create a patch git removes all the lines in invite.module and adds them, even though I only added three rules_invoke_event() calls to the file. They were basically added in the same places where Invite already calls module_invoke_all() on those events. So, this is all it is in those places:
I would guess you could probably just use $invite->inviter instead as I assume the object comes from global $user, right?
Anyways, I'll post the patch that I did get here. invite.rules.inc is at the bottom of the patch file and is surprisingly small for all it can do for the module. It's only an implementation of hook_rules_event_info() to identify the data types as user and gain access to all the rules user conditions and actions. I'll also post a zip file for convenience.
P.s. Any tips or suggestions on why I am not creating proper patches would be greatly appreciated. I'm admittedly new to git, but I followed the documentation at http://drupal.org/node/1054616 precisely and numerous times to no avail. It just believes I removed all the lines for some reason.
Talk to you soon!
Comment #27
jordojuice commentedIf there are any conditions or actions anyone could think of that could make use of the $invite object (other than the users inviting and invited) I wrote a rules data type for "invite". I just haven't thought of any good reason to use the data type as these events are called on invites sent, accepted, or cancelled, so I saw no reason to manipulate the invite again. Maybe other users might have a condition or action suggestion? If so, please express that!
Comment #28
jordojuice commentedGot it. So, git was basically not working nicely with windows. It was using
/n, thus replacing every line of the file so I turned that off. Attached is a proper, working patch for 6.x-2.x. I'll be posting a 7.x-2.x patch shortly after I test it.Comment #29
jordojuice commentedAnd here's the 7.x-2.x patch. Any tests and feedback would be greatly appreciated. I'd be glad to implement any conditions or actions beyond what the 'user' data type provides by default if any Invite users have suggestions.
Comment #30
jordojuice commentedIgnore last patch. Forgot to convert tabs to spaces in Dreamweaver.
Comment #31
jordojuice commentedUgh... and again 7.x-2.x patch to patch the patch. Just coding standards issues no substantive changes. Sloppy!
Comment #32
brunorios1 commentedjordo, what steps should i do to add this integration?
you posted one zip file and two patches, i'm lost...
can i add this feature to 6.x-2.0-beta3?
thank you!
Comment #33
jordojuice commentedFor 6.x the patch in #28 is good for Invite 6.x-2.x. Apply that patch only and it will add events for "Invitation was sent", "Invitation was accepted", and "Invitation was cancelled". These three events will give you access to the user that sent the invitation - or in the case of "Invitation was selected" the user that accepted the invitation. The other two patches were for the 7.x branch.
Comment #34
ezeedub commentedHere's a patch against 6.x-2.0-beta3.
To be honest, I'm still a bit sketchy on creating patches with git. The documentation appears to assume you're building a patch off a git checkout, but I'm doing so off a regular drupal.org download.
My method was to just read the beta2 patch, and duplicate it in my own install, and then create a patch. I tried testing that the patch I created worked, and, well, it didn't... :(
I tried a few things. One was to edit the patch file with
Anyway, my problem is either in how I'm creating the patch, or how I'm applying the thing... If anyone has advice, I'd appreciate it!
Cheers
Comment #35
bjalford commentedcould someone post a patch fro d7 to test?
Comment #36
Sylense commented+1 for D7 integration. The patches in #30 and #31 do not work with the newest dev.
Comment #37
milesw commentedPosted a new patch for D7 here: #1539336: Rules integration for D7
Let's leave this issue for D6.
Comment #38
svinod999 commentedHave implemented the patch by Jordo in #28, the 6.x version... It works and emails get triggered using rules for the defined events (invites sent, accepted and cancelled). For the invites sent and cancelled, how can the invited email id be included in the mail body?
Comment #39
avpadernoI am closing this issue, since it's for a Drupal version no longer supported.