Also look in the next-highest directory when detecting VCS; add SVN
[interchange.git] / code / SystemTag / assign.coretag
1 # Copyright 2002-2007 Interchange Development Group and others
2
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.  See the LICENSE file for details.
7
8 UserTag assign              addAttr
9 UserTag assign              PosNumber    0
10 UserTag assign              Version      1.5
11 UserTag assign              Routine      <<EOR
12 my %_assignable = (qw/
13                                 salestax        1
14                                 shipping        1
15                                 handling        1
16                                 subtotal        1
17                                 credit          1       
18                                 /);
19 sub {
20         my ($opt) = @_;
21         if($opt->{clear}) {
22                 delete $Vend::Session->{assigned};
23                 return;
24         }
25         $Vend::Session->{assigned} ||= {};
26         for(keys %$opt) {
27                 next unless $_assignable{$_};
28                 my $value = $opt->{$_};
29                 $value =~ s/^\s+//;
30                 $value =~ s/\s+$//;
31                 if($value =~ /^-?\d+\.?\d*$/) {
32                         $Vend::Session->{assigned}{$_} = $value;
33                 }
34                 else {
35             if ($value) {
36                         logError(
37                                 "Attempted assign of non-numeric '%s' to %s. Deleted.",
38                                 $value,
39                                 $_,
40                             );
41             }
42                         delete $Vend::Session->{assigned}{$_};
43                 }
44         }
45         return;
46 }
47 EOR