Okay, I have integrated this module with rules. I don't know how to write patches yet but I'll work on that. In the mean time, I have written the functions and the lines on where to put them to have rules integration.
The problem is, I'm not 100% sure that where I put the rules events is the best/most secure way to do it. All that I know is that "it works." I'd like to confer with people here that my approach is correct.
Currently, I have created two rules events:
1. A user is invited to the node.
2. A user RSVP's to the node.
Here is the code you will place in the code in order for it to work:
At the bottom of node_invite.module:
After
drupal_json($matches);
}
(line 985 I believe)
Put this code:
//Rules Integration
function node_invite_rules_event_info() {
return array (
'user_invited' => array(
'label' => t('A user is invited to a node'),
'module' => 'node_invite',
'arguments' => array(
'user' => array('type' => 'user', 'label' => t('The user invited to the node.')),
'node' => array('type' => 'node', 'label' => t('The node the user is invited to.')),
),),
'user_rsvp' => array(
'label' => t('A user RSVPs to a node'),
'module' => 'node_invite',
'arguments' => array(
'user' => array('type' => 'user', 'label' => t('The user that RSVPd to the node.')),
'node' => array('type' => 'node', 'label' => t('The node the user RSVPd to.')),
),)
);
}
Put this code in node_invite.send.inc, within function node_invite_send_submit($form, &$form_state), around line 198.
// Send the invite
node_invite_send_mail($invite, $node);
//Rules integration
rules_invoke_event('user_invited', $account, $node);
$send_count++;
}
Put this code in node_invite.rsvp.inc, after the bracket on line 185, and right above the //notify the inviter line.
//Rules Integration
//Check to see if the user RSVP'd and is a user, $user->uid
//if (($invite->status == 'Yes') && ($invite->uid_invitee)) {
$nid = $invite->nid;
$node = node_load($nid);
$uid = $invite->uid_invitee;
$user = user_load($uid);
rules_invoke_event('user_rsvp', $user, $node);
That's it! Any suggestions to make this more efficient would probably be a good thing
Thanks!
Comments
Comment #1
rc2020 commentedHas anyone else tried their hand at testing this? I think somehow the user_invited rule is somewhat problematic...I'd love extra input.
Comment #2
rc2020 commentedCorrection: For the "user is invited to node" rule, the rules trigger is improperly placed on node_invite_send.inc
It should be on line 184, right above the code as follows: