Bug 12032: disable automatic URL conversion by TinyMCE in news

To test:

* create a news item with a link in it that is within the same domain

example: my koha was at http://demo.mykoha.co.nz, I created a link in a
news item to http://demo-intra.mykoha.co.nz

* note that when the item is saved, the url changes to ../../../../ (or
something like)

* apply the patch

* edit the link again, and save it

* note that the link is saved correctly

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
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 12024: fix add to list opening the list adding UI in two windows

In Item details, when using the menu toolbar for Add To > List,
the list adding UI opens in a popup window, and also in the original
window. The original window should stay showing the item details page.

This patch corrects this behavior, which has been observed in Chromium
on Ubuntu and Chrome on Windows.

Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com>
Works fixing problem. No koha-qa errors.

Test:
1. On staff, go to detail of some biblio,
click add to List, described behavior

2. With patch applied, original windows stay on item detail

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

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 11850: Add -append option to bulkmarcimport.pl to append to logfile

Signed-off-by: Magnus Enger <digitalutvikling@gmail.com>
Keeps current behaviour as default.
The -append option is described in the POD and works as expected.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as described.
Adding a date/time to the output might
be good, to make it easier to find the entry you were looking for.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 11570 - Upgrade jQueryUI to latest version in the staff client

This patch upgrades the version of jQueryUI included in the Koha staff
client from v1.8.23 to v.1.10.4. The upgrade introduces a few minor API
changes which require the updates in this patch:

- In CSS, the term "active" is used instead of "selected"
- Autocomplete functions use slightly changed parameters

Changes to the default jQueryUI CSS allows us to remove some instances
of "!important" from jQueryUI-related CSS in the staff client's main CSS
file.

To test:

Testing changes to autocomplete:

- Enable the CircAutocompl system preference. Try searching in the
  header's "Check out" tab. Autocomplete should look correct and
  function correctly.

- In Circulation -> Overdues: The patron attribute authorized value
  filter (must have patron attributes enabled, and a patron attribute
  defined which uses authorized values.

- Course reserves -> Course -> Edit: Searching for an instructor

- In the unimarc_field_210c_bis.pl plugin:
  1. Link the publisher name field in your MARC structure to
     the unimarc_field_210c_bis.pl plugin.
  2. Open a MARC record for editing and click the "tag editor" link to
     launch the plugin.
  3. Type the first few letters of a publisher which exists in your
     database. You should get an autocomplete menu of publishers
     which match your search.
  4. Select one and click the "choose" button to fill the field in the
     MARC editor.

- Tools -> Patron lists: Add a list or choose an existing list and add
  patrons. Perform a search for a patron.

- Placing a hold: After choose a title and clicking "Place hold,"
  search for a patron.

- Tags management: The sidebar filter for "reviewer" should let you
  search by patron name.

Other jQueryUI widget changes:

- Check tabs appearance in header search, biblio detail, cataloging, and
  circulation patron fines pages.

To confirm other jQueryUI widgets still function correctly:

- Check accordion (collapsing sections) in Patrons -> Patrons requesting
  modifications and the MARC subfield structure edit screen.

- Check datepickers, especially in Circulation with the added timepicker.
  Test a linked datepicker, for example in Reports -> Stats wizards ->
  Circulation where the value in one date field affects what dates are
  available in the matching field.

- Check the calendar interface in Tools -> Calendar

To confirm that the new jQueryUI default CSS is more flexible (fixing
Bug 11042), add the following CSS to your IntranetUserCSS system
preference and confirm that the header search active tab border color
changes (hash mark escaped so that it will appear in commit msg):

\#header_search ul.ui-tabs-nav li.ui-tabs-active {
  background-color: #FFFFF1;
  border: 1px solid #800000;
  border-top: 0 !important;
  top: -2px;
}

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 10790: fix misalignment in item type form when noItemTypeImages is off

This patch fixes the odd behavior when noItemTypesImages is set
to 'Don't show'. Just a misplaced </div>

To test:

1) Set syspref noItemTypeImages to 'Don't show'
2) Go to Admininstration > Item types
3) Edit some item type, you will view a display
similar to the attached image
4) Apply the patch
5) Reload the page, now the display is fixed
6) Change syspref to 'Show' to check that
the display is also good

Also fixed a missing '/' on a closing select

Signed-off-by: Mark Tompsett <mtompset@hotmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567: add tests for C4::NewsChannel

Testing was lacking, this tests every function call. As a
side effect, this moved the stub of a test file from
t/NewsChannels.t to t/db_dependent/NewsChannels.t, since the
table opac_news must exist.

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

