[interchange-cvs] interchange - heins modified lib/Vend/Order.pm
interchange-core@interchange.redhat.com
interchange-core@interchange.redhat.com
Mon Jun 24 23:19:01 2002
User: heins
Date: 2002-06-25 03:18:09 GMT
Modified: lib/Vend Order.pm
Log:
* Add &update=[yes|no] to automatically update a values variable
upon checking good. Usually useful for mv_form_profile.
Example:
[set tprof]
&fail=@@MV_PAGE@@
&update=yes
&fatal=no
name=required
addr=required
email=email
[/set]
<FONT color="red">
[error all=1 show_error=1 show_label=1 joiner="<br>"]
</font>
<form action="[area index]">
<input type=hidden name=mv_action value=back>
<input type=hidden name=mv_failpage value="@@MV_PAGE@@">
Name <input name=name value="[value name]"><br>
Addr <input name=addr value="[value addr]"><br>
Email<input name=email value="[value email]"><br>
<input type=submit>
</form>
As the variables check good, they will be updated.
Revision Changes Path
2.24 +15 -3 interchange/lib/Vend/Order.pm
rev 2.24, prev_rev 2.23
Index: Order.pm
===================================================================
RCS file: /anon_cvs/repository/interchange/lib/Vend/Order.pm,v
retrieving revision 2.23
retrieving revision 2.24
diff -u -r2.23 -r2.24
--- Order.pm 17 Jun 2002 22:24:07 -0000 2.23
+++ Order.pm 25 Jun 2002 03:18:09 -0000 2.24
@@ -1,8 +1,8 @@
# Vend::Order - Interchange order routing routines
#
-# $Id: Order.pm,v 2.23 2002/06/17 22:24:07 jon Exp $
+# $Id: Order.pm,v 2.24 2002/06/25 03:18:09 mheins Exp $
#
-# Copyright (C) 1996-2002 Red Hat, Inc. <interchange@redhat.com>
+# Copyright (C) 1996-2001 Red Hat, Inc. <interchange@redhat.com>
#
# This program was originally based on Vend 0.2 and 0.3
# Copyright 1995 by Andrew M. Wilcox <awilcox@world.std.com>
@@ -28,7 +28,7 @@
package Vend::Order;
require Exporter;
-$VERSION = substr(q$Revision: 2.23 $, 10);
+$VERSION = substr(q$Revision: 2.24 $, 10);
@ISA = qw(Exporter);
@@ -58,6 +58,7 @@
use autouse 'Vend::Error' => qw/do_lockout/;
my @Errors = ();
+my $Update = 0;
my $Fatal = 0;
my $And;
my $Final = 0;
@@ -74,6 +75,7 @@
'&charge' => \&_charge,
'&credit_card' => \&_credit_card,
'&return' => \&_return,
+ '&update' => \&_update,
'&fatal' => \&_fatal,
'&and' => \&_and_check,
'&or' => \&_or_check,
@@ -211,6 +213,11 @@
);
+sub _update {
+ $Update = is_yes($_[1]);
+ return 1;
+}
+
sub _fatal {
$Fatal = ( defined($_[1]) && ($_[1] =~ /^[yYtT1]/) ) ? 1 : 0;
return 1;
@@ -820,6 +827,7 @@
my $ref = \%CGI::values;
my $vref = shift || $::Values;
+ my $conditional_update;
my $parameter = $_;
my($var, $val, $m, $message);
if (/^&/) {
@@ -828,6 +836,7 @@
elsif ($parameter =~ /(\w+)[\s=]+(.*)/) {
my $k = $1;
my $v = $2;
+ $conditional_update = $Update;
$m = $v =~ s/\s+(.*)// ? $1 : undef;
($var,$val) =
('&format',
@@ -852,6 +861,9 @@
return undef;
}
#::logDebug("&Vend::Order::do_check returning val=$val, var=$var, message=$message");
+ if($conditional_update and $val) {
+ ::update_values($var);
+ }
return ($val, $var, $message);
}