You are here

function gmap_location_block_save in GMap Module 7.2

Same name and namespace in other branches
  1. 7 gmap_location.module \gmap_location_block_save()

Implements hook_block_save().

File

./gmap_location.module, line 697
GMap Location module is a module to add some gmap funcationality based on location.modules information.

Code

function gmap_location_block_save($delta = '', $edit = array()) {
  if ($delta == 0) {

    // Save macro, if customized.
    $macro = trim($edit['gmap_location_block_macro']);
    if ($macro == '[gmap |width=100% |height=200px |control=None |behavior=+autozoom +notype]' || empty($macro)) {

      // If the user doesn't customize the variable, don't set it.
      // This saves a lot of headache in the future.
      variable_del('gmap_location_block_macro');
    }
    else {
      variable_set('gmap_location_block_macro', $macro);
    }

    // Save node type specific macros.
    $ntypes = node_type_get_types();
    foreach ($ntypes as $key => $value) {
      $settings = variable_get("location_settings_node_{$key}", FALSE);
      if (isset($settings['multiple']['max']) && $settings['multiple']['max'] || variable_get("location_maxnum_{$key}", 0)) {
        $val = trim($edit["gmap_location_block_macro_{$key}"]);
        if (empty($val)) {
          variable_del("gmap_location_block_macro_{$key}");
        }
        else {
          variable_set('gmap_location_block_macro_' . $key, $edit['gmap_location_block_macro_' . $key]);
        }
      }
    }
  }
  elseif ($delta == 1) {

    // Save macro, if customized.
    $macro = trim($edit['gmap_location_author_block_macro']);
    if ($macro == '[gmap |width=100% |height=200px |control=None |behavior=+autozoom +notype]' || empty($macro)) {

      // If the user doesn't customize the variable, don't set it.
      // This saves a lot of headache in the future.
      variable_del('gmap_location_author_block_macro');
    }
    else {
      variable_set('gmap_location_author_block_macro', $macro);
    }

    // Save "enabled on" types.
    variable_set('gmap_location_author_block_types', array_keys(array_filter($edit['gmap_location_author_block_types'])));

    // Save marker.
    variable_set('gmap_location_author_block_marker', $edit['gmap_location_author_block_marker']);
  }
}