From 4c0d0b732017960130f197900029f375b92d4a2c Mon Sep 17 00:00:00 2001 From: einhverfr Date: Tue, 8 May 2007 16:59:05 +0000 Subject: Adding copy=> and merge=>\@list args to DBObject->new git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1174 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB.pm | 4 ++-- 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 = ?"; -- cgit v1.2.3