You are here

function profile2_regpath_regpath_save in Profile2 Registration Path 7

Same name and namespace in other branches
  1. 7.2 profile2_regpath.module \profile2_regpath_regpath_save()

Save a single regpath.

2 calls to profile2_regpath_regpath_save()
profile2_regpath_features_rebuild in ./profile2_regpath.module
Implements hook_features_rebuild(). Rebuild menu after all profile2_regpath components is re-built.
profile2_regpath_save_settings in ./profile2_regpath.admin.inc
Helper function to save profile settings.

File

./profile2_regpath.module, line 283
Attach profile2 form to registration form according to path.

Code

function profile2_regpath_regpath_save(&$regpath) {
  $exist = profile2_regpath_regpath_load($regpath['profile_type']);
  $update = $exist ? 'profile_type' : array();

  // Check if we have profile id when creating new regpath
  if (!$update) {

    // We are creating new profile type
    if (!isset($regpath['profile_id']) || !is_numeric($regpath['profile_id']) || $regpath['profile_id'] <= 0) {

      // Unvalid profile id
      // New profile type need profile id, we load it from database
      $profile_type = profile2_type_load($regpath['profile_type']);
      if (empty($profile_type)) {

        // No profile types was found
        return FALSE;
      }
      else {
        $regpath['profile_id'] = $profile_type->id;
      }
    }
  }
  return db_merge('profile2_regpath')
    ->key(array(
    'profile_type' => $regpath['profile_type'],
  ))
    ->fields($regpath)
    ->execute();
}