Bug 4461

Summary: Add a context-sensitive report a problem process
Product: Koha Reporter: Jared Camins <camins>
Component: OPACAssignee: Aleisha Amohia <aleisha>
Status: CLOSED FIXED QA Contact: Jonathan Druart <jonathan.druart>
Severity: new feature    
Priority: P5 - low CC: 1joynelson, aleisha, andrewfh, barton, david, dcook, eric.gosselin.5, jonathan.druart, josef.moravec, katrin.fischer, lars, martin.renvoize, nick, oleonard, sally.healey, tomascohen, veron
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=26127
Change sponsored?: Sponsored Patch complexity: Medium patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This new feature, when enabled, lets patrons report problems using the OPAC. It adds a link to each page of the OPAC to a form so that patrons can report problems. Problems are then available via a new problem report management area in the staff interface. **New system preference**: `OPACReportProblem` defaults to disabled.
Version(s) released in:
20.05.00
Bug Depends on: 10269, 22823    
Bug Blocks: 25213, 25214, 27052, 34324, 25215, 25466, 25582, 25626, 25627, 26127    
Attachments: Bug 4461: Add a context-sensitive 'Report a Problem' feature to OPAC
Bug 4461: Add a context-sensitive 'Report a Problem' feature to OPAC
Bug 4461: Add a context-sensitive 'Report a Problem' feature to OPAC
Bug 4461: [FOLLOW-UP] Problem Report feature
Bug 4461: [FOLLOW-UP] Problem Report feature
[SIGNED-OFF] Bug 4461: Add a context-sensitive 'Report a Problem' feature to OPAC
[SIGNED-OFF] Bug 4461: [FOLLOW-UP] Problem Report feature
Bug 4461: Database and syspref changes
Bug 4461: Problem Report Koha objects
Bug 4461: Submit a problem report
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled
Bug 4461: (follow-up) Creating sample notice and other fixes
Bug 4461: Database and syspref changes
Bug 4461: Problem Report Koha objects
Bug 4461: Submit a problem report
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled
Bug 4461: (follow-up) Creating sample notice and other fixes
Bug 4461: Rename report date with created_on
Bug 4461: Use KohaAdminEmailAddress pref as 'from'
Bug 4461: Use our local_referer instead of HTTP_REFERER
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined
Bug 4461: Simplify recipients code
Bug 4461: Better error handling
Bug 4461: Database and syspref changes
Bug 4461: Problem Report Koha objects
Bug 4461: Submit a problem report
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled
Bug 4461: (follow-up) Creating sample notice and other fixes
Bug 4461: Rename report date with created_on
Bug 4461: Use KohaAdminEmailAddress pref as 'from'
Bug 4461: Use our local_referer instead of HTTP_REFERER
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined
Bug 4461: Simplify recipients code
Bug 4461: Better error handling
Bug 4461: Remove hard requirement on OpacKohaUrl
Bug 4461: Drop 'from_address' use 'reply_address'
Bug 4461: Use get_effective_email from bug 22823
Bug 4461: (follow-up) Creating sample notice and other fixes
Bug 4461: Rename report date with created_on
Bug 4461: Use KohaAdminEmailAddress pref as 'from'
Bug 4461: Use our local_referer instead of HTTP_REFERER
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined
Bug 4461: Simplify recipients code
Bug 4461: Better error handling
Bug 4461: Remove hard requirement on OpacKohaUrl
Bug 4461: Drop 'from_address' use 'reply_address'
Bug 4461: Use get_effective_email from bug 22823
Bug 4461: Adding user flags for managing OPAC problem reports
Bug 4461: Add problem reports link to mainpage and admin home
Bug 4461: Manage problem reports on the staff client
Bug 4461: Database and syspref changes
Bug 4461: Problem Report Koha objects
Bug 4461: Submit a problem report
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled
Bug 4461: (follow-up) Creating sample notice and other fixes
Bug 4461: Rename report date with created_on
Bug 4461: Use KohaAdminEmailAddress pref as 'from'
Bug 4461: Use our local_referer instead of HTTP_REFERER
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined
Bug 4461: Simplify recipients code
Bug 4461: Better error handling
Bug 4461: Remove hard requirement on OpacKohaUrl
Bug 4461: Drop 'from_address' use 'reply_address'
Bug 4461: Use get_effective_email from bug 22823
Bug 4461: Adding user flags for managing OPAC problem reports
Bug 4461: Add problem reports link to mainpage and admin home
Bug 4461: Manage problem reports on the staff client
Bug 4461: (follow-up) Add missing relationship accessor
Bug 4461: DBIC Schema Files
Bug 4461: Update license statements
Bug 4461: Fix status and borrowernumber fields in problem_reports and more
Bug 4461: Checks on library email before enqueuing letter
Bug 4461: Database and syspref changes
Bug 4461: Problem Report Koha objects
Bug 4461: Submit a problem report
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled
Bug 4461: (follow-up) Creating sample notice and other fixes
Bug 4461: Rename report date with created_on
Bug 4461: Use KohaAdminEmailAddress pref as 'from'
Bug 4461: Use our local_referer instead of HTTP_REFERER
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined
Bug 4461: Simplify recipients code
Bug 4461: Better error handling
Bug 4461: Remove hard requirement on OpacKohaUrl
Bug 4461: Drop 'from_address' use 'reply_address'
Bug 4461: Use get_effective_email from bug 22823
Bug 4461: Adding user flags for managing OPAC problem reports
Bug 4461: Add problem reports link to mainpage and admin home
Bug 4461: Manage problem reports on the staff client
Bug 4461: (follow-up) Add missing relationship accessor
Bug 4461: Update license statements
Bug 4461: Checks on library email before enqueuing letter
Bug 4461: DBIC Schema Files
Bug 4461: Fix status and borrowernumber fields in problem_reports and more
Bug 4461: Error log when using MySQL 5.5
Bug 4461: get_effective_email has been renamed inbound_email_address
Bug 4461: Fix OPAC link from staff
Bug 4461: Database and syspref changes
Bug 4461: Problem Report Koha objects
Bug 4461: Submit a problem report
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled
Bug 4461: (follow-up) Creating sample notice and other fixes
Bug 4461: Rename report date with created_on
Bug 4461: Use KohaAdminEmailAddress pref as 'from'
Bug 4461: Use our local_referer instead of HTTP_REFERER
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined
Bug 4461: Simplify recipients code
Bug 4461: Better error handling
Bug 4461: Remove hard requirement on OpacKohaUrl
Bug 4461: Drop 'from_address' use 'reply_address'
Bug 4461: Use get_effective_email from bug 22823
Bug 4461: Adding user flags for managing OPAC problem reports
Bug 4461: Add problem reports link to mainpage and admin home
Bug 4461: Manage problem reports on the staff client
Bug 4461: (follow-up) Add missing relationship accessor
Bug 4461: Update license statements
Bug 4461: Checks on library email before enqueuing letter
Bug 4461: DBIC Schema Files
Bug 4461: Fix status and borrowernumber fields in problem_reports and more
Bug 4461: get_effective_email has been renamed inbound_email_address
Bug 4461: Fix OPAC link from staff
Bug 4461: Database and syspref changes
Bug 4461: Problem Report Koha objects
Bug 4461: Submit a problem report
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled
Bug 4461: (follow-up) Creating sample notice and other fixes
Bug 4461: Rename report date with created_on
Bug 4461: Use KohaAdminEmailAddress pref as 'from'
Bug 4461: Use our local_referer instead of HTTP_REFERER
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined
Bug 4461: Simplify recipients code
Bug 4461: Better error handling
Bug 4461: Remove hard requirement on OpacKohaUrl
Bug 4461: Drop 'from_address' use 'reply_address'
Bug 4461: Use get_effective_email from bug 22823
Bug 4461: Adding user flags for managing OPAC problem reports
Bug 4461: Add problem reports link to mainpage and admin home
Bug 4461: Manage problem reports on the staff client
Bug 4461: (follow-up) Add missing relationship accessor
Bug 4461: Update license statements
Bug 4461: Checks on library email before enqueuing letter
Bug 4461: DBIC Schema Files
Bug 4461: Fix status and borrowernumber fields in problem_reports and more
Bug 4461: get_effective_email has been renamed inbound_email_address
Bug 4461: Fix OPAC link from staff
Bug 4461: Hide link if KohaAdminEmailAddress is not set
Bug 4461: dbic schema update
Bug 4461: Extend problem_reports.problempage to TEXT
Bug 4461: Correctly deal with encoding/escaping chars
Bug 4461: Use inbound_email_address to know if we display the dropdown list

Description Chris Cormack 2010-05-21 01:27:28 UTC


---- Reported by camins@numismatics.org 2010-05-06 14:44:22 ----

It would be very helpful to optionally have a context-sensitive "report a problem" link on every page. The page that opens should have an input box for the user to compose a message to KohaAdminEmailAddress. The resulting e-mail should include not just the user's message but also the exact page s/he is on, and the currently-logged in username.

I have seen features like this in a number of libraries' catalogs, but I can't seem to remember which at the moment.



---- Additional Comments From irma@calyx.net.au 2010-05-06 23:33:32 ----

In fact to have 2 options to "report a problem' would be good.
1) Linking to KohaAdminEmailAddress 
2) Linking to a librarian as some reports might be more re "how to use this page".




--- Bug imported by chris@bigballofwax.co.nz 2010-05-21 01:27 UTC  ---

This bug was previously known as _bug_ 4461 at http://bugs.koha.org/cgi-bin/bugzilla3/show_bug.cgi?id=4461

Actual time not defined. Setting to 0.0
Setting qa contact to the default for this product.
   This bug either had no qa contact or an invalid one.
CC member irma@calyx.net.au does not have an account here

Comment 1 Owen Leonard 2010-08-27 19:36:16 UTC
*** Bug 4881 has been marked as a duplicate of this bug. ***
Comment 2 Aleisha Amohia 2017-01-12 23:03:43 UTC Comment hidden (obsolete)
Comment 3 Owen Leonard 2017-01-13 13:18:31 UTC
I think this looks good, but there are some issues that need to be looked at:

I think that if there is no email address for the logged-in user's library the page should not offer to email the librarian. In my test if I submit a report to the librarian and there is no email address for my home library, the entry saved in message_queue has an empty 'to_address' field.

There are HTML validation errors triggered by duplicate id attributes on form fields. The form fields on the two different tabs should not have the same ids (note that input name and id attributes do not have to match);

Also, in the OPAC (and soon to be the case in the staff client), page-specific JavaScript goes into a special BLOCK which is processed in the footer include. So instead of this, at the end of opac-reportaproblem.tt:

