--- D:\src\drupal\4.7\modules\autologout\autologout.module Mon Feb 12 01:18:58 2007 UTC +++ D:\src\htdocs\sms\modules\users\autologout\autologout.module Mon Feb 19 12:44:12 2007 UTC @@ -30,6 +30,7 @@ var $refresh_delta = 0; // force browser refresh (timeout+refresh_delta) var $use_watchdog = 1; // log auto-logouts to watchdog var $block_title = 'Automatic logout in'; + var $autologout_mode = 0; // policy mode } /* }}} */ @@ -321,16 +322,24 @@ t('Exculde : all users in this role are excluded from auto-logout functionality'), t('By user : all users in this role can select to switch off this functionality') ); - $markup3 = theme_item_list($markup3_items, t('Policy description')) . - t('Please note, if a user is found to be in a role '. - 'that allows disabling this feature, this overrides '. - 'any enforcement'); + $markup3 = theme_item_list($markup3_items, t('Policy description')); $form['autologout']['markup3'] = array( '#type' => 'markup', '#value' => $markup3 ); + $form['autologout']['autologout_mode'] = array( + '#type' => 'select', + '#title' => t('Policy rule'), + '#options' => array(0 => t('Enforcement overrides'), 1 => t('Excluding overrides'), 2 => t('By user overrides')), + '#default_value' => _autologout_local_settings('autologout_mode'), + '#description' => + t('Enforcement overrides: If a user is found to be in a role that allows enforcement, this overrides any excluding.'). '
'. + t('Excluding overrides: If a user is found to be in a role that allows disabling this feature, this overrides any enforcement.'). '
'. + t('By user overrides: User own autologout setting overrides any enforcement or excluding.') + ); + return $form; } /* }}} */ @@ -365,26 +374,30 @@ $local_user = $passed_user; } - foreach (user_roles(TRUE) as $role) { + $mode = _autologout_local_settings('autologout_mode'); + $result = FALSE; + foreach ($local_user->roles as $role) { switch (_autologout_local_settings($role)) { case 0: // Enforce for all in this role + if ($mode == 0) { + return FALSE; + } else $result = FALSE; break; case 1: // Exclude all users in this role - if (in_array($role, $local_user->roles)) { + if ($mode == 1) { return TRUE; - } + } else $result = TRUE; break; case 2: // Exclude user if user set to disable - if (in_array($role, $local_user->roles)) { - if (isset($local_user->autologout) && $local_user->autologout != 0) { - return TRUE; - } - } + $u = isset($local_user->autologout) && $local_user->autologout != 0; + if ($mode == 2) { + return $u; + } else $result = $u; break; } } - return FALSE; + return $result; } /* }}} */