When switching the default-language to german the invite-block suddenly disappears.

I found the problem in invite.module in function invite_get_role_limit. This always returns 0, thereby generating no block-output in hook invite_block.

The current code looks lilke this

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)) {
..

The last "in_array"-comparison failes because user_roles returns a translated role and $account->roles holds the original english rolename.

I did a quick-fix which is surely not the best way to go, but it works for me at least:

function invite_get_role_limit($account) {
  if (!isset($account->roles)) {
    $account = user_load(array('uid' => $account->uid));
  }

  $role_limit = 0;
  // added this because role-comparison went wrong when using non-english-language
  // therefor take all roles and put them in the translated language in an array
  $translatedRoles = array();
  foreach ($account->roles as $role) {
    $translatedRoles[] = t($role);
  }
  foreach (user_roles(0, 'send invitations') as $role) {
    $role_no_space = str_replace(' ', '_', $role);
    // compare $role with the roles in the translated array $translatedRoles not with $account->roles
    if (in_array($role, $translatedRoles)) {
..

Best regards and thanks for this wonderful module
Stefan

Comments

smk-ka’s picture

Status: Active » Closed (duplicate)