function user_stats_settings_change in User Stats 7
Same name and namespace in other branches
- 6 user_stats.admin.inc \user_stats_settings_change()
Settings change callback. TODO: make this check a setting has been changed before resetting counts.
1 string reference to 'user_stats_settings_change'
- user_stats_admin_settings in ./
user_stats.admin.inc - Implements hook_settings().
File
- ./
user_stats.admin.inc, line 147 - Commonly requested user statistics for themers administration interface.
Code
function user_stats_settings_change($form, &$form_state) {
$op = isset($form_state['values']['op']) ? $form_state['values']['op'] : '';
// Give user feedback that post counts have been reset as requested.
if ($op == t('Reset all post counts')) {
drupal_goto('admin/config/people/user_stats/reset_post_count');
}
else {
if ($op == t('Reset all login counts')) {
drupal_goto('admin/config/people/user_stats/reset_login_count');
}
}
// If the user has decided not to track IPs, we delete all the logged entries.
if (!$form_state['values']['user_stats_track_ips'] && variable_get('user_stats_track_ips', TRUE) && db_query("SELECT COUNT(*) FROM {user_stats_ips}")
->fetchField()) {
db_query("TRUNCATE TABLE {user_stats_ips}");
}
// We also need to rebuild the menus, as some Views we provide in the
// Reports section rely on IP address tracking.
if ($form_state['values']['user_stats_track_ips'] != variable_get('user_stats_track_ips', TRUE)) {
// We have to save the form value for user_stats_track_ips before the menus
// are rebuilt.
variable_set('user_stats_track_ips', $form_state['values']['user_stats_track_ips']);
menu_rebuild();
}
// Rebuild post count stats when settings change.
variable_set('user_stats_rebuild_stats', TRUE);
user_stats_reset_counts('post_count');
}