You are here

function ultimenu_admin_settings_form_submit in Ultimenu 7

Submit handler for ultimenu_admin_settings().

1 string reference to 'ultimenu_admin_settings_form_submit'
ultimenu_admin_settings in includes/ultimenu.admin.inc
Menu callback for 'admin/structure/ultimenu'.

File

includes/ultimenu.admin.inc, line 134
The setting for Ultimenu.

Code

function ultimenu_admin_settings_form_submit($form, &$form_state) {

  // We compact the variables for the sake of simplicity.
  $data = array();
  $data['blocks'] = array_filter($form_state['values']['blocks']);
  $data['regions'] = array_filter($form_state['values']['regions']);
  $data['goodies'] = array_filter($form_state['values']['goodies']);
  $data['skins'] = $form_state['values']['skins'];
  $old_data = variable_get('ultimenu_settings', array());

  // Do not litter global $conf.
  foreach ($data['regions'] as $key => $value) {
    if (empty($value)) {
      unset($data['regions'][$key]);
    }
  }
  foreach ($data['blocks'] as $key => $value) {
    if (empty($value)) {
      unset($data['blocks'][$key]);
    }
  }
  variable_set('ultimenu_settings', array_merge($old_data, $data));

  // Delete variables since we merged them already.
  unset($form_state['values']['blocks'], $form_state['values']['regions'], $form_state['values']['goodies']);
  drupal_static_reset('ultimenu_regions');
  drupal_static_reset('ultimenu_regions_enabled');

  // Update the system table.
  // system_rebuild_theme_data();
  // Update the theme registry.
  // drupal_theme_rebuild();
  // Last resort if anything fails.
  // drupal_flush_all_caches();
  // Warn to clear cache if anything fails.
  drupal_set_message(t('Be sure to clear cache if trouble to see the newly created regions at block admin.'));
}