Bug 11960: replace unnecessary call of GetMemberDetails by CanBookBeRenewed

C4::Circulation::CanBookBeRenewed called C4::Members::GetMemberDetails to
retrieve categorycode and branchcode.

- categorycode is used to retrieve the issuing rule
- the borrower information is passed to
  C4::Circulation::_GetCircControlBranch. Which only uses the branchcode
  parameter.

GetMemberDetails does a lot of calls/queries (patronflags,
account, etc.) that are not needed by CanBookBeRenewed.

This patch replaces it with a call to C4::Members::GetMember.

Note: I presented this small optimisation during a quick introduction to
NYTProf (hackfest 14 in Marseille).

Test plan:
- launch member unit tests
- check the code

Checking the code resulted in the following:
CanBookBeRenewed builds a hash reference from the borrowernumber
(2482). Note it is only used in this function and not passed in.

_GetCircControlBranch (2485) requires that hashreference to
have a branchcode key. As stated above.

The following line (2486) requires it have a categorycode key.

As such, C4::Members::GetMemberDetails is confirmed to be
overkill, and C4::Members::GetMember is sufficient.

Testing Done
------------
0) Back up DB
1) Make sure MPL is in the list of libraries.
2) Apply the patch.
3) run the koha qa test tool
4) prove -v t/db_dependent/Circulation.t

Patch applies cleanly. QA Test tool was all OK. All tests ran successfully.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 9132f9befb36f32fc35a511c3829c224b42893bf)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 12076: better detect an untranslatable template construct

Per bug 6458, template constructs of the form

<li [% IF (foo) %]selected="selected"[% END %]...

are forbidden as they can cause problems with translated templates.
However, the tt_valid.t test currently doesn't catch the variation
where '-' is used to suppress extra whitespace:

<li [%- IF (foo) -%]selected="selected"[%- END -%]...

This patch corrects the issue.

To test:

[1] Temporarily add the following line to a template file:

<li [%- IF a -%]a="a"[%- END -%] />

[2] Run prove -v xt/tt_valid.t.  Note that no error is reported.
[3] Apply the patch, and rerun the tt_valid.t test.  This time,
    an error should be reported.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Works well, detects the forbidden pattern
No koha-qa errors.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described, passes all tests and QA script.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 9a7eedce78af128772a36b5a16416fdad1a16fcc)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 12069: redirect to staff login if you access members/mod_debarment.pl when logged out

members/mod_debarment.pl's call to checkauth should pass 'intranet' so
that if the user happens to be logged out they will be redirected to the
staff client login form, rather than the OPAC.

To test, apply the patch and log in to the staff client:

- Add a restriction to a patron's account.
- View the restrictions tab on the patron's account. You should see the
  restriction and a "Remove" link for that restriction.
- In another tab, log out of the staff client.
- In the first tab, click the "Remove" link. You should be redirected to
  the staff client login page.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Good catch! Works as described, passes all tests and QA script.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit cbcfb847e0022f79b82f0601c955ae085917d377)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 12073: don't show link URLs when printing Bootstrap OPAC detail page

On OPAC Bootstrap detail page, by clicking Print link on the right the
page is printed. But the printed page contains HTML <a> anchors URL
attribute. It's useless, and unreadable. It isn't the case with prog
theme.

This patch hides all <a> href attributes when printing any OPAC page.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described and improves the printed detail page's readability.
Currently there is no less file for the print.css.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit fe8242fc0383f9bafe1ead9033926c405ee5dfbe)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 7143: Updating history with new developers

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit c52b086d38cde98504457aa9f40f65ba20bbfbe1)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 12075: fix keyboard shortcuts broken by jQueryUI upgrade

The recent jQueryUI upgrade broke keyboard shortcuts in the staff client
because of changes to the jQueryUI API. This patch fixes the problem.

To test, apply the patch and clear your browser cache if necessary.

- View any page in the staff which includes header search tabs for check
  out, check in, or catalog search (staff client home page or
  circulation page for instance).
- Test the keyboard shortcuts: Alt-q for catalog search, Alt-u for check
  out, Alt-r for check in.
- Each keyboard shortcut should select the correct tab.

