Bugzilla – Attachment 66253 Details for
Bug 4461
Add a context-sensitive report a problem process
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 4461: [FOLLOW-UP] Problem Report feature
Bug-4461-FOLLOW-UP-Problem-Report-feature.patch (text/plain), 23.04 KB, created by
Aleisha Amohia
on 2017-08-20 22:16:47 UTC
(
hide
)
Description:
Bug 4461: [FOLLOW-UP] Problem Report feature
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2017-08-20 22:16:47 UTC
Size:
23.04 KB
patch
obsolete
>From 0c12d7812b5b7af15abfefe1af245f2aea8267ea Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Fri, 11 Aug 2017 05:05:31 +0000 >Subject: [PATCH] Bug 4461: [FOLLOW-UP] Problem Report feature > >This patch: > - uses a pull down menu to switch the recipient instead of tabs > - if the library has no email or the administrator has no email, this > error message has been moved to be down by the Submit button > - includes use of branchreplyto and ReplytoDefault for branch email > - disables use of the feature if the user is not logged in > - adds a syspref to hide or show the feature > - provides support for if JS is disabled > >Additional testing: > - using the message_queue table, check that the correct recipient > receives a problem report when switching in the drop down menu > - check appropriate error message shows next to the submit button if an > email is not provided. this should dynamically change as you select a > different recipient from the drop down menu > - check that when the library is the recipient, the feature sends the > report to the branchreplyto, then the ReplytoDefault, then the branch > email in that priority order > - log out of the OPAC and confirm that you can't submit a report > without logging in. the submit button should be disabled > - disable the OPACReportProblem syspref. the Report a Problem link in > the footer should be gone. if you force the URL > (/cgi-bin/koha/opac-reportproblem.pl) the form should be hidden and > replaced with an error message. > - disable JS in your browser. confirm that you are still able to send > problem reports to library and administrator. remove the administrator > email address. confirm the error message shows next to the submit > button and that clicking the submit button returns an error. check in > the message_queue that the email was never sent. > >After this feature is passed: > - i would like to add a staff-side feature where staff can see the > problem reports and mark them as 'read'. i'll work on that once this > gets through :) >--- > .../bug-4461_add-problem-reports-syspref.sql | 1 + > installer/data/mysql/sysprefs.sql | 1 + > .../prog/en/modules/admin/preferences/opac.pref | 6 + > .../bootstrap/en/includes/opac-bottom.inc | 8 +- > .../bootstrap/en/modules/opac-reportproblem.tt | 132 +++++++++++---------- > opac/opac-reportproblem.pl | 116 ++++++++++-------- > 6 files changed, 147 insertions(+), 117 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-syspref.sql > >diff --git a/installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-syspref.sql b/installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-syspref.sql >new file mode 100644 >index 0000000..ad8abc4 >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-syspref.sql >@@ -0,0 +1 @@ >+INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('OPACReportProblem', 1, NULL, "A feature for users to submit problem reports for OPAC pages.",'YesNo'); >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 0bd8cac..e4dc732 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -365,6 +365,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('opacreadinghistory','1','','If ON, enables display of Patron Circulation History in OPAC','YesNo'), > ('OpacRenewalAllowed','0',NULL,'If ON, users can renew their issues directly from their OPAC account','YesNo'), > ('OpacRenewalBranch','checkoutbranch','itemhomebranch|patronhomebranch|checkoutbranch|null','Choose how the branch for an OPAC renewal is recorded in statistics','Choice'), >+('OPACReportProblem', 1, NULL, "A feature for users to submit problem reports for OPAC pages.",'YesNo'), > ('OpacResetPassword','0','','Shows the ''Forgot your password?'' link in the OPAC','YesNo'), > ('OPACResultsLibrary', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice'), > ('OPACResultsSidebar','','70|10','Define HTML to be included on the search results page, underneath the facets sidebar','Textarea'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >index b6954ef..bcae28a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref >@@ -345,6 +345,12 @@ OPAC: > footer: "only footer" > Features: > - >+ - pref: OPACReportProblem >+ choices: >+ yes: Allow >+ no: "Don't allow" >+ - patrons to submit problem reports for OPAC pages. >+ - > - pref: opacuserlogin > choices: > yes: Allow >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >index 633847d..2f2f5a6 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc >@@ -16,9 +16,11 @@ > <div class="container-fluid"> > <div class="row-fluid"> > <div class="span12"> >- <div id="report_a_problem" class="noprint" style="float:left;"> >- <a class="koha_url" href="/cgi-bin/koha/opac-reportproblem.pl">Report a problem</a> >- </div> >+ [% IF ( Koha.Preference('OPACReportProblem') ) %] >+ <div id="report_a_problem" class="noprint" style="float:left;"> >+ <a class="koha_url" href="/cgi-bin/koha/opac-reportproblem.pl">Report a problem</a> >+ </div> >+ [% END %] > <div id="koha_url" class="clearfix noprint"> > <p>Powered by > [% IF template.name.match('opac-main.tt') %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt >index f36c745..f7c32cb 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt >@@ -26,92 +26,64 @@ > <div class="span12"> > [% END %] > <h1>Report a problem</h1> >- [% IF ( successfuladd ) %] >- <div class="alert alert-info">Your problem report has been sent to the [% IF ( recipient == 'admin' ) %]Koha Administrator[% ELSE %] [% recipient %][% END %].</div> >- [% END %] >- [% IF ( nolibemail ) %] >- <div class="alert">Your library has not provided an email address.</div> >- [% END %] >- [% IF ( noadminemail ) %] >- <div class="alert">The Koha Administrator has not provided an email address.</div> >- [% END %] >- [% IF ( nolibemail && noadminemail ) %] >- <div class="alert">Unable to send problem reports.</div> >- [% END %] >- <div id="reportproblem" class="maincontent toptabs"> >- <ul> >- <li><a href="#reportlib">Report to librarian</a></li> >- <li><a href="#reportadmin">Report to Koha Administrator</a></li> >- </ul> >- <div id="reportlib"> >+ [% IF ( Koha.Preference('OPACReportProblem') ) %] >+ [% UNLESS ( loggedinusername ) %] >+ <div class="alert">You must be logged in to send problem reports. Please <a class="loginModal-trigger" href="/cgi-bin/koha/opac-user.pl" role="button" data-toggle="modal">log in</a> and return to the page where you found a problem to send a problem report.</div> >+ [% END %] >+ [% IF ( successfuladd ) %] >+ <div class="alert alert-info">Your problem report has been sent to the [% IF ( recipient == 'admin' ) %]Koha Administrator[% ELSE %] [% recipient %][% END %].</div> >+ [% END %] >+ [% IF ( failedadd_admin ) %] >+ <div class="alert">Failed to send a problem report because the Koha Administrator has not provided an email address.</div> >+ [% ELSIF ( failedadd_lib ) %] >+ <div class="alert">Failed to send a problem report because the library has not provided an email address.</div> >+ [% END %] >+ <div id="reportproblem" class="maincontent"> > <form name="reportlibform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post"> > <input type="hidden" name="op" value="addreport"> >- <input type="hidden" name="recipient" value="library"> > <fieldset class="rows"> > <ol> > <li> >- <label for="place">Problem found on page: </label> >- <input type="hidden" name="place" id="libplace" value="[% probpage %]" class="span6"> >- [% probpage | html %] >- </li> >- <li> >- <label for="user">Username: </label> >- <input type="hidden" name="user" id="libuser" value="[% username %]" class="span3"> >- [% username | html %] >- <li> >- <label for="subject">Subject: </label> >- <input type="text" name="subject" id="libsubject" value="[% subject %]" class="span3"> >+ <label for="recipient">Send problem report to: </label> >+ <select name="recipient" id="recipient"> >+ <option value="library">A librarian</option> >+ <option value="admin">Koha Administrator</option> >+ </select> > </li> > <li> >- <label for="message">Message: </label> >- <textarea name="message" id="libmessage" rows="7" cols="60"></textarea> >- </li> >- </ol> >- </fieldset> >- <fieldset class="action"> >- [% IF ( nolibemail ) %] >- <input type="submit" value="Submit" class="btn" disabled="disabled"> >- [% ELSE %] >- <input type="submit" value="Submit" class="btn"> >- [% END %] >- </fieldset> >- </form> >- </div> >- <div id="reportadmin"> >- <form name="reportadminform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post"> >- <input type="hidden" name="op" value="addreport"> >- <input type="hidden" name="recipient" value="admin"> >- <fieldset class="rows"> >- <ol> >- <li> > <label for="place">Problem found on page: </label> >- <input type="hidden" name="place" id="adminplace" value="[% probpage %]"> >+ <input type="hidden" name="place" id="place" value="[% probpage %]" class="span6"> > [% probpage | html %] > </li> > <li> > <label for="user">Username: </label> >- <input type="hidden" name="user" id="adminuser" value="[% username %]" class="span3"> >+ <input type="hidden" name="user" id="user" value="[% username %]" class="span3"> > [% username | html %] >+ </li> > <li> > <label for="subject">Subject: </label> >- <input type="text" name="subject" id="adminsubject" value="[% subject %]" class="span3"> >+ <input type="text" name="subject" id="subject" value="[% subject %]" class="span3"> > </li> > <li> > <label for="message">Message: </label> >- <textarea name="message" id="adminmessage" rows="7" cols="60"></textarea> >+ <textarea name="message" id="message" rows="7" cols="60"></textarea> > </li> > </ol> > </fieldset> > <fieldset class="action"> >- [% IF ( noadminemail ) %] >- <input type="submit" value="Submit" class="btn" disabled="disabled"> >+ [% IF ( loggedinusername ) %] >+ <input type="submit" value="Submit" class="btn" id="submit"> >+ [% IF ( nolibemail ) %]<span id="nolibemail">Your library has not provided an email address.</span>[% END %] >+ [% IF ( noadminemail ) %]<span id="noadminemail">The Koha Administrator has not provided an email address.</span>[% END %] > [% ELSE %] >- <input type="submit" value="Submit" class="btn"> >+ <input type="submit" value="Submit" class="btn" id="submit" disabled="disabled"> > [% END %] > </fieldset> > </form> > </div> >- </div> >+ [% ELSE %] >+ <div class="alert">Your library has not activated this feature.</div> >+ [% END %] > </div> <!-- / .span10/12 --> > </div> <!-- / .row-fluid --> > </div> <!-- / .container-fluid --> >@@ -119,11 +91,43 @@ > > [% INCLUDE 'opac-bottom.inc' %] > [% BLOCK jsinclude %] >+<script type="text/javascript"> >+ $(document).ready(function(){ >+ [% IF loggedinusername %] >+ var nolibemail = 0; >+ var noadminemail = 0; >+ >+ [% IF nolibemail %] >+ nolibemail = [% nolibemail %]; >+ [% END %] >+ >+ [% IF noadminemail %] >+ noadminemail = [% noadminemail %] >+ [% END %] >+ >+ $(".submitbtn").prop("disabled", false); >+ checkEmails(); > >- <script type="text/javascript"> >- $(document).ready(function(){ >- $("#reportproblem").tabs(); >- }); >- </script> >+ $("#recipient").change(function(){ >+ checkEmails(); >+ }); > >+ function checkEmails(){ >+ if ( $("#recipient").val() == 'library' && nolibemail == 1 ){ >+ $("#submit").prop("disabled", true); >+ $("#nolibemail").show(); >+ $("#noadminemail").hide(); >+ } else if ( $("#recipient").val() == 'admin' && noadminemail == 1 ){ >+ $("#submit").prop("disabled", true); >+ $("#nolibemail").hide(); >+ $("#noadminemail").show(); >+ } else { >+ $("#submit").prop("disabled", false); >+ $("#nolibemail").hide(); >+ $("#noadminemail").hide(); >+ } >+ } >+ [% END %] >+ }); >+</script> > [% END %] >diff --git a/opac/opac-reportproblem.pl b/opac/opac-reportproblem.pl >index b4ed191..b353d4c 100755 >--- a/opac/opac-reportproblem.pl >+++ b/opac/opac-reportproblem.pl >@@ -27,6 +27,7 @@ use C4::Letters; > use Koha::ProblemReport; > use Koha::DateUtils; > use Koha::Libraries; >+use Koha::Patrons; > > my $input = new CGI; > >@@ -35,66 +36,81 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( > template_name => "opac-reportproblem.tt", > type => "opac", > query => $input, >- authnotrequired => 0, >+ authnotrequired => 1, > } > ); > >-my $problempage = $ENV{HTTP_REFERER}; >-my $member = GetMember( borrowernumber => $borrowernumber ); >-my $username = $member->{'userid'}; >-my $branchcode = $member->{'branchcode'}; >-my $library = Koha::Libraries->find($branchcode); >-if ( $library->branchemail eq undef || ! $library->branchemail ) { >- $template->param( nolibemail => 1 ); >-} >-my $koha_admin = C4::Context->preference('KohaAdminEmailAddress'); >-if ( ! $koha_admin ) { >- $template->param( noadminemail => 1 ); >-} >-my $recipient = $input->param('recipient') || 'library'; >-$template->param( >- username => $username, >- probpage => $problempage, >-); >+if ( $borrowernumber ) { # if user is logged in > >-my $op = $input->param('op') || ''; >-if ( $op eq 'addreport' ) { >- my $subject = $input->param('subject'); >- my $message = $input->param('message'); >- my $place = $input->param('place'); >- my $problem = Koha::ProblemReport->new({ title => $subject, content => $message, borrowernumber => $borrowernumber, branchcode => $branchcode, username => $username, problempage => $place, recipient => $recipient, reportdate => dt_from_string() })->store; >+ my $problempage = $ENV{HTTP_REFERER}; >+ my $member = Koha::Patrons->find( $borrowernumber ); >+ my $username = $member->userid; >+ my $branchcode = $member->branchcode; >+ my $library = Koha::Libraries->find($branchcode); >+ if ( ( !defined $library->branchreplyto ) && ( !defined C4::Context->preference('ReplytoDefault') ) && ( !defined $library->branchemail ) ) { >+ $template->param( nolibemail => 1 ); >+ } >+ my $koha_admin = C4::Context->preference('KohaAdminEmailAddress'); >+ if ( !$koha_admin ) { >+ $template->param( noadminemail => 1 ); >+ } >+ my $recipient = $input->param('recipient') || 'library'; > $template->param( >- recipient => $recipient, >- successfuladd => 1, >- probpage => $place, >+ username => $username, >+ probpage => $problempage, > ); > >- my $problemreport = $problem->unblessed; >- $problemreport->{code} = 'PROBLEM_REPORT'; >- $problemreport->{content} .= "\nUsername: $username"; >- $problemreport->{content} .= "\nProblem page: $place"; >- my $transport = 'email'; >+ my $op = $input->param('op') || ''; >+ if ( $op eq 'addreport' ) { >+ # if user does not have JS enabled and the submit button is still enabled, the following lines ensure a report isn't submitted if the required recipient emails don't exist >+ if ( $recipient eq 'admin' && !$koha_admin ) { >+ $template->param( failedadd_admin => 1 ); >+ } elsif ( ( !defined $library->branchreplyto ) && ( !defined C4::Context->preference('ReplytoDefault') ) && ( !defined $library->branchemail ) ) { >+ $template->param( failedadd_lib => 1 ); >+ } else { >+ >+ my $subject = $input->param('subject'); >+ my $message = $input->param('message'); >+ my $place = $input->param('place'); >+ my $problem = Koha::ProblemReport->new({ title => $subject, content => $message, borrowernumber => $borrowernumber, branchcode => $branchcode, username => $username, problempage => $place, recipient => $recipient, reportdate => dt_from_string() })->store; >+ $template->param( >+ recipient => $recipient, >+ successfuladd => 1, >+ probpage => $place, >+ ); > >- my $from_address = $member->{email} || $member->{emailpro} || $member->{B_email} || $koha_admin; >+ my $problemreport = $problem->unblessed; >+ $problemreport->{code} = 'PROBLEM_REPORT'; >+ $problemreport->{content} .= "\nUsername: $username"; >+ $problemreport->{content} .= "\nProblem page: $place"; >+ my $transport = 'email'; > >- if ( $recipient eq 'admin' ) { >- C4::Letters::EnqueueLetter({ >- letter => $problemreport, >- borrowernumber => $borrowernumber, >- message_transport_type => $transport, >- to_address => $koha_admin, >- from_address => $from_address, >- }); >- } else { >- my $to_address = $library->branchemail; >- C4::Letters::EnqueueLetter({ >- letter => $problemreport, >- borrowernumber => $borrowernumber, >- message_transport_type => $transport, >- to_address => $to_address, >- from_address => $from_address, >- }); >+ my $from_address = $member->email || $member->emailpro || $member->B_email || $koha_admin; >+ >+ if ( $recipient eq 'admin' ) { >+ C4::Letters::EnqueueLetter({ >+ letter => $problemreport, >+ borrowernumber => $borrowernumber, >+ message_transport_type => $transport, >+ to_address => $koha_admin, >+ from_address => $from_address, >+ }); >+ } else { >+ my $to_address = $library->branchreplyto || C4::Context->preference('ReplytoDefault') || $library->branchemail; >+ C4::Letters::EnqueueLetter({ >+ letter => $problemreport, >+ borrowernumber => $borrowernumber, >+ message_transport_type => $transport, >+ to_address => $to_address, >+ from_address => $from_address, >+ }); >+ } >+ } > } >+ >+} else { # if no user logged in >+ my $problempage = $ENV{HTTP_REFERER}; >+ $template->param( probpage => $problempage ); > } > > output_html_with_http_headers $input, $cookie, $template->output; >-- >2.1.4
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 4461
:
58887
|
59032
|
61654
|
65871
|
66253
|
66323
|
66324
|
98687
|
98688
|
98689
|
98725
|
99551
|
99599
|
99600
|
99601
|
99602
|
99603
|
99633
|
99635
|
99636
|
99637
|
99638
|
99639
|
99929
|
99930
|
99931
|
99932
|
99933
|
99934
|
99935
|
99936
|
99937
|
99938
|
99939
|
99940
|
99941
|
99942
|
100488
|
100489
|
100490
|
100491
|
100492
|
100493
|
100494
|
100495
|
100496
|
100497
|
100498
|
100499
|
100500
|
100506
|
100507
|
100508
|
100509
|
100510
|
100511
|
100512
|
100513
|
100514
|
100515
|
100516
|
100517
|
100518
|
100519
|
100520
|
100521
|
100522
|
100523
|
100524
|
100619
|
100989
|
100990
|
102188
|
102189
|
102190
|
102191
|
102192
|
102193
|
102194
|
102195
|
102196
|
102198
|
102200
|
102201
|
102202
|
102203
|
102204
|
102205
|
102206
|
102207
|
102208
|
102209
|
102210
|
102211
|
102253
|
102279
|
102281
|
102308
|
102309
|
102310
|
102311
|
102312
|
102313
|
102314
|
102315
|
102316
|
102317
|
102318
|
102319
|
102320
|
102321
|
102322
|
102323
|
102324
|
102325
|
102326
|
102327
|
102328
|
102329
|
102330
|
102331
|
102358
|
102359
|
102360
|
102361
|
102362
|
102363
|
102364
|
102365
|
102366
|
102367
|
102368
|
102369
|
102370
|
102371
|
102372
|
102373
|
102374
|
102375
|
102376
|
102377
|
102378
|
102379
|
102380
|
102381
|
102382
|
102383
|
102384
|
102385
|
102386