diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index e8a9cf6e5..2c16fdd52 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,4 +1,5 @@ 7.7.18 + - fixed #10781: User Profile Editable/Required gotcha - fixed #10786: Matrix navigation: search screen to view screen - fixed #10766: Matrix search: search dropdowns do not match what is displayed when search form opens. - fixed #10783: Inbox Copy Sender broken diff --git a/docs/upgrades/upgrade_7.7.17-7.7.18.pl b/docs/upgrades/upgrade_7.7.17-7.7.18.pl index 0140eb301..52220794a 100644 --- a/docs/upgrades/upgrade_7.7.17-7.7.18.pl +++ b/docs/upgrades/upgrade_7.7.17-7.7.18.pl @@ -33,9 +33,9 @@ my $session = start(); # this line required # upgrade functions go here addSmsGatewaySubjectSetting($session); addInboxNotificationsSubjectSetting($session); +profileFieldRequiredEditable($session); finish($session); # this line required - #---------------------------------------------------------------------------- # Describe what our function does #sub exampleFunction { @@ -45,6 +45,18 @@ finish($session); # this line required # print "DONE!\n" unless $quiet; #} +sub profileFieldRequiredEditable { + my $session = shift; + print "\tTurn on the editable bit for all Profile Fields which are required... " unless $quiet; + FIELD: foreach my $field (@{ WebGUI::ProfileField->getRequiredFields($session) } ) { + my $properties = $field->get(); + next FIELD unless !$properties->{editable}; + $properties->{editable} = 1; + $field->set($properties); + } + print "DONE!\n" unless $quiet; +} + sub addSmsGatewaySubjectSetting { my $session = shift; print "\tAdding smsGatewaySubject setting... " unless $quiet; diff --git a/lib/WebGUI/ProfileField.pm b/lib/WebGUI/ProfileField.pm index f431add4e..f13d624a8 100644 --- a/lib/WebGUI/ProfileField.pm +++ b/lib/WebGUI/ProfileField.pm @@ -877,13 +877,15 @@ sub set { my $db = $session->db; # Set the defaults - $properties->{visible} = 0 unless ($properties->{visible} == 1); - $properties->{editable} = 0 unless ($properties->{editable} == 1); - $properties->{protected} = 0 unless ($properties->{protected} == 1); - $properties->{required} = 0 unless ($properties->{required} == 1); - $properties->{label} = 'Undefined' if ($properties->{label} =~ /^[\"\']*$/); - $properties->{fieldType} = 'text' unless ($properties->{fieldType}); - $properties->{extras} = '' unless ($properties->{extras}); + $properties->{visible} = 0 unless ($properties->{visible} == 1); + $properties->{protected} = 0 unless ($properties->{protected} == 1); + $properties->{required} = 0 unless ($properties->{required} == 1); + $properties->{editable} = $properties->{required} == 1 ? 1 + : $properties->{editable} == 1 ? 1 + : 0; + $properties->{label} = 'Undefined' if ($properties->{label} =~ /^[\"\']*$/); + $properties->{fieldType} = 'text' unless ($properties->{fieldType}); + $properties->{extras} = '' unless ($properties->{extras}); if ($properties->{dataDefault} && $properties->{fieldType}=~/List$/) { unless ($properties->{dataDefault} =~ /^\[/) { $properties->{dataDefault} = "[".$properties->{dataDefault}; diff --git a/lib/WebGUI/i18n/English/WebGUIProfile.pm b/lib/WebGUI/i18n/English/WebGUIProfile.pm index 6385bfad9..42e73ae46 100644 --- a/lib/WebGUI/i18n/English/WebGUIProfile.pm +++ b/lib/WebGUI/i18n/English/WebGUIProfile.pm @@ -69,8 +69,8 @@ Internationalization system if labels need to be localized.|, }, '474 description' => { - message => q|Should the user be required to fill out this field?|, - lastUpdated => 1122316558, + message => q|Should the user be required to fill out this field? If this option is set to yes, then the field will automatically be set to be editable as well.|, + lastUpdated => 1250537322, }, '486 description' => { diff --git a/t/ProfileField.t b/t/ProfileField.t index 0a2ccbcf3..0d569f3a4 100644 --- a/t/ProfileField.t +++ b/t/ProfileField.t @@ -33,7 +33,7 @@ WebGUI::Test->usersToDelete($newUser); #---------------------------------------------------------------------------- # Tests -plan tests => 37; # Increment this number for each test you create +plan tests => 45; # Increment this number for each test you create #---------------------------------------------------------------------------- # Test the creation of ProfileField @@ -147,11 +147,38 @@ ok( !WebGUI::ProfileField->isReservedFieldName('shop'), '... shop is not'); ok( WebGUI::ProfileField->exists($session, 'email'), 'exists: email'); ok( !WebGUI::ProfileField->exists($session, 'userId'), '... userId (not)'); +########################################################### +# +# set +# +########################################################### + +my $newProfileField3 = WebGUI::ProfileField->create($session, 'testField3', { + label => q|WebGUI::International::get('webgui','WebGUI')|, + fieldName => 'Text', +}); + +is ($newProfileField3->get('editable'), 0, 'default editable = 0'); +is ($newProfileField3->get('required'), 0, 'default required = 0'); + +$newProfileField3->set({ editable => 1}); +is ($newProfileField3->get('editable'), 1, 'set editable=1'); +is ($newProfileField3->get('required'), 0, '... required=0'); + +$newProfileField3->set({ editable => 0}); +is ($newProfileField3->get('editable'), 0, 'set editable = 0'); +is ($newProfileField3->get('required'), 0, '... required = 0'); + +$newProfileField3->set({ required => 1}); +is ($newProfileField3->get('required'), 1, 'set required = 1'); +is ($newProfileField3->get('editable'), 1, '... editable = 1'); + #---------------------------------------------------------------------------- # Cleanup END { $newProfileField->delete; $newProfileField2->delete; + $newProfileField3->delete; }