function userpoints_admin_settings in User Points 7
Same name and namespace in other branches
- 5.3 userpoints.module \userpoints_admin_settings()
- 5 userpoints.module \userpoints_admin_settings()
- 5.2 userpoints.module \userpoints_admin_settings()
- 6 userpoints.module \userpoints_admin_settings()
- 7.2 userpoints.admin.inc \userpoints_admin_settings()
Menu callback for settings form.
1 string reference to 'userpoints_admin_settings'
- userpoints_menu in ./
userpoints.module - Implements hook_menu().
File
- ./
userpoints.admin.inc, line 566 - Admin menu callbacks for userpoints.module.
Code
function userpoints_admin_settings($form, &$form_state) {
drupal_set_title(t('!Points settings', userpoints_translation()));
drupal_add_js(drupal_get_path('module', 'userpoints') . '/userpoints_admin.js');
$form['settings'] = array(
'#prefix' => '<h3>' . t('Core !points settings', userpoints_translation()) . '</h3>',
'#type' => 'vertical_tabs',
);
$group = 'renaming';
$form[$group] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Branding'),
'#group' => 'settings',
);
$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_UCPOINT] = array(
'#type' => 'textfield',
'#title' => t('Word to use in the interface for the upper case singular word !Point', userpoints_translation()),
'#default_value' => variable_get(USERPOINTS_TRANS_UCPOINT, 'Point'),
'#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,
);
$group = 'status';
$form[$group] = array(
'#type' => 'fieldset',
'#title' => t('Moderation'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => -1,
'#group' => 'settings',
);
$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 = "Points expiration";
$form[$group] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Expiration', userpoints_translation()),
'#description' => t('These settings affect new !points only, they are not retroactive. !Points expiration depends upon cron.', userpoints_translation()),
'#group' => 'settings',
);
$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', userpoints_translation()),
'#options' => userpoints_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,
))) < REQUEST_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 ', userpoints_translation()) . $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('When !points expire, you may include a description that explains to the user why his !points balance has changed. You may include the following variables in your description:', userpoints_translation()) . '<br /><br />' . t('!points = Brand name used for points (lowercase, plural)
<br />!point = Brand name used for point (lowercase, singular)
<br />!Points = Brand name used for Points (capitalized, plural)
<br />!Point = Brand name used for Point (capitalized, singular)
<br />!operation = Operation that granted the original points transaction
<br />!description = Description of the original points transaction
<br />!txn_id = Transaction ID for the original points transaction
<br />!date = Date and time of the original points transaction'),
'#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.'),
'#group' => 'settings',
);
$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/subtracted.', userpoints_translation()),
);
$group = "reports";
$form[$group] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Listings'),
'#group' => 'settings',
);
$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()),
);
$form[$group]['userpoints_truncate'] = array(
'#type' => 'textfield',
'#title' => t('Truncation length for the "Reason" column in transaction listings'),
'#description' => t('Choose the truncation length in characters for the "Reason" column in transaction listings. The reason is not truncated on the transaction details page.'),
'#default_value' => variable_get('userpoints_truncate', 30),
'#size' => 5,
'#maxlength' => 5,
);
// 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('Categorization', userpoints_translation()),
'#group' => 'settings',
);
$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_merge(userpoints_translation(), array(
'!url' => url('admin/structure/taxonomy/' . taxonomy_vocabulary_load(variable_get(USERPOINTS_CATEGORY_DEFAULT_VID, ''))->machine_name),
))),
);
$options = userpoints_get_categories(NULL);
// 0 can not be used as a checkbox value.
$options = array(
'uncategorized' => $options[0],
) + $options + array(
'all' => t('Total !points in all categories', userpoints_translation()),
);
unset($options[0]);
$form[$group][USERPOINTS_CATEGORY_PROFILE_DISPLAY_TID] = array(
'#type' => 'checkboxes',
'#title' => t("Categories to display on the user profile page and in the User's !points block", userpoints_translation()),
'#default_value' => variable_get(USERPOINTS_CATEGORY_PROFILE_DISPLAY_TID, array_keys($options)),
'#options' => $options,
'#description' => t('Select the !points categories that should be displayed. Check "Total !points in all categories" to display a sum total of all individual !points categories.', userpoints_translation()),
);
$form[$group][USERPOINTS_TRANS_UNCAT] = array(
'#type' => 'textfield',
'#title' => t('Word to use for the general category'),
'#default_value' => variable_get(USERPOINTS_TRANS_UNCAT, 'General'),
'#description' => t("By default, %default is the name used for the module's umbrella category. You may change this here.", array(
'%default' => t('General'),
)),
'#size' => 20,
'#maxlength' => 20,
);
}
// New configuration options to override current timestamp.
$group = "stamping";
$form[$group] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Transaction stamping'),
'#group' => 'settings',
);
$form[$group][USERPOINTS_TRANSACTION_TIMESTAMP] = array(
'#type' => 'checkbox',
'#title' => t('Always use system time'),
'#default_value' => variable_get(USERPOINTS_TRANSACTION_TIMESTAMP, 1),
'#description' => t('Sets if the transaction timestamp should obey current time, or can be modified by the API operations. Unchecking this option will allow customization of timestamp for the transactions.'),
);
$form['settings_additional'] = array(
'#prefix' => '<h3>' . t('Additional !points settings', userpoints_translation()) . '</h3>',
'#type' => 'vertical_tabs',
);
$form['setting'] = userpoints_invoke_all('setting');
// Hide the additional vertical_tabs element if nothing is being displayed in
// it.
if (isset($form['settings']) && empty($form['settings'])) {
$form['settings_additional']['#access'] = FALSE;
}
return system_settings_form($form);
}