function weather_custom_block_form_submit in Weather 5
Same name and namespace in other branches
- 5.6 weather.module \weather_custom_block_form_submit()
- 6.5 weather.module \weather_custom_block_form_submit()
Handle the submission of the custom weather block
File
- ./
weather.module, line 536 - Display <acronym title="METeorological Aerodrome Report">METAR</acronym> weather data from anywhere in the world
Code
function weather_custom_block_form_submit($form_id, $form_values) {
// delete the previous entry
$sql = "DELETE FROM {weather_config} WHERE uid=%d AND cid=%d";
db_query($sql, $form_values['uid'], $form_values['cid']);
if ($form_values['op'] == t('Save configuration')) {
// insert the new configuration values into the DB
$sql = "INSERT INTO {weather_config}\n (uid, cid, icao, real_name, units, weight)\n VALUES(%d, %d, '%s', '%s', '%s', %d)";
db_query($sql, $form_values['uid'], $form_values['cid'], $form_values['icao'], $form_values['real_name'], $form_values['units'], $form_values['weight']);
drupal_set_message(t('The configuration options have been saved.'));
}
else {
drupal_set_message(t('The configuration has been deleted.'));
$form_values['cid'] = _weather_get_first_valid_config($form_values['uid']);
}
if ($form_values['uid'] == 0) {
// go back to the administration of the system weather block
drupal_goto('admin/settings/weather/' . $form_values['cid']);
}
else {
drupal_goto('user/' . $form_values['uid'] . '/weather/' . $form_values['cid']);
}
}