X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_event_condition.pm;h=78aa3b1a97280934a069595384b94afd8434133a;hb=13f21e01ac9faa50c07f64c20cbceae0ae50790c;hp=1efd0f8793c801cef36efd23007dd13fc8b1598e;hpb=eb4ff7f73c5d4bdf74a3472448b5a195598ff4cd;p=freeside.git diff --git a/FS/FS/part_event_condition.pm b/FS/FS/part_event_condition.pm index 1efd0f879..78aa3b1a9 100644 --- a/FS/FS/part_event_condition.pm +++ b/FS/FS/part_event_condition.pm @@ -1,8 +1,8 @@ package FS::part_event_condition; use strict; -use vars qw( @ISA $DEBUG ); -use FS::UID qw(dbh); +use vars qw( @ISA $DEBUG @SKIP_CONDITION_SQL ); +use FS::UID qw( dbh driver_name ); use FS::Record qw( qsearch qsearchs ); use FS::option_Common; use FS::part_event; #for order_conditions_sql... @@ -10,6 +10,8 @@ use FS::part_event; #for order_conditions_sql... @ISA = qw( FS::option_Common ); # FS::Record ); $DEBUG = 0; +@SKIP_CONDITION_SQL = (); + =head1 NAME FS::part_event_condition - Object methods for part_event_condition records @@ -183,12 +185,20 @@ foreach my $INC ( @INC ) { }; my $mod = $1; my $fullmod = "FS::part_event::Condition::$mod"; + if ( $fullmod =~ /_(Mixin|Common)$/ ) { + #warn "skipping $1 class $fullmod\n"; + next; + } eval "use $fullmod;"; if ( $@ ) { die "error using $fullmod (skipping): $@\n" if $@; #warn "error using $fullmod (skipping): $@\n" if $@; #next; } + if ( $fullmod->disabled ) { + warn "$fullmod is disabled; skipping\n"; + next; + } #my $full_condition_sql = $fullmod. '::condition_sql'; my $condition_sql_coderef = sub { $fullmod->condition_sql(@_) }; my $order_sql_coderef = $fullmod->can('order_sql') @@ -214,8 +224,7 @@ sub conditions { my( $class, $eventtable ) = @_; ( map { $_ => $conditions{$_} } -# sort { $conditions{$a}->{'default_weight'}<=>$conditions{$b}->{'default_weight'} } -# sort by ? + sort {$conditions{$a}->{'description'} cmp $conditions{$b}->{'description'}} $class->all_conditionnames( $eventtable ) ); @@ -279,11 +288,16 @@ sub where_conditions_sql { map { my $conditionname = $_; my $coderef = $conditions{$conditionname}->{condition_sql}; - my $sql = &$coderef( $eventtable, 'time'=>$time ); + my $sql = &$coderef( $eventtable, 'time' => $time, + 'driver_name' => driver_name(), + ); die "$coderef is not a CODEREF" unless ref($coderef) eq 'CODE'; "( cond_$conditionname.conditionname IS NULL OR $sql )"; } - keys %conditions + grep { my $cond = $_; + ! grep { $_ eq $cond } @SKIP_CONDITION_SQL + } + keys %conditions ); $where;