From 0f7af1b87b8e739374d447ff5aede8ac81dc2b72 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 12 Jul 2006 04:07:41 +0000 Subject: [PATCH] fix department i18n problem without overwriting user configured values --- docs/upgrades/upgrade_7.0.0-7.0.1.pl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/upgrades/upgrade_7.0.0-7.0.1.pl b/docs/upgrades/upgrade_7.0.0-7.0.1.pl index f77575a81..2b6307d56 100644 --- a/docs/upgrades/upgrade_7.0.0-7.0.1.pl +++ b/docs/upgrades/upgrade_7.0.0-7.0.1.pl @@ -12,12 +12,12 @@ use lib "../../lib"; use strict; use Getopt::Long; use WebGUI::Session; - +use WebGUI::Operation::Shared; +use Data::Dumper; 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 @@ -39,8 +39,16 @@ sub addMissingAssets { 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]); + my ($codeValues) = $session->db->quickArray(q|select possibleValues from userProfileField where fieldName='department'|); + + my $possibleValues = WebGUI::Operation::Shared::secureEval($codeValues); + delete $possibleValues->{IT}; + delete $possibleValues->{HR}; + delete $possibleValues->{'Regular Staff'}; + local $Data::Dumper::Terse = 1; + my $i18nValues = Dumper $possibleValues; + $i18nValues =~ s/\{/{'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'!, [$i18nValues]); }