You are here

function global_filter_block_save in Views Global Filter 8

Same name and namespace in other branches
  1. 6 global_filter.blocks.inc \global_filter_block_save()
  2. 7 global_filter.blocks.inc \global_filter_block_save()

Implements hook_block_save().

Notes: $delta may be something like 'global_filter_2'. $edit holds the contents of the block form

File

./global_filter.blocks.inc, line 370
global_filter.block.inc

Code

function global_filter_block_save($delta, $edit = array()) {
  foreach (_global_filter_extract_filters_from_form($edit) as $key => $filter) {
    $old_name = global_filter_get_parameter($key, 'name');
    $new_name = $filter['uses_view'] ? $filter['view'] : $filter['field'];
    global_filter_set_parameter($key, 'name', $new_name);
    global_filter_set_parameter($key, 'block', empty($new_name) ? NULL : $delta);
    if (empty($old_name) || $old_name != $new_name) {
      if (!empty($old_name)) {
        global_filter_remove_default_filter_from_views($old_name);
      }
      if (!empty($new_name)) {
        drupal_set_message(t('As you changed the global filter driver to %new, please check that the <strong>Global Filter defaults</strong> are correct. If not, make a selection and press <em>Save block</em>.', array(
          '%new' => $new_name,
        )));
        $reload_page = TRUE;
      }
    }
    if ($filter['widget'] == 'links') {
      $filter['set_on_select'] = TRUE;
    }
    foreach ($filter as $parameter_name => $value) {
      global_filter_set_parameter($key, $parameter_name, empty($new_name) ? NULL : $value);
    }
  }
  if (isset($reload_page)) {
    drupal_goto($_GET['q']);
  }
}