Followed test plan, patch behaves as expected.
Signed-off-by: Marc Véron <veron@veron.ch>

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.
Confirmed that the shortcuts were broken before the patch
and now work again after applying it.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit dcca71f0befa92d2212855aecfc0f473b6304832)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 5052: make it possible to pick a language if all choices are sublanguage

This was tricky to catch. In current implementation, Bug 6755
introduced in C4/Templates.pm as condition to send the array of
hashrefs of languages that (@$languages_loop<2), but with one
language group that condition is false, there is only one
element in that array.

This patch changes that condition to have more than one language
selected, grouped or not.

Also send $bidi value always, that was only sent if there is
more than one group language.

To test:
1. Translate to en-GB and en-NZ, or simply do mkdirs
on intranet-tmpl/prog and opac-tmpl/bootstrap

2. Go to Administration > System preferences > I18N
enable those languages on staff/opac

3. Check that language chooser is nowhere to be found

4. Apply the patch

5. Reload staff/opac, now you can see language chooser

NOTE: I made little changes on staff, but can't replicate
bootstrap colors for selected/unselected language. Someone
need to touch css files to make it happen. But that is
current behavior.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Good catch!

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit c212b9328edd69a8e8f5082674a9f29741d159ee)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11797: add regression test

This patch adds unit tests for C4::AuthoritiesMarc::BuildSummary
for both UNIMARC and MARC21 and a regression test for the "Odd
number of elements in anonymous hash" warning.

To test:

[1] Run prove -v t/db_dependent/AuthoritiesMarc.t.  It should
    report one failure.
[2] Apply the main patch.
[3] Run t/db_dependent/AuthoritiesMarc.t again; it should pass.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit f2b655dfabc4a4464099e7d9bc219b6714ef7de1)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11797: fix odd number of elements in hash warning (MARC21)

This was discovered when someone triggered an authority search
on an authority record that was missing what is assumed the
default subfield for a given field.

It, however, also can be triggered in an OPAC authority search
by looking at the record that lacks the default subfield for a
given field.

TEST PLAN
---------
1) Create an authority record with 180$x and NOT 180$v.
   See C4::AuthoritiesMarc::BuildSummary in the 1.. foreach loop
   for known tags and default values. The default subfields are
   the first letter of the $subfields_to_report string.
2) Trigger the bug:
   Method 1: /cgi-bin/koha/opac-authoritiesdetail.pl?authid=#
             Where # is the authority id of your tweaked record.
             The error occurs in Normal view.
   Method 2: Home -> Cataloging -> + New record
                  -> Click the 'Tag Editor' on 100$a
                  Editing of $a to $b and back may be required.
3) Notice there is an error log entry.
4) Apply the patch
5) Attempt to trigger the bug again
6) That specific error log entry is not generated.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Could generate the warning with a missing 151$a with both methods.
No warning anymore after applying this patch.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 129bc3281180d892659d3ad1ef253fbc7ec6f316)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11797: fix odd number of elements in hash (UNIMARC)

I got the same warning for my UNIMARC DB.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit fa989631f6b6f2d4a6dc86e8b9535bd9ce786c1e)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11797: (follow-up) fix MARC21 branch of bug more idiomatically

This patch puts the MARC21 variant of the bugfix in alignment
with the UNIMARC variant, removing the use of unnecessary
temporary variables.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit cc7a99ba7f23c7f77bb28c23613fbd9b4ab61cd5)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 10825: don't display enum/chron twice for items received via the serials module

TEST PLAN
---------
1) In the staff interface, display a bib that has one or more items
   that were received in the serials module.  The following query
   can identify them:
   -- in MySQL:
      SELECT items.biblionumber,items.enumchron,serial.serialseq
      FROM items,serial,serialitems
      WHERE items.itemnumber=serialitems.itemnumber
        AND serialitems.serialid=serial.serialid;
2) Note that in the holdings tab, the serial enumeration/chronology
   is displayed twice.
3) Apply the patch
4) Refresh the screen
4) Now, the enum/chron should be displayed only once per item.

Signed-off-by: Mason James <mtj@kohaaloha.com>
Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described, passes tests and QA script.
Template change only.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 3f5636cac39ca1109a73b40be08d9dbef096a17c)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 12052: New syspref to display message on the OPAC patron summary page

Test plan:

