You are here

function userpoints_admin_settings in User Points 5.3

Same name and namespace in other branches
  1. 5 userpoints.module \userpoints_admin_settings()
  2. 5.2 userpoints.module \userpoints_admin_settings()
  3. 6 userpoints.module \userpoints_admin_settings()
  4. 7.2 userpoints.admin.inc \userpoints_admin_settings()
  5. 7 userpoints.admin.inc \userpoints_admin_settings()

menu callback for settings form.

1 string reference to 'userpoints_admin_settings'
userpoints_menu in ./userpoints.module
Implementation of hook_menu().

File

./userpoints.module, line 186

Code

function userpoints_admin_settings() {
  $form = array();
  $group = 'status';
  $form[$group] = array(
    '#type' => 'fieldset',
    '#title' => t('Moderation'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#weight' => -1,
  );
  $form[$group][USERPOINTS_POINTS_MODERATION] = array(
    '#type' => 'radios',
    '#title' => t('Transaction status'),
    '#default_value' => variable_get(USERPOINTS_POINTS_MODERATION, 0),
    '#options' => array(
      t('Approved'),
      t('Moderated'),
    ),
    '#description' => t('Select whether all !points should be approved automatically, or moderated, and require admin approval', userpoints_translation()),
  );
  $group = 'renaming';
  $form[$group] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Points branding'),
  );
  $form[$group][USERPOINTS_TRANS_UCPOINTS] = array(
    '#type' => 'textfield',
    '#title' => t('Word to use in the interface for the upper case plural word !Points', userpoints_translation()),
    '#default_value' => variable_get(USERPOINTS_TRANS_UCPOINTS, 'Points'),
    '#size' => 20,
    '#maxlength' => 20,
  );
  $form[$group][USERPOINTS_TRANS_LCPOINTS] = array(
    '#type' => 'textfield',
    '#title' => t('Word to use in the interface for the lower case plural word !points', userpoints_translation()),
    '#default_value' => variable_get(USERPOINTS_TRANS_LCPOINTS, 'points'),
    '#size' => 20,
    '#maxlength' => 20,
  );
  $form[$group][USERPOINTS_TRANS_LCPOINT] = array(
    '#type' => 'textfield',
    '#title' => t('Word to use in the interface for the lower case singular word !point', userpoints_translation()),
    '#default_value' => variable_get(USERPOINTS_TRANS_LCPOINT, 'point'),
    '#size' => 20,
    '#maxlength' => 20,
  );
  $form[$group][USERPOINTS_TRANS_UNCAT] = array(
    '#type' => 'textfield',
    '#title' => t('Word to use for the uncategorized category'),
    '#default_value' => variable_get(USERPOINTS_TRANS_UNCAT, 'Uncategorized'),
    '#size' => 20,
    '#maxlength' => 20,
  );
  $group = "Points expiration";
  $form[$group] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('!Points expiration', userpoints_translation()),
    '#description' => t('These settings affect new points only, they are not retroactive!
                        Point expiration depends upon cron.
                       '),
  );
  $form[$group][USERPOINTS_EXPIREAFTER_DATE] = array(
    '#type' => 'select',
    '#title' => t('Expire !points after', userpoints_translation()),
    '#description' => t('Once points have been obtained by the user
                          they will expire according to this setting'),
    '#options' => expiry_dates(),
    '#default_value' => variable_get(USERPOINTS_EXPIREAFTER_DATE, NULL),
  );

  /**
   * If the expiration date is earlier than today
   * new points will last forever. Although this may be desirable
   * it could also be an oversight so we'll display a message
   * to the administrator
   *
   */
  $warning = "";
  if (userpoints_date_to_timestamp(variable_get(USERPOINTS_EXPIREON_DATE, array(
    'day' => 1,
    'month' => 1,
    'year' => 1900,
  ))) < time()) {
    $warning = '<br /><strong>' . t('This setting will not take affect, date must be in the future') . '</strong>';
  }
  $form[$group][USERPOINTS_EXPIREON_DATE] = array(
    '#type' => 'date',
    '#title' => t('Expire !points on this date', userpoints_translation()),
    '#description' => t('Once points have been obtained by the user they will
                         last until this date. This setting overrides the
                         "Expire after setting" above' . $warning),
    '#default_value' => variable_get(USERPOINTS_EXPIREON_DATE, array(
      'day' => 1,
      'month' => 1,
      'year' => 1980,
    )),
  );
  $form[$group][USERPOINTS_EXPIRY_DESCRIPTION] = array(
    '#type' => 'textarea',
    '#title' => t('Expiration entry description'),
    '#description' => t('A negating expiration entry is made to expire
                         points leaving the original entry intact
                         (e.g. original points + expiration points = 0).
                         When the expiration entry is made this description will
                         be placed on the entry. This is useful so the users will
                         know what happened to their point balance. In crafting
                         your message you can use the following variables.
                         <br /> !points = The name used in branding
                         above (also use !Points and !point)
                         <br />!operation = Original operation that granted the points
                         <br/> !description = Original description for the point
                         <br /> !txn_id Original transaction ID
                         <br /> !date = Date of the original entry'),
    '#default_value' => variable_get(USERPOINTS_EXPIRY_DESCRIPTION, ''),
  );
  $group = "misc";
  $form[$group] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Messages'),
    '#description' => t('Control the behavior of messages users see. '),
  );
  $form[$group][USERPOINTS_DISPLAY_MESSAGE] = array(
    '#type' => 'radios',
    '#title' => t('Display message'),
    '#default_value' => variable_get(USERPOINTS_DISPLAY_MESSAGE, 1),
    '#options' => array(
      0 => t('No'),
      1 => t('Yes'),
    ),
    '#description' => t('Determines if a message should be displayed whenever !points are awarded/substracted ', userpoints_translation()),
  );
  $group = "reports";
  $form[$group] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Report Settings'),
    '#description' => t(''),
  );
  $form[$group][USERPOINTS_REPORT_LIMIT] = array(
    '#type' => 'select',
    '#title' => t('Transactions per page'),
    '#default_value' => variable_get(USERPOINTS_REPORT_LIMIT, 10),
    '#options' => array(
      10 => 10,
      20 => 20,
      30 => 30,
      40 => 40,
      50 => 50,
      100 => 100,
    ),
    '#description' => t('Limits the number of transactions displayed per page'),
  );
  $form[$group][USERPOINTS_REPORT_DISPLAYZERO] = array(
    '#type' => 'radios',
    '#title' => t('Display zero !point users?', userpoints_translation()),
    '#default_value' => variable_get(USERPOINTS_REPORT_DISPLAYZERO, 1),
    '#options' => array(
      t('No'),
      t('Yes'),
    ),
    '#description' => t('If set to "No" users with zero !points will not be displayed in the reports ', userpoints_translation()),
  );
  $form[$group][USERPOINTS_REPORT_USERCOUNT] = array(
    '#type' => 'select',
    '#title' => t('Users per page'),
    '#default_value' => variable_get(USERPOINTS_REPORT_USERCOUNT, 30),
    '#options' => array(
      10 => 10,
      20 => 20,
      30 => 30,
      40 => 40,
      50 => 50,
      100 => 100,
    ),
    '#description' => t('When listing !points by user limit how many users are displayed on a single page', userpoints_translation()),
  );

  /* Categories will only appear if the taxonomy module is enabled as
   * the module is required for this functionality but not necessarily
   * a requirement for the module.
   */
  if (module_exists('taxonomy')) {
    $group = 'category';
    $form[$group] = array(
      '#type' => 'fieldset',
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#title' => t('!Points Categorization', userpoints_translation()),
    );
    $form[$group][USERPOINTS_CATEGORY_DEFAULT_TID] = array(
      '#type' => 'select',
      '#title' => t('Default Category'),
      '#default_value' => variable_get(USERPOINTS_CATEGORY_DEFAULT_TID, NULL),
      '#options' => userpoints_get_categories(),
      '#description' => t('By default all points are assigned to this category.  You can modify what categories are available by modifying the <a href="!url">Userpoints taxonomy</a>', array(
        '!url' => url('admin/content/taxonomy/' . variable_get(USERPOINTS_CATEGORY_DEFAULT_VID, '')),
      )),
    );
  }
  $form['setting'] = module_invoke_all('userpoints', 'setting');
  return system_settings_form($form);
}