Priority: Enhancement
Current State: Closed
Released In: n/a
Target Release: n/a
%GETVAR%
already has the ability to use placeholders like
$value
in its output. The same is useful for
%SETVAR%
if you want to include the value of the field in the variable you're setting.
In short: the enhancement is that we support
$value
(and potentially other attributes of a meta field) in the
value
attribute for
%SETVAR%
.
Here's a diff that implements this:
Index: lib/Foswiki/Plugins/SetVariablePlugin/Core.pm
===================================================================
--- lib/Foswiki/Plugins/SetVariablePlugin/Core.pm (revision 15731)
+++ lib/Foswiki/Plugins/SetVariablePlugin/Core.pm (working copy)
@@ -70,18 +70,18 @@
foreach my $record (sort {$b->{prio} <=> $a->{prio}} @{$this->{rules}}) {
# check conditions
+ my $found;
if ($record->{field}) {
next unless defined $record->{regex}; # illegal rule
- my $found = 0;
foreach my $field (@fields) {
my $name = $field->{name} || '';
my $value = $field->{value} || '';
if ($name eq $record->{field} && $value =~ /^($record->{regex})$/) {
- $found = 1;
+ $found = $field;
last;
}
}
- next unless $found;
+ next unless defined $found;
} else {
if ($record->{regex}) { # check against topic text
next unless $text =~ /$record->{regex}/;
@@ -91,7 +91,8 @@
# get settings
my $var = $record->{var};
my $type = $record->{type} || 'Local';
- my $value = expandVariables($record->{value});
+ $found = {} unless defined $found;
+ my $value = expandVariables($record->{value}, %$found);
if (defined $value) {
$value = Foswiki::Func::expandCommonVariables($value, $topic, $web);
}
--
JanKrueger - 26 Oct 2012