You are here

function user_stats_admin_settings in User Stats 5

Same name and namespace in other branches
  1. 6 user_stats.admin.inc \user_stats_admin_settings()
  2. 7 user_stats.admin.inc \user_stats_admin_settings()

Implementation of hook_settings().

1 string reference to 'user_stats_admin_settings'
user_stats_menu in ./user_stats.module
Implementation of hook_menu().

File

./user_stats.module, line 63
User Stats provides commonly requested user statistics for themers. These are:

Code

function user_stats_admin_settings() {
  $form['post_count_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Post count options'),
    '#collapsible' => TRUE,
    '#collapsed' => variable_get('user_stats_count_posts', TRUE) || variable_get('user_stats_count_comments', TRUE) ? FALSE : TRUE,
  );
  $form['post_count_options']['user_stats_count_posts'] = array(
    '#type' => 'checkbox',
    '#title' => t('Count posts'),
    '#description' => t('If checked user post counts will be calculated.'),
    '#default_value' => variable_get('user_stats_count_posts', TRUE),
  );
  $form['post_count_options']['user_stats_count_comments'] = array(
    '#type' => 'checkbox',
    '#title' => t('Count comments'),
    '#description' => t('If checked user comments counts will be included in the total user post count.'),
    '#default_value' => variable_get('user_stats_count_comments', TRUE),
  );
  foreach (node_get_types() as $types) {
    $options[$types->type] = $types->name;
  }
  $form['post_count_options']['user_stats_included_content_types'] = array(
    '#type' => 'select',
    '#title' => t('Content types to include in post count'),
    '#description' => t('Select the content types to include in the user post count (hold ctrl or shift to select multiple types). Both nodes and comments will be included in the post count. If you do not select any content types, then all types will be counted.'),
    '#options' => $options,
    '#default_value' => variable_get('user_stats_included_content_types', array()),
    '#multiple' => TRUE,
    '#size' => 10,
  );
  $profile_fields = array(
    '' => 'None',
  );
  $result = db_query("SELECT name, title FROM {profile_fields} ORDER BY fid");
  while ($row = db_fetch_object($result)) {
    $profile_fields[$row->name] = $row->title;
  }
  $form['post_count_options']['user_stats_post_count_profile_field'] = array(
    '#type' => 'select',
    '#title' => t('User stats post count profile field'),
    '#description' => t('This is the profile field that holds the post count for a user. Changing this can be useful if you have multiple sites using the same database (or you just do not like the default field used for post counts). <strong>The default setting should work for most people.</strong>'),
    '#options' => $profile_fields,
    '#default_value' => variable_get('user_stats_post_count_profile_field', 'user_post_count'),
    '#required' => TRUE,
  );
  $form['post_count_options']['user_stats_user_per_cron'] = array(
    '#type' => 'select',
    '#title' => t('Number of users to update per cron run'),
    '#options' => array(
      '10' => '10',
      '25' => '25',
      '50' => '50',
      '100' => '100',
      '200' => '200',
    ),
    '#default_value' => variable_get('user_stats_user_per_cron', array(
      '25',
    )),
  );
  $form['post_count_options']['post_count_reset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Post count reset'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['post_count_options']['post_count_reset']['user_stats_reset_post_count'] = array(
    '#type' => 'submit',
    '#value' => t('Reset all post counts'),
  );
  $form['login_count_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Login count options'),
    '#collapsible' => TRUE,
    '#collapsed' => variable_get('user_stats_count_logins', TRUE) ? FALSE : TRUE,
  );
  $form['login_count_options']['user_stats_count_logins'] = array(
    '#type' => 'checkbox',
    '#title' => t('Count logins'),
    '#description' => t('If checked user login counts will be calculated.'),
    '#default_value' => variable_get('user_stats_count_logins', TRUE),
  );
  $form['login_count_options']['login_count_reset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Login count reset'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['login_count_options']['login_count_reset']['user_stats_reset_login_count'] = array(
    '#type' => 'submit',
    '#value' => t('Reset all login counts'),
  );
  return system_settings_form($form);
}