View | Details | Raw Unified | Return to bug 4461
Collapse All | Expand All

(-)a/installer/data/mysql/atomicupdate/bug-4461_add-problem-reports-syspref.sql (+1 lines)
Line 0 Link Here
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');
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 365-370 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
365
('opacreadinghistory','1','','If ON, enables display of Patron Circulation History in OPAC','YesNo'),
365
('opacreadinghistory','1','','If ON, enables display of Patron Circulation History in OPAC','YesNo'),
366
('OpacRenewalAllowed','0',NULL,'If ON, users can renew their issues directly from their OPAC account','YesNo'),
366
('OpacRenewalAllowed','0',NULL,'If ON, users can renew their issues directly from their OPAC account','YesNo'),
367
('OpacRenewalBranch','checkoutbranch','itemhomebranch|patronhomebranch|checkoutbranch|null','Choose how the branch for an OPAC renewal is recorded in statistics','Choice'),
367
('OpacRenewalBranch','checkoutbranch','itemhomebranch|patronhomebranch|checkoutbranch|null','Choose how the branch for an OPAC renewal is recorded in statistics','Choice'),
368
('OPACReportProblem', 1, NULL, "A feature for users to submit problem reports for OPAC pages.",'YesNo'),
368
('OpacResetPassword','0','','Shows the ''Forgot your password?'' link in the OPAC','YesNo'),
369
('OpacResetPassword','0','','Shows the ''Forgot your password?'' link in the OPAC','YesNo'),
369
('OPACResultsLibrary', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice'),
370
('OPACResultsLibrary', 'homebranch', 'homebranch|holdingbranch', 'Defines whether the OPAC displays the holding or home branch in search results when using XSLT', 'Choice'),
370
('OPACResultsSidebar','','70|10','Define HTML to be included on the search results page, underneath the facets sidebar','Textarea'),
371
('OPACResultsSidebar','','70|10','Define HTML to be included on the search results page, underneath the facets sidebar','Textarea'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+6 lines)
Lines 345-350 OPAC: Link Here
345
                  footer: "only footer"
345
                  footer: "only footer"
346
    Features:
346
    Features:
347
        -
347
        -
348
            - pref: OPACReportProblem
349
              choices:
350
                  yes: Allow
351
                  no: "Don't allow"
352
            - patrons to submit problem reports for OPAC pages.
353
        -
348
            - pref: opacuserlogin
354
            - pref: opacuserlogin
349
              choices:
355
              choices:
350
                  yes: Allow
356
                  yes: Allow
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc (-3 / +5 lines)
Lines 16-24 Link Here
16
        <div class="container-fluid">
16
        <div class="container-fluid">
17
            <div class="row-fluid">
17
            <div class="row-fluid">
18
                <div class="span12">
18
                <div class="span12">
19
                    <div id="report_a_problem" class="noprint" style="float:left;">
19
                    [% IF ( Koha.Preference('OPACReportProblem') ) %]
20
                        <a class="koha_url" href="/cgi-bin/koha/opac-reportproblem.pl">Report a problem</a>
20
                        <div id="report_a_problem" class="noprint" style="float:left;">
21
                    </div>
21
                            <a class="koha_url" href="/cgi-bin/koha/opac-reportproblem.pl">Report a problem</a>
22
                        </div>
23
                    [% END %]
22
                    <div id="koha_url" class="clearfix noprint">
24
                    <div id="koha_url" class="clearfix noprint">
23
                        <p>Powered by
25
                        <p>Powered by
24
                        [% IF template.name.match('opac-main.tt') %]
26
                        [% IF template.name.match('opac-main.tt') %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt (-64 / +68 lines)
Lines 26-117 Link Here
26
                    <div class="span12">
26
                    <div class="span12">
27
                [% END %]
27
                [% END %]
28
                    <h1>Report a problem</h1>
28
                    <h1>Report a problem</h1>
29
                    [% IF ( successfuladd ) %]
29
                    [% IF ( Koha.Preference('OPACReportProblem') ) %]
30
                        <div class="alert alert-info">Your problem report has been sent to the [% IF ( recipient == 'admin' ) %]Koha Administrator[% ELSE %] [% recipient %][% END %].</div>
30
                        [% UNLESS ( loggedinusername ) %]
31
                    [% END %]
31
                            <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>
32
                    [% IF ( nolibemail ) %]
32
                        [% END %]
33
                        <div class="alert">Your library has not provided an email address.</div>
33
                        [% IF ( successfuladd ) %]
34
                    [% END %]
34
                            <div class="alert alert-info">Your problem report has been sent to the [% IF ( recipient == 'admin' ) %]Koha Administrator[% ELSE %] [% recipient %][% END %].</div>
35
                    [% IF ( noadminemail ) %]
35
                        [% END %]
36
                        <div class="alert">The Koha Administrator has not provided an email address.</div>
36
                        [% IF ( failedadd_admin ) %]
37
                    [% END %]
37
                            <div class="alert">Failed to send a problem report because the Koha Administrator has not provided an email address.</div>
38
                    [% IF ( nolibemail && noadminemail ) %]
38
                        [% ELSIF ( failedadd_lib ) %]
39
                        <div class="alert">Unable to send problem reports.</div>
39
                            <div class="alert">Failed to send a problem report because the library has not provided an email address.</div>
40
                    [% END %]
40
                        [% END %]
41
                    <div id="reportproblem" class="maincontent toptabs">
41
                        <div id="reportproblem" class="maincontent">
42
                        <ul>
43
                            <li><a href="#reportlib">Report to librarian</a></li>
44
                            <li><a href="#reportadmin">Report to Koha Administrator</a></li>
45
                        </ul>
46
                        <div id="reportlib">
47
                            <form name="reportlibform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
42
                            <form name="reportlibform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
48
                                <input type="hidden" name="op" value="addreport">
43
                                <input type="hidden" name="op" value="addreport">
49
                                <input type="hidden" name="recipient" value="library">
50
                                <fieldset class="rows">
44
                                <fieldset class="rows">
51
                                    <ol>
45
                                    <ol>
52
                                        <li>
46
                                        <li>
53
                                            <label for="place">Problem found on page: </label>
47
                                            <label for="recipient">Send problem report to: </label>
54
                                            <input type="hidden" name="place" id="libplace" value="[% probpage %]" class="span6">
48
                                            <select name="recipient" id="recipient">
55
                                            [% probpage | html %]
49
                                                <option value="library">A librarian</option>
56
                                        </li>
50
                                                <option value="admin">Koha Administrator</option>
57
                                        <li>
51
                                            </select>
58
                                            <label for="user">Username: </label>
59
                                            <input type="hidden" name="user" id="libuser" value="[% username %]" class="span3">
60
                                            [% username | html %]
61
                                        <li>
62
                                            <label for="subject">Subject: </label>
63
                                            <input type="text" name="subject" id="libsubject" value="[% subject %]" class="span3">
64
                                        </li>
52
                                        </li>
65
                                        <li>
53
                                        <li>
66
                                            <label for="message">Message: </label>
67
                                            <textarea name="message" id="libmessage" rows="7" cols="60"></textarea>
68
                                        </li>
69
                                    </ol>
70
                                </fieldset>
71
                                <fieldset class="action">
72
                                    [% IF ( nolibemail ) %]
73
                                        <input type="submit" value="Submit" class="btn" disabled="disabled">
74
                                    [% ELSE %]
75
                                        <input type="submit" value="Submit" class="btn">
76
                                    [% END %]
77
                                </fieldset>
78
                            </form>
79
                        </div>
80
                        <div id="reportadmin">
81
                             <form name="reportadminform" action="/cgi-bin/koha/opac-reportproblem.pl" method="post">
82
                                <input type="hidden" name="op" value="addreport">
83
                                <input type="hidden" name="recipient" value="admin">
84
                                <fieldset class="rows">
85
                                    <ol>
86
                                        <li>
87
                                            <label for="place">Problem found on page: </label>
54
                                            <label for="place">Problem found on page: </label>
88
                                            <input type="hidden" name="place" id="adminplace" value="[% probpage %]">
55
                                            <input type="hidden" name="place" id="place" value="[% probpage %]" class="span6">
89
                                            [% probpage | html %]
56
                                            [% probpage | html %]
90
                                        </li>
57
                                        </li>
91
                                        <li>
58
                                        <li>
92
                                            <label for="user">Username: </label>
59
                                            <label for="user">Username: </label>
93
                                            <input type="hidden" name="user" id="adminuser" value="[% username %]" class="span3">
60
                                            <input type="hidden" name="user" id="user" value="[% username %]" class="span3">
94
                                            [% username | html %]
61
                                            [% username | html %]
62
                                        </li>
95
                                        <li>
63
                                        <li>
96
                                            <label for="subject">Subject: </label>
64
                                            <label for="subject">Subject: </label>
97
                                            <input type="text" name="subject" id="adminsubject" value="[% subject %]" class="span3">
65
                                            <input type="text" name="subject" id="subject" value="[% subject %]" class="span3">
98
                                        </li>
66
                                        </li>
99
                                        <li>
67
                                        <li>
100
                                            <label for="message">Message: </label>
68
                                            <label for="message">Message: </label>
101
                                            <textarea name="message" id="adminmessage" rows="7" cols="60"></textarea>
69
                                            <textarea name="message" id="message" rows="7" cols="60"></textarea>
102
                                        </li>
70
                                        </li>
103
                                    </ol>
71
                                    </ol>
104
                                </fieldset>
72
                                </fieldset>
105
                                <fieldset class="action">
73
                                <fieldset class="action">
106
                                    [% IF ( noadminemail ) %]
74
                                    [% IF ( loggedinusername ) %]
107
                                        <input type="submit" value="Submit" class="btn" disabled="disabled">
75
                                        <input type="submit" value="Submit" class="btn" id="submit">
76
                                        [% IF ( nolibemail ) %]<span id="nolibemail">Your library has not provided an email address.</span>[% END %]
77
                                        [% IF ( noadminemail ) %]<span id="noadminemail">The Koha Administrator has not provided an email address.</span>[% END %]
108
                                    [% ELSE %]
78
                                    [% ELSE %]
109
                                        <input type="submit" value="Submit" class="btn">
79
                                        <input type="submit" value="Submit" class="btn" id="submit" disabled="disabled">
110
                                    [% END %]
80
                                    [% END %]
111
                                </fieldset>
81
                                </fieldset>
112
                            </form>
82
                            </form>
113
                        </div>
83
                        </div>
114
                    </div>
84
                    [% ELSE %]
85
                        <div class="alert">Your library has not activated this feature.</div>
86
                    [% END %]
115
                </div> <!-- / .span10/12 -->
87
                </div> <!-- / .span10/12 -->
116
            </div> <!-- / .row-fluid -->
88
            </div> <!-- / .row-fluid -->
117
        </div> <!-- / .container-fluid -->
89
        </div> <!-- / .container-fluid -->
Lines 119-129 Link Here
119
91
120
[% INCLUDE 'opac-bottom.inc' %]
92
[% INCLUDE 'opac-bottom.inc' %]
121
[% BLOCK jsinclude %]
93
[% BLOCK jsinclude %]
94
<script type="text/javascript">
95
    $(document).ready(function(){
96
        [% IF loggedinusername %]
97
            var nolibemail = 0;
98
            var noadminemail = 0;
99
100
            [% IF nolibemail %]
101
                nolibemail = [% nolibemail %];
102
            [% END %]
103
104
            [% IF noadminemail %]
105
                noadminemail = [% noadminemail %]
106
            [% END %]
107
108
            $(".submitbtn").prop("disabled", false);
109
            checkEmails();
122
110
123
    <script type="text/javascript">
111
            $("#recipient").change(function(){
124
        $(document).ready(function(){
112
                checkEmails();
125
            $("#reportproblem").tabs();
113
            });
126
        });
127
    </script>
128
114
115
            function checkEmails(){
116
                if ( $("#recipient").val() == 'library' && nolibemail == 1 ){
117
                    $("#submit").prop("disabled", true);
118
                    $("#nolibemail").show();
119
                    $("#noadminemail").hide();
120
                } else if ( $("#recipient").val() == 'admin' && noadminemail == 1 ){
121
                    $("#submit").prop("disabled", true);
122
                    $("#nolibemail").hide();
123
                    $("#noadminemail").show();
124
                } else {
125
                    $("#submit").prop("disabled", false);
126
                    $("#nolibemail").hide();
127
                    $("#noadminemail").hide();
128
                }
129
            }
130
        [% END %]
131
    });
132
</script>
129
[% END %]
133
[% END %]
(-)a/opac/opac-reportproblem.pl (-51 / +66 lines)
Lines 27-32 use C4::Letters; Link Here
27
use Koha::ProblemReport;
27
use Koha::ProblemReport;
28
use Koha::DateUtils;
28
use Koha::DateUtils;
29
use Koha::Libraries;
29
use Koha::Libraries;
30
use Koha::Patrons;
30
31
31
my $input = new CGI;
32
my $input = new CGI;
32
33
Lines 35-100 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
35
        template_name   => "opac-reportproblem.tt",
36
        template_name   => "opac-reportproblem.tt",
36
        type            => "opac",
37
        type            => "opac",
37
        query           => $input,
38
        query           => $input,
38
        authnotrequired => 0,
39
        authnotrequired => 1,
39
    }
40
    }
