You are here

function yr_verdata_add_location_submit in Yr Weatherdata 6

Implementation of hook_submit().

File

./yr_verdata.module, line 630
yr_verdata.module This file provides the yr_verdata forecast module.

Code

function yr_verdata_add_location_submit($form, &$form_state) {
  $url = $form_state['values']['language'] . '/' . $form_state['values']['country'] . '/' . $form_state['values']['region'] . '/' . $form_state['values']['subregion'];
  $url .= !empty($form_state['values']['location']) ? '/' . $form_state['values']['location'] : '';
  $url = str_replace(' ', '_', $url);

  // Attempt to underscore any spaces in names, for better usability.
  // To make sure that locations without a locationname don't always show up first, we give them 'x' as location name.
  $location = !empty($form_state['values']['location']) ? $form_state['values']['location'] : 'x';
  db_query("INSERT INTO {yr_verdata} (url, location, subregion, region, country) VALUES ('%s', '%s', '%s', '%s', '%s')", $url, $location, $form_state['values']['subregion'], $form_state['values']['region'], $form_state['values']['country']);
}