You are here

function invite_target_roles in Invite 6.2

Same name and namespace in other branches
  1. 7.4 invite.module \invite_target_roles()
  2. 7.2 invite.module \invite_target_roles()

Determine target roles based on the roles of an inviter.

Parameters

$invite: An invite object.

Return value

Array of target roles for an invited user.

1 call to invite_target_roles()
invite_process in ./invite.module
Process a user that accepted an invitation.

File

./invite.module, line 548
Allows your users to send and track invitations to join your site.

Code

function invite_target_roles($invite) {
  $targets = array();

  // Add a dummy entry to retrieve the default target role setting.
  $roles = array(
    'default' => 'default',
  );

  // Add roles of inviter.
  if ($invite->inviter) {
    $roles = array_merge($roles, array_intersect($invite->inviter->roles, user_roles(FALSE, 'send invitations')));
  }

  // Map to configured target roles.
  foreach ($roles as $rid => $role) {
    $target = variable_get('invite_target_role_' . $rid, DRUPAL_AUTHENTICATED_RID);
    if ($target != DRUPAL_AUTHENTICATED_RID) {
      $targets[$target] = $target;
    }
  }
  return $targets;
}