function smart_ip_update_db_batch in Smart IP 6
Same name and namespace in other branches
- 6.2 includes/smart_ip.utility.inc \smart_ip_update_db_batch()
- 7.2 includes/smart_ip.utility.inc \smart_ip_update_db_batch()
- 7 includes/smart_ip.utility.inc \smart_ip_update_db_batch()
Prepare a batch definition
This will download/extract CSV from maxmind.com and update the Smart IP database.
1 call to smart_ip_update_db_batch()
- _smart_ip_database_update_submit in includes/
smart_ip.admin.inc - Submit handler to update the Smart IP database.
File
- includes/
smart_ip.utility.inc, line 14 - Utility routines to load the Smart IP database.
Code
function smart_ip_update_db_batch($src = NULL) {
if (empty($src)) {
$src = smart_ip_get_csv_source_filename();
}
$operations = array();
$operations[] = array(
'smart_ip_get_zip',
array(
$src,
),
);
$operations[] = array(
'smart_ip_extract_zip',
array(),
);
$operations[] = array(
'smart_ip_store_location_csv',
array(),
);
$operations[] = array(
'smart_ip_update_database',
array(),
);
$recover = variable_get('smart_ip_get_zip_done', FALSE) | variable_get('smart_ip_extract_zip_done', FALSE) | variable_get('smart_ip_store_location_csv_done', FALSE);
$batch = array(
'operations' => $operations,
'finished' => 'smart_ip_update_db_batch_finished',
// We can define custom messages instead of the default ones.
'title' => t('Processing download/extract CSV from maxmind.com and update Smart IP database'),
'init_message' => $recover ? t('Recovering...') : t('Starting...'),
//'progress_message' => t('Elapsed: @elapsed.'),
'error_message' => t('Downloading/extracting CSV has encountered an error.'),
'file' => drupal_get_path('module', 'smart_ip') . '/includes/smart_ip.utility.inc',
);
return $batch;
}