Because the roles name 'authenticated user' and 'anonymous' will be localized, so there use user_roles to get the roles, and compare with the settings, it caused a bug, I used this code to resolve it, please check.
# It uses platform neutral UTF-8 encoding and \n newlines.
--- 24060
+++ 24061
@@ -364,6 +364,17 @@
$account = $user;
}
+ /**
+ * fixed the bug
+ * when the anonymous or authenticated role name were translated, so the comparsion will be fail
+ */
+ foreach ($account->roles as $rid => $rname) {
+ if ( $rid == DRUPAL_ANONYMOUS_RID
+ ||$rid == DRUPAL_AUTHENTICATED_RID ) {
+ $account->roles[$rid] = t($rname);
+ }
+ }
+
foreach (user_roles(TRUE) as $role) {
switch (_autologout_local_settings($role)) {
case 0: // Enforce for all in this role
@@ -394,6 +405,17 @@
$account = $user;
}
+ /**
+ * fixed the bug
+ * when the anonymous or authenticated role name were translated, so the comparsion will be fail
+ */
+ foreach ($account->roles as $rid => $rname) {
+ if ( $rid == DRUPAL_ANONYMOUS_RID
+ || $rid == DRUPAL_AUTHENTICATED_RID ) {
+ $account->roles[$rid] = t($rname);
+ }
+ }
+
foreach (user_roles(TRUE) as $role) {
if (_autologout_local_settings($role) == 2 && in_array($role, array_values($account->roles))) {
return TRUE;
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | autologout.patch | 1.2 KB | robbin.zhao |
Comments
Comment #1
robbin.zhao commentedThe code was messed up, and I uploaded a patch file, please check.
Comment #2
robbin.zhao commentedBy default, if a user has one role was excluded, so this user won't be logout automatically.
Replace the follow 2 functions and add 1 function if you want to set the user logout automatically if who has only one autologout role
Comment #3
johnennew commentedClosing old issue. The supported 6.x-4.x branch uses role rid so should not have this issue.