function weather_custom_block_form_submit in Weather 6.5
Same name and namespace in other branches
- 5.6 weather.module \weather_custom_block_form_submit()
- 5 weather.module \weather_custom_block_form_submit()
Handle the submission of the custom weather block
File
- ./
weather.module, line 962 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function weather_custom_block_form_submit($form, &$form_state) {
// delete the previous entry
$sql = "DELETE FROM {weather_config} WHERE uid=%d AND cid=%d";
db_query($sql, $form_state['values']['uid'], $form_state['values']['cid']);
// insert the new configuration values into the DB
$sql = "INSERT INTO {weather_config}\n (uid, cid, icao, real_name, units, settings, weight)\n VALUES(%d, %d, '%s', '%s', '%s', '%s', %d)";
db_query($sql, $form_state['values']['uid'], $form_state['values']['cid'], strtoupper($form_state['values']['icao']), $form_state['values']['real_name'], serialize($form_state['values']['units']), serialize($form_state['values']['settings']), $form_state['values']['weight']);
if ($form_state['values']['uid'] == 0) {
drupal_set_message(t('The default configuration has been saved.'));
}
else {
drupal_set_message(t('The location has been saved.'));
}
if ($form_state['values']['uid'] <= 0) {
// go back to the administration of the system weather block,
// if this is the default configuration or a system-wide block
$form_state['redirect'] = 'admin/settings/weather';
/** TODO
* Rehashing is not needed on every submission, only if the block
* is newly created. On the other hand, this happens only
* rarely and surely is not a performance bottleneck.
*/
_block_rehash();
}
else {
$form_state['redirect'] = 'user/' . $form_state['values']['uid'] . '/weather';
}
}