[% BLOCK jsinclude %][% END %]

<script type="text/javascript">
    $(document).ready(function(){
        $("#reportproblem").tabs();
    });
</script>

It should be:

[% BLOCK jsinclude %]
    <script type="text/javascript">
        $(document).ready(function(){
            $("#reportproblem").tabs();
        });
    </script>
[% END %]
Comment 4 Aleisha Amohia 2017-01-16 21:57:11 UTC Comment hidden (obsolete)
Comment 5 Eric 2017-03-21 15:31:15 UTC
Patch doesn't apply :

Some problems occurred applying patches from bug 4461:
<h1>Something went wrong !</h1>Applying: Bug 4461: Add a context-sensitive 'Report a Problem' feature to OPAC
Using index info to reconstruct a base tree...
M       Koha/Schema/Result/Borrower.pm
M       installer/data/mysql/kohastructure.sql
M       koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc
Falling back to patching base and 3-way merge...
Auto-merging koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-bottom.inc
Auto-merging installer/data/mysql/kohastructure.sql
Auto-merging Koha/Schema/Result/Borrower.pm
CONFLICT (content): Merge conflict in Koha/Schema/Result/Borrower.pm
Patch failed at 0001 Bug 4461: Add a context-sensitive 'Report a Problem' feature to OPAC
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem run git bz apply --continue.
If you would prefer to skip this patch, instead run git bz apply --skip.
To restore the original branch and stop patching run git bz apply --abort.
error: Failed to merge in the changes.
Bug 4461 - Context-sensitive report a problem screen

59032 - Bug 4461: Add a context-sensitive 'Report a Problem' feature to OPAC
Comment 6 Aleisha Amohia 2017-03-28 04:00:03 UTC Comment hidden (obsolete)
Comment 7 Katrin Fischer 2017-05-01 15:34:04 UTC
Hi Aleisha,

this doesn't apply. It is recommended to have the changes to the Schema in a separate patch, because it's likely to conflict a lot. This way one can opt to not apply the patch and run the schema update locally when testing or pushing and you don't have to rebase as often.
https://wiki.koha-community.org/wiki/Database_updates#Changes_with_DBIx::Class
Comment 8 Katrin Fischer 2017-05-01 15:34:59 UTC
Ok... partially talking nonsense. It DOES currently apply!
Comment 9 Katrin Fischer 2017-05-01 15:54:55 UTC
Really like the feature! Maybe we should add something like this to staff too?

Possible problems:
- Instead of tabs have a simple pull down to switch the recipient. At the moment, if you have typed up your message and then change your mind about whom to send it to, you have to start over as the text won't carry over from one tab to the other.
- When submitting a problem report to the aministrator and there is no branch email supplied, the 'success' message and the 'error' message will both show at the same time after submitting. This might be confusing to the patron. Maybe we could avoid that by showing the 'error' next to the submit button or if we didn't have the tabs, not show the option to email the library at all, when there is no email address set for the branch?
- There are some constraints with email sending if you are hosted and using the provider's mail server. So a while ago we have added branchreplyto (branches) and ReplyToDefault (system preference). It would be cool if you could check those first and email there if they are set and then fall back to branchemal and KohaAdminEmailAddress (like it's done for overdues etc.)
- If you are not logged in when clicking on 'report a bug' the problem will be reported against the opac-reportproblem page.

Questions:
- I know that the feature can be hidden using the id (thx!), but maybe this should also be a preference? 
- How will the table in the database be maintained? Is there a way to empty it or plans to make it accessible from the GUI?
Comment 10 Aleisha Amohia 2017-08-11 05:15:32 UTC Comment hidden (obsolete)
Comment 11 Aleisha Amohia 2017-08-20 22:16:47 UTC Comment hidden (obsolete)
Comment 12 Aleisha Amohia 2017-08-20 22:17:07 UTC
Forgot to change status - this is ready to test
Comment 13 Josef Moravec 2017-08-22 11:50:38 UTC
Created attachment 66323 [details] [review]
[SIGNED-OFF] Bug 4461: Add a context-sensitive 'Report a Problem' feature to OPAC

This patch adds a 'Report a problem' link to the bottom of every page in
the OPAC. The user can choose to submit their report to the library or
Koha administrator. The report will store the user's problem message,
but also their username and the page they were on when they clicked the
'report a problem' link. The patch adds a table 'problem_reports' to the
db.

Update: This patch adds a check for the KohaAdminEmailAddress and
library branch email before sending the report.
Update: Fix merge conflicts

To test:
1) Apply patch, update database, rebuild schema
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 your syspref KohaAdminEmailAddress is NOT filled.
6) Log into OPAC
7) Click the 'Report a problem' link at the bottom of whatever page
you're on
8) Notice that there are error messages alerting that library does not
have an email address and that the Koha Administrator does not have
email address. Both submit buttons will be disabled.
9) Add an email address for your library. You may have to restart
memcached again. The error message for the library email address will
have disappeared and the Submit button for 'Report to library' will now
work.
10) Add an email address for the syspref KohaAdminEmailAddress. You may
have to restart memcached again. The error message for the administrator
email address will have disappeared and the Submit button for 'Report to
Koha Administrator' will not work.
11) First try submitting a problem to the library. Confirm that the
fields for 'Problem found on page' and 'Username' are correct, then fill
out the 'Subject' and 'Message' and click Submit.
12) Confirm a message shows at the top of the page to show success.
13) Go into mysql and display records from the message_queue table.
Confirm that the borrowernumber and subject are correct. Confirm that
content shows the message from the problem report, but also the user's
username and the problem page. Confirm that the to_address shows the
library's email address and the from_address shows the user's email
address.
14) Now try submitting a problem to the Koha Admin. Fill fields and
click Submit. Confirm message shows at top to show success again.
15) Check message_queue for new problem report. Confirm that the
to_address shows the email address from the syspref
KohaAdminEmailAddress.

Sponsored-by: Catalyst IT

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 14 Josef Moravec 2017-08-22 11:50:41 UTC
Created attachment 66324 [details] [review]
[SIGNED-OFF] 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 :)

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Comment 15 Josef Moravec 2017-08-22 11:52:13 UTC
(In reply to Aleisha Amohia from comment #11)

> 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 :)

Great idea, I am really looking forward to ;)
Comment 16 Barton Chittenden 2017-09-01 15:54:59 UTC
This is a *bit* off topic, but I've been working on a plugin that fills a similar niche on the staff side: https://github.com/bywatersolutions/koha-plugin-support
Comment 17 Nick Clemens 2017-10-26 11:48:08 UTC
Hi Aleisha,

1 - Need tests for new Objects

2 - With 'DefaultReplyTo' unset it is still 'defined' so I get the library email option even when none are set.

3 - If not logged in I still see the report form, I think I should just get the warning to log in.

3 - Similarly, if both emails are undefined maybe I shouldn't get the form at all since I can't submit?

4 - Rather than a JS function to disable the submit button can we just disable the input on the dropdown and add a tooltip? Or only provide a dropdown if there is a choice possible? The warning about missing emails seems more appropriate for the about page than the users.

5 - The new preference is defaulting to 'Allow' it should default to 'Don't Allow'
Comment 18 Aleisha Amohia 2020-02-11 03:50:07 UTC
Created attachment 98687 [details] [review]
Bug 4461: Database and syspref changes

adding problem_reports table and OPACReportProblem syspref
Comment 19 Aleisha Amohia 2020-02-11 03:50:21 UTC
Created attachment 98688 [details] [review]
Bug 4461: Problem Report Koha objects
Comment 20 Aleisha Amohia 2020-02-11 03:50:29 UTC
Created attachment 98689 [details] [review]
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
Comment 21 Owen Leonard 2020-02-11 14:38:05 UTC
This looks like it's working well. I have only one issue: Based on how we handle it with other features/pages which can be deactivated I think this page should return a 404 error if it's not active.
Comment 22 Aleisha Amohia 2020-02-11 19:49:20 UTC
Created attachment 98725 [details] [review]
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled
Comment 23 Andrew Fuerste-Henry 2020-02-14 17:54:19 UTC
The sandbox got mad about letting me sign off, but I followed the test plan successfully. Signing off!
Comment 24 Katrin Fischer 2020-02-18 22:54:25 UTC
Hi Aleisha, 

starting with review and QA tools here:

1) Can you check if this is a real one or a false positive? 
 FAIL	Koha/ProblemReport.pm
   FAIL	  pod coverage
		POD coverage was greater before, try perl -MPod::Coverage=PackageName -e666


2) Please fix filters:

 FAIL	koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt
   FAIL	  filters
		missing_filter at line 3 (<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Report a Problem</title>)
		missing_filter at line 31 (                        <div class="alert alert-info">Your problem report has been sent to the [% IF ( recipient == 'admin' ) %]Koha Administrator[% ELSE %][% recipient %][% END %].</div>)
		missing_filter at line 56 (                                            <input type="hidden" name="place" id="place" value="[% probpage %]">)
		missing_filter at line 61 (                                            <input type="hidden" name="user" id="user" value="[% username %]" class="span3">)
		missing_filter at line 65 (                                            <input type="text" name="subject" id="subject" value="[% subject %]" class="span3">)


3) Database update

You got:
+    $dbh->do(q{ DROP TABLE IF EXISTS `problem_reports` });

I think this could be destructive in some cases. I think checking for existence of the table is better:

20126     if ( !TableExists('return_claims') ) {


4) Capitalization

catalog &rsaquo; Report a Problem</title>
Koha Administrator

5)   print $input->redirect("/cgi-bin/koha/opac-reportproblem?norecipients=1.pl");

Looks like a typo with the .pl at the end?

6) Translatatability

I these go in the email to the library/admin, but won't be translatable: 

+    $problemreport->{code} = 'PROBLEM_REPORT';
+    $problemreport->{content} .= "\nUsername: $username";
+    $problemreport->{content} .= "\nProblem page: $place";

Using a notice template would be the most elegant way to make those translatable. I think with https://bugs.koha-community.org/bugzilla3/showdependencytree.cgi?id=15395&hide_resolved=1 you can not yet add strings to .pl fils in a translatable way.


If I understand correctly the only way to access the reports for now would be a report? It might be nice (new bug!) to have this on the dashoard and visible in staff or even the patron account :)
Comment 25 Aleisha Amohia 2020-02-18 22:59:28 UTC
Thanks Katrin I'll work on fixing those. The staff side follow-up was already in my plan:

