Bug 10058 - Fix unapi for NORMARC

This patch uses a lot of MARC21 XSLT to transform NORMARC records
to desired formats. Since NORMARC is mostly a subset of MARC21, I
think this should give passable results. And better results than
no unapi-support at all for NORMARC!

To reproduce:
- Make sure you have marcflavour = NORMARC
- Visit /cgi-bin/koha/unapi in a browser
- Observe the empty <formats></formats> element

To test:
- Apply the patch
- Visit /cgi-bin/koha/unapi in a browser
- Observe the the list of formats in the <formats></formats> element
- Import the provided sample NORMARC record and make a note of its
  biblionumber
- View the record at /cgi-bin/koha/unapi?id=koha:biblionumber:x&format=y
  where x = the biblionumber of the sample record and y = one of the
  formats marcxml, marcxml-full, mods, mods-full, mods3, mods3-full,
  oai_dc, rdfdc, rss2, rss2-full and srw_dc
- Check that the transformed records make some kind of superficial
  sense

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit c5e2c06a791f97f39cc2e93fa0092de6eaa9cb07)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 10074 - Encoding problems at login time

Bug 6554 patched output_html_with_http_headers to encode utf8 data, and Templates.pm to expect utf8 data to be encoded.
(At least) the staff login screen outputs directly to STDOUT (Auth.pm does, WHICH IS WRONG!) and wasn't fixed to do the encoding first.

This patch makes it use output_html_with_http_headers and solves the problem.

Changed 'use' for 'require' as jcamins and marcelr suggested.

Regards
To+

Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit 5805b5f363bd657d3dac6aeba225438bf80cae9b)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 10074 - Encoding problems for installer

Bug 6554 patched output_html_with_http_headers to encode utf8 data, and Templates.pm to expect utf8 data to be encoded.
The Installer page login screen outputs directly to STDOUT (InstallAuthAuth.pm does, WHICH IS WRONG!) and wasn't fixed to do the encoding first.

This patch makes it use output_html_with_http_headers and solves the problem.

Regards
To+

Sponsored-by: Universidad Nacional de Cordoba
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit d0c6e09429d2af711f911b57601a02f17591d441)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 10074: QA Followup for InstallAuth.pm

Moving use Output.pm to optional require.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit e848d89e45d3e6610c3e9d246bd3672636dd63fb)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 10019: Fix for userid containing UTF8 chars

Decodes userid on two places in checkauth of C4/Auth.pm

Test plan:
Include some non-Latin characters in your userid (loginname). Arab, Chinese?
Login into opac and check user page.
Go to staff (no new login), check your login name at various places.
Logout, login via staff.
Do the same.
Go to opac again (no new login), check user page.
Optionally: Remove all your sessions from table. Do a login. Check sessions.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>

Comment: Works as described. No errors.
This patch fixes this problem, but I wonder if
there is a general solution that handle all as utf8.
Tested in opac and staff.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit 7e90e1524f7e586dac0f98241ace430e5cbeac7f)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 10072 - "my suggestions" always says "There are no pending purchase suggestions."

Test Plan:
1) Switch off the IndependantBranches syspref
2) Log into the OPAC
3) Place a suggestions
4) Instead of seeing your suggestion, you will see "There are no pending
   purchase suggestions."
5) Apply this patch
6) Reload the page
7) You should now see your suggestions

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit fd9534628b0234375688e031fc65d4aee3bbd091)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 9951: Followup for Tools

Adds decoding for Patron Cards/Patron Search and Tags (moderation).

Test plan:
Goto Tools. Add accent with diacritics in both areas. Check if you do not see
converted characters.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit 252568aa8babdcc9508d3b3c7626543bfa648d99)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 9951: Followup for tools/viewlog.pl

Adds utf8 cgi parameter decoding.

Test plan: Enter diacritics in librarian field. Submit. Check.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>

This is ok in this case, as we are not doing any post/get of binary
data, but I note from the man page

This makes CGI.pm treat all parameters as UTF-8 strings. Use this with
care, as it will interfere
with the processing of binary uploads. It is better to
manually select which fields are expected
to return utf-8 strings and convert them using code like
this:

  use Encode;
  my $arg = decode utf8=>param('foo');
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit de7ba790fd2533bcf44ad7fd2f1255514ed9313c)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 8746: rebuild_zebra_sliced.sh now export/index records as MARCXML

This avoid indexing failures due to "bad offset" or "bad length" error
with ISO2709 format

+ minor improvements:
  -  --length parameter is optional. If not given, it will execute the
     right sql query to find the number of records to index
  -  new parameter --reset-index. If set, index is reset before indexing

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

Test: Edit record to make it longer than 9999. Without patch rebuild_sliced
fails. With patches works.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit eef4b3f23c0b4558bd2a87af009f39012393994c)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 8746: Fix indexation in DOM index mode

When in DOM index mode, files exported by `rebuild_zebra.pl -x` are
wrapped by '<collection></collection>' tag.
This is a problem because splitting files produces invalid files.
This is fixed by adding the missing <collection> tags in each generated
file.
Another problem was that the wrong zebra configuration file was used.
The script now uses C4::Context->zebraconfig($server)->{config} to know
which configuration file has to be used.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit a4e844369106f0713123c8a2ecec12b0ed7b0027)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 8746 [Follow-up] Replace == by eq in string comparison

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
All tests and QA script pass.
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit 357cf7fdd850008e4c4f94a4d8d115490a3f4262)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 9860 [Alternate] Incorrect box heading 'Cannot check in' when a late document is returned

