You are here

function getlocations_tools_import_form_submit in Get Locations 7

Same name and namespace in other branches
  1. 7.2 modules/getlocations_tools/getlocations_tools.module \getlocations_tools_import_form_submit()

File

modules/getlocations_tools/getlocations_tools.module, line 241
getlocations_tools.module @author Bob Hutchinson http://drupal.org/user/52366 @copyright GNU GPL

Code

function getlocations_tools_import_form_submit($form, &$form_state) {
  if ($form_state['values']['getlocations_tools_import_select'] == 0) {
    return;
  }
  else {
    variable_set('getlocations_tools_import_select', $form_state['values']['getlocations_tools_import_select']);
  }
  if (empty($form_state['values']['getlocations_tools_import_content'])) {
    return;
  }
  $import_select = $form_state['values']['getlocations_tools_import_select'];

  // Be forgiving if someone pastes code that starts with '<?php'.
  if (substr($form_state['values']['getlocations_tools_import_content'], 0, 5) == '<?php') {
    $form_state['values']['getlocations_tools_import_content'] = substr($form_state['values']['getlocations_tools_import_content'], 5);
  }
  ob_start();
  eval($form_state['values']['getlocations_tools_import_content']);
  ob_end_clean();
  $msg = t('Unable to interpret code.');
  if ($import_select == 1) {

    // getlocations_defaults
    if (isset($getlocations_defaults) && is_array($getlocations_defaults)) {
      variable_set('getlocations_defaults', $getlocations_defaults);
      $msg = t('Getlocations settings imported');
    }
    if (isset($getlocations_paths) && is_array($getlocations_paths)) {
      variable_set('getlocations_paths', $getlocations_paths);
    }
    if (isset($getlocations_node_marker) && is_array($getlocations_node_marker)) {
      variable_set('getlocations_node_marker', $getlocations_node_marker);
    }
    if (isset($getlocations_vocabulary_marker) && is_array($getlocations_vocabulary_marker)) {
      variable_set('getlocations_vocabulary_marker', $getlocations_vocabulary_marker);
    }
    if (isset($getlocations_term_marker) && is_array($getlocations_term_marker)) {
      variable_set('getlocations_term_marker', $getlocations_term_marker);
    }
    if (isset($getlocations_colorbox) && is_array($getlocations_colorbox)) {
      variable_set('getlocations_colorbox', $getlocations_colorbox);
    }
    if (isset($getlocations_ua) && is_array($getlocations_ua)) {
      variable_set('getlocations_ua', $getlocations_ua);
    }
    if (isset($getlocations_aggr)) {
      variable_set('getlocations_aggr', $getlocations_aggr);
    }
    if (isset($getlocations_flush)) {
      variable_set('getlocations_flush', $getlocations_flush);
    }
    if (isset($getlocations_api3_key)) {
      variable_set('getlocations_api3_key', $getlocations_api3_key);
    }
  }
  elseif ($import_select == 2) {

    // getlocations_fields_defaults
    if (isset($getlocations_fields_defaults) && is_array($getlocations_fields_defaults)) {
      variable_set('getlocations_fields_defaults', $getlocations_fields_defaults);
      $msg = t('Getlocations Fields settings imported');
    }
    if (isset($getlocations_fields_paths) && is_array($getlocations_fields_paths)) {
      variable_set('getlocations_fields_paths', $getlocations_fields_paths);
    }
  }
  elseif ($import_select == 3) {

    // getlocations_search_defaults
    if (isset($getlocations_search_defaults) && is_array($getlocations_search_defaults)) {
      variable_set('getlocations_search_defaults', $getlocations_search_defaults);
      $msg = t('Getlocations Search settings imported');
    }
    if (isset($getlocations_search_paths) && is_array($getlocations_search_paths)) {
      variable_set('getlocations_search_paths', $getlocations_search_paths);
    }
  }
  elseif ($import_select == 4) {

    // getlocations_leaflet_defaults
    if (isset($getlocations_leaflet_defaults) && is_array($getlocations_leaflet_defaults)) {
      variable_set('getlocations_leaflet_defaults', $getlocations_leaflet_defaults);
      $msg = t('Getlocations Leaflet settings imported');
    }
    if (isset($getlocations_leaflet_paths) && is_array($getlocations_leaflet_paths)) {
      variable_set('getlocations_leaflet_paths', $getlocations_leaflet_paths);
    }
    if (isset($getlocations_leaflet_plugins) && is_array($getlocations_leaflet_plugins)) {
      variable_set('getlocations_leaflet_plugins', $getlocations_leaflet_plugins);
    }
    if (isset($getlocations_leaflet_cloudmade) && is_array($getlocations_leaflet_cloudmade)) {
      variable_set('getlocations_leaflet_cloudmade', $getlocations_leaflet_cloudmade);
    }
  }
  drupal_set_message($msg);
}