(In reply to Aleisha Amohia from comment #11)

> 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 :)
Comment 26 Aleisha Amohia 2020-02-25 04:12:26 UTC
Created attachment 99551 [details] [review]
Bug 4461: (follow-up) Creating sample notice and other fixes

- filters
- capitalisation
- atomic update
Comment 27 Aleisha Amohia 2020-02-25 04:13:15 UTC
(In reply to Katrin Fischer from comment #24)
> Hi Aleisha, 
> 
> starting with review and QA tools here:
> 
> 1) Can you check if this is a real one or a false positive? 
>  FAIL	Koha/ProblemReport.pm
>    FAIL	  pod coverage
> 		POD coverage was greater before, try perl -MPod::Coverage=PackageName -e666
> 

i dont really know how i could expand on the documentation i've already done!
Comment 28 Katrin Fischer 2020-02-25 07:06:37 UTC
(In reply to Aleisha Amohia from comment #27)
> (In reply to Katrin Fischer from comment #24)
> > Hi Aleisha, 
> > 
> > starting with review and QA tools here:
> > 
> > 1) Can you check if this is a real one or a false positive? 
> >  FAIL	Koha/ProblemReport.pm
> >    FAIL	  pod coverage
> > 		POD coverage was greater before, try perl -MPod::Coverage=PackageName -e666
> > 
> 
> i dont really know how i could expand on the documentation i've already done!

That's ok, we get those as false positives sometimes.
Comment 29 David Nind 2020-02-25 17:58:08 UTC
Created attachment 99599 [details] [review]
Bug 4461: Database and syspref changes

adding problem_reports table and OPACReportProblem syspref

Signed-off-by: David Nind <david@davidnind.com>
Comment 30 David Nind 2020-02-25 17:58:12 UTC
Created attachment 99600 [details] [review]
Bug 4461: Problem Report Koha objects

Signed-off-by: David Nind <david@davidnind.com>
Comment 31 David Nind 2020-02-25 17:58:16 UTC
Created attachment 99601 [details] [review]
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>
Comment 32 David Nind 2020-02-25 17:58:20 UTC
Created attachment 99602 [details] [review]
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled

Signed-off-by: David Nind <david@davidnind.com>
Comment 33 David Nind 2020-02-25 17:58:25 UTC
Created attachment 99603 [details] [review]
Bug 4461: (follow-up) Creating sample notice and other fixes

- filters
- capitalisation
- atomic update

Signed-off-by: David Nind <david@davidnind.com>
Comment 34 Jonathan Druart 2020-02-26 10:02:08 UTC
Created attachment 99633 [details] [review]
Bug 4461: Rename report date with created_on

And make it a timestamp type column
Comment 35 Jonathan Druart 2020-02-26 10:06:38 UTC
Some notes:

1. reportdate must be created_on, with a type "timestamp".

2. opac/opac-reportproblem.pl

112     my $from_address = $member->email || $member->emailpro || $member->B_email || $koha_admin;

We usually do not specify the from_address on enqueuing the notice, but when sending it (from _send_message_by_email). That way a) the code is centralized (as we must use $patron->notice_email_address) and b) the email used is the one that is in the DB when the letter is effectively sent.
Here I guess you need to give it when the notice is enqueued as you want to default to the koha admin address.

I do not think it's a good idea, we should not send an email with "from" if not really sent by the user.
We have the borrowernumber anyway to know who filled the form.
Comment 36 Jonathan Druart 2020-02-26 10:07:02 UTC
I am trying to submit follow-ups.
Comment 37 Jonathan Druart 2020-02-26 11:21:31 UTC
Created attachment 99635 [details] [review]
Bug 4461: Use KohaAdminEmailAddress pref as 'from'

We usually do not specify the from_address on enqueuing the notice, but
when sending it (from _send_message_by_email). That way a) the code is
centralized (as we must use $patron->notice_email_address) and b) the
email used is the one that is in the DB when the letter is effectively
sent.
Here I guess you need to give it when the notice is enqueued as you want
to default to the koha admin address.

I do not think it's a good idea, we should not send an email with "from"
if not really sent by the user.
We have the borrowernumber anyway to know who filled the form.
Comment 38 Jonathan Druart 2020-02-26 11:21:35 UTC
Created attachment 99636 [details] [review]
Bug 4461: Use our local_referer instead of HTTP_REFERER

Cannot remember why exactly, but it seems that we should not use
HTTP_REFERER directly.
Comment 39 Jonathan Druart 2020-02-26 11:21:39 UTC
Created attachment 99637 [details] [review]
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined
Comment 40 Jonathan Druart 2020-02-26 11:21:43 UTC
Created attachment 99638 [details] [review]
Bug 4461: Simplify recipients code

As the feature is now turned off without KohaAdminEmailAddress, we only
need to check if the email address of the library if defined.
Not that we should not check for $library->branchreplyto or
ReplytoDefault, but only $library->branchemail, as we do everywhere else
(I think)
Comment 41 Jonathan Druart 2020-02-26 11:21:47 UTC
Created attachment 99639 [details] [review]
Bug 4461: Better error handling
Comment 42 Jonathan Druart 2020-02-26 11:23:06 UTC
I have attached few follow-ups, pick the ones you need/want.

However I am a bit at lost here.

There is no UI so far, but we have such things:
+        status varchar(1) NOT NULL default 'N', -- status of the report. N=new, V=viewed, C=closed

so the status will never be updated, what will happen when we will have the UI?

IMO we should bring the UI with that patchset, and remove the notice. Do we really want the notice to be sent? If yes, do we really want the new table? :)

Also, do we really need the problem_reports.recipient DB field if we have the email?
Same for username? We have the borrowernumber.

About the DB structure again, it seems that status should be an ENUM.
Comment 43 Aleisha Amohia 2020-02-26 22:27:59 UTC
(In reply to Jonathan Druart from comment #42)
> I have attached few follow-ups, pick the ones you need/want.
> 
> However I am a bit at lost here.
> 
> There is no UI so far, but we have such things:
> +        status varchar(1) NOT NULL default 'N', -- status of the report.
> N=new, V=viewed, C=closed
> 
> so the status will never be updated, what will happen when we will have the
> UI?
> 
> IMO we should bring the UI with that patchset, and remove the notice. Do we
> really want the notice to be sent? If yes, do we really want the new table?
> :)

As mentioned in multiple earlier comments, once this is pushed I want to add a follow-up feature where staff can manage problem reports on the intranet. The original report for this feature asked for an email to be sent so that's what I implemented. Up to the community if they would prefer the email notice version or the staff-side management version, but I don't see any harm in having both.

> 
> Also, do we really need the problem_reports.recipient DB field if we have
> the email?
> Same for username? We have the borrowernumber.
> 
> About the DB structure again, it seems that status should be an ENUM.

