From f3346bd0086c85ac2922b6bb0ee341d59b987b41 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 11 Jul 2006 04:15:31 +0000 Subject: [PATCH] i18n for Department user profile --- docs/changelog/7.x.x.txt | 4 + docs/upgrades/upgrade_7.0.0-7.0.1.pl | 134 ++++++++++++++++++++ lib/WebGUI/i18n/English/Asset_InOutBoard.pm | 23 ++++ 3 files changed, 161 insertions(+) create mode 100644 docs/upgrades/upgrade_7.0.0-7.0.1.pl diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 9077c55d5..2582ff7b0 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,3 +1,7 @@ +7.0.1 + - fix: User profile field "Department" needs i18n + + 7.0.0 - Welcome to a whole new world of WebGUI. After 2.5 years and 20,000 hours of development, WebGUI 7 is finally here. diff --git a/docs/upgrades/upgrade_7.0.0-7.0.1.pl b/docs/upgrades/upgrade_7.0.0-7.0.1.pl new file mode 100644 index 000000000..2e38d282e --- /dev/null +++ b/docs/upgrades/upgrade_7.0.0-7.0.1.pl @@ -0,0 +1,134 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2006 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------- +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------- + +use lib "../../lib"; +use strict; +use Getopt::Long; +use WebGUI::Session; + + +my $toVersion = "7.0.1"; # make this match what version you're going to +my $quiet; # this line required + + +my $session = start(); # this line required + +# upgrade functions go here +i18nDepartmentNames(); + +finish($session); # this line required + +#-------------------------------------------------- +sub i18nDepartmentNames { + print "\tInternationalizing department settings in user profile\n" unless ($quiet); + $session->db->write(q!update userProfileField set label=? where fieldName='department'!, ["WebGUI::International::get('Department','Asset_InOutBoard')"]); + my $possibleValues = q|{ IT => WebGUI::International::get('IT','Asset_InOutBoard'), HR => WebGUI::International::get('HR','Asset_InOutBoard'), 'Regular Staff' => WebGUI::International::get('Regular Staff','Asset_InOutBoard')}|; + $session->db->write(q!update userProfileField set possibleValues=? where fieldName='department'!, [$possibleValues]); +} + + +##------------------------------------------------- +#sub exampleFunction { +# my $session = shift; +# print "\tWe're doing some stuff here that you should know about.\n" unless ($quiet); +# # and here's our code +#} + + + +# ---- DO NOT EDIT BELOW THIS LINE ---- + +#------------------------------------------------- +sub start { + my $configFile; + $|=1; #disable output buffering + GetOptions( + 'configFile=s'=>\$configFile, + 'quiet'=>\$quiet + ); + my $session = WebGUI::Session->open("../..",$configFile); + $session->user({userId=>3}); + my $versionTag = WebGUI::VersionTag->getWorking($session); + $versionTag->set({name=>"Upgrade to ".$toVersion}); + $session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".$session->datetime->time().")"); + updateTemplates($session); + return $session; +} + +#------------------------------------------------- +sub finish { + my $session = shift; + my $versionTag = WebGUI::VersionTag->getWorking($session); + $versionTag->commit; + $session->close(); +} + +#------------------------------------------------- +sub updateTemplates { + my $session = shift; + return undef unless (-d "templates-".$toVersion); + print "\tUpdating templates.\n" unless ($quiet); + opendir(DIR,"templates-".$toVersion); + my @files = readdir(DIR); + closedir(DIR); + my $importNode = WebGUI::Asset->getImportNode($session); + my $newFolder = undef; + foreach my $file (@files) { + next unless ($file =~ /\.tmpl$/); + open(FILE,""WebGUI::Asset::Template"); + while (my $line = ) { + if ($first) { + $line =~ m/^\#(.*)$/; + $properties{id} = $1; + $first = 0; + } elsif ($line =~ m/^\#create$/) { + $create = 1; + } elsif ($line =~ m/^\#(.*):(.*)$/) { + $properties{$1} = $2; + } elsif ($line =~ m/^~~~$/) { + $head = 1; + } elsif ($head) { + $properties{headBlock} .= $line; + } else { + $properties{template} .= $line; + } + } + close(FILE); + if ($create) { + $newFolder = createNewTemplatesFolder($importNode) unless (defined $newFolder); + my $template = $newFolder->addChild(\%properties, $properties{id}); + } else { + my $template = WebGUI::Asset->new($session,$properties{id}, "WebGUI::Asset::Template"); + if (defined $template) { + my $newRevision = $template->addRevision(\%properties); + } + } + } +} + +#------------------------------------------------- +sub createNewTemplatesFolder { + my $importNode = shift; + my $newFolder = $importNode->addChild({ + className=>"WebGUI::Asset::Wobject::Folder", + title => $toVersion." New Templates", + menuTitle => $toVersion." New Templates", + url=> $toVersion."_new_templates", + groupIdView=>"12" + }); + return $newFolder; +} + + + diff --git a/lib/WebGUI/i18n/English/Asset_InOutBoard.pm b/lib/WebGUI/i18n/English/Asset_InOutBoard.pm index 0ffe75ccf..e3457ebee 100644 --- a/lib/WebGUI/i18n/English/Asset_InOutBoard.pm +++ b/lib/WebGUI/i18n/English/Asset_InOutBoard.pm @@ -376,6 +376,29 @@ can alter their status.|, lastUpdated =>1139262439 }, + 'IT' => { + message => q|IT|, + lastUpdated =>1152589736, + context => q|User profile field, abbreviation for Information Technology|, + }, + + 'HR' => { + message => q|HR|, + lastUpdated =>1152589736, + context => q|User profile field, abbreviation for Human Resources|, + }, + + 'Regular Staff' => { + message => q|Regular Staff|, + lastUpdated =>1152589736, + context => q|User profile field|, + }, + + 'Department' => { + message => q|Department|, + lastUpdated =>1152589736, + context => q|label for user profile field|, + }, };