Using role-names instead of ids caused problems with other languages
guldi - April 24, 2009 - 13:15
| Project: | Invite |
| Version: | 6.x-2.0-alpha1 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | duplicate |
Description
I had some irregularities with proper assigning of the maximum invites allowed to send by role.
After reviewing the code, I found the bug.
In invite_get_role_limit, we compare the names of $account->roles with names of the results user_roles().
As long as we use only English, this is not a problem. Although the version with $role_no_space is not very nice.
But when we use another language than English, we compare the translated role-names of $account-roles with the untranslated ones of user_roles().
My suggestion: let's use the roles id's instead of the names.
I tried to change every position where the names were used to the id-using behaviour.
| Attachment | Size |
|---|---|
| invite.module.patch | 1.6 KB |
| invite_admin.inc_.patch | 1.99 KB |

#1
Could someone please have a look at this?
#2
This looks good to me except that the default target role setting was lost, so I've put it back in.
All we need now is an update function that performs the role names to rid conversion.
#3
This should be it.
Would be glad if you could check it...
<?php$result = db_query('SELECT * FROM {role} ORDER BY name');
while($role = db_fetch_object($result)) {
$role_no_space = str_replace(' ', '_', t($role->name));
$query1 = db_query("UPDATE {variable} SET name='%s' WHERE name='%s'",'invite_maxnum_'.$role->rid,'invite_maxnum_'.$role_no_space);
$query2 = db_query("UPDATE {variable} SET name='%s' WHERE name='%s'",'invite_target_role_'.$role->rid,'invite_target_role_'.$role_no_space);
}
?>
#4
what's the state here??
#5
Same patch :) but with upgrade path
http://drupal.org/node/322748#comment-1850916