function uc_ip2country_admin_settings in IP-based Determination of a Visitor's Country 5
Default IP to Country administration settings.
Return value
Forms for store administrator to set configuration options.
1 string reference to 'uc_ip2country_admin_settings'
- uc_ip2country_menu in ./
uc_ip2country.module - Implementation of hook_menu().
File
- ./
uc_ip2country.module, line 234 - Determination of user's Country based on IP
Code
function uc_ip2country_admin_settings() {
uc_add_js(drupal_get_path('module', 'uc_ip2country') . '/uc_ip2country.js');
drupal_add_css(drupal_get_path('module', 'uc_ip2country') . '/uc_ip2country.css');
/* Container for database update preference forms */
$form['ip2country_database_update'] = array(
'#type' => 'fieldset',
'#title' => t('Database Updates'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
/* Form to enable watchdog logging of updates */
$form['ip2country_database_update']['ip2country_watchdog'] = array(
'#type' => 'checkbox',
'#title' => t('Log database updates to watchdog'),
'#default_value' => variable_get('ip2country_watchdog', 1),
);
/* Form to choose RIR */
$form['ip2country_database_update']['ip2country_rir'] = array(
'#type' => 'select',
'#title' => t('Regional Internet Registry to use'),
'#options' => array(
'afrinic' => 'AFRINIC',
'apnic' => 'APNIC',
'arin' => 'ARIN',
'lacnic' => 'LACNIC',
'ripe' => 'RIPE',
),
'#default_value' => variable_get('ip2country_rir', 'arin'),
'#description' => t('You may find that the regional server nearest you has the best response time, but note that AFRINIC provides only its own subset of registration data.'),
);
$period = drupal_map_assoc(array(
86400,
302400,
604800,
1209600,
2419200,
), 'format_interval');
/* Form to set automatic update interval */
$form['ip2country_database_update']['ip2country_update_interval'] = array(
'#type' => 'select',
'#title' => t('Database update frequency'),
'#default_value' => variable_get('ip2country_update_interval', 604800),
'#options' => $period,
'#description' => t('Database will be automatically updated via cron.php. Cron must be enabled for this to work. Default period is 1 week (604800 seconds).'),
);
$update_time = variable_get('ip2country_last_update', 0);
/* Form for manual updating of the IP-Country database */
$form['ip2country_database_update']['ip2country_update_database'] = array(
'#type' => 'button',
'#value' => t('Update'),
'#prefix' => '<div>' . t('The IP to Country Database may be updated manually by pressing the Update button below. Note, this may take several minutes.') . '</div>',
'#suffix' => '<span id="dbthrobber" class="message">' . t('Database last updated on ') . format_date($update_time, 'custom', 'n/j/Y') . ' at ' . format_date($update_time, 'custom', 'H:i:s T') . '</span>',
);
/* Container for manual lookup */
$form['ip2country_manual_lookup'] = array(
'#type' => 'fieldset',
'#title' => t('Manual Lookup'),
'#description' => t('Examine database values'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
/* Form for manual lookups */
$form['ip2country_manual_lookup']['ip2country_lookup'] = array(
'#type' => 'textfield',
'#title' => t('Manual Lookup'),
'#description' => t('Enter IP address'),
);
/* Form for manual updating of the IP-Country database */
$form['ip2country_manual_lookup']['ip2country_lookup_button'] = array(
'#type' => 'button',
'#value' => t('Lookup'),
'#prefix' => '<div>' . t('An IP address may be looked up in the database by entering the address above then pressing the Lookup button below.') . '</div>',
'#suffix' => '<span id="lookup-message" class="message"></span>',
);
/* Container for debugging preference forms */
$form['ip2country_debug_preferences'] = array(
'#type' => 'fieldset',
'#title' => t('Debug Preferences'),
'#description' => t('Set debugging values'),
'#collapsible' => FALSE,
'#collapsed' => FALSE,
);
/* Form to turn on debugging */
$form['ip2country_debug_preferences']['ip2country_debug'] = array(
'#type' => 'checkbox',
'#title' => t('Admin Debug'),
'#default_value' => variable_get('ip2country_debug', FALSE),
'#description' => t('Allows admin to specify an IP Address or Country to use for location-based currency.'),
);
/* Form to select Dummy Country or Dummy IP Address for testing */
$form['ip2country_debug_preferences']['ip2country_test_type'] = array(
'#type' => 'radios',
'#title' => t('Bypass IP/Country check for administrator and manually enter'),
'#default_value' => variable_get('ip2country_test_type', 0),
'#options' => array(
t('Country'),
t('IP Address'),
),
);
$dd = variable_get('ip2country_test_country', uc_ip2country_get_country($_SERVER['REMOTE_ADDR']));
$form['ip2country_debug_preferences']['ip2country_test_country'] = uc_country_select(t('Dummy Country to use for testing'), $dd, NULL, 'name', FALSE);
$form['ip2country_debug_preferences']['ip2country_test_ip_address'] = array(
'#type' => 'textfield',
'#title' => t('Dummy IP to use for testing'),
'#default_value' => variable_get('ip2country_test_ip_address', $_SERVER['REMOTE_ADDR']),
);
return system_settings_form($form);
}