You are here

function profile2_form_submit_build_profile in Profile 2 7.2

Same name and namespace in other branches
  1. 7 profile2.module \profile2_form_submit_build_profile()

Submit builder. Extracts the form values and updates the profile entities.

See also

profile2_attach_form()

2 calls to profile2_form_submit_build_profile()
profile2_diff_profile2_form_preview_changes in contrib/profile2_diff.module
Callback if 'View changes' is pressed.
profile2_form_submit_handler in ./profile2.module
Submit handler that builds and saves all profiles in the form.

File

./profile2.module, line 924
Support for configurable user profiles.

Code

function profile2_form_submit_build_profile(&$form, &$form_state) {
  foreach ($form_state['profiles'] as $type => $profile) {

    // @see entity_form_submit_build_entity()
    if (isset($form['profile_' . $type]['#entity_builders'])) {
      foreach ($form['profile_' . $type]['#entity_builders'] as $function) {
        $function('profile2', $profile, $form['profile_' . $type], $form_state);
      }
    }
    field_attach_submit('profile2', $profile, $form['profile_' . $type], $form_state);

    // Handle revisions.
    if (!empty($form_state['values']['profile_' . $type]['revision_information']['revision'])) {
      global $user;
      $profile->authorid = $user->uid;
      $profile->timestamp = REQUEST_TIME;
      $profile->log = empty($form_state['values']['profile_' . $type]['revision_information']['log']) ? '' : $form_state['values']['profile_' . $type]['revision_information']['log'];
      $profile->is_new_revision = TRUE;
    }
    elseif ($profile->vid) {

      // Updating existing revision, ensure we keep the log.
      $profile_orig = profile2_revision_list($profile)[$profile->vid];
      $profile->log = $profile_orig->log;
    }
  }
}