Passes all 8 tests

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567: (code cleanup) update license and use Modern::Perl

Grabbed the current license from
  http://wiki.koha-community.org/wiki/Coding_Guidelines#Licence
and changed the use strict; use warnings; into a
use Modern::Perl instead.

TEST PLAN
---------
1) Log into staff client.
    - Does news look okay?
2) Apply patch
3) Refresh staff client.
    - Does news look the same?

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

Safe no op action

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567: (code cleanup) update License tools/koha-news.pl

Updated license text using
    http://wiki.koha-community.org/wiki/Coding_Guidelines#Licence
for the base text.

TEST PLAN
---------
1) less tools/koha-news.pl
2) apply patch
3) less tools/koha-news.pl
    - was any contributor information lost?

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

Safe no op action

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567 - Clean up sample news files

Some files had truncate. Some files had foreign key checks.
Other files had foreign key checks disabled. Some files gave
the column names expressly, and others assumed the fields in
a particular order. Everything was modified to:
- not truncate
- not say utf8 (because it should already be by default)
- not disable foreign key checks (because it should work)
- expressly name the fields (adding fields shouldn't break it)

TEST PLAN
---------
0) Backup opac_news if you care about your news.
1) open mysql client
2) use the koha database
3) Run the following script
TRUNCATE opac_news;
source ~/kohaclone/installer/data/mysql/uk-UA/optional/sample_news.sql
source ~/kohaclone/installer/data/mysql/it-IT/necessari/sample_news.sql
source ~/kohaclone/installer/data/mysql/de-DE/optional/sample_news.sql
source ~/kohaclone/installer/data/mysql/nb-NO/2-Valgfritt/sample_news.sql
source ~/kohaclone/installer/data/mysql/en/optional/sample_news.sql
source ~/kohaclone/installer/data/mysql/pl-PL/optional/sample_news.sql
source ~/kohaclone/installer/data/mysql/es-ES/optional/sample_news.sql
source ~/kohaclone/installer/data/mysql/ru-RU/optional/sample_news.sql
source ~/kohaclone/installer/data/mysql/fr-FR/2-Optionel/sample_news.sql

- Were there errors?
- Did everything add nicely?
    - Not likely, by expressly stating the idnew field, the news
      items in some files would not be added.

4) apply patch
5) try running the script again

- Were there errors?
- Did everything add nicely?
6) Log into the staff client
7) Tools->News
- Do you see the news items added?

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

Much needed clean up, making for much more robust and less error prone
sql

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567: (code cleanup) remove excess line

The template parameter { $lang => 1 } does not seem used in
master. It is unconfirmed whether this is used in earlier
versions of Koha.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567 - Correct Filtering and Default dropdown values

In the staff client, when you went to Home -> Tools -> News
the default 'Display location' is 'All'. Everything is correctly
displayed. However, if you change the filter it filters the
table correctly, but does not set the dropdown value to match.
This patch corrects this.

TEST PLAN
---------
 1) Home -> Tools -> News
 2) Change 'Display location' value and click 'Filter'.
    - Is the 'Display location' value the same now?
      (no)
    - Are the correct values displayed?
 3) Click 'New entry'
    - Is it anything other than 'All'?
      (no, and is this correct?)
 4) Click 'Cancel'
 5) Click 'Edit' for various news items with different locations.
    - Does the 'Display location' get proper set?
      (no)
 6) Apply patch
 7) Change the 'Display location' value and click 'Filter'.
    - Does the 'Display location' value stay the same?
      (this should be correct now)
    - Are the correct values displayed?
 8) Change the 'Display location' value to 'All' and click 'Filter'.
    - Does everything display?
 9) Change the 'Display location' value and click 'Filter'.
10) Click 'New entry'
    - Does it match what the filter was?
      (should match now)
11) Click 'Cancel'
12) Click 'Edit' for various news items with different locations.
    - Does the 'Display location' get proper set?
      (this should be correct now)

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567: (code cleanup) remove finish calls

"When all the data has been fetched from a SELECT statement,
the driver will automatically call finish for you. So you should
not call it explicitly except when you know that you've not
fetched all the data from a statement handle and the handle
won't be destroyed soon."
(http://search.cpan.org/~timb/DBI-1.627/DBI.pm#finish)

All the $sth variables were scoped within the functions,
and would be destroyed immediately. Additionally, there was
one after a SELECT, for only a single idnew, and so it was
not necessary.

TEST PLAN
---------
1) prove -v t/db_dependent/NewsChannels.t
2) apply patch
3) prove -v t/db_dependent/NewsChannels.t

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