Agreed that some of these fields are redundant, and status can be an ENUM. Happy to make these changes.
Comment 44 Jonathan Druart 2020-02-27 08:43:08 UTC
What do others think? Could we get your opinions?
Comment 45 Nick Clemens 2020-02-27 15:49:54 UTC
(In reply to Jonathan Druart from comment #44)
> What do others think? Could we get your opinions?

I think having option to get email notices as well as having the staff interface is useful - I don't think we need to pick only one - but once there is a GUI the notices should be optional

>Bug 4461: Use KohaAdminEmailAddress pref as 'from'
I don't understand that followup - 'from_address' is just picked form the message in C4/Letters - it is 'to_address' that usually gets filled at send - to be to the borrowernumber

In this case I think we could set it as:
$patron->notice_email_address || $koha_admin;
Comment 46 Jonathan Druart 2020-03-02 12:03:54 UTC
(In reply to Nick Clemens from comment #45)
> (In reply to Jonathan Druart from comment #44)
> > What do others think? Could we get your opinions?
> 
> I think having option to get email notices as well as having the staff
> interface is useful - I don't think we need to pick only one - but once
> there is a GUI the notices should be optional

The problem with having the GUI after is that we do not deal with some of the already created fields.
See comment 42: "the status will never be updated, what will happen when we will have the UI?"

> >Bug 4461: Use KohaAdminEmailAddress pref as 'from'
> I don't understand that followup - 'from_address' is just picked form the
> message in C4/Letters - it is 'to_address' that usually gets filled at send
> - to be to the borrowernumber
> 
> In this case I think we could set it as:
> $patron->notice_email_address || $koha_admin;

I do not think so, as said in the commit message "I do not think it's a good idea, we should not send an email with "from" if not really sent by the user." I think it's bad practice to do that, I may be wrong however.
Comment 47 Katrin Fischer 2020-03-02 13:24:27 UTC
If Aleisha says the GUI will be next, I am not so worried about the status and such. It would be nice to see the code, but I feel this was just planning ahead and would not cause harm for now.

> > In this case I think we could set it as:
> > $patron->notice_email_address || $koha_admin;
> 
> I do not think so, as said in the commit message "I do not think it's a good
> idea, we should not send an email with "from" if not really sent by the
> user." I think it's bad practice to do that, I may be wrong however.

I agree here. To avoid being rejected as spam you can use the reporting patron's email as replyto, but not as From. So it's more than a bad practice as a lot of mail servers got a lot stricter in the last years - it will be real trouble (been there). From and Return-path needs to be from the mail servers domain. See also:
https://wiki.koha-community.org/wiki/MRenvoize/Email
Comment 48 Martin Renvoize 2020-03-02 13:42:18 UTC
I documented some of the ReplyTo stuff back when it was first introduced as a feature in bug 9530.. Jonathan is correct, we should not spoof user address in the from address is it's very likely you'll end up in a spam list that way.

https://wiki.koha-community.org/wiki/MRenvoize/Email roughly explains it and I have a feeling that was lifted and put in our own manual somewhere but I can't see it right now.

In bug 22821 I add some handling to allow specifying reply-to address at the EnqueuLetter stage.. it is my feeling if you want to send email 'from' a patron 'to' a library you should use a combination of not supplying a 'from' address (as it'll pick an appropriate one in _send_message_by_email), setting the 'to' using Koha::Library->get_effective_email (perhaps I should rename that get_inbound_email_address) which will do an appropriate fallback through replyto addresses and finally add a reply-to address of the patron so whoever receives the email can reply to the actual user.

See bug 22821 and bug 22823 for some further details around email handling.
Comment 49 Jonathan Druart 2020-03-02 14:12:11 UTC
(In reply to Katrin Fischer from comment #47)
> If Aleisha says the GUI will be next, I am not so worried about the status
> and such. It would be nice to see the code, but I feel this was just
> planning ahead and would not cause harm for now.

For now no. But when the GUI will be there the message will be marked as "new" even if they have been processed already. If we mark them all as "processed" when the GUI is added, that will also be wrong: some may have not still been processed.
Comment 50 Martin Renvoize 2020-03-02 14:31:38 UTC
Comment on attachment 99637 [details] [review]
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined

Review of attachment 99637 [details] [review]:
-----------------------------------------------------------------

::: koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
@@ +376,5 @@
>                    yes: Allow
>                    no: "Don't allow"
>              - patrons to submit problem reports for OPAC pages to the library or Koha Administrator.
> +            - "<br/>"
> +            - "<strong>NOTE:</strong> You must have KohaAdminEmailAddress enabled."

This isn't actually true is it?.. we use branch email in preference to KohaAdminEmailAddress so it's just a fallback not a hard requirement.

::: opac/opac-reportproblem.pl
@@ +41,5 @@
>  );
>  
> +if (   !C4::Context->preference('OPACReportProblem')
> +    || !C4::Context->preference('KohaAdminEmailAddress') )
> +{

Don't we actually use branchemail in preference to KohaAdminEmailAddress so this isn't actually a hard requirement?
Comment 51 Martin Renvoize 2020-03-02 14:34:36 UTC
Comment on attachment 99638 [details] [review]
Bug 4461: Simplify recipients code

Review of attachment 99638 [details] [review]:
-----------------------------------------------------------------

::: koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt
@@ +32,5 @@
> +                        [% IF recipient == 'admin' %]
> +                            Your problem report has been sent to the Koha administrator.
> +                        [% ELSE %]
> +                            Your problem report has been sent to the library.
> +                        [% END %]

Do we really need to get this specific in the OPAC?

I'd say we just need to say whether the email was successfully sent or not and not worry so much whether it's KohaAdminEmail or Library Branch Email.. the end user doesn't have a way to select who it goes to anyway.

If we remove this we could simplify the code a little
Comment 52 Martin Renvoize 2020-03-02 14:37:50 UTC
(In reply to Jonathan Druart from comment #49)
> (In reply to Katrin Fischer from comment #47)
> > If Aleisha says the GUI will be next, I am not so worried about the status
> > and such. It would be nice to see the code, but I feel this was just
> > planning ahead and would not cause harm for now.
> 
> For now no. But when the GUI will be there the message will be marked as
> "new" even if they have been processed already. If we mark them all as
> "processed" when the GUI is added, that will also be wrong: some may have
> not still been processed.

Agreed, without any way of maintaining the status, I think we should remove it from this bug.. I like the idea of having a UI with Koha for progressing and tracking reported issues but until that time we shouldn't record incorrect status's.
Comment 53 Jonathan Druart 2020-03-02 14:38:27 UTC
(In reply to Martin Renvoize from comment #50)
> Comment on attachment 99637 [details] [review] [review]
> Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined
> 
> Review of attachment 99637 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> ::: koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref
> @@ +376,5 @@
> >                    yes: Allow
> >                    no: "Don't allow"
> >              - patrons to submit problem reports for OPAC pages to the library or Koha Administrator.
> > +            - "<br/>"
> > +            - "<strong>NOTE:</strong> You must have KohaAdminEmailAddress enabled."
> 
> This isn't actually true is it?.. we use branch email in preference to
> KohaAdminEmailAddress so it's just a fallback not a hard requirement.

With the 404 redirect in opac-reportproblem.pl it is a hard requirement.
Original code was assuming the pref was filled IIRC.

> ::: opac/opac-reportproblem.pl
> @@ +41,5 @@
> >  );
> >  
> > +if (   !C4::Context->preference('OPACReportProblem')
> > +    || !C4::Context->preference('KohaAdminEmailAddress') )
> > +{
> 
> Don't we actually use branchemail in preference to KohaAdminEmailAddress so
> this isn't actually a hard requirement?

Not what the code is actually doing. Maybe it needs to be adjusted.
105                         to_address             => C4::Context->preference('KohaAdminEmailAddress'),

(In reply to Martin Renvoize from comment #51)
> Comment on attachment 99638 [details] [review] [review]
> Bug 4461: Simplify recipients code
> 
> Review of attachment 99638 [details] [review] [review]:
> -----------------------------------------------------------------
> 
> ::: koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-reportproblem.tt
> @@ +32,5 @@
> > +                        [% IF recipient == 'admin' %]
> > +                            Your problem report has been sent to the Koha administrator.
> > +                        [% ELSE %]
> > +                            Your problem report has been sent to the library.
> > +                        [% END %]
> 
> Do we really need to get this specific in the OPAC?
> 
> I'd say we just need to say whether the email was successfully sent or not
> and not worry so much whether it's KohaAdminEmail or Library Branch Email..
> the end user doesn't have a way to select who it goes to anyway.
> 
> If we remove this we could simplify the code a little

Feel free to submit any follow-ups you wish ;)
Comment 54 Martin Renvoize 2020-03-02 14:39:02 UTC
Bug say's it's sponsored.. can we add a Sponsored-by line to at least one of the patches ;)
Comment 55 Katrin Fischer 2020-03-02 14:49:41 UTC
(In reply to Jonathan Druart from comment #49)
> (In reply to Katrin Fischer from comment #47)
> > If Aleisha says the GUI will be next, I am not so worried about the status
> > and such. It would be nice to see the code, but I feel this was just
> > planning ahead and would not cause harm for now.
> 
> For now no. But when the GUI will be there the message will be marked as
> "new" even if they have been processed already. If we mark them all as
> "processed" when the GUI is added, that will also be wrong: some may have
> not still been processed.

But that problem will be the same when we add the status column later on - if it's there now or not. I'd just aim for having the GUI same release if possible? I don't see the big issue here I'd rather spent the time to build the GUI then to make it work perfectly without now.
Comment 56 Martin Renvoize 2020-03-02 14:52:05 UTC
It also requires 'OpacKohaUrl' to be enabled.. that feels like an error.
Comment 57 Martin Renvoize 2020-03-02 14:53:44 UTC
Followups coming.. this has turned into a todo list for myself to help get this past the line.
Comment 58 Martin Renvoize 2020-03-02 15:22:12 UTC
Created attachment 99929 [details] [review]
Bug 4461: Database and syspref changes

adding problem_reports table and OPACReportProblem syspref

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 59 Martin Renvoize 2020-03-02 15:22:16 UTC
Created attachment 99930 [details] [review]
Bug 4461: Problem Report Koha objects

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 60 Martin Renvoize 2020-03-02 15:22:20 UTC
Created attachment 99931 [details] [review]
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>
Comment 61 Martin Renvoize 2020-03-02 15:22:24 UTC
Created attachment 99932 [details] [review]
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 62 Martin Renvoize 2020-03-02 15:22:28 UTC
Created attachment 99933 [details] [review]
Bug 4461: (follow-up) Creating sample notice and other fixes

- filters
- capitalisation
- atomic update

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 63 Martin Renvoize 2020-03-02 15:22:32 UTC
Created attachment 99934 [details] [review]
Bug 4461: Rename report date with created_on

And make it a timestamp type column

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 64 Martin Renvoize 2020-03-02 15:22:35 UTC
Created attachment 99935 [details] [review]
Bug 4461: Use KohaAdminEmailAddress pref as 'from'

We usually do not specify the from_address on enqueuing the notice, but
when sending it (from _send_message_by_email). That way a) the code is
centralized (as we must use $patron->notice_email_address) and b) the
email used is the one that is in the DB when the letter is effectively
sent.
Here I guess you need to give it when the notice is enqueued as you want
to default to the koha admin address.

I do not think it's a good idea, we should not send an email with "from"
if not really sent by the user.
We have the borrowernumber anyway to know who filled the form.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 65 Martin Renvoize 2020-03-02 15:22:40 UTC
Created attachment 99936 [details] [review]
Bug 4461: Use our local_referer instead of HTTP_REFERER

Cannot remember why exactly, but it seems that we should not use
HTTP_REFERER directly.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 66 Martin Renvoize 2020-03-02 15:22:44 UTC
Created attachment 99937 [details] [review]
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 67 Martin Renvoize 2020-03-02 15:22:47 UTC
Created attachment 99938 [details] [review]
Bug 4461: Simplify recipients code

As the feature is now turned off without KohaAdminEmailAddress, we only
need to check if the email address of the library if defined.
Not that we should not check for $library->branchreplyto or
ReplytoDefault, but only $library->branchemail, as we do everywhere else
(I think)

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 68 Martin Renvoize 2020-03-02 15:22:51 UTC
Created attachment 99939 [details] [review]
Bug 4461: Better error handling

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 69 Martin Renvoize 2020-03-02 15:22:55 UTC
Created attachment 99940 [details] [review]
Bug 4461: Remove hard requirement on OpacKohaUrl

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 70 Martin Renvoize 2020-03-02 15:22:59 UTC
Created attachment 99941 [details] [review]
Bug 4461: Drop 'from_address' use 'reply_address'

This patch adds support for using the reply-to field added in bug 10269
and drops 'from_address' as it will get defined at a later stage in the
emailing process anyway.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 71 Martin Renvoize 2020-03-02 15:23:03 UTC
Created attachment 99942 [details] [review]
Bug 4461: Use get_effective_email from bug 22823

Use the get_effective_email from Koha::Library to get an appropriate
inbound address for the branch as aposed to using branchemail directly.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 72 Martin Renvoize 2020-03-02 15:25:13 UTC
I'm reasonably happy with the followups here.. it feels like this was written with a GUI and a process in mind but without submitting the GUI half and as such the code is a little confusing.. why not just send emails and skip the table element entirely ;)

Still.. I like the feature and at this point, the code seems to work reasonably well.. I'd love to see a GUI including a process for moving reports through various states added this cycle if possible.
Comment 73 Aleisha Amohia 2020-03-03 01:28:32 UTC
We keep getting stuck on the lack of GUI. I understand. I'll write the GUI for this now so it can all go through in one go.
Comment 74 Aleisha Amohia 2020-03-11 02:17:18 UTC
Created attachment 100488 [details] [review]
Bug 4461: (follow-up) Creating sample notice and other fixes

- filters
- capitalisation
- atomic update

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 75 Aleisha Amohia 2020-03-11 02:17:24 UTC
Created attachment 100489 [details] [review]
Bug 4461: Rename report date with created_on

And make it a timestamp type column

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 76 Aleisha Amohia 2020-03-11 02:17:31 UTC
Created attachment 100490 [details] [review]
Bug 4461: Use KohaAdminEmailAddress pref as 'from'

We usually do not specify the from_address on enqueuing the notice, but
when sending it (from _send_message_by_email). That way a) the code is
centralized (as we must use $patron->notice_email_address) and b) the
email used is the one that is in the DB when the letter is effectively
sent.
Here I guess you need to give it when the notice is enqueued as you want
to default to the koha admin address.

I do not think it's a good idea, we should not send an email with "from"
if not really sent by the user.
We have the borrowernumber anyway to know who filled the form.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 77 Aleisha Amohia 2020-03-11 02:17:38 UTC
Created attachment 100491 [details] [review]
Bug 4461: Use our local_referer instead of HTTP_REFERER

Cannot remember why exactly, but it seems that we should not use
HTTP_REFERER directly.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 78 Aleisha Amohia 2020-03-11 02:17:44 UTC
Created attachment 100492 [details] [review]
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 79 Aleisha Amohia 2020-03-11 02:17:51 UTC
Created attachment 100493 [details] [review]
Bug 4461: Simplify recipients code

As the feature is now turned off without KohaAdminEmailAddress, we only
need to check if the email address of the library if defined.
Not that we should not check for $library->branchreplyto or
ReplytoDefault, but only $library->branchemail, as we do everywhere else
(I think)

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 80 Aleisha Amohia 2020-03-11 02:17:57 UTC
Created attachment 100494 [details] [review]
Bug 4461: Better error handling

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 81 Aleisha Amohia 2020-03-11 02:18:03 UTC
Created attachment 100495 [details] [review]
Bug 4461: Remove hard requirement on OpacKohaUrl

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 82 Aleisha Amohia 2020-03-11 02:18:11 UTC
Created attachment 100496 [details] [review]
Bug 4461: Drop 'from_address' use 'reply_address'

This patch adds support for using the reply-to field added in bug 10269
and drops 'from_address' as it will get defined at a later stage in the
emailing process anyway.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 83 Aleisha Amohia 2020-03-11 02:18:18 UTC
Created attachment 100497 [details] [review]
Bug 4461: Use get_effective_email from bug 22823

Use the get_effective_email from Koha::Library to get an appropriate
inbound address for the branch as aposed to using branchemail directly.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 84 Aleisha Amohia 2020-03-11 02:18:25 UTC
Created attachment 100498 [details] [review]
Bug 4461: Adding user flags for managing OPAC problem reports
Comment 85 Aleisha Amohia 2020-03-11 02:18:31 UTC
Created attachment 100499 [details] [review]
Bug 4461: Add problem reports link to mainpage and admin home
Comment 86 Aleisha Amohia 2020-03-11 02:18:37 UTC
Created attachment 100500 [details] [review]
Bug 4461: Manage problem reports on the staff client

Test plan:

- Update database and upgrade schema files (if you haven't already).
Restart memcached
- Check your user's permissions and ensure the 'problem_reports'
permission is ticked. Confirm the OPACReportProblem syspref is enabled
- Log into the OPAC and submit a problem report
- Log into the staff client
- You should see a box at the bottom of the main page showing your
pending problem report
- Click the link and confirm it takes you to the new page for managing
problem reports
- Go to Administration
- Confirm you can see a link to 'OPAC problem reports' under the
'Additional parameters' heading
- Click 'OPAC problem reports'
- Confirm your problem report is showing in the table
- Open the OPAC in another tab and submit at least two more problem
reports (so you should have at least three in the table after
refreshing)
- Try the different buttons
    - selecting multiple problem reports and using the big 'mark
    viewed', 'mark closed', 'mark new' buttons. Confirm there are no
    failures and that the number of selected problem reports is correct
    - select all, clear all, hide viewed, hide closed, hide new, show
    all
    - individual 'mark viewed', 'mark closed', 'mark new' buttons for
    each problem report. Confirm the status shows and the correct button
    is disabled while others are enabled
- Confirm the problem page link works as expected

Sponsored-by: Catalyst IT
Comment 87 Martin Renvoize 2020-03-11 09:11:51 UTC
Created attachment 100506 [details] [review]
Bug 4461: Database and syspref changes

adding problem_reports table and OPACReportProblem syspref

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 88 Martin Renvoize 2020-03-11 09:11:55 UTC
Created attachment 100507 [details] [review]
Bug 4461: Problem Report Koha objects

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 89 Martin Renvoize 2020-03-11 09:11:59 UTC
Created attachment 100508 [details] [review]
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>
Comment 90 Martin Renvoize 2020-03-11 09:12:03 UTC
Created attachment 100509 [details] [review]
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 91 Martin Renvoize 2020-03-11 09:12:08 UTC
Created attachment 100510 [details] [review]
Bug 4461: (follow-up) Creating sample notice and other fixes

- filters
- capitalisation
- atomic update

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 92 Martin Renvoize 2020-03-11 09:12:12 UTC
Created attachment 100511 [details] [review]
Bug 4461: Rename report date with created_on

And make it a timestamp type column

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 93 Martin Renvoize 2020-03-11 09:12:16 UTC
Created attachment 100512 [details] [review]
Bug 4461: Use KohaAdminEmailAddress pref as 'from'

We usually do not specify the from_address on enqueuing the notice, but
when sending it (from _send_message_by_email). That way a) the code is
centralized (as we must use $patron->notice_email_address) and b) the
email used is the one that is in the DB when the letter is effectively
sent.
Here I guess you need to give it when the notice is enqueued as you want
to default to the koha admin address.

I do not think it's a good idea, we should not send an email with "from"
if not really sent by the user.
We have the borrowernumber anyway to know who filled the form.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 94 Martin Renvoize 2020-03-11 09:12:21 UTC
Created attachment 100513 [details] [review]
Bug 4461: Use our local_referer instead of HTTP_REFERER

Cannot remember why exactly, but it seems that we should not use
HTTP_REFERER directly.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 95 Martin Renvoize 2020-03-11 09:12:25 UTC
Created attachment 100514 [details] [review]
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 96 Martin Renvoize 2020-03-11 09:12:29 UTC
Created attachment 100515 [details] [review]
Bug 4461: Simplify recipients code

As the feature is now turned off without KohaAdminEmailAddress, we only
need to check if the email address of the library if defined.
Not that we should not check for $library->branchreplyto or
ReplytoDefault, but only $library->branchemail, as we do everywhere else
(I think)

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 97 Martin Renvoize 2020-03-11 09:12:33 UTC
Created attachment 100516 [details] [review]
Bug 4461: Better error handling

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 98 Martin Renvoize 2020-03-11 09:12:37 UTC
Created attachment 100517 [details] [review]
Bug 4461: Remove hard requirement on OpacKohaUrl

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 99 Martin Renvoize 2020-03-11 09:12:41 UTC
Created attachment 100518 [details] [review]
Bug 4461: Drop 'from_address' use 'reply_address'

This patch adds support for using the reply-to field added in bug 10269
and drops 'from_address' as it will get defined at a later stage in the
emailing process anyway.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 100 Martin Renvoize 2020-03-11 09:12:46 UTC
Created attachment 100519 [details] [review]
Bug 4461: Use get_effective_email from bug 22823

Use the get_effective_email from Koha::Library to get an appropriate
inbound address for the branch as aposed to using branchemail directly.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 101 Martin Renvoize 2020-03-11 09:12:50 UTC
Created attachment 100520 [details] [review]
Bug 4461: Adding user flags for managing OPAC problem reports

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 102 Martin Renvoize 2020-03-11 09:12:54 UTC
Created attachment 100521 [details] [review]
Bug 4461: Add problem reports link to mainpage and admin home

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 103 Martin Renvoize 2020-03-11 09:12:59 UTC
Created attachment 100522 [details] [review]
Bug 4461: Manage problem reports on the staff client

Test plan:

- Update database and upgrade schema files (if you haven't already).
Restart memcached
- Check your user's permissions and ensure the 'problem_reports'
permission is ticked. Confirm the OPACReportProblem syspref is enabled
- Log into the OPAC and submit a problem report
- Log into the staff client
- You should see a box at the bottom of the main page showing your
pending problem report
- Click the link and confirm it takes you to the new page for managing
problem reports
- Go to Administration
- Confirm you can see a link to 'OPAC problem reports' under the
'Additional parameters' heading
- Click 'OPAC problem reports'
- Confirm your problem report is showing in the table
- Open the OPAC in another tab and submit at least two more problem
reports (so you should have at least three in the table after
refreshing)
- Try the different buttons
    - selecting multiple problem reports and using the big 'mark
    viewed', 'mark closed', 'mark new' buttons. Confirm there are no
    failures and that the number of selected problem reports is correct
    - select all, clear all, hide viewed, hide closed, hide new, show
    all
    - individual 'mark viewed', 'mark closed', 'mark new' buttons for
    each problem report. Confirm the status shows and the correct button
    is disabled while others are enabled
- Confirm the problem page link works as expected

Sponsored-by: Catalyst IT
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 104 Martin Renvoize 2020-03-11 09:13:03 UTC
Created attachment 100523 [details] [review]
Bug 4461: (follow-up) Add missing relationship accessor

I think this was a simple case of Aliesha missing a file when commiting.

So I could proceed with testing I just quickly re-implimented the patron
relationship accessor.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 105 Martin Renvoize 2020-03-11 09:13:07 UTC
Created attachment 100524 [details] [review]
Bug 4461: DBIC Schema Files

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 106 Martin Renvoize 2020-03-11 09:15:34 UTC
This is looking great now Aliesha, thankyou for the addition of a UI, it makes is significantly easier to test and more of a complete feature.

I feel we've hit minimum viable product here now and would love to get this go through.. I added a couple of followups simply to aid in testing.. firstly I think you just missed adding the file to the commit for the patron relationships accessor and then I added a commit with the dbic schema changes so this can be tested on sandboxes and the likes.

Signing off.
Comment 107 Aleisha Amohia 2020-03-11 20:14:40 UTC
(In reply to Martin Renvoize from comment #106)
> This is looking great now Aliesha, thankyou for the addition of a UI, it
> makes is significantly easier to test and more of a complete feature.
> 
> I feel we've hit minimum viable product here now and would love to get this
> go through.. I added a couple of followups simply to aid in testing..
> firstly I think you just missed adding the file to the commit for the patron
> relationships accessor and then I added a commit with the dbic schema
> changes so this can be tested on sandboxes and the likes.
> 
> Signing off.

Thanks I did forget to attach that file!
Comment 108 Jonathan Druart 2020-03-12 11:51:51 UTC
Created attachment 100619 [details] [review]
Bug 4461: Update license statements
Comment 109 Jonathan Druart 2020-03-12 11:52:23 UTC
report_problems.borrowernumber defaults to NULL. Should not it be NOT NULL instead?
Comment 110 Jonathan Druart 2020-03-12 11:56:19 UTC
When the form is sent, the success message appears but with the form bellow.

Should not we hide it?

https://snipboard.io/HJKtdp.jpg
Comment 111 Jonathan Druart 2020-03-12 12:08:45 UTC
- I would prefer status to be a varchar and have a readable status, instead of N, V, C
- The "hide viewed" and  "hide closed" filters does not work if the page is not reloaded
- Why do not we see the recipient of the report in the table?
We see the reports sent to the administrator, is that expected?
- I think there is a missing test in the controller (minor)
If recipient is forced to "librarian" but the library does not have an email address defined, then the message will be enqueued anyway.
Comment 112 Aleisha Amohia 2020-03-19 00:03:01 UTC
Created attachment 100989 [details] [review]
Bug 4461: Fix status and borrowernumber fields in problem_reports and more

status varchar(6) with readable statuses
borrowernumber not null default 0
hide form if message successfully sent
fixing hide viewed and hide closed filters
adding recipient column
Comment 113 Aleisha Amohia 2020-03-19 00:27:40 UTC
Created attachment 100990 [details] [review]
Bug 4461: Checks on library email before enqueuing letter
Comment 114 David Nind 2020-04-01 09:21:27 UTC
Patch no longer applies 8-(:

root@9512ab8ec1bb:koha(bz4461)$ git bz apply 4461
Bug 4461 - Context-sensitive report a problem screen

100506 - Bug 4461: Database and syspref changes
100507 - Bug 4461: Problem Report Koha objects
100508 - Bug 4461: Submit a problem report
100509 - Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled
100510 - Bug 4461: (follow-up) Creating sample notice and other fixes
100511 - Bug 4461: Rename report date with created_on
100512 - Bug 4461: Use KohaAdminEmailAddress pref as 'from'
100513 - Bug 4461: Use our local_referer instead of HTTP_REFERER
100514 - Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined
100515 - Bug 4461: Simplify recipients code
100516 - Bug 4461: Better error handling
100517 - Bug 4461: Remove hard requirement on OpacKohaUrl
100518 - Bug 4461: Drop 'from_address' use 'reply_address'
100519 - Bug 4461: Use get_effective_email from bug 22823
100520 - Bug 4461: Adding user flags for managing OPAC problem reports
100521 - Bug 4461: Add problem reports link to mainpage and admin home
100522 - Bug 4461: Manage problem reports on the staff client
100523 - Bug 4461: (follow-up) Add missing relationship accessor
100524 - Bug 4461: DBIC Schema Files
100619 - Bug 4461: Update license statements
100989 - Bug 4461: Fix status and borrowernumber fields in problem_reports and more
100990 - Bug 4461: Checks on library email before enqueuing letter

Apply? [(y)es, (n)o, (i)nteractive] y
Applying: Bug 4461: Database and syspref changes
error: sha1 information is lacking or useless (installer/data/mysql/kohastructure.sql).
error: could not build fake ancestor
Patch failed at 0001 Bug 4461: Database and syspref changes
Comment 115 Jonathan Druart 2020-04-01 09:48:24 UTC
Created attachment 102188 [details] [review]
Bug 4461: Database and syspref changes

adding problem_reports table and OPACReportProblem syspref

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 116 Jonathan Druart 2020-04-01 09:48:30 UTC
Created attachment 102189 [details] [review]
Bug 4461: Problem Report Koha objects

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 117 Jonathan Druart 2020-04-01 09:48:36 UTC
Created attachment 102190 [details] [review]
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>
Comment 118 Jonathan Druart 2020-04-01 09:48:41 UTC
Created attachment 102191 [details] [review]
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 119 Jonathan Druart 2020-04-01 09:48:47 UTC
Created attachment 102192 [details] [review]
Bug 4461: (follow-up) Creating sample notice and other fixes

- filters
- capitalisation
- atomic update

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 120 Jonathan Druart 2020-04-01 09:48:52 UTC
Created attachment 102193 [details] [review]
Bug 4461: Rename report date with created_on

And make it a timestamp type column

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 121 Jonathan Druart 2020-04-01 09:48:58 UTC
Created attachment 102194 [details] [review]
Bug 4461: Use KohaAdminEmailAddress pref as 'from'

We usually do not specify the from_address on enqueuing the notice, but
when sending it (from _send_message_by_email). That way a) the code is
centralized (as we must use $patron->notice_email_address) and b) the
email used is the one that is in the DB when the letter is effectively
sent.
Here I guess you need to give it when the notice is enqueued as you want
to default to the koha admin address.

I do not think it's a good idea, we should not send an email with "from"
if not really sent by the user.
We have the borrowernumber anyway to know who filled the form.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 122 Jonathan Druart 2020-04-01 09:49:03 UTC
Created attachment 102195 [details] [review]
Bug 4461: Use our local_referer instead of HTTP_REFERER

Cannot remember why exactly, but it seems that we should not use
HTTP_REFERER directly.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 123 Jonathan Druart 2020-04-01 09:49:08 UTC
Created attachment 102196 [details] [review]
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 124 Jonathan Druart 2020-04-01 09:49:14 UTC
Created attachment 102198 [details] [review]
Bug 4461: Simplify recipients code

As the feature is now turned off without KohaAdminEmailAddress, we only
need to check if the email address of the library if defined.
Not that we should not check for $library->branchreplyto or
ReplytoDefault, but only $library->branchemail, as we do everywhere else
(I think)

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 125 Jonathan Druart 2020-04-01 09:49:19 UTC
Created attachment 102200 [details] [review]
Bug 4461: Better error handling

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 126 Jonathan Druart 2020-04-01 09:49:25 UTC
Created attachment 102201 [details] [review]
Bug 4461: Remove hard requirement on OpacKohaUrl

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 127 Jonathan Druart 2020-04-01 09:49:31 UTC
Created attachment 102202 [details] [review]
Bug 4461: Drop 'from_address' use 'reply_address'

This patch adds support for using the reply-to field added in bug 10269
and drops 'from_address' as it will get defined at a later stage in the
emailing process anyway.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 128 Jonathan Druart 2020-04-01 09:49:36 UTC
Created attachment 102203 [details] [review]
Bug 4461: Use get_effective_email from bug 22823

Use the get_effective_email from Koha::Library to get an appropriate
inbound address for the branch as aposed to using branchemail directly.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 129 Jonathan Druart 2020-04-01 09:49:42 UTC
Created attachment 102204 [details] [review]
Bug 4461: Adding user flags for managing OPAC problem reports

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 130 Jonathan Druart 2020-04-01 09:49:47 UTC
Created attachment 102205 [details] [review]
Bug 4461: Add problem reports link to mainpage and admin home

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 131 Jonathan Druart 2020-04-01 09:49:52 UTC
Created attachment 102206 [details] [review]
Bug 4461: Manage problem reports on the staff client

Test plan:

- Update database and upgrade schema files (if you haven't already).
Restart memcached
- Check your user's permissions and ensure the 'problem_reports'
permission is ticked. Confirm the OPACReportProblem syspref is enabled
- Log into the OPAC and submit a problem report
- Log into the staff client
- You should see a box at the bottom of the main page showing your
pending problem report
- Click the link and confirm it takes you to the new page for managing
problem reports
- Go to Administration
- Confirm you can see a link to 'OPAC problem reports' under the
'Additional parameters' heading
- Click 'OPAC problem reports'
- Confirm your problem report is showing in the table
- Open the OPAC in another tab and submit at least two more problem
reports (so you should have at least three in the table after
refreshing)
- Try the different buttons
    - selecting multiple problem reports and using the big 'mark
    viewed', 'mark closed', 'mark new' buttons. Confirm there are no
    failures and that the number of selected problem reports is correct
    - select all, clear all, hide viewed, hide closed, hide new, show
    all
    - individual 'mark viewed', 'mark closed', 'mark new' buttons for
    each problem report. Confirm the status shows and the correct button
    is disabled while others are enabled
- Confirm the problem page link works as expected

Sponsored-by: Catalyst IT
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 132 Jonathan Druart 2020-04-01 09:49:57 UTC
Created attachment 102207 [details] [review]
Bug 4461: (follow-up) Add missing relationship accessor

I think this was a simple case of Aliesha missing a file when commiting.

So I could proceed with testing I just quickly re-implimented the patron
relationship accessor.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 133 Jonathan Druart 2020-04-01 09:50:03 UTC
Created attachment 102208 [details] [review]
Bug 4461: Update license statements
Comment 134 Jonathan Druart 2020-04-01 09:50:08 UTC
Created attachment 102209 [details] [review]
Bug 4461: Checks on library email before enqueuing letter
Comment 135 Jonathan Druart 2020-04-01 09:50:13 UTC
Created attachment 102210 [details] [review]
Bug 4461: DBIC Schema Files

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 136 Jonathan Druart 2020-04-01 09:50:19 UTC
Created attachment 102211 [details] [review]
Bug 4461: Fix status and borrowernumber fields in problem_reports and more

status varchar(6) with readable statuses
borrowernumber not null default 0
hide form if message successfully sent
fixing hide viewed and hide closed filters
adding recipient column
Comment 137 David Nind 2020-04-01 10:15:12 UTC
I'm now getting this error message when trying to submit the form, no matter what I do:

[#% We really should avoid reaching this! %] Something wrong happened when sending the report. Please contact your library. 

Note: I'm following the test plan in Comment 117
Comment 138 Jonathan Druart 2020-04-01 10:26:14 UTC
(In reply to David Nind from comment #137)
> I'm now getting this error message when trying to submit the form, no matter
> what I do:
> 
> [#% We really should avoid reaching this! %] Something wrong happened when
> sending the report. Please contact your library. 
> 
> Note: I'm following the test plan in Comment 117

Do you see something relevant in the Koha log file?
Comment 139 David Nind 2020-04-01 19:59:07 UTC
I've retested again. Two issues I've identified:

1) If there is no library email address there is no drop down list on the report a problem page, which is the expected behavour. If there is an email address set for the library then there is a drop down list with 'A librarian' and 'Koha administrator' options. Koha administrator works fine, if you select 'A librarian' you get this error message when submitting "[#% We really should avoid reaching this! %] Something wrong happened when sending the report. Please contact your library."

2)In the staff interface the link to the problem page (in the 'Problem page') displays correctly, however the actual link is adding additional information before it, for example:
- Displays as http://kohadev.myDNSname.org:8080/
- Actual link when you try to click on it: 
http://127.0.0.1:8081/cgi-bin/koha/admin/http%3A%2F%2Fkohadev.myDNSname.org%3A8080%2F
Comment 140 David Nind 2020-04-01 20:18:38 UTC
Also, the results from Comment 139 were from testing with koha-testing-dock and starting with ku (Koha using MySQL 5.5).

If I test with ku-mdb (MariaDB) then I get different problems. With KohaAdminEmailAddress set and a library email address set I get this error message when submitting a problem report "[#% We really should avoid reaching this! %] Something wrong happened when sending the report. Please contact your library."

Something has happened since I originally tested, as I didn't have this problem then.

This is the error in the plack-error.log after submitting the problem report in the OPAC (using MariaDB):

36 DBD::mysql::st execute failed: Incorrect datetime value: 'current_timestamp()' for column `koha_kohadev`.`problem_reports`.`created_on`     at row 1 [for Statement "INSERT INTO `problem_reports` ( `borrowernumber`, `branchcode`, `content`, `created_on`, `problempage`, `reci    pient`, `title`, `username`) VALUES ( ?, ?, ?, ?, ?, ?, ?, ? )" with ParamValues: 0="51", 1='CPL', 2="Test 145", 3='current_timestamp()    ', 4="http://kohadev.myDNSname.org:8080/", 5="admin", 6="Test 145", 7='koha'] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1836.
37 DBIx::Class::Storage::DBI::_dbh_execute(): Incorrect datetime value: 'current_timestamp()' for column `koha_kohadev`.`problem_reports`.    `created_on` at row 1 at /kohadevbox/koha/Koha/Object.pm line 164
38 Something wrong happened when sending the report problem: Invalid value passed, problem_reports.created_on=current_timestamp() expected     type is datetime at /kohadevbox/koha/opac/opac-reportproblem.pl line 131.
Comment 141 David Nind 2020-04-01 23:47:16 UTC
Created attachment 102253 [details]
Bug 4461: Error log when using MySQL 5.5

I've attached the error log when testing on koha-testing-docker with MySQL v 5.5 (started with ku) when submitting a problem report when 'A librarian' is selected.
Comment 142 David Nind 2020-04-02 00:02:04 UTC
To clarify comments about MySQL and MariaDB, starting koha-testing-docker with:

- ku: Server version = 5.5.62 MySQL Community Server (GPL)

- ku-mdb: Server version = 10.4.12-MariaDB-1:10.4.12+maria~bionic mariadb.org binary distribution
Comment 143 Jonathan Druart 2020-04-02 09:23:24 UTC
(In reply to David Nind from comment #140)
> This is the error in the plack-error.log after submitting the problem report
> in the OPAC (using MariaDB):
> 
> 36 DBD::mysql::st execute failed: Incorrect datetime value:
> 'current_timestamp()' for column
> `koha_kohadev`.`problem_reports`.`created_on`     at row 1 [for Statement
> "INSERT INTO `problem_reports` ( `borrowernumber`, `branchcode`, `content`,
> `created_on`, `problempage`, `reci    pient`, `title`, `username`) VALUES (
> ?, ?, ?, ?, ?, ?, ?, ? )" with ParamValues: 0="51", 1='CPL', 2="Test 145",
> 3='current_timestamp()    ', 4="http://kohadev.myDNSname.org:8080/",
> 5="admin", 6="Test 145", 7='koha'] at
> /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1836.
> 37 DBIx::Class::Storage::DBI::_dbh_execute(): Incorrect datetime value:
> 'current_timestamp()' for column `koha_kohadev`.`problem_reports`.   
> `created_on` at row 1 at /kohadevbox/koha/Koha/Object.pm line 164
> 38 Something wrong happened when sending the report problem: Invalid value
> passed, problem_reports.created_on=current_timestamp() expected     type is
> datetime at /kohadevbox/koha/opac/opac-reportproblem.pl line 131.

This is coming from a bug in master, see bug 25040.
Comment 144 Jonathan Druart 2020-04-02 09:26:20 UTC
Created attachment 102279 [details] [review]
Bug 4461: get_effective_email has been renamed inbound_email_address

On commit 027051c938924a33a64014794705526ab68351af
   Bug 22823: Rename method with ->inbound_email_address
Comment 145 Jonathan Druart 2020-04-02 09:29:01 UTC
(In reply to David Nind from comment #141)
> Created attachment 102253 [details]
> Bug 4461: Error log when using MySQL 5.5
> 
> I've attached the error log when testing on koha-testing-docker with MySQL v
> 5.5 (started with ku) when submitting a problem report when 'A librarian' is
> selected.

The important line was the first one:
135 Something wrong happened when sending the report problem: The method Koha::Library->get_effective_email is not covered by tests!

Sorry David I missed that when rebasing the patches.
That should be fixed by the last patch.
I am resetting to NSO, but you will need to apply patch from bug 25040, if not pushed yet.
I do not have time to retest this feature right now, if you face errors again, please to not spend too much time and FQA it immediatly.
Comment 146 David Nind 2020-04-02 10:17:52 UTC
Thanks Jonathan for figuring out the problem!

Applying Bug 25040 before applying 4461 fixes the problem.

When someone gets a chance to fix item 2 (pretty minor - but I don't know how to fix the template) from Comment 139 I'll happily sign off.

David
Comment 147 Jonathan Druart 2020-04-02 10:52:46 UTC
Created attachment 102281 [details] [review]
Bug 4461: Fix OPAC link from staff

QA: We have a security issue here, we should not make this link
clickable from the staff side.
Comment 148 David Nind 2020-04-02 20:08:21 UTC
Created attachment 102308 [details] [review]
Bug 4461: Database and syspref changes

adding problem_reports table and OPACReportProblem syspref

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>
Comment 149 David Nind 2020-04-02 20:08:26 UTC
Created attachment 102309 [details] [review]
Bug 4461: Problem Report Koha objects

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>
Comment 150 David Nind 2020-04-02 20:08:32 UTC
Created attachment 102310 [details] [review]
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>
Comment 151 David Nind 2020-04-02 20:08:37 UTC
Created attachment 102311 [details] [review]
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled

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>
Comment 152 David Nind 2020-04-02 20:08:43 UTC
Created attachment 102312 [details] [review]
Bug 4461: (follow-up) Creating sample notice and other fixes

- filters
- capitalisation
- atomic update

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>
Comment 153 David Nind 2020-04-02 20:08:48 UTC
Created attachment 102313 [details] [review]
Bug 4461: Rename report date with created_on

And make it a timestamp type column

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 154 David Nind 2020-04-02 20:08:53 UTC
Created attachment 102314 [details] [review]
Bug 4461: Use KohaAdminEmailAddress pref as 'from'

We usually do not specify the from_address on enqueuing the notice, but
when sending it (from _send_message_by_email). That way a) the code is
centralized (as we must use $patron->notice_email_address) and b) the
email used is the one that is in the DB when the letter is effectively
sent.
Here I guess you need to give it when the notice is enqueued as you want
to default to the koha admin address.

I do not think it's a good idea, we should not send an email with "from"
if not really sent by the user.
We have the borrowernumber anyway to know who filled the form.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 155 David Nind 2020-04-02 20:08:58 UTC
Created attachment 102315 [details] [review]
Bug 4461: Use our local_referer instead of HTTP_REFERER

Cannot remember why exactly, but it seems that we should not use
HTTP_REFERER directly.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 156 David Nind 2020-04-02 20:09:04 UTC
Created attachment 102316 [details] [review]
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 157 David Nind 2020-04-02 20:09:09 UTC
Created attachment 102317 [details] [review]
Bug 4461: Simplify recipients code

As the feature is now turned off without KohaAdminEmailAddress, we only
need to check if the email address of the library if defined.
Not that we should not check for $library->branchreplyto or
ReplytoDefault, but only $library->branchemail, as we do everywhere else
(I think)

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 158 David Nind 2020-04-02 20:09:14 UTC
Created attachment 102318 [details] [review]
Bug 4461: Better error handling

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 159 David Nind 2020-04-02 20:09:20 UTC
Created attachment 102319 [details] [review]
Bug 4461: Remove hard requirement on OpacKohaUrl

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 160 David Nind 2020-04-02 20:09:25 UTC
Created attachment 102320 [details] [review]
Bug 4461: Drop 'from_address' use 'reply_address'

This patch adds support for using the reply-to field added in bug 10269
and drops 'from_address' as it will get defined at a later stage in the
emailing process anyway.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 161 David Nind 2020-04-02 20:09:30 UTC
Created attachment 102321 [details] [review]
Bug 4461: Use get_effective_email from bug 22823

Use the get_effective_email from Koha::Library to get an appropriate
inbound address for the branch as aposed to using branchemail directly.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 162 David Nind 2020-04-02 20:09:36 UTC
Created attachment 102322 [details] [review]
Bug 4461: Adding user flags for managing OPAC problem reports

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 163 David Nind 2020-04-02 20:09:41 UTC
Created attachment 102323 [details] [review]
Bug 4461: Add problem reports link to mainpage and admin home

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 164 David Nind 2020-04-02 20:09:47 UTC
Created attachment 102324 [details] [review]
Bug 4461: Manage problem reports on the staff client

Test plan:

- Update database and upgrade schema files (if you haven't already).
Restart memcached
- Check your user's permissions and ensure the 'problem_reports'
permission is ticked. Confirm the OPACReportProblem syspref is enabled
- Log into the OPAC and submit a problem report
- Log into the staff client
- You should see a box at the bottom of the main page showing your
pending problem report
- Click the link and confirm it takes you to the new page for managing
problem reports
- Go to Administration
- Confirm you can see a link to 'OPAC problem reports' under the
'Additional parameters' heading
- Click 'OPAC problem reports'
- Confirm your problem report is showing in the table
- Open the OPAC in another tab and submit at least two more problem
reports (so you should have at least three in the table after
refreshing)
- Try the different buttons
    - selecting multiple problem reports and using the big 'mark
    viewed', 'mark closed', 'mark new' buttons. Confirm there are no
    failures and that the number of selected problem reports is correct
    - select all, clear all, hide viewed, hide closed, hide new, show
    all
    - individual 'mark viewed', 'mark closed', 'mark new' buttons for
    each problem report. Confirm the status shows and the correct button
    is disabled while others are enabled
- Confirm the problem page link works as expected

Sponsored-by: Catalyst IT
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 165 David Nind 2020-04-02 20:09:52 UTC
Created attachment 102325 [details] [review]
Bug 4461: (follow-up) Add missing relationship accessor

I think this was a simple case of Aliesha missing a file when commiting.

So I could proceed with testing I just quickly re-implimented the patron
relationship accessor.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 166 David Nind 2020-04-02 20:09:58 UTC
Created attachment 102326 [details] [review]
Bug 4461: Update license statements

Signed-off-by: David Nind <david@davidnind.com>
Comment 167 David Nind 2020-04-02 20:10:03 UTC
Created attachment 102327 [details] [review]
Bug 4461: Checks on library email before enqueuing letter

Signed-off-by: David Nind <david@davidnind.com>
Comment 168 David Nind 2020-04-02 20:10:08 UTC
Created attachment 102328 [details] [review]
Bug 4461: DBIC Schema Files

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: David Nind <david@davidnind.com>
Comment 169 David Nind 2020-04-02 20:10:14 UTC
Created attachment 102329 [details] [review]
Bug 4461: Fix status and borrowernumber fields in problem_reports and more

status varchar(6) with readable statuses
borrowernumber not null default 0
hide form if message successfully sent
fixing hide viewed and hide closed filters
adding recipient column

Signed-off-by: David Nind <david@davidnind.com>
Comment 170 David Nind 2020-04-02 20:10:19 UTC
Created attachment 102330 [details] [review]
Bug 4461: get_effective_email has been renamed inbound_email_address

On commit 027051c938924a33a64014794705526ab68351af
   Bug 22823: Rename method with ->inbound_email_address

Signed-off-by: David Nind <david@davidnind.com>
Comment 171 David Nind 2020-04-02 20:10:25 UTC
Created attachment 102331 [details] [review]
Bug 4461: Fix OPAC link from staff

QA: We have a security issue here, we should not make this link
clickable from the staff side.

Signed-off-by: David Nind <david@davidnind.com>
Comment 172 David Nind 2020-04-02 20:12:39 UTC
Note: Bug 25040 needs to be applied first for this to work correctly (see comment 146).
Comment 173 Jonathan Druart 2020-04-03 13:07:57 UTC
Created attachment 102358 [details] [review]
Bug 4461: Database and syspref changes

adding problem_reports table and OPACReportProblem syspref

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>
Comment 174 Jonathan Druart 2020-04-03 13:08:12 UTC
Created attachment 102359 [details] [review]
Bug 4461: Problem Report Koha objects

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>
Comment 175 Jonathan Druart 2020-04-03 13:08:24 UTC
Created attachment 102360 [details] [review]
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>
Comment 176 Jonathan Druart 2020-04-03 13:08:38 UTC
Created attachment 102361 [details] [review]
Bug 4461: (follow-up) Redirect to 404 if OPACProblemReport not enabled

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>
Comment 177 Jonathan Druart 2020-04-03 13:08:51 UTC
Created attachment 102362 [details] [review]
Bug 4461: (follow-up) Creating sample notice and other fixes

- filters
- capitalisation
- atomic update

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>
Comment 178 Jonathan Druart 2020-04-03 13:09:05 UTC
Created attachment 102363 [details] [review]
Bug 4461: Rename report date with created_on

And make it a timestamp type column

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>
Comment 179 Jonathan Druart 2020-04-03 13:09:18 UTC
Created attachment 102364 [details] [review]
Bug 4461: Use KohaAdminEmailAddress pref as 'from'

We usually do not specify the from_address on enqueuing the notice, but
when sending it (from _send_message_by_email). That way a) the code is
centralized (as we must use $patron->notice_email_address) and b) the
email used is the one that is in the DB when the letter is effectively
sent.
Here I guess you need to give it when the notice is enqueued as you want
to default to the koha admin address.

I do not think it's a good idea, we should not send an email with "from"
if not really sent by the user.
We have the borrowernumber anyway to know who filled the form.

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>
Comment 180 Jonathan Druart 2020-04-03 13:09:30 UTC
Created attachment 102365 [details] [review]
Bug 4461: Use our local_referer instead of HTTP_REFERER

Cannot remember why exactly, but it seems that we should not use
HTTP_REFERER directly.

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>
Comment 181 Jonathan Druart 2020-04-03 13:09:43 UTC
Created attachment 102366 [details] [review]
Bug 4461: Redirect to 404 if KohaAdminEmailAddress is not defined

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>
Comment 182 Jonathan Druart 2020-04-03 13:09:55 UTC
Created attachment 102367 [details] [review]
Bug 4461: Simplify recipients code

As the feature is now turned off without KohaAdminEmailAddress, we only
need to check if the email address of the library if defined.
Not that we should not check for $library->branchreplyto or
ReplytoDefault, but only $library->branchemail, as we do everywhere else
(I think)

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>
Comment 183 Jonathan Druart 2020-04-03 13:10:09 UTC
Created attachment 102368 [details] [review]
Bug 4461: Better error handling

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>
Comment 184 Jonathan Druart 2020-04-03 13:10:21 UTC
Created attachment 102369 [details] [review]
Bug 4461: Remove hard requirement on OpacKohaUrl

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>
Comment 185 Jonathan Druart 2020-04-03 13:10:34 UTC
Created attachment 102370 [details] [review]
Bug 4461: Drop 'from_address' use 'reply_address'

This patch adds support for using the reply-to field added in bug 10269
and drops 'from_address' as it will get defined at a later stage in the
emailing process anyway.

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>
Comment 186 Jonathan Druart 2020-04-03 13:10:47 UTC
Created attachment 102371 [details] [review]
Bug 4461: Use get_effective_email from bug 22823

Use the get_effective_email from Koha::Library to get an appropriate
inbound address for the branch as aposed to using branchemail directly.

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>
Comment 187 Jonathan Druart 2020-04-03 13:11:02 UTC
Created attachment 102372 [details] [review]
Bug 4461: Adding user flags for managing OPAC problem reports

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>
Comment 188 Jonathan Druart 2020-04-03 13:11:15 UTC
Created attachment 102373 [details] [review]
Bug 4461: Add problem reports link to mainpage and admin home

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>
Comment 189 Jonathan Druart 2020-04-03 13:11:27 UTC
Created attachment 102374 [details] [review]
Bug 4461: Manage problem reports on the staff client

Test plan:

- Update database and upgrade schema files (if you haven't already).
Restart memcached
- Check your user's permissions and ensure the 'problem_reports'
permission is ticked. Confirm the OPACReportProblem syspref is enabled
- Log into the OPAC and submit a problem report
- Log into the staff client
- You should see a box at the bottom of the main page showing your
pending problem report
- Click the link and confirm it takes you to the new page for managing
problem reports
- Go to Administration
- Confirm you can see a link to 'OPAC problem reports' under the
'Additional parameters' heading
- Click 'OPAC problem reports'
- Confirm your problem report is showing in the table
- Open the OPAC in another tab and submit at least two more problem
reports (so you should have at least three in the table after
refreshing)
- Try the different buttons
    - selecting multiple problem reports and using the big 'mark
    viewed', 'mark closed', 'mark new' buttons. Confirm there are no
    failures and that the number of selected problem reports is correct
    - select all, clear all, hide viewed, hide closed, hide new, show
    all
    - individual 'mark viewed', 'mark closed', 'mark new' buttons for
    each problem report. Confirm the status shows and the correct button
    is disabled while others are enabled
- Confirm the problem page link works as expected

Sponsored-by: Catalyst IT
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>
Comment 190 Jonathan Druart 2020-04-03 13:11:41 UTC
Created attachment 102375 [details] [review]
Bug 4461: (follow-up) Add missing relationship accessor

I think this was a simple case of Aliesha missing a file when commiting.

So I could proceed with testing I just quickly re-implimented the patron
relationship accessor.

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>
Comment 191 Jonathan Druart 2020-04-03 13:11:54 UTC
Created attachment 102376 [details] [review]
Bug 4461: Update license statements

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 192 Jonathan Druart 2020-04-03 13:12:07 UTC
Created attachment 102377 [details] [review]
Bug 4461: Checks on library email before enqueuing letter

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 193 Jonathan Druart 2020-04-03 13:12:20 UTC
Created attachment 102378 [details] [review]
Bug 4461: DBIC Schema Files

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>
Comment 194 Jonathan Druart 2020-04-03 13:12:34 UTC
Created attachment 102379 [details] [review]
Bug 4461: Fix status and borrowernumber fields in problem_reports and more

status varchar(6) with readable statuses
borrowernumber not null default 0
hide form if message successfully sent
fixing hide viewed and hide closed filters
adding recipient column

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 195 Jonathan Druart 2020-04-03 13:12:47 UTC
Created attachment 102380 [details] [review]
Bug 4461: get_effective_email has been renamed inbound_email_address

On commit 027051c938924a33a64014794705526ab68351af
   Bug 22823: Rename method with ->inbound_email_address

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 196 Jonathan Druart 2020-04-03 13:13:08 UTC
Created attachment 102381 [details] [review]
Bug 4461: Fix OPAC link from staff

QA: We have a security issue here, we should not make this link
clickable from the staff side.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 197 Jonathan Druart 2020-04-03 13:13:25 UTC
Created attachment 102382 [details] [review]
Bug 4461: Hide link if KohaAdminEmailAddress is not set

opac-reportproblem.pl returns a 404 in that case

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 198 Jonathan Druart 2020-04-03 13:13:39 UTC
Created attachment 102383 [details] [review]
Bug 4461: dbic schema update

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 199 Jonathan Druart 2020-04-03 13:13:56 UTC
Created attachment 102384 [details] [review]
Bug 4461: Extend problem_reports.problempage to TEXT

255 chars is not enough if want want to store any kind of URL, for
instance an authorities search can be much longer

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 200 Jonathan Druart 2020-04-03 13:14:14 UTC
Created attachment 102385 [details] [review]
Bug 4461: Correctly deal with encoding/escaping chars

This patch deals (hopefully) correctly with encoding and escaping chars.
It also remove OPACBaseURL from the url stored in DB, and readd is on
display, to avoid possible attacks.

Test plan:
Go to the authority search
fill term with something hacky
<script>alert('booh!')</script>And Ŝ♥m€ E★tr₳
Search
Click the "Report a problem" link
Fill the form and make sure the url is displayed correctly
submit
Check problem_reports.problempage in DB => Should be correctly displayed
Go to staff interface, "OPAC problem reports"
=> Confirm the link is correctly display
Click it
=> Confirm that you are at the OPAC, and the URL is correct

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 201 Jonathan Druart 2020-04-03 13:14:28 UTC
Created attachment 102386 [details] [review]
Bug 4461: Use inbound_email_address to know if we display the dropdown list

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 202 Martin Renvoize 2020-04-06 11:22:28 UTC
Nice work everyone!

Pushed to master for 20.05
Comment 203 Joy Nelson 2020-04-29 20:18:29 UTC
feature not backported to 19.11.x
Comment 204 Tomás Cohen Arazi 2020-05-12 13:28:25 UTC
Nice job!