You are here

function pmpapi_push_admin_config_submit in Public Media Platform API Integration 7

Form submission handler for pmpapi_push_admin_config().

See also

pmpapi_push_admin_config_validate()

File

pmpapi_push/pmpapi_push.admin.inc, line 194
Basic admin forms, validators, and submit handlers for the PMPAPI Push module.

Code

function pmpapi_push_admin_config_submit($form, &$form_state) {
  variable_set('pmpapi_push_push_active', $form_state['values']['pmpapi_push_push_active']);
  foreach (pmpapi_push_get_entities() as $entity_type => $entity) {
    $bundles = $entity['bundles'];
    if ($bundles) {
      foreach ($bundles as $bundle_name => $bundle) {
        $uname = $entity_type . '__' . $bundle_name;
        $profile = $form_state['values'][$uname . '_push_profile'];
        if ($profile) {
          $mapping = array();
          $fields = pmpapi_get_augmented_fields($entity_type, $bundle_name);
          foreach ($fields as $field_name => $field) {
            $mapping[$field_name] = $form_state['values']['pmpapi_push_mapping_' . $uname . '_' . $field['field_name']];
          }
          variable_set('pmpapi_push_mapping_' . $uname . '_' . $profile, $mapping);
          variable_set('pmpapi_push_' . $uname . '_push_flag', $form_state['values'][$uname . '_push_flag']);
        }
        variable_set('pmpapi_push_' . $uname . '_profile', $profile);
      }
    }
  }
  drupal_set_message(t('Push settings have been successfully saved.'));
}