Fill the OPACMySummaryNote with HTML code or just text.
The content should be displayed at the OPAC on the summary page for
patrons.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Work as described. No koha-qa errors

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described, passes tests and QA script.
Rephrased the pref text a little bit, using 'logged in' instead of
'connected', also added " so the description appears correctly in the
pref editor.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit f82d22b0df63e2924e9c8b35d2a4eb02edc2650e)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 12052: DBrev 3.14.09.001

Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 12081: make tmpl_process3.pl delete ts temp files

This patch enable deletion of temp files used by
tmpl_process3.pl.
Just removed coments on existing code

To test:
1. Do a count of files on /tmp ( ls /tmp | wc -l )
2. Update preferred language
3. Count again, new files on /tmp
4. Apply the patch
5. Update again, check, no new files

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>

NOTE: I watched what temp files were actually in /tmp to make
      sure other processes didn't magically increase/decrease
      the number.
          $ perl translate update {lang code}
      generated 10 temporary files for me (2x5 po files). After
      removing those ten files, and applying the patch, no
      other files were generated.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
These lines has been commented by commit
a399dcefad193fc21ef2dc1fe31d07686ab2da46 without any apparent good
reason.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit de81d7abe43f3c2eed327b52e212bc790b406961)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11484: Add option to cleanup_database.pl to purge Z39.50 search records from reservoir

It would be good to be able to specifically target import records from
Z39.50 for cleanup.

Test Plan:
1) Apply this patch
2) Import one or more batch record sets into Koha
3) Perform some Z39.50 searches
4) Run this command: misc/cronjobs/cleanup_database.pl -v --z3950
5) Verify that only Z39.50 records were deleted

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit f796d1002a39cd714433a219b35eefbce31b02d8)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11484: (follow-up) standardize capitalization of "Z39.50"

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 5492d82bc2aa9c884fe67810ddb3cd08c83910fe)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 12058: make OverDrive search results page show cart, lists, and login links

The template for OverDrive search results in the Bootstrap OPAC doesn't
show the cart, lists, or login links because the template's checks of
related system preferences relies on [% USE Koha %], which is not
present. This patch adds it.

To test, enable the bootstrap theme and OverDrive integration
(OverDriveClientKey, etc.). Perform a search in the OPAC and click to
view results from your OverDrive library. Confirm that cart, lists, and
login links appear in the header.

Signed-off-by: Jesse Weaver <pianohacker@gmail.com>
Bug confirmed, and this patch fixes it.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit b1e09cb0fa900964200f224cad771d95062bc48d)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11258: fix another case where holds queue made transfer requests that contradict the library holds policy

This patch fixes a problem where the holds queue generator
was making requests where the pickup library is the
same as the item's library but not the patron's branch,
even if there is a "Default holds policy by item type" rule that states
this item can only fill holds for patrons of the same library as the
item.

Test Plan:
1) Create a test record with 2 items with different itemtypes
2) Set the Default holds policy by item type for the first
   item to "From any library"
3) Set the Default holds policy by item type for the second
   item to "From home library"
4) Place a record level hold for a patron from another library,
   but for pickup at the same library as the item is from
5) Rebuild the holds queue
6) View the holds queue, note the item is listed, though this
   patron cannot place a hold on this item
7) Apply this patch
8) Repeat step 5, note the hold is no longer in the queue

Signed-off-by: Liz Rea <liz@catalyst.net.nz>
automated tests pass, functional tests pass. Bug replicated, eradicated by patch.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
I finally managed to reproduce this, patch works as described.
Passes tests and QA script, provided tests fail without patch, but
succeed with the patch.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit 79660377470e8d6ba9057eb59645886410852c92)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
Bug 11955: Remove spaces in empty indicators when linking an authority to a biblio record.

This patch removes spaces in indicators which are imported when we link an
authority to a biblio record. The spaces made the indicators harder to edit
after the linking, because we had to delete the superfluous space character
before a new value could be entered.

To test:
1. Open some authority on editor, save with empty indicators.
   They are saved as ind1=" " ind2=" " on auth_header tables, with spaces
2. Edit some record, link some tag with previous auth,
   indicators now have a space on it (or ind1 at last)
3. Apply the patch
4. repeat 2, space is gone

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Work as described. No koha-qa errors.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
(cherry picked from commit afc9549a6f58ddf36cf6d9a5399239385c377c90)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>