View source
<?php
function radioactivity_admin_general_form() {
$form = array();
$form['radioactivity_ajax_callback_path'] = array(
'#type' => 'textfield',
'#title' => t('Radioactivity ajax callback path'),
'#description' => t('This is the path/file that is used by the Radioactivity ajax emitter. ' . 'If you are using Varnish or a similiar HTTP accelerator you should set it not to cache this path. ' . 'Make sure no other modules use the path before changing this. ' . 'The default path is @default', array(
"@default" => RADIOACTIVITY_AJAX_PATH,
)),
'#size' => 128,
'#required' => TRUE,
'#value' => variable_get('radioactivity_ajax_callback_path', RADIOACTIVITY_AJAX_PATH),
);
$form['flooding'] = array(
'#type' => 'fieldset',
'#disabled' => true,
'#title' => t('Flood protection'),
'#description' => "Flood protection is not yet functional",
);
$form['flooding']['radioactivity_flood_protection'] = array(
'#type' => 'checkbox',
'#title' => t('Enable flood protection'),
'#description' => t('This prevents users from boosting entities by refreshing the page multiple times or by ' . 'calling the callback function directory. With flood protection enabled Radioactivity ' . 'metrics are also more accurate but consume more resources.'),
'#value' => variable_get('radioactivity_flood_protection', false),
);
$form['flooding']['radioactivity_flood_timeout'] = array(
'#type' => 'textfield',
'#title' => t('Flood protection timeout'),
'#description' => t('How many minutes are required to pass between calls to emit energy for a single field. ' . 'One incident per field per given amount of minutes.'),
'#size' => 5,
'#value' => variable_get('radioactivity_flood_timeout', 15),
);
$form['save'] = array(
'#type' => 'submit',
'#value' => t('Save'),
);
return $form;
}
function radioactivity_admin_general_form_submit($form_id, $form_state) {
$old = variable_get('radioactivity_ajax_callback_path', RADIOACTIVITY_AJAX_PATH);
$new = $form_state['input']['radioactivity_ajax_callback_path'];
variable_set('radioactivity_ajax_callback_path', $new);
if ($old != $new) {
menu_rebuild();
drupal_set_message("Menu rebuilt to reflect changes");
}
variable_set('radioactivity_flood_protection', isset($form_state['input']['radioactivity_flood_protection']) ? true : false);
variable_set('radioactivity_flood_timeout', $form_state['input']['radioactivity_flood_timeout']);
}