ok 1 - use C4::NewsChannels;
ok 2 - Successfully added the first dummy news item!
ok 3 - Successfully added the second dummy news item!
ok 4 - Successfully updated second dummy news item!
ok 5 - Successfully tested get_opac_new id1!
ok 6 - Successfully tested get_opac_new id2!
ok 7 - Successfully tested get_opac_news!
ok 8 - Successfully tested GetNewsToDisplay!

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567: convert news add/update routines to take hashref; fix bugs

Changed the add and update functions to use a hash reference
for the parameter, so that adding or subtracting parameters
should be easier. Added some POD for the add_opac_news and
upd_opac_news functions, so that developers would know how to
call it.

The hashref changes resulted in being able to return 0 for
failure and 1 for success. This meant adding a couple tests
to the test file.

And while testing, there was some sort of logic problem with
the matter of '' being all, but selecting all only showed
things set for all, and excluded particular languages, or other
interfaces.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567 - Added branchcode to opac_news

This patch merely adds branchcode varchar(10) DEFAULT NULL to
the opac_news table.

TEST PLAN
---------
 1) backup your kohadata base if you care about the data.
 2) use the koha database
 3) describe opac_news;
 4) show create table opac_news;
    -- No branchcode constraint will exist.
 5) apply the patch
 6) upgrade the database (either staff client or script)
 7) use the koha database
 8) describe opac_news;
 9) show create table opac_news;
    -- The branchcode constraint should be listed.
10) drop that koha database
11) create the koha database
12) use the koha database
13) source ~/kohaclone/installer/data/mysql/kohastructure.sql
    -- there should be no errors in creating the database.
14) describe opac_news;
15) show create table opac_news;
    -- The branchcode constraint should be listed.
16) restore your koha database if you backed it up.

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

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567 - Schema update for opac_news

This was generated by:
Reset hard to master.
Restore old DB
Apply the patches for 7567
./installer/data/mysql/updatedatabase.pl
./misc/devel/update_dbix_class_files.pl -db_name=... -db_user=... -db_passwd=...
git add Koha/Schema/Results/OpacNews.pm

This should provide the necessary changes to the schema files for
Koha 3.16 and forward.

Had to generate under Debian, because Ubuntu's was broken by comparison.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567 - Use, display, filter News by library

This adds the ability to specify whether staff, OPAC,
or slip news entries apply to all libraries or just a
particular library.

With the branch parameter added to key functions in
C4/NewsChannels.pm, function calls in C4/Members.pm,
mainpage.pl, opac/opac-main.pl, tools/koha-news.pl, and
t/db_dependent/NewsChannels.t were needed.

Some license texts were updated.

Templates were modified to display, allow for entry and editing
of the branches selected.

TEST PLAN
---------
1) Having logged into the staff client, is the news displaying
   correctly? Have you entered a news item which should not
   display for this branch of logged in user?
2) Find a patron (with some items checked out?)
3) Print a slip
   - News which is labelled 'All Branches' or for the same branch
     as the one printing the slip should display on the slip.
   - THIS DOES NOT AFFECT QUICK SLIPS
4) Home -> Tools -> News
   - Can you edit a news item?
   - Does the change save correctly?
   - Can you filter based on location and branch correctly?
   - Can you add a new entry correctly?
   - Can you delete an entry correctly?
5) Open an OPAC client.
   - Does only the news for all branches display?
6) Log into the OPAC client.
   - Does the news for all branches and the specific branch display?
7) prove -v t/db_dependent/NewsChannels.t
   - Does it run and all succeed?
   - Does the code seem to catch the required cases?
8) Comparing the patched and unpatched versions of files affected,
   are the license changes missing anything?

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567: QA followup: FIX SQL query

The WHERE clause should not erase $query.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567: QA followup: remove useless $parameters hashref

This hashref is useless, it is only used once.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567: (follow-up) Modify DataTables configuration

This follow-up corrects a JavaScript error by converting the sorting
configuration to be class-based
(http://wiki.koha-community.org/wiki/DataTables_HowTo#Sorting_dates_regardless_of_date_format_preference).

I have also changed the DataTables configuration to allow for pagination
and JS-based filtering.

To test, apply the patch and view the list of News items. Your browser
should report no JavaScript errors. Table sorting, pagination, and
filtering should work correctly.

Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Bug 7567: DBRev 3.15.00.027

Signed-off-by: Galen Charlton <gmc@esilibrary.com>