Hey,

As we've talked there is a strong use case for creating triggers that integrate with rules to perform back-end workflow jobs. The results of this can be highly flexible. Mails can be sent to users, messages can be sent, system messages can be set, and nodes can be flagged that can show listings of users because of flag relationships in views.

(For example: Have a hidden flag that can be triggered when a user RSVP's to a node via node invite. Using rules, that user flags the node behind the scenes (they never see it). Views are then used to show the user who has flagged that node, thus creating a list of users who have RSVP'd in views, no muss, no fuss.

The basic step that facilitates this functionality is writing some triggers that integrates with rules module. Essentially, the triggers should be as follows (in my opinion).

1. If a site user is invited to the node (via the userreference functionality).
2. If a site user replies to an invite, I.E. receives invite and RSVP's to it.
3. If a site user replies to an invite and shows interest/chooses 'maybe' option (if node invite has this, I might be getting this mixed up with RSVP).

I'll try to think of some more in a few and reply back.

What do you think about this?

Thanks!

Comments

rc2020’s picture

The normal trigger/actions module isn't too effective in generating complex workflow. The Rules module (http://drupal.org/project/rules) is far superior, and I think that should be the method to write the triggers.

I looked through the documentation and I have made some headway on this. I added this code at the bottom of node_invite.module and the event populates in the rules selection just fine.

 /**
   * hook_rules_event_info().
   * @ingroup rules
   */

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('User is invited to node')),
		'node' => array('type' => 'node', 'label => t('The node the user is invited to')),
		),
	),
);
	}

Essentially, this works when a piece of code is fired in the module file. To make this trigger 'work' so I.E. rules knows when it's about to happen, this code is excecuted:

  rules_invoke_event('user_invited', $user, $node);

So essentially, as per the rule I wrote above, when "A user is invited to a node, execute this code." For testing purposes, where on the module is the function that invites the user to the node, so I can capture these variables for testing? (Obviously final incorporation would work differently but I want to get it working first!).

Thanks!

rc2020’s picture

I have completed this. I'll be figuring out how to include it in a patch shortly.