diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index eebb0789b..5778aacd7 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -22,6 +22,7 @@ that still allows non-realm based Basic authentication. - fixed #10228: Calendar: Weekly re-occurence function not working properly ( Martin Kamerbeek / Oqapi ) + - fixed #9851: New Users have blank profile field privacy settings 7.7.8 - fixed: Basic Auth doesn't work if password contains colon (Arjan Widlak, diff --git a/docs/upgrades/upgrade_7.7.8-7.7.9.pl b/docs/upgrades/upgrade_7.7.8-7.7.9.pl index 2fd26f437..e3ce67df6 100644 --- a/docs/upgrades/upgrade_7.7.8-7.7.9.pl +++ b/docs/upgrades/upgrade_7.7.8-7.7.9.pl @@ -34,6 +34,7 @@ my $session = start(); # this line required # upgrade functions go here repackTemplates( $session ); deleteUnattachedAddressBooks( $session ); +addDefaultPrivacySettings( $session ); finish($session); # this line required @@ -47,6 +48,16 @@ finish($session); # this line required # print "DONE!\n" unless $quiet; #} +#---------------------------------------------------------------------------- +sub addDefaultPrivacySettings { + my $session = shift; + print "\tAdding default privacy setting to profile fields..." unless $quiet; + $session->db->write("alter table userProfileField add defaultPrivacySetting char(128);"); + $session->db->write("update userProfileField set defaultPrivacySetting = 'all' where profileCategoryId IN(2,3,6);"); + $session->db->write("update userProfileField set defaultPrivacySetting = 'none' where !(profileCategoryId IN(2,3,6));"); + print "Done.\n" unless $quiet; +} + #---------------------------------------------------------------------------- # Repack all templates since the packed columns may have been wiped out due to the bug. sub repackTemplates { diff --git a/lib/WebGUI/Operation/ProfileSettings.pm b/lib/WebGUI/Operation/ProfileSettings.pm index 5b910b429..48c83f0df 100644 --- a/lib/WebGUI/Operation/ProfileSettings.pm +++ b/lib/WebGUI/Operation/ProfileSettings.pm @@ -301,7 +301,14 @@ sub www_editProfileField { -value=>$data->{forceImageOnly}, -defaultValue=>1, ); - } + } + $f->radioList( + -name => 'defaultPrivacySetting', + -label => $i18n->get('default privacy setting label'), + -hoverHelp => $i18n->get('default privacy setting description'), + -options => WebGUI::ProfileField->getPrivacyOptions($session), + -value => $data->{defaultPrivacySetting} + ); my $fieldType = WebGUI::Form::FieldType->new($session, -name=>"fieldType", -label=>$i18n->get(486), @@ -377,6 +384,7 @@ sub www_editProfileFieldSave { fieldType=>$session->form->fieldType("fieldType"), forceImageOnly=>$session->form->yesNo("forceImageOnly"), extras=>$session->form->text('extras'), + defaultPrivacySetting=>$session->form->radioList('defaultPrivacySetting'), ); my $categoryId = $session->form->selectBox("profileCategoryId"); if ($session->form->process("new")) { diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index fe37376eb..7ea7a453a 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -25,6 +25,7 @@ use WebGUI::Workflow::Instance; use WebGUI::Shop::AddressBook; use JSON; use WebGUI::Exception; +use WebGUI::ProfileField; =head1 NAME @@ -83,6 +84,19 @@ sub _create { my $userId = shift || $session->id->generate(); $session->db->write("insert into users (userId,dateCreated) values (?,?)",[$userId, time()]); $session->db->write("INSERT INTO userProfileData (userId) VALUES (?)",[$userId]); + + # Set wg_privacySettings + my @fields = @{WebGUI::ProfileField->getFields($session)}; + my $privacy = {}; + foreach my $field (@fields) { + #$session->errorHandler->warn('getting privacy setting for field: '.$fieldName); + my $privacySetting = $field->get('defaultPrivacySetting'); + next unless (WebGUI::Utility::isIn($privacySetting,qw(all none friends))); + $privacy->{$field->get('fieldName')} = $privacySetting; + } + my $json = JSON->new->encode($privacy); + $session->db->write("update userProfileData set wg_privacySettings=? where userId=?",[$json,$userId]); + WebGUI::Group->new($session,2)->addUsers([$userId]); WebGUI::Group->new($session,7)->addUsers([$userId]); return $userId; diff --git a/lib/WebGUI/i18n/English/WebGUIProfile.pm b/lib/WebGUI/i18n/English/WebGUIProfile.pm index afed1aee5..6385bfad9 100644 --- a/lib/WebGUI/i18n/English/WebGUIProfile.pm +++ b/lib/WebGUI/i18n/English/WebGUIProfile.pm @@ -418,6 +418,19 @@ If you wish to set the Default Value for any other field. Create the field with message => q|Extra HTML to include with this profile field.|, lastUpdated => 1224620527, }, + + 'default privacy setting label' => { + message => q|Default Privacy Setting|, + lastUpdated => 0, + context => q|Label for a profile field property on the Edit User Profile Field screen.|, + }, + + 'default privacy setting description' => { + message => q|Select the default privacy setting for this profile field. This will be used when a new user is created.|, + lastUpdated => 0, + context => q|Description for a profile field property, used as hoverhelp on the Edit User Profile Field screen.|, + }, + }; 1;