Bug 10925: fix LDAP auth failing if DEBUG is enabled

To reproduce:
1/ Edit your apache virtual host and set the DEBUG environment variable
(SetEnv DEBUG 1).
2/ Try to login with an ldap user
3/ You will be redirected to the 500 error page.
The Koha logs contains:
malformed header from script. Bad header=------------------------------: mainpage.pl

The hashdump routine directly prints to STDOUT (!) and breaks the
headers.
It appears Net::LDAP::?->dump does the same thing.

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>

Maybe we can kill C4::Utils after getting rid of this

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10965: fix breakage when loading sample itemtypes during install

Bug 10513 added two columns to table itemtypes,
but sample_itemtypes can't be loaded because
it relies on old structure.

This patch rewrites sample_itemtypes.sql, stating
explicitly columns, removing backticks and consolidates
all in one insertion.

To test:
1) On master with current DB structure, delete item types

2) try loading sample_itemtyes.sql
It fails with "ERROR 1136 (21S01) at line 1: Column count doesn't match value count at row 1"

3) apply patch

4) try again, this time it will load and itemtypes created

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
SQL change only.
Tested by running the web installer on an empty database.
All sample data loads without errors.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10949: restore ability to successfully print hold slips

This fixes a regression introduced by the patch for bug
9394 -- when printing a hold slip using the 'print and confirm'
button, the slip would contain only the text 'reserve not found',
not a full hold slip.

This patch also adds a regression test.

To test:

[1] Check in an item that would fill a hold.  Use the 'print
    and confirm button' to confirm the hold.
[2] The printout will only contain text to the effect of
    'reserve not found'.
[3] Apply the patch.
[4] Repeat step 1.  This time, a full hold slip should be printed.
[5] Verify that prove -v t/db_dependent/Reserves.t passes.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Pass all tests, new and old, and QA script.
Verified wrong and corrected behaviour.

Note: Sometimes there will not be the message 'reserve not found'
showing up, but hold information for a different record. This happens
when there exists a reserve_id with the borrowernumber of the patron
in question in your database.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10967: fix minor POD error

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

No koha-qa errors.
Fixes problem, but I think is better to remove
=back than to add nother =over 4, but I'm not
a POD expert

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 5645: improve converting simple search to Z39.50 search

This patch builds on the patch for bug 10742 by ensuring
that when a search initiated from the staff interface simple
search returns results, if you click on the Z39.50 search
button, the search form is populated with the search string
without "kw,wrdl".

To test:

[1] Perform a search in the staff interface that will return
    results.
[2] Click the Z39.50 search button.
[3] Observe that the search string appears in the title
    field in the Z39.50 search form, but with a prefix of
    "kw,wrdl".
[4] Apply the patch.
[5] Repeat steps 1-2.  This time, the search string appears
    without the index prefix.  This will make the Z39.50 search
    much more likely to work.
[6] Repeat steps 1-2, but with a search that does *not* return
    any hits in the Koha database.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10948: make reference labels translatable in OPAC auth results

For some reason the translator script was not picking up the see also
and used for/see from labels on the OPAC. This patch fixes the problem.

To test:
1) Apply patch.
2) Generate PO files.
3) Note that "see from" and "used for/see from" appear.
4) Sign off.

Signed-off-by: Nuño López Ansótegui <nunyo@masmedios.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works nicely, thx for the fix.
Tested by updating the German po files, translating the
strings and installing the templates.
Verified strings show up in German in the authority
result list.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10806: make the staff benchmark script check authentication failure.

Currently, if you launch the script
misc/load_testing/benchmark_staff.pl, it always displays
"Authentication successful" or continue to execute the script even if
nothing is done.

This patch checks if the url is right and if the authentication is
correctly done.

Test plan:
Suppose that a correct login/pwd is koha/koha
1/
perl misc/load_testing/benchmark_staff.pl --steps=1
--url=http://admin.koha.local/cgi-bin/koha/
--password="koha" --user="koha"
should produce:
  Authentication successful
  ...
  Step 1
  ...

2/
perl misc/load_testing/benchmark_staff.pl --steps=1
--url=http://admin.koha.local/cgi-bin/koha/
--password="KOHA" --user="KOHA"
should produce:
Authentication failure: bad login/password

3/
perl misc/load_testing/benchmark_staff.pl --steps=1
--url=http://admin.kobe.local/cgi-bin/koha/
--password="koha" --user="koha"
should produce:
Authentication failure:
    500 Can't connect to admin.kobe.local:80 (Bad
    hostname)

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Comment: Works as described, detects bad url and user credentials.
No koha-qa errors

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described and gives better error messages.
There are some warnings output when running the script before
and after applying the patch.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10927: remove disused C4::Utils module

Bug 10925 removes the last call to C4::Utils.
The module becomes useless and can be deleted.

Verify that t/db_dependent/Context.t still successfully passes.
git grep hashdump
git grep maxwidth

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Passes koha-qa.pl, no subs from the module are used anywhere

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10419: new cronjob for deleting patrons

This patch provides a cronjob script for deleting patrons.

