You are here

function invite_get_role_limit in Invite 7.2

Same name and namespace in other branches
  1. 5.2 invite.module \invite_get_role_limit()
  2. 6.2 invite.module \invite_get_role_limit()

Calculate the max. number of invites based on a user's role.

Parameters

$account: A user object.

Return value

The configured maximum of invites.

1 call to invite_get_role_limit()
invite_get_remaining_invites in ./invite.module
Calculate the remaining invites of a user.

File

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

Code

function invite_get_role_limit($account) {
  if (!isset($account->roles)) {
    $account = user_load($account->uid);
  }
  $role_limit = 0;
  foreach (user_roles(FALSE, 'send invitations') as $rid => $role) {
    if (array_key_exists($rid, $account->roles)) {
      $role_max = variable_get('invite_maxnum_' . $rid, INVITE_UNLIMITED);
      if ($role_max == INVITE_UNLIMITED) {
        return INVITE_UNLIMITED;
      }
      $role_limit = max($role_max, $role_limit);
    }
  }
  return $role_limit;
}