diff --git a/lib/NGCP/Panel/Block/Block.pm b/lib/NGCP/Panel/Block/Block.pm index a52c5da509..61136b8e45 100644 --- a/lib/NGCP/Panel/Block/Block.pm +++ b/lib/NGCP/Panel/Block/Block.pm @@ -10,7 +10,7 @@ sub new { die __PACKAGE__ . " is abstract" if __PACKAGE__ eq $class; my $self = {}; $self->{form} = $args{form}; - $self->{c} = $args{form}->{ctx} or die "form context required for $class"; + $self->{c} = $args{form}->{ctx}; return bless $self, $class; } @@ -26,6 +26,7 @@ sub template { sub render { my $self = shift; + return unless $self->{c}; my $output = ''; diff --git a/lib/NGCP/Panel/Form/DestinationSet.pm b/lib/NGCP/Panel/Form/DestinationSet.pm index 202b646a4b..723ff799e0 100644 --- a/lib/NGCP/Panel/Form/DestinationSet.pm +++ b/lib/NGCP/Panel/Form/DestinationSet.pm @@ -172,9 +172,11 @@ sub build_announcements { my ($self) = @_; my @options = (); my $c = $self->form->ctx; - push @options, { label => 'Select announcement', value => '' }; - foreach($c->stash->{custom_announcements_rs}->all){ - push @options, { label => $_->name, value => $_->id }; + if(defined $c) { + push @options, { label => 'Select announcement', value => '' }; + foreach($c->stash->{custom_announcements_rs}->all){ + push @options, { label => $_->name, value => $_->id }; + } } return \@options; } diff --git a/lib/NGCP/Panel/Form/SubscriberCFSimple.pm b/lib/NGCP/Panel/Form/SubscriberCFSimple.pm index e3997b632b..ea8212e9ed 100644 --- a/lib/NGCP/Panel/Form/SubscriberCFSimple.pm +++ b/lib/NGCP/Panel/Form/SubscriberCFSimple.pm @@ -146,9 +146,11 @@ sub build_announcements { my ($self) = @_; my @options = (); my $c = $self->form->ctx; - push @options, { label => 'Select announcement', value => '' }; - foreach($c->stash->{custom_announcements_rs}->all){ - push @options, { label => $_->name, value => $_->id }; + if(defined $c) { + push @options, { label => 'Select announcement', value => '' }; + foreach($c->stash->{custom_announcements_rs}->all){ + push @options, { label => $_->name, value => $_->id }; + } } return \@options; } diff --git a/script/ngcp_panel_dump_db_strings.pl b/script/ngcp_panel_dump_db_strings.pl index 3729fd76d9..36f05417d4 100755 --- a/script/ngcp_panel_dump_db_strings.pl +++ b/script/ngcp_panel_dump_db_strings.pl @@ -53,13 +53,16 @@ sub dummy::loc { shift; return shift; }; my %unique_strings; foreach my $mod(@files){ my $modname = $mod =~ s!lib/!!r =~ s!/!::!gr =~ s!\.pm$!!r; - eval { - require $mod; - my $form = $modname->new; - my $strings = NGCP::Panel::Utils::I18N->translate_form($dummy, $form, 1); - print $fh " #$modname\n"; - @unique_strings{@$strings} = 1; - } || print $fh " #$modname: error\n"; + if (eval "require $modname; 1;") { + eval { + my $form = $modname->new; + my $strings = NGCP::Panel::Utils::I18N->translate_form($dummy, $form, 1); + print $fh " #$modname\n"; + @unique_strings{@$strings} = 1; + } || print $fh " #$modname: error: $@\n"; + } else { + print $fh "#'$modname' could not be loaded. Skipping it...\n"; + } } for my $s (keys %unique_strings) { @@ -75,10 +78,34 @@ print $fh < + =head1 LICENSE -This library is free software. You can redistribute it and/or modify -it under the same terms as Perl itself. +This software is Copyright 2021 by Sipwise GmbH, Austria. + +All rights reserved. You may not copy, distribute +or modify without prior written permission from +Sipwise GmbH, Austria. =cut