diff options
-rwxr-xr-x | LedgerSMB.pm | 4 | ||||
-rw-r--r-- | LedgerSMB/DBObject.pm | 16 |
2 files changed, 14 insertions, 6 deletions
diff --git a/LedgerSMB.pm b/LedgerSMB.pm index 3f15ecc7..b3d6e1dd 100755 --- a/LedgerSMB.pm +++ b/LedgerSMB.pm @@ -460,8 +460,8 @@ sub call_procedure { sub is_allowed_role { my $self = shift @_; my %args = @_; - my @roles = @{$args{allowed_roles}} - for $role (@roles){ + my @roles = @{$args{allowed_roles}}; + for my $role (@roles){ if (scalar(grep /^$role$/, $self->{_roles})){ return 1; } diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm index 63c27f7c..109c22ff 100644 --- a/LedgerSMB/DBObject.pm +++ b/LedgerSMB/DBObject.pm @@ -47,21 +47,30 @@ sub AUTOLOAD { $type =~ m/::(.*?)$/; $type = lc $1; print "Type: $type\n"; - $self->exec_method( procname => "$type" . "_" . $AUTOLOAD, args => \@_ - order_by => $order_by); + $self->exec_method( procname => "$type" . "_" . $AUTOLOAD, args => \@_); } sub new { my $class = shift @_; my %args = @_; my $base = $args{base}; + my $mode = $args{copy}; + my @mergelist = @{$args{merge}}; my $self = bless {}, $class; if ( !$base->isa('LedgerSMB') ) { $self->error("Constructor called without LedgerSMB object arg"); } my $attr; - $self->merge($base); + if (lc($mode) eq 'base'){ + $self->merge($base, 'dbh', '_roles'); + } + elsif (lc($mode) eq 'list'){ + $self->merge($base, @mergelist); + } + else { + $self->merge($base); + } $self; } @@ -142,7 +151,6 @@ sub run_custom_queries { } for ( keys %temphash ) { my @data; - my $ins_values; $query = "$query_type "; if ( $query_type eq 'UPDATE' ) { $query = "DELETE FROM $_ WHERE row_id = ?"; |