@@ -, +, @@ --------- address bar: -- A blank news item is added without warning! -- "ERROR: Required news title missing!" is displayed and no blank news is added --- .../prog/en/modules/tools/koha-news.tt | 1 + tools/koha-news.pl | 34 ++++++++++++++-------- 2 files changed, 23 insertions(+), 12 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt @@ -60,6 +60,7 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %]
[% UNLESS ( add_form ) %] + [% IF (error_message) %]

[% error_message %]

[% END %]
New entry
--- a/tools/koha-news.pl +++ a/tools/koha-news.pl @@ -45,6 +45,8 @@ my $timestamp = format_date_in_iso($cgi->param('timestamp')); my $number = $cgi->param('number'); my $lang = $cgi->param('lang'); my $branchcode = $cgi->param('branch'); +my $error_message = $cgi->param('error_message'); + # Foreign Key constraints work with NULL, not '' # NULL = All branches. $branchcode = undef if (defined($branchcode) && $branchcode eq ''); @@ -62,6 +64,9 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); +# Pass error message if there is one. +$template->param( error_message => $error_message ) if $error_message; + # get lang list my @lang_list; my $tlangs = getTranslatedLanguages() ; @@ -99,18 +104,23 @@ if ( $op eq 'add_form' ) { } } elsif ( $op eq 'add' ) { - add_opac_new( - { - title => $title, - new => $new, - lang => $lang, - expirationdate => $expirationdate, - timestamp => $timestamp, - number => $number, - branchcode => $branchcode, - } - ); - print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); + if ($title) { + add_opac_new( + { + title => $title, + new => $new, + lang => $lang, + expirationdate => $expirationdate, + timestamp => $timestamp, + number => $number, + branchcode => $branchcode, + } + ); + print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl"); + } + else { + print $cgi->redirect("/cgi-bin/koha/tools/koha-news.pl?error_message=ERROR:+Required+news+title+missing!"); + } } elsif ( $op eq 'edit' ) { upd_opac_new( --