X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FFile.pm;h=ca065e0c72fb36510a58162768a82b5ab17b5eda;hb=2b2a37fd95a5cae44a8c6862e79f86d2cbc2a189;hp=761a0ad7f1ee1f0e08c0f6930c9e0c214e87e5b9;hpb=e26881e3c924b1293ff34002986ea96bbdb41b89;p=kivitendo-erp.git diff --git a/SL/File.pm b/SL/File.pm index 761a0ad7f..ca065e0c7 100644 --- a/SL/File.pm +++ b/SL/File.pm @@ -21,11 +21,11 @@ use constant RENAME_NEW_VERSION => 4; sub get { my ($self, %params) = @_; - die 'no id' unless $params{id}; - my $dbfile = SL::DB::Manager::File->get_first(query => [id => $params{id}]); - die 'not found' unless $dbfile; - $main::lxdebug->message(LXDebug->DEBUG2(), "object_id=".$dbfile->object_id." object_type=".$dbfile->object_type." dbfile=".$dbfile); - SL::File::Object->new(db_file => $dbfile, id => $dbfile->id, loaded => 1); + die "no id or dbfile" unless $params{id} || $params{dbfile}; + $params{dbfile} = SL::DB::Manager::File->get_first(query => [id => $params{id}]) if !$params{dbfile}; + die 'not found' unless $params{dbfile}; + $main::lxdebug->message(LXDebug->DEBUG2(), "object_id=".$params{dbfile}->object_id." object_type=".$params{dbfile}->object_type." dbfile=".$params{dbfile}); + SL::File::Object->new(db_file => $params{dbfile}, id => $params{dbfile}->id, loaded => 1); } sub get_version_count { @@ -63,9 +63,9 @@ sub get_all { sub get_all_versions { my ($self, %params) = @_; my @versionobjs; - my @fileobjs = $self->get_all(%params); + my @fileobjs; if ( $params{dbfile} ) { - push @fileobjs, SL::File::Object->new(dbfile => $params{db_file}, id => $params{dbfile}->id, loaded => 1); + push @fileobjs, SL::File::Object->new(db_file => $params{dbfile}, id => $params{dbfile}->id, loaded => 1); } else { @fileobjs = $self->get_all(%params); }