You are here

function invite_get_role_limit in Invite 5.2

Same name and namespace in other branches
  1. 6.2 invite.module \invite_get_role_limit()
  2. 7.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 623
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(array(
      'uid' => $account->uid,
    ));
  }
  $role_limit = 0;
  foreach (user_roles(0, 'send invitations') as $role) {
    $role_no_space = str_replace(' ', '_', $role);
    if (in_array($role, $account->roles)) {
      $role_max = variable_get('invite_maxnum_' . $role_no_space, INVITE_UNLIMITED);
      if ($role_max == INVITE_UNLIMITED) {
        return INVITE_UNLIMITED;
      }
      $role_limit = max($role_max, $role_limit);
    }
  }
  return $role_limit;
}