Closed (duplicate)
Project:
Invite
Version:
6.x-2.x-dev
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
20 Feb 2009 at 07:30 UTC
Updated:
4 Oct 2009 at 14:36 UTC
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
Comment #1
smk-ka commentedDuplicate of #322748: Only administrator can send invitations on multilingual installation..