From cf2803a434205bd817c0860c72785c1b9fe63e10 Mon Sep 17 00:00:00 2001 From: jordojuice Date: Thu, 9 Jun 2011 21:03:45 -0700 Subject: [PATCH 1/2] Issue #622152: Invite Rules integration for 7.x-2.x. --- invite.module | 15 +++++++++++++++ invite.rules.inc | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 0 deletions(-) mode change 100644 => 100755 invite.module create mode 100755 invite.rules.inc diff --git a/invite.module b/invite.module old mode 100644 new mode 100755 index c25c5fe..1545a71 --- a/invite.module +++ b/invite.module @@ -541,6 +541,11 @@ function invite_process_invite($invite, $account) { $args = array('invitee' => $account, 'inviter' => $invite->inviter, 'roles' => &$roles); module_invoke_all('invite', 'escalate', $args); + // Invokes rules event "Invitation was accepted". + if (module_exists('rules')) { + rules_invoke_event('invite_accept_event', user_load($invite->inviter->uid), $account); + } + return $roles; } @@ -1139,6 +1144,11 @@ function invite_form_submit($form, &$form_state) { if (!$form_state['values']['resent']) { $args = array('inviter' => $invite->inviter, 'email' => $invite->email, 'code' => $invite->code); module_invoke_all('invite', 'invite', $args); + + // Invokes rules event "Invitation was sent". + if (module_exists('rules')) { + rules_invoke_event('invite_invite_event', user_load($invite->inviter->uid)); + } } $num_succeeded++; @@ -1300,6 +1310,11 @@ function invite_cancel_submit($form, &$form_state) { // Notify other modules. $args = array('inviter' => $invite->inviter, 'email' => $invite->email, 'code' => $invite->reg_code); module_invoke_all('invite', 'cancel', $args); + + // Invokes rules event "Invitation was cancelled". + if (module_exists('rules')) { + rules_invoke_event('invite_cancel_event', user_load($invite->inviter->uid)); + } } /** diff --git a/invite.rules.inc b/invite.rules.inc new file mode 100755 index 0000000..2d24e5e --- /dev/null +++ b/invite.rules.inc @@ -0,0 +1,38 @@ + t('Invite'), + 'module' => 'invite', + 'access callback' => 'rules_invite_integration_access', + ); + return array( + 'invite_invite_event' => $defaults + array( + 'label' => t('Invitation was sent'), + 'variables' => array( + 'inviter' => array('type' => 'user', 'label' => t('Inviting user')), + ), + ), + 'invite_cancel_event' => $defaults + array( + 'label' => t('Invitation was cancelled'), + 'variables' => array( + 'inviter' => array('type' => 'user', 'label' => t('Inviting user')), + ), + ), + 'invite_accept_event' => $defaults + array( + 'label' => t('Invitation was accepted'), + 'variables' => array( + 'inviter' => array('type' => 'user', 'label' => t('Inviting user')), + 'invited' => array('type' => 'user', 'label' => t('Invited user')), + ), + ), + ); +} -- 1.7.4 From 5e2ddc79dbafbe15378d7178ae25cb526a01b298 Mon Sep 17 00:00:00 2001 From: jordojuice Date: Thu, 9 Jun 2011 21:10:41 -0700 Subject: [PATCH 2/2] Issue #622152: Fixed formatting issues. --- invite.rules.inc | 50 +++++++++++++++++++++++++------------------------- 1 files changed, 25 insertions(+), 25 deletions(-) diff --git a/invite.rules.inc b/invite.rules.inc index 2d24e5e..6c45d37 100755 --- a/invite.rules.inc +++ b/invite.rules.inc @@ -9,30 +9,30 @@ * Implements hook_rules_event_info(). */ function invite_rules_event_info() { - $defaults = array( - 'group' => t('Invite'), - 'module' => 'invite', - 'access callback' => 'rules_invite_integration_access', - ); - return array( - 'invite_invite_event' => $defaults + array( - 'label' => t('Invitation was sent'), - 'variables' => array( - 'inviter' => array('type' => 'user', 'label' => t('Inviting user')), - ), - ), - 'invite_cancel_event' => $defaults + array( - 'label' => t('Invitation was cancelled'), - 'variables' => array( - 'inviter' => array('type' => 'user', 'label' => t('Inviting user')), - ), - ), - 'invite_accept_event' => $defaults + array( - 'label' => t('Invitation was accepted'), - 'variables' => array( - 'inviter' => array('type' => 'user', 'label' => t('Inviting user')), + $defaults = array( + 'group' => t('Invite'), + 'module' => 'invite', + 'access callback' => 'rules_invite_integration_access', + ); + return array( + 'invite_invite_event' => $defaults + array( + 'label' => t('Invitation was sent'), + 'variables' => array( + 'inviter' => array('type' => 'user', 'label' => t('Inviting user')), + ), + ), + 'invite_cancel_event' => $defaults + array( + 'label' => t('Invitation was cancelled'), + 'variables' => array( + 'inviter' => array('type' => 'user', 'label' => t('Inviting user')), + ), + ), + 'invite_accept_event' => $defaults + array( + 'label' => t('Invitation was accepted'), + 'variables' => array( + 'inviter' => array('type' => 'user', 'label' => t('Inviting user')), 'invited' => array('type' => 'user', 'label' => t('Invited user')), - ), - ), - ); + ), + ), + ); } -- 1.7.4