function profile2_regpath_regpath_save in Profile2 Registration Path 7.2
Same name and namespace in other branches
- 7 profile2_regpath.module \profile2_regpath_regpath_save()
Save a single regpath.
1 call 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.
File
- ./
profile2_regpath.module, line 329 - 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();
}