From: Moritz Bunkus Date: Tue, 25 Nov 2014 12:52:27 +0000 (+0100) Subject: CustomerVendor-Presenter: croaken, wenn Parameter fehlen oder falsch sind X-Git-Tag: release-3.2.0beta~226^2~3 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=3b01b816f1c52e187babf1988d7e7d765fe18299;p=kivitendo-erp.git CustomerVendor-Presenter: croaken, wenn Parameter fehlen oder falsch sind --- diff --git a/SL/Presenter/CustomerVendor.pm b/SL/Presenter/CustomerVendor.pm index 2bf5ebc3c..4a3702970 100644 --- a/SL/Presenter/CustomerVendor.pm +++ b/SL/Presenter/CustomerVendor.pm @@ -39,7 +39,14 @@ sub _customer_vendor { sub customer_vendor_picker { my ($self, $name, $value, %params) = @_; - $value = SL::DB::Manager::Customer->find_by(id => $value) if $value && !ref $value; + croak 'Unknown "type" parameter' unless $params{type} =~ m{^(?:customer|vendor)$}; + croak 'Unknown value class' if $value && (ref($value) !~ m{^SL::DB::(?:Customer|Vendor)$}); + + if ($value && !ref $value) { + my $class = $params{type} eq 'customer' ? 'SL::DB::Manager::Customer' : 'SL::DB::Manager::Vendor'; + $value = $class->find_by(id => $value); + } + my $id = delete($params{id}) || $self->name_to_id($name); my $fat_set_item = delete $params{fat_set_item};