Index: branches/5.2.x/core/units/user_profile/user_profile_eh.php =================================================================== diff -u -N -r13840 -r14092 --- branches/5.2.x/core/units/user_profile/user_profile_eh.php (.../user_profile_eh.php) (revision 13840) +++ branches/5.2.x/core/units/user_profile/user_profile_eh.php (.../user_profile_eh.php) (revision 14092) @@ -1,6 +1,6 @@ Application->getUnitOption('u', 'UserProfileMapping'); + foreach ($field_values as $variable_name => $variable_value) { - $this->Application->StorePersistentVar($variable_name, unhtmlentities($variable_value)); + if (array_key_exists($variable_name, $profile_mapping)) { + // old style variable for displaying fields in public profile (named "pp_*") + if ($variable_value) { + $public_profile_add[] = $profile_mapping[$variable_name]; + } + else { + $public_profile_remove[] = $profile_mapping[$variable_name]; + } + } + else { + $this->Application->StorePersistentVar($variable_name, unhtmlentities($variable_value)); + } } - } + if ($public_profile_add || $public_profile_remove) { + $user =& $this->Application->recallObject('u.current'); + /* @var $user kDBItem */ + + // get current value + $display_to_public_old = $user->GetDBField('DisplayToPublic'); + $display_to_public_new = $display_to_public_old ? explode('|', substr($display_to_public_old, 1, -1)) : Array (); + + // update value + $display_to_public_new = array_diff(array_merge($display_to_public_new, $public_profile_add), $public_profile_remove); + $display_to_public_new = array_unique($display_to_public_new); + $display_to_public_new = $display_to_public_new ? '|' . implode('|', $display_to_public_new) . '|' : ''; + + if ($display_to_public_new != $display_to_public_old) { + $user->SetDBField('DisplayToPublic', $display_to_public_new); + $user->Update(); + } + } + } } \ No newline at end of file