Fix the Post handling Metadata possibleValues differently from other Assets.

This commit is contained in:
Colin Kuskie 2009-06-26 22:42:15 +00:00
parent a75e83b52d
commit 7901e1d398
4 changed files with 42 additions and 24 deletions

View file

@ -32,6 +32,7 @@ my $session = start(); # this line required
# upgrade functions go here
addSessionTokenId($session);
correctPostMetaData($session);
finish($session); # this line required
@ -46,7 +47,6 @@ finish($session); # this line required
#}
#----------------------------------------------------------------------------
# Describe what our function does
sub addSessionTokenId {
my $session = shift;
print "\tAdding CSRF token to userSession, if needed... " unless $quiet;
@ -58,6 +58,28 @@ sub addSessionTokenId {
print "DONE!\n" unless $quiet;
}
#----------------------------------------------------------------------------
sub correctPostMetaData {
my $session = shift;
my $root = WebGUI::Asset->getRoot($session);
print "\tPutting metadata associated with posts into the standard metadata possibleValues format... " unless $quiet;
# and here's our code
my $meta = $root->getMetaDataFields();
FIELD: foreach my $field (keys %{ $meta }) {
next FIELD unless $meta->{$field}->{possibleValues} && $meta->{$field}->{possibleValues} =~ m/\}/;
my $values = WebGUI::Operation::Shared::secureEval($session, $meta->{$field}->{possibleValues});
next FIELD unless ref $values eq 'HASH';
my $newValues = '';
while (my ($key, $value) = each %{ $values }) {
$newValues .= join '|', $key, $value;
$newValues .= "\n";
}
print "\n\t\tUpdating ".$meta->{$field}->{fieldName};
$root->addMetaDataField(@{ $meta->{$field} }{ qw/fieldId fieldName defaultValue description fieldType/ }, $newValues);
}
print "DONE!\n" unless $quiet;
}
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------