The fix for Bug 9397 moved the "cannot check in" heading from within the
one conditional where it should have been displayed to the top of all
check-in errors/messages. "Cannot check in" is still only valid if the
item is withdrawn and BlockReturnOfWithdrawnItems is ON.

In order to accomplish the goal of Bug 9397 while fixing Bug 9860 this
patch puts "cannot check in" back into the correct conditional and adds
a generic heading to check in messages for accessibility purposes.

To test, check in items which will trigger a variety of errors
including:

- item must be returned to home library
- item is lost
- item is withdrawn (wtih BlockReturnOfWithdrawnItems on and off)
- item is overdue

...as well as items which should check in normally. Messages should
display correctly.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit 3ce75bcf2631bccb584dff6ea2f78d16f49770f8)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 10046: Standardize terms used in invoices

Changes are:
budget > where actually fund is meant
branch > library
bookseller, supplier > vendor

To test:

1) Receive a shipment, check the little form where you
   enter your invoice number for correct use of terms.
2) Receive some orders and save finish receiving.
3) Search for your created invoice. Check filters and
   results table for correct use of terms.
4) Look at the details of your invoice, repeat check there.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit 9a67617eaffc8427441c1270e9b0acd0a7d2f33d)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 9613: items namespace missing in XSLT

In some XSLT, "items" namespace is used in exclude-result-prefixes but is not defined.

This patch add this namespace where missing.
Also corrects a koha.org, instead of koha-community.org, in one namespace URL.

Test plan :
- Enable XSLT on search results
- Perform a search
=> Look at error logs to check that there is no xsl error like :
[Fri Feb 08 15:35:06 2013] [error] [client 127.0.0.1] [Fri Feb  8 15:35:06 2013] opac-search.pl: compilation error: file koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslimUtils.xsl line 8 element stylesheet, referer: http://opac.master.community.localhost/cgi-bin/koha/opac-detail.pl?biblionumber=299
[Fri Feb 08 15:35:06 2013] [error] [client 127.0.0.1] [Fri Feb  8 15:35:06 2013] opac-search.pl: xsl:exclude-result-prefixes : undefined namespace items, referer: http://opac.master.community.localhost/cgi-bin/koha/opac-detail.pl?biblionumber=299

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Mathieu Saby <mathieu.saby@univ-rennes2.fr>
Passed-QA-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
With comment on Bugzilla.

Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit 00b587e5ccc3de4d457eef45008ce9741146ab13)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 8745 - Disallow rebuild_zebra.pl from executing, when run by root user.

Added a check to warn users of execution as root user.
Added a 'runas-root' switch to allow users to force execution as root user.

Signed-off-by: Mason James <mtj@kohaaloha.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit ef86a77801ea42eb1f703a77f53123ccb924a9fe)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 8745: General whitespace and tab tidy

http://bugs.koha-community.org/show_bug.cgi?id=8745
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
1) Runs not with root.
2) Runs with root and -run-as-root.
3) Runs using the normal koha user.

Note: Maybe the message should be clear about why
running as root is bad and which user you should
be running the script with?
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit 2eefd1f3a588532950bed42ff20fcb6ff3f932a3)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Add Barry Cannon to the history file

Welcome, Barry, you are the 208th developer with a patch in Koha!
(cherry picked from commit d2c989713999cab4a7b4bf7ea69e2d7d036e876c)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 10065 - Style invoice edit form according to standard structure

The structure of the invoice edit form does not match that of similar
forms in the staff client. This patch alters it to be consistent.

To test you must also have the patch for Bug 10046 applied.

Go to Acquisitions -> Invoices and search for invoices. Click an invoice
to view/edit details. The form displaying fields for shipment date,
billing date, etc. should look correct and work correctly.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit 6e88f5c736689cab23561e3f8be968e973f52c61)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 9995 - For reference items no longer listed in XSLT result lists

Re-added the xsl that shouldn't have been removed.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Tested with different settings for OpacItemLocation
and not for loan set in the item and for the item type.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit cbe3e7656d9050dbebb6224f7f7c5fb419a2e6c3)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
Bug 9839 - when importing MARC records, item record not created even when set to "always add"

Test Plan:
1) Catalog a new record with an ISBN
2) Add some items to the record
3) Download the record as MARCXML
4) Delete the itemnumbers from the 952 fields in the record,
   Change the barcode fields to unused barcodes
5) Use xml2marc to save as a standard MARC file
6) Import the record using the 'Stage MARC for import' tool
   Use the settings:
       Record matching rule: ISBN
       Action if matching record found: ignore
       Action if no match found: ignore
       Item processing: always_add
       Check for embedded item record data?: Yes
       How to process items: Always add items
7) Import, note the bib is ignored, and the items are not processed
8) Undo import into catalog
8) Apply this patch
9) Import this batch into the catalog
10) Note the items were processed and are now added to the matching
record

Signed-off-by: Mathieu Saby <mathieu.saby@univ-rennes2.fr>
Tested with UNIMARC record. I followed the test plan, just changing 952 by 995
Signed-off-by: Mason James <mtj@kohaaloha.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
(cherry picked from commit a986c92c4d92da6fb1bba330cf693dde31207877)

Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>