You are here

function statistics_advanced_form_submit in Statistics Advanced 5

1 string reference to 'statistics_advanced_form_submit'
statistics_advanced_form_alter in ./statistics_advanced.module
Implementation of hook_form_alter().

File

./statistics_advanced.module, line 35

Code

function statistics_advanced_form_submit($form, &$form_state) {
  $users = array_diff($form_state['values']['statistics_advanced_ignore_user_roles'], array(
    0,
  ));
  if (!empty($users)) {
    $query = db_query("SELECT DISTINCT uid FROM {users_roles} WHERE rid IN (" . db_placeholders($users, 'int') . ")", $users);
    while ($user = (int) db_result($query)) {
      $users[] = $user;

      //$result = db_query("DELETE FROM {accesslog} WHERE uid = %d", $user);
    }
    if (!empty($users) && db_query("DELETE FROM {accesslog} WHERE uid IN (" . db_placeholders($users, 'int') . ")", $users)) {
      if (db_affected_rows()) {
        drupal_set_message(format_plural(db_affected_rows(), 'Pruned 1 record from the access log.', 'Pruned @count records from the access log.'));
      }
    }
  }
}