Bugzilla – Attachment 31805 Details for
Bug 12740
It should not be possible to store empty news
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12740 - Data Validation followup
Bug-12740---Data-Validation-followup.patch (text/plain), 3.80 KB, created by
Jonathan Druart
on 2014-09-22 07:56:46 UTC
(
hide
)
Description:
Bug 12740 - Data Validation followup
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2014-09-22 07:56:46 UTC
Size:
3.80 KB
patch
obsolete
>From c8cf71fd5f9b3ee6682a99b287b06573b17aa9cf Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Sat, 20 Sep 2014 08:01:36 -0400 >Subject: [PATCH] Bug 12740 - Data Validation followup >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Added server-side validation and feedback to Koha news. > >TEST PLAN >--------- >1) Log in to staff client as someone who can add news >2) Paste a variation of the ugly following URL into your > address bar: > >https://demo.library-admin.kohasystem.ca/cgi-bin/koha/tools/koha-news.pl?op=add&lang=&branch=&title=&from=&to=&number=&new= > > -- A blank news item is added without warning! >3) Apply patch >4) Repeat step 2 > -- "ERROR: Required news title missing!" is displayed > and no blank news is added >5) run koha qa test tools > >Followed test plan, Error message appears as expected, qa test tool: OK >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > .../prog/en/modules/tools/koha-news.tt | 1 + > tools/koha-news.pl | 34 ++++++++++++++-------- > 2 files changed, 23 insertions(+), 12 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt >index e1159f8..dda0738 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt >+++ b/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 %]</div> > <div class="yui-b"> > > [% UNLESS ( add_form ) %] >+ [% IF (error_message) %]<p>[% error_message %]</p>[% END %] > <div id="toolbar" class="btn-toolbar"> > <a class="btn btn-small" id="newentry" href="/cgi-bin/koha/tools/koha-news.pl?op=add_form&lang=[% lang %]"><i class="icon-plus"></i> New entry</a> > </div> >diff --git a/tools/koha-news.pl b/tools/koha-news.pl >index a07b3d4..42dd149 100755 >--- a/tools/koha-news.pl >+++ b/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( >-- >2.1.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12740
:
30647
|
31579
|
31788
|
31789
|
31790
|
31791
|
31804
| 31805 |
31806