diff options
author | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-05-08 16:59:05 +0000 |
---|---|---|
committer | einhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-05-08 16:59:05 +0000 |
commit | 4c0d0b732017960130f197900029f375b92d4a2c (patch) | |
tree | a2aec7d3756e7fe622cfb9152374062e32ac9634 | |
parent | dcfdaee7499fcc73bd766f556cd2b1a1334719b0 (diff) |
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
-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 = ?"; |