You are here

function userpoints_nc_visits_userpoints in User points Nodes and Comments 7

Implements hook_userpoints().

File

userpoints_nc_visits/userpoints_nc_visits.module, line 46
Hooks and functions for userpoints_nc_visits module.

Code

function userpoints_nc_visits_userpoints($op = 'setting', $params = array()) {
  if ($op == 'setting') {
    $group = 'userpoints_nc_visits';
    $form[$group] = array(
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#title' => t('Content visits'),
      '#group' => 'settings_additional',
      '#weight' => 30,
      '#attached' => array(
        'js' => array(
          'userpoints_nc_visits' => drupal_get_path('module', 'userpoints_nc_visits') . '/userpoints_nc_visits.js',
        ),
      ),
    );
    $form[$group]['userpoints_nc_visits_enabled'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enabled by default'),
      '#default_value' => userpoints_nc_visits_get_setting('enabled', NULL, TRUE),
      '#description' => t('If checked, all content types award !points for visited content by default. This can be overridden for each content type on the content type edit page.', userpoints_translation()),
    );
    $form[$group]['userpoints_nc_visits_points'] = array(
      '#type' => 'textfield',
      '#title' => t('Default !points for visited content', userpoints_translation()),
      '#description' => t('Set the default number of !points awarded to a content author when the content is visited (by another user). This can be overridden for each content type.', userpoints_translation()),
      '#default_value' => userpoints_nc_visits_get_setting('points'),
      '#size' => 5,
      '#maxlength' => 5,
    );
    $form[$group]['userpoints_nc_visits_category'] = array(
      '#type' => 'select',
      '#title' => t('Default !points category for visited content', userpoints_translation()),
      '#description' => t('Choose the category of !points to be used by default when content is visited. This can be overridden for each content type.', userpoints_translation()),
      '#options' => userpoints_get_categories(),
      '#default_value' => userpoints_nc_visits_get_setting('category'),
    );
    $form[$group]['userpoints_nc_visits_interval'] = array(
      '#type' => 'select',
      '#title' => t('Recurring visits duration'),
      '#default_value' => userpoints_nc_visits_get_setting('interval', NULL, 86400),
      '#options' => drupal_map_assoc(array(
        3600,
        10800,
        21600,
        32400,
        43200,
        86400,
        172800,
        259200,
        604800,
        1209600,
        2419200,
      ), 'format_interval'),
      '#description' => t('Select a time interval in which repeat visits to the same content from the same IP address will be considered a single visit.'),
    );
    $options = array(
      'all' => t('All content'),
      'one' => t('Only the first visited content'),
    );
    $form[$group]['userpoints_nc_visits_limit'] = array(
      '#type' => 'radios',
      '#title' => t('Eligible content'),
      '#default_value' => userpoints_nc_visits_get_setting('limit', NULL, 'all'),
      '#options' => $options,
      '#description' => t('Selecting "All content" (the default behavior) allows !points to be awarded for all content visited by a user. Alternately, selecting "Only the first visited content" will allow !points only to be awarded for the first piece of content a user visits during the "recurring visits duration" (with visits to additional content items ignored during the time interval).', userpoints_translation()),
    );
    return $form;
  }
}