Bug 4461: Submit a problem report
To test: 1) Apply patch, update database, rebuild schema file 2) Restart koha-common and memcached 3) Confirm that your user has an email address. 4) Confirm that your library does NOT have an email address. 5) Confirm that syspref KohaAdminEmailAddress and syspref ReplytoDefault are not filled. Enable the OPACReportProblem syspref. 6) Log into OPAC 7) Click the 'Report a problem' link at the bottom of whatever page you're on 8) Notice that there is no form is and there is an error message alerting that reports cannot be submitted 9) Add an email address for your library (in either the email field or the replyto field). Refresh the OPAC problem report page. The form should now show, and the recipient field should say 'library'. 10) Complete the form and submit. Check the message_queue in the database and confirm the to_address is correct. Confirm there is a success message. 11) Add an email address for the syspref KohaAdminEmailAddress and refresh the OPAC problem report page again. The recipient field should now be a dropdown. Select the Koha Administrator option. 12) Complete the form and submit. Check the message_queue in the database and confirm the to_address is the value in KohaAdminEmailAddress. Confirm there is a success message. 13) Ensure all details in the message_queue are correct. 14) Log out of the OPAC 15) Click the Report a problem link again and confirm you are forced to log in Sponsored-by: Catalyst IT Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
5877fcf2c9
commit
5d05b4d01c
3 changed files with 215 additions and 0 deletions
|
@ -20,6 +20,11 @@
|
|||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
<div class="span12">
|
||||
[% 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') %]
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
[% USE Koha %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Report a Problem</title>
|
||||
[% INCLUDE 'doc-head-close.inc' %]
|
||||
[% BLOCK cssinclude %][% END %]
|
||||
</head>
|
||||
[% INCLUDE 'bodytag.inc' bodyid='opac-reportproblem' bodyclass='scrollto' %]
|
||||
[% INCLUDE 'masthead.inc' %]
|
||||
|
||||
<div class="main">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li>
|
||||
<li><a href="#">Report a problem</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row-fluid">
|
||||
[% IF ( OpacNav || OpacNavBottom ) %]
|
||||
<div class="span2">
|
||||
<div id="navigation">
|
||||
[% INCLUDE 'navigation.inc' %]
|
||||
</div>
|
||||
</div>
|
||||
<div class="span10">
|
||||
[% ELSE %]
|
||||
<div class="span12">
|
||||
[% END %]
|
||||
<h1>Report a problem</h1>
|
||||
|
||||
[% IF Koha.Preference('OPACReportProblem') %]
|
||||
|
||||
[% 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 and noadminemail ) or norecipients ) %]
|
||||
<div class="alert">Unable to send problem reports.</div>
|
||||
[% ELSE %]
|
||||
<div id="reportproblem" class="maincontent toptabs">
|
||||
<form name="reportlibform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
|
||||
<input type="hidden" name="op" value="addreport">
|
||||
<fieldset class="rows">
|
||||
<ol>
|
||||
<li>
|
||||
<label for="recipient">Send problem report to: </label>
|
||||
[% IF !nolibemail and noadminemail %]
|
||||
<option value="library">A librarian</option>
|
||||
[% ELSIF !noadminemail and nolibemail %]
|
||||
<option value="admin">Koha Administrator</option>
|
||||
[% ELSE %]
|
||||
<select name="recipient" id="recipient">
|
||||
<option value="library">A librarian</option>
|
||||
<option value="admin">Koha Administrator</option>
|
||||
</select>
|
||||
[% END %]
|
||||
</li>
|
||||
<li>
|
||||
<label for="place">Problem found on page: </label>
|
||||
<input type="hidden" name="place" id="place" value="[% probpage %]">
|
||||
[% probpage | html %]
|
||||
</li>
|
||||
<li>
|
||||
<label for="user">Username: </label>
|
||||
<input type="hidden" name="user" id="user" value="[% username %]" class="span3">
|
||||
[% username | html %]
|
||||
<li>
|
||||
<label for="subject">Subject: </label>
|
||||
<input type="text" name="subject" id="subject" value="[% subject %]" class="span3">
|
||||
</li>
|
||||
<li>
|
||||
<label for="message">Message: </label>
|
||||
<textarea name="message" id="message" rows="7" cols="60"></textarea>
|
||||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
<fieldset class="action">
|
||||
<input type="submit" value="Submit" class="btn">
|
||||
</fieldset>
|
||||
</form>
|
||||
</div>
|
||||
[% END %]
|
||||
|
||||
[% ELSE %] <!-- OPACReportProblem preference -->
|
||||
<div class="alert">Your library has not activated this feature.</div>
|
||||
[% END %]
|
||||
|
||||
</div> <!-- / .span10/12 -->
|
||||
</div> <!-- / .row-fluid -->
|
||||
</div> <!-- / .container-fluid -->
|
||||
</div> <!-- / .main -->
|
||||
|
||||
[% INCLUDE 'opac-bottom.inc' %]
|
||||
[% BLOCK jsinclude %][% END %]
|
118
opac/opac-reportproblem.pl
Normal file
118
opac/opac-reportproblem.pl
Normal file
|
@ -0,0 +1,118 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# This file is part of Koha.
|
||||
#
|
||||
# Copyright 2019 Aleisha Amohia <aleisha@catalyst.net.nz>
|
||||
#
|
||||
# Koha is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Koha is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Koha; if not, see <http://www.gnu.org/licenses>.
|
||||
|
||||
use Modern::Perl;
|
||||
use CGI qw ( -utf8 );
|
||||
use C4::Auth; # get_template_and_user
|
||||
use C4::Output;
|
||||
use C4::Members;
|
||||
use C4::Letters;
|
||||
use Koha::ProblemReport;
|
||||
use Koha::DateUtils;
|
||||
use Koha::Libraries;
|
||||
use Koha::Patrons;
|
||||
|
||||
my $input = new CGI;
|
||||
|
||||
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
|
||||
{
|
||||
template_name => "opac-reportproblem.tt",
|
||||
type => "opac",
|
||||
query => $input,
|
||||
authnotrequired => 0,
|
||||
}
|
||||
);
|
||||
|
||||
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);
|
||||
my $recipients = 2;
|
||||
|
||||
if (
|
||||
( !defined($library->branchreplyto) || $library->branchreplyto eq '' ) &&
|
||||
( C4::Context->preference('ReplytoDefault') eq '' ) &&
|
||||
( !defined($library->branchemail) || $library->branchemail eq '' )
|
||||
) {
|
||||
$template->param( nolibemail => 1 );
|
||||
$recipients--;
|
||||
}
|
||||
|
||||
my $koha_admin = C4::Context->preference('KohaAdminEmailAddress');
|
||||
if ( $koha_admin eq '' ) {
|
||||
$template->param( noadminemail => 1 );
|
||||
$recipients--;
|
||||
}
|
||||
|
||||
$template->param(
|
||||
username => $username,
|
||||
probpage => $problempage,
|
||||
);
|
||||
|
||||
my $op = $input->param('op') || '';
|
||||
if ( $op eq 'addreport' ) {
|
||||
|
||||
if ( $recipients == 0 ){
|
||||
print $input->redirect("/cgi-bin/koha/opac-reportproblem?norecipients=1.pl");
|
||||
exit;
|
||||
}
|
||||
|
||||
my $subject = $input->param('subject');
|
||||
my $message = $input->param('message');
|
||||
my $place = $input->param('place');
|
||||
my $recipient = $input->param('recipient') || 'library';
|
||||
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 $problemreport = $problem->unblessed;
|
||||
$problemreport->{code} = 'PROBLEM_REPORT';
|
||||
$problemreport->{content} .= "\nUsername: $username";
|
||||
$problemreport->{content} .= "\nProblem page: $place";
|
||||
my $transport = 'email';
|
||||
|
||||
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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
output_html_with_http_headers $input, $cookie, $template->output;
|
Loading…
Reference in a new issue