Commit b9bbc3a8 authored by othermachines's avatar othermachines Committed by amitaibu

Issue #1816800 by othermachines, hernani: Integration of OG Grant Roles with Rules

parent b32258ab
......@@ -2931,7 +2931,7 @@ function og_role_grant($group_type, $gid, $uid, $rid) {
return;
}
// Get the existiong user roles.
// Get the existing user roles.
$user_roles = og_get_user_roles($group_type, $gid, $uid);
if (empty($user_roles[$rid])) {
$role = new stdClass();
......@@ -2943,6 +2943,10 @@ function og_role_grant($group_type, $gid, $uid, $rid) {
drupal_write_record('og_users_roles', $role);
og_invalidate_cache();
module_invoke_all('og_role_grant', $group_type, $gid, $uid, $rid);
if (module_exists('rules')) {
rules_invoke_event('og_role_grant', og_get_membership($group_type, $gid, 'user', $uid), entity_metadata_wrapper('user', $uid), $rid);
}
}
}
......@@ -2968,6 +2972,10 @@ function og_role_revoke($group_type, $gid, $uid, $rid) {
->condition('gid', $gid)
->execute();
module_invoke_all('og_role_revoke', $group_type, $gid, $uid, $rid);
if (module_exists('rules')) {
rules_invoke_event('og_role_revoke', og_get_membership($group_type, $gid, 'user', $uid), entity_metadata_wrapper('user', $uid), $rid);
}
}
}
......
......@@ -41,8 +41,30 @@ function og_rules_event_info() {
'og_user_delete' => $defaults + array(
'label' => t('User has been removed from group'),
'help' => t("A user has been removed from group and is no longer a group member."),
),
);
),
'og_role_grant' => array_merge_recursive($defaults, array(
'label' => t('OG role granted to user'),
'help' => t("An OG role has been granted to this user."),
'variables' => array(
'og_rid' => array(
'type' => 'integer',
'label' => t('OG role ID'),
'description' => t('The id of the OG user role.'),
),
),
)),
'og_role_revoke' => array_merge_recursive($defaults, array(
'label' => t('OG role revoked from user'),
'help' => t("An OG role has been revoked from this user."),
'variables' => array(
'og_rid' => array(
'type' => 'integer',
'label' => t('OG role ID'),
'description' => t('The id of the OG user role.'),
),
),
)),
);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment