You are here

function location_addanother_form_submit in Location 5.3

Same name and namespace in other branches
  1. 6.3 contrib/location_addanother/location_addanother.module \location_addanother_form_submit()
  2. 7.5 contrib/location_addanother/location_addanother.module \location_addanother_form_submit()
  3. 7.3 contrib/location_addanother/location_addanother.module \location_addanother_form_submit()
  4. 7.4 contrib/location_addanother/location_addanother.module \location_addanother_form_submit()

Submission function for "add another location" form.

File

contrib/location_addanother/location_addanother.module, line 82
"Add location from node view" functionality. Split from main location.module in version 3.

Code

function location_addanother_form_submit($form_id, &$form_values) {
  $location = $form_values['location'];
  $node = node_load($location['nid']);
  unset($location['nid']);

  // As this is always a new location, no need to delete anything first...
  $lid = location_save($location, TRUE);
  if ($lid) {
    db_query('INSERT INTO {location_instance} (nid, vid, lid) VALUES (%d, %d, %d)', $node->nid, $node->vid, $lid);
    drupal_set_message(t('Your new location has been added. (See below)'));
  }
  return 'node/' . $node->nid;
}