You are here

function pmpapi_pull_admin_config_submit in Public Media Platform API Integration 7

Form submission handler for pmpapi_pull_admin_config().

See also

pmpapi_pull_admin_config_validate()

File

pmpapi_pull/pmpapi_pull.admin.inc, line 200
Basic admin forms, validators, and submit handlers.

Code

function pmpapi_pull_admin_config_submit($form, &$form_state) {
  variable_set('pmpapi_pull_pull_active', $form_state['values']['pmpapi_pull_pull_active']);
  variable_set('pmpapi_pull_pull_user', $form_state['values']['pmpapi_pull_pull_user']);
  foreach (pmpapi_pull_get_entities() as $entity_type => $entity) {
    $bundles = $entity['bundles'];
    foreach ($bundles as $bundle_name => $bundle) {
      $uname = $entity_type . '__' . $bundle_name;
      $profile = $form_state['values'][$uname . '_pull_profile'];
      if ($profile) {
        $pmp_fields = pmpapi_get_profile_info($profile);
        $map = array();
        foreach ($pmp_fields as $pmp_name => $pmp_field) {
          if (isset($form_state['values']['pmpapi_pull_mapping_' . $uname . '_' . $pmp_name])) {
            $map[$pmp_name] = $form_state['values']['pmpapi_pull_mapping_' . $uname . '_' . $pmp_name];
          }
        }
        variable_set('pmpapi_pull_mapping_' . $uname . '_' . $profile, $map);
      }
      variable_set('pmpapi_pull_' . $uname . '_profile', $profile);
    }
  }
  drupal_set_message(t('Pull settings have been successfully saved.'));
}