Created
November 16, 2009 16:59
-
-
Save perlDreamer/236133 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt | |
index 3c85b83..7d431d5 100644 | |
--- a/docs/changelog/7.x.x.txt | |
+++ b/docs/changelog/7.x.x.txt | |
@@ -17,6 +17,7 @@ | |
- fixed #11217: LDAP authentication fails if user DN changes | |
- fixed #11228: Gallery image upload to other users folder permission denied | |
- added USPS International driver. | |
+ - added #10727: language choice during site adding | |
7.8.4 | |
- Fixed a compatibility problem between WRE and new Spectre code. | |
diff --git a/lib/WebGUI/Content/Setup.pm b/lib/WebGUI/Content/Setup.pm | |
index d3ee8aa..8eb2ed6 100644 | |
--- a/lib/WebGUI/Content/Setup.pm | |
+++ b/lib/WebGUI/Content/Setup.pm | |
@@ -112,21 +112,44 @@ The current WebGUI::Session object. | |
sub handler { | |
my $session = shift; | |
+ my $form = $session->form; | |
unless ($session->setting->get("specialState") eq "init") { | |
return undef; | |
} | |
$session->http->setCacheControl("none"); | |
my $i18n = WebGUI::International->new($session, "WebGUI"); | |
my ($output,$legend) = ""; | |
- if ($session->form->process("step") eq "2") { | |
+ if ($form->process("step") eq "2") { | |
$legend = $i18n->get('company information'); | |
+ | |
+ my $timezone = $form->timeZone("timeZone"); | |
+ my $language = $form->selectBox("language"); | |
+ | |
+ ##update Admin and Visitor users | |
my $u = WebGUI::User->new($session,"3"); | |
- $u->username($session->form->process("username","text","Admin")); | |
- $u->profileField("email",$session->form->email("email")); | |
- $u->profileField("timeZone",$session->form->timeZone("timeZone")); | |
- $u->identifier(Digest::MD5::md5_base64($session->form->process("identifier","password","123qwe"))); | |
+ $u->username($form->process("username","text","Admin")); | |
+ $u->profileField("email",$form->email("email")); | |
+ $u->profileField("timeZone",$timezone); | |
+ $u->profileField("language",$language); | |
+ $u->identifier(Digest::MD5::md5_base64($form->process("identifier","password","123qwe"))); | |
+ | |
$u = WebGUI::User->new($session,"1"); | |
- $u->profileField("timeZone",$session->form->timeZone("timeZone")); | |
+ $u->profileField("timeZone",$timezone); | |
+ $u->profileField("language",$language); | |
+ | |
+ ##update ProfileField defaults so new users the get the defaults, too | |
+ my $properties; | |
+ | |
+ my $zoneField = WebGUI::ProfileField->new($session, 'timeZone'); | |
+ $properties = $zoneField->get(); | |
+ $properties->{dataDefault} = $timezone; | |
+ $zoneField->set($properties); | |
+ | |
+ my $languageField = WebGUI::ProfileField->new($session, 'language'); | |
+ $properties = $languageField->get(); | |
+ $properties->{dataDefault} = $language; | |
+ $languageField->set($properties); | |
+ | |
my $f = WebGUI::HTMLForm->new($session,action=>$session->url->gateway()); | |
$f->hidden( name=>"step", value=>"3"); | |
$f->text( | |
@@ -516,9 +539,17 @@ a:visited { color: '.$form->get("visitedLinkColor").'; } | |
-hoverHelp=>$i18n->get('56 description'), | |
); | |
$f->timeZone( | |
- -name=>"timeZone", | |
- -value=>$u->profileField("timeZone"), | |
- -label=>$i18n->get('timezone','DateTime'), | |
+ -name => "timeZone", | |
+ -value => $u->profileField("timeZone"), | |
+ -label => $i18n->get('timezone','DateTime'), | |
+ -hoverHelp => $i18n->get('timezone help'), | |
+ ); | |
+ $f->selectBox( | |
+ -name => "language", | |
+ -value => $u->profileField("language"), | |
+ -label => $i18n->get('304'), | |
+ -hoverHelp => $i18n->get('language help'), | |
+ -options => $i18n->getLanguages(), | |
); | |
$f->submit; | |
$output .= $f->print; | |
diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm | |
index 725eb30..e827884 100644 | |
--- a/lib/WebGUI/i18n/English/WebGUI.pm | |
+++ b/lib/WebGUI/i18n/English/WebGUI.pm | |
@@ -174,6 +174,11 @@ our $I18N = { | |
lastUpdated => 1031514049 | |
}, | |
+ 'language help' => { | |
+ message => q|Select the default language for users on the site.|, | |
+ lastUpdated => 1258340387, | |
+ }, | |
+ | |
'559' => { | |
message => q|On Create User (User)|, | |
lastUpdated => 1185738895 | |
@@ -4650,6 +4655,11 @@ Users may override this setting in their profile. | |
lastUpdated => 0, | |
}, | |
+ 'timezone help' => { | |
+ message => 'Set up the default time zone for the site.', | |
+ lastUpdated => 0, | |
+ }, | |
+ | |
}; | |
1; | |
diff --git a/t/Content/Setup.t b/t/Content/Setup.t | |
index 2de56f1..e12b473 100644 | |
--- a/t/Content/Setup.t | |
+++ b/t/Content/Setup.t | |
@@ -17,7 +17,7 @@ use WebGUI::Content::Setup; | |
# load your modules here | |
-use Test::More tests => 2; # increment this value for each test you create | |
+use Test::More tests => 8; # increment this value for each test you create | |
my $session = WebGUI::Test->session; | |
@@ -28,3 +28,42 @@ isnt(WebGUI::Content::Setup::handler($session), undef, "Setup should return some | |
$session->setting->remove("specialState"); | |
is(WebGUI::Content::Setup::handler($session), undef, "Setup shouldn't return anything when no special state is present"); | |
+$session->request->setup_body({ | |
+ step => 2, | |
+ timeZone => 'America/New_York', | |
+ language => 'Spanish', | |
+}); | |
+ | |
+$session->setting->set("specialState", "init"); | |
+WebGUI::Content::Setup::handler($session); | |
+ | |
+my $admin = WebGUI::User->new($session, '3'); | |
+is($admin->get('language'), 'Spanish', 'Admin language set to Spanish'); | |
+is($admin->get('timeZone'), 'America/New_York', 'Admin timezone set to America/New_York'); | |
+ | |
+my $visitor = WebGUI::User->new($session, '1'); | |
+is($visitor->get('language'), 'Spanish', 'Visitor language set to Spanish'); | |
+is($visitor->get('timeZone'), 'America/New_York', 'Visitor timezone set to America/New_York'); | |
+ | |
+my $zoneField = WebGUI::ProfileField->new($session, 'timeZone'); | |
+is $zoneField->get('dataDefault'), 'America/New_York', 'timezone profile field default set to America/New_York'; | |
+ | |
+my $languageField = WebGUI::ProfileField->new($session, 'language'); | |
+is $languageField->get('dataDefault'), 'Spanish', 'timezone profile field default set to Spanish'; | |
+ | |
+$admin->update( { language => 'English' } ); | |
+$visitor->update({ language => 'English' } ); | |
+ | |
+$admin->update( { timeZone => 'America/Chicago' } ); | |
+$visitor->update({ timeZone => 'America/Chicago' } ); | |
+ | |
+my $properties; | |
+$properties = $zoneField->get(); | |
+$properties->{dataDefault} = 'America/Chicago'; | |
+$zoneField->set($properties); | |
+ | |
+$properties = $languageField->get(); | |
+$properties->{dataDefault} = 'English'; | |
+$zoneField->set($properties); | |
+ | |
+$session->setting->remove("specialState"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment