X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/kivitendo-erp.git/blobdiff_plain/2cf0b165a479c86d378e795ca5d0745a901f422f..6bad0469c4f5bb92830f77cf7675e76730e79ae4:/bin/mozilla/common.pl diff --git a/bin/mozilla/common.pl b/bin/mozilla/common.pl index 97391b2a9..38297576d 100644 --- a/bin/mozilla/common.pl +++ b/bin/mozilla/common.pl @@ -17,8 +17,7 @@ use SL::Common; sub save_form { $lxdebug->enter_sub(); - my $yaml = new YAML; - my $old_form = $yaml->dump($form); + my $old_form = YAML::Dump($form); $old_form =~ s|!|!!|g; $old_form =~ s|\n|!n|g; $old_form =~ s|\r|!r|g; @@ -98,7 +97,7 @@ sub select_employee_internal { restore_form($form->{"old_form"}); - &{ $callback_sub }($new_id, $new_name); + call_sub($callback_sub, $new_id, $new_name); $lxdebug->leave_sub(); } @@ -168,7 +167,7 @@ sub select_part_internal { restore_form($form->{"old_form"}); - &{ $callback_sub }($new_item); + call_sub($callback_sub, $new_item); $lxdebug->leave_sub(); } @@ -544,4 +543,24 @@ sub show_history { $lxdebug->leave_sub(); } +sub call_sub { + $lxdebug->enter_sub(); + + my $name = shift; + + if (!$name) { + $form->error($locale->text("Trying to call a sub without a name")); + } + + $name =~ s/[^a-zA-Z0-9_]//g; + + if (!defined(&{ $name })) { + $form->error(sprintf($locale->text("Attempt to call an undefined sub named '%s'"), $name)); + } + + &{ $name }(@_); + + $lxdebug->leave_sub(); +} + 1;