It takes 3 options:

--not_borrowed_since
--expired_date
--category_code

See the perldoc misc/cronjobs/delete_patrons.pl.
Use the -v flag for a verbose mode.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10419: (followup) - tidy up cronjob for deleting patrons

This followup adds:
- execute flag (+x) for the cronjob script.
- replaces --dry-run with --confirm (according with existing scripts).
- changes output text (remove 'first person' style).
- updates the doc and simplifies the dates parameters.
- changes flags PrintError and RaiseError for the dbh in order to catch
  something if an error occurs...

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10419: (follow-up) add branchcode parameter to patron deletion script

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10419: (followup) fix license statement

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10419: (follow-up) tidy names of command-line switches

[1] Use --library instead of --branchcode to be consistent
    with other scripts and user-facing Koha terminology.
[2] Use --not_borrowed_since instead of --not_borrowered_since;
    no need to expose typos in the API to the user.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10419: (follow-up) functional improvements

[1] Patron deletion now happens atomically; if one part
    of the process fails, the record isn't left in a
    partially deleted state.
[2] The routine for handling lists properly during patron
    deletion is now invoked.
[3] The script now prints an indication if it's run
    without --confirm; otherwise, one might think that
    patron records were actually being deleted.
[4] --verbose now actually does something.

Without --verbose, the script will print the dry-run
warning (if applicable), the number of patrons to be
deleted, and error messages.

With --verbose, the script will also print a line with
the borrowernumber of each patron to be deleted.

To test:

[1] Run the script with and without --verbose and compare
    the, well, verbosity.
[2] Run the script without --confirm and note that the script
    prints a message saying that it's running in dry-run mode.
[3] Use the script to try to delete one or more patrons that have
    loans.  Confirm that error messages are printed reporting
    foreign constraints preventing the deletion.  Also confirm that
    no new rows are added to deletedborrowers for those patrons that
    could not be completely deleted.
[4] Use the script to delete a patron that has a public list.  Verify
    that after the deletion, the public list still exists but now
    has a null owner.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10419: (follow-up) fix hardcoded records and pod

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Missing a sign. Removes harcoded values

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10419: (follow-up) patrons with fines should not be deleted

Test plan:
- add a fine for a patron
- verify the script does not delete this patron.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Works, script do not delete a patron with fines.
No koha-qa errors with all patches applied

Test
1) Added a fine to a patron
2) run script
3) reports condition
Trying to delete patron 5... Failed to delete patron 5: patron has 10.00 in fines
4) Patron is not deleted

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Passes all tests and QA script.

Tested various combinations of options:
./delete_patrons.pl
  Gives a helpful message about the use of the script.
./delete_patrons.pl -h
  Outputs useful information about the use of the script
  and its various options.
./delete_patrons.pl --category_code ST --library CPL
  Gives the correct results in numbers and deletion was done
  properly.

Also tested:
  --expired_before
  --not_borrowed_since
  -v

Testing various conditions where a delete should not occur:
- Patron has checkouts
  Patron is not in list of patrons to delete (x patrons to delete)
- Patron has fines
  Patron is still in list of patrons to delete (x patrons to delete)

Checked deleted patrons had been moved to deletedborrowers.

Notes about possible enhancements:
- only print the success message 'x patrons deleted' when confirm
  flag was set
- patrons with current checkouts are silently excluded from the number
  of patrons to be deleted. Printing the number with current checkouts
  might be helpful.

Changes made:
  Fixed a small error in the documentation: expired_date is expired_before.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
bug 10419: (follow-up) improvements to the usage text

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 9611: Change the password hashing algorithm from MD5 to Bcrypt

What this patch aims to accomplish?

 * All new passwords are stored as Bcrypt-hashes
 * For password verification:
     - If the user was created before this patch was applied then use
        MD5 to hash the entered password <-- backwards compatibility
     - If the user was created after this patch was applied then use
       Bcrypt to hash the entered password
 * Any password change made via the staff interface or the OPAC will
   be automatically Bcrypt-hashed; this applies to old users whose
   passwords were stored as MD5 hashes previously

Test plan:
  1) Add new users and check whether their passwords are stored as
     Bcrypt hashes or not.
  2) To test that authentication works for both old as well as new
     users:
       a) Login as an existing user whose password is stored as a
          MD5 hash
       b) Login as an existing user whose password is stored as a
          Bcrypt hash
  3) In the staff interface, change the password of an existing user
     whose password is stored as an MD5 hash
	a) Check the new password is stored as a Bcrypt-hash in the database
	b) Try to login with the new password
  4) In the OPAC, verify that
    a) Old user with old pass can change password, new format
    b) New user with new pass can change password
    c) Old and new user with self-updated pass can login

Whitespace cleanup was contributed by  Bernardo Gonzalez Kriegel.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Mason James <mtj@kohaaloha.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 9611: add Crypt::Eksblowfish::Bcrypt to list of Perl dependencies

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Mason James <mtj@kohaaloha.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
bug 9611: Extract checkpw_internal() and checkpw_hash() from checkpw()

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>