You are here

function forward_admin_settings_submit in Forward 7.3

Same name and namespace in other branches
  1. 6 forward.module \forward_admin_settings_submit()
  2. 7 forward.module \forward_admin_settings_submit()
  3. 7.2 forward.admin.inc \forward_admin_settings_submit()

Additional submit handler for administrative settings to handle entity type settings

1 string reference to 'forward_admin_settings_submit'
forward_admin_settings in ./forward.admin.inc
Callback function for administration menu item

File

./forward.admin.inc, line 510
Administrative page for Forward module

Code

function forward_admin_settings_submit($form, &$form_state) {
  $entity_types = entity_get_info();

  // Entity types and bundles
  foreach ($entity_types as $type => $info) {
    if (!empty($form_state['values']['forward_entity_types'][$type])) {
      variable_set('forward_entity_' . $type, TRUE);
    }
    else {
      variable_set('forward_entity_' . $type, FALSE);
    }
    foreach ($entity_types[$type]['bundles'] as $bundle => $bundle_info) {
      if (!empty($form_state['values']['forward_entity_types'][$type]) && !empty($form_state['values']['forward_' . $type . '_types'][$bundle])) {
        variable_set('forward_' . $type . '_' . $bundle, TRUE);
      }
      else {
        variable_set('forward_' . $type . '_' . $bundle, FALSE);
      }

      // If only one bundle, it gets the same setting as its type
      if (count($entity_types[$type]['bundles']) == 1) {
        variable_set('forward_' . $type . '_' . $bundle, variable_get('forward_entity_' . $type, FALSE));
      }
    }
    unset($form_state['values']['forward_' . $type . '_types']);
  }
  unset($form_state['values']['forward_entity_types']);

  // View modes
  $modes = array(
    'full' => t('Full entity'),
    'teaser' => t('Teaser'),
  );
  foreach ($modes as $mode => $info) {
    if (!empty($form_state['values']['forward_view_modes'][$mode])) {
      variable_set('forward_view_' . $mode, TRUE);
    }
    else {
      variable_set('forward_view_' . $mode, FALSE);
    }
  }
  unset($form_state['values']['forward_view_modes']);
}