40
);
41
);
41
42
42
my $problempage = $ENV{HTTP_REFERER};
43
if ( $borrowernumber ) { # if user is logged in
43
my $member = GetMember( borrowernumber => $borrowernumber );
44
my $username = $member->{'userid'};
45
my $branchcode = $member->{'branchcode'};
46
my $library = Koha::Libraries->find($branchcode);
47
if ( $library->branchemail eq undef || ! $library->branchemail ) {
48
    $template->param( nolibemail => 1 );
49
}
50
my $koha_admin = C4::Context->preference('KohaAdminEmailAddress');
51
if ( ! $koha_admin ) {
52
    $template->param( noadminemail => 1 );
53
}
54
my $recipient = $input->param('recipient') || 'library';
55
$template->param(
56
    username => $username,
57
    probpage => $problempage,
58
);
59
44
60
my $op = $input->param('op') || '';
45
    my $problempage = $ENV{HTTP_REFERER};
61
if ( $op eq 'addreport' ) {
46
    my $member = Koha::Patrons->find( $borrowernumber );
62
    my $subject = $input->param('subject');
47
    my $username = $member->userid;
63
    my $message = $input->param('message');
48
    my $branchcode = $member->branchcode;
64
    my $place = $input->param('place');
49
    my $library = Koha::Libraries->find($branchcode);
65
    my $problem = Koha::ProblemReport->new({ title => $subject, content => $message, borrowernumber => $borrowernumber, branchcode => $branchcode, username => $username, problempage => $place, recipient => $recipient, reportdate => dt_from_string() })->store;
50
    if ( ( !defined $library->branchreplyto ) && ( !defined C4::Context->preference('ReplytoDefault') ) && ( !defined $library->branchemail ) ) {
51
        $template->param( nolibemail => 1 );
52
    }
53
    my $koha_admin = C4::Context->preference('KohaAdminEmailAddress');
54
    if ( !$koha_admin ) {
55
        $template->param( noadminemail => 1 );
56
    }
57
    my $recipient = $input->param('recipient') || 'library';
66
    $template->param(
58
    $template->param(
67
        recipient => $recipient,
59
        username => $username,
68
        successfuladd => 1,
60
        probpage => $problempage,
69
        probpage => $place,
70
    );
61
    );
71
62
72
    my $problemreport = $problem->unblessed;
63
    my $op = $input->param('op') || '';
73
    $problemreport->{code} = 'PROBLEM_REPORT';
64
    if ( $op eq 'addreport' ) {
74
    $problemreport->{content} .= "\nUsername: $username";
65
        # 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
75
    $problemreport->{content} .= "\nProblem page: $place";
66
        if ( $recipient eq 'admin' && !$koha_admin ) {
76
    my $transport = 'email';
67
            $template->param( failedadd_admin => 1 );
68
        } elsif ( ( !defined $library->branchreplyto ) && ( !defined C4::Context->preference('ReplytoDefault') ) && ( !defined $library->branchemail ) ) {
69
            $template->param( failedadd_lib => 1 );
70
        } else {
71
72
            my $subject = $input->param('subject');
73
            my $message = $input->param('message');
74
            my $place = $input->param('place');
75
            my $problem = Koha::ProblemReport->new({ title => $subject, content => $message, borrowernumber => $borrowernumber, branchcode => $branchcode, username => $username, problempage => $place, recipient => $recipient, reportdate => dt_from_string() })->store;
76
            $template->param(
77
                recipient => $recipient,
78
                successfuladd => 1,
79
                probpage => $place,
80
            );
77
81
78
    my $from_address = $member->{email} || $member->{emailpro} || $member->{B_email} || $koha_admin;
82
            my $problemreport = $problem->unblessed;
83
            $problemreport->{code} = 'PROBLEM_REPORT';
84
            $problemreport->{content} .= "\nUsername: $username";
85
            $problemreport->{content} .= "\nProblem page: $place";
86
            my $transport = 'email';
79
87
80
    if ( $recipient eq 'admin' ) {
88
            my $from_address = $member->email || $member->emailpro || $member->B_email || $koha_admin;
81
        C4::Letters::EnqueueLetter({
89
82
            letter                 => $problemreport,
90
            if ( $recipient eq 'admin' ) {
83
            borrowernumber         => $borrowernumber,
91
                C4::Letters::EnqueueLetter({
84
            message_transport_type => $transport,
92
                    letter                 => $problemreport,
85
            to_address             => $koha_admin,
93
                    borrowernumber         => $borrowernumber,
86
            from_address           => $from_address,
94
                    message_transport_type => $transport,
87
        });
95
                    to_address             => $koha_admin,
88
    } else {
96
                    from_address           => $from_address,
89
        my $to_address = $library->branchemail;
97
                });
90
        C4::Letters::EnqueueLetter({
98
            } else {
91
            letter                 => $problemreport,
99
                my $to_address = $library->branchreplyto || C4::Context->preference('ReplytoDefault') || $library->branchemail;
92
            borrowernumber         => $borrowernumber,
100
                C4::Letters::EnqueueLetter({
93
            message_transport_type => $transport,
101
                    letter                 => $problemreport,
94
            to_address             => $to_address,
102
                    borrowernumber         => $borrowernumber,
95
            from_address           => $from_address,
103
                    message_transport_type => $transport,
96
        });
104
                    to_address             => $to_address,
105
                    from_address           => $from_address,
106
                });
107
            }
108
        }
97
    }
109
    }
110
111
} else { # if no user logged in
112
    my $problempage = $ENV{HTTP_REFERER};
113
    $template->param( probpage => $problempage );
98
}
114
}
99
115
100
output_html_with_http_headers $input, $cookie, $template->output;
116
output_html_with_http_headers $input, $cookie, $template->output;
101
- 

Return to bug 4461