From 7ffa2433c7ac894a7a0aaf6f626714e9ef2bde63 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 10 Jan 2019 19:08:59 +0000 Subject: [PATCH] Bug 11815: Convert BorrowersTitles to an authorised value This patch removes the BorrowersTitles system preference in favor of using authorized values to store patron titles. To test, apply the patch and run the database update. - In Administration -> Authorized values, locate the category 'PATRON_TITLE'. - Create two or more authorized values with new patron titles. - In Administration -> System preferences -> Patrons, there should be no entry for BorrowersTitles. - Create or edit a patron. Under "Salutation" your authorized values should appear correctly. - Log in to the OPAC and go to "Your personal details." Confirm that the correct values are shown there. - Remove all PATRON_TITLE authorized values and confirm that the "Salutation" field no longer appears on the staff client or OPAC patron entry form. --- ...bug_11815-convert-borrowertitle-to-authval.perl | 23 ++++++++++++++++++++++ installer/data/mysql/sysprefs.sql | 1 - .../prog/en/modules/admin/authorised_values.tt | 2 ++ .../prog/en/modules/admin/preferences/patrons.pref | 5 ----- .../prog/en/modules/members/memberentrygen.tt | 10 +++++----- .../bootstrap/en/modules/opac-memberentry.tt | 10 +++++----- members/memberentry.pl | 3 +++ opac/opac-memberentry.pl | 3 +++ 8 files changed, 41 insertions(+), 16 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_11815-convert-borrowertitle-to-authval.perl diff --git a/installer/data/mysql/atomicupdate/bug_11815-convert-borrowertitle-to-authval.perl b/installer/data/mysql/atomicupdate/bug_11815-convert-borrowertitle-to-authval.perl new file mode 100644 index 00000000000..57a00a3e42b --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_11815-convert-borrowertitle-to-authval.perl @@ -0,0 +1,23 @@ +$DBversion = 'XXX'; # will be replaced by the RM +if( CheckVersion( $DBversion ) ) { + my ( $BorrowersTitles ) = $dbh->selectrow_array( q| + SELECT value FROM systempreferences WHERE variable='BorrowersTitles'; + |); + if( $BorrowersTitles ){ + $dbh->do(" + INSERT INTO authorised_value_categories( category_name ) VALUES ('PATRON_TITLE') + "); + my @titles; + push @titles, split ('\|', $BorrowersTitles); + my $sth = $dbh->prepare(" + INSERT INTO authorised_values(category, authorised_value, lib, lib_opac) VALUES ('PATRON_TITLE', ?, ?, ?) + "); + foreach my $patron_title ( @titles ) { + $sth->execute( $patron_title, $patron_title, $patron_title ); + } + } + # Remove the BorrowersTitles system preference + $dbh->do("DELETE FROM systempreferences WHERE variable='BorrowersTitles'"); + SetVersion ($DBversion); + print "Upgrade to $DBversion done (Bug 11815: convert BorrowersTitles to an authorised value)\n"; +} diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 11aa53d1dce..34702fe792e 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -101,7 +101,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('borrowerRelationship','father|mother','','Define valid relationships between a guarantor & a guarantee (separated by | or ,)','free'), ('BorrowerRenewalPeriodBase','now','dateexpiry|now|combination','Set whether the borrower renewal date should be counted from the dateexpiry, from the current date or by combination: if the dateexpiry is in future use dateexpiry, else use current date ','Choice'), ('BorrowersLog','1',NULL,'If ON, log edit/create/delete actions on patron data','YesNo'), -('BorrowersTitles','Mr|Mrs|Miss|Ms',NULL,'Define appropriate Titles for patrons','free'), ('BorrowerUnwantedField','',NULL,'Name the fields you don\'t need to store for a patron\'s account','free'), ('BranchTransferLimitsType','ccode','itemtype|ccode','When using branch transfer limits, choose whether to limit by itemtype or collection code.','Choice'), ('BrowseResultSelection','0',NULL,'Enable/Disable browsing search results fromt the bibliographic record detail page in staff client','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt index 7715e0b6f52..06cc8b43042 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tt @@ -392,6 +392,8 @@

A list of reasons displayed in the suggestion form on the OPAC.

[% CASE 'ORDER_CANCELLATION_REASON' %]

Reasons why an order might have been cancelled

+ [% CASE 'PATRON_TITLE' %] +

Titles or honorifics which can be added to a patron record

[% CASE 'PAYMENT_TYPE' %]

Populates a dropdown list of custom payment types when paying fines

[% CASE 'qualif' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref index 14f1ef910c9..beaff7c58c3 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref @@ -53,11 +53,6 @@ Patrons: class: multi - (input multiple choices separated by |). Leave empty to deactivate - - - "Borrowers can have the following titles:" - - pref: BorrowersTitles - class: multi - - (separate multiple choices with |) - - - pref: CheckPrevCheckout default: no choices: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index f36d98314b4..b63b0618908 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -183,7 +183,7 @@
    [% UNLESS ( I ) %] [% UNLESS notitle %] - [% IF Koha.Preference('BorrowersTitles') %] + [% IF ( patron_titles ) %]
  1. [% IF ( mandatorytitle ) %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt index 8761cc88ae5..70970abc24c 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt @@ -274,7 +274,7 @@ Identity
      - [% UNLESS hidden.defined('title') || !Koha.Preference('BorrowersTitles') %] + [% UNLESS hidden.defined('title') || !patron_titles %]
    1. [% IF mandatory.defined('title') %] @@ -284,11 +284,11 @@ diff --git a/members/memberentry.pl b/members/memberentry.pl index fa5cbe427e2..b713ae323ef 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -641,9 +641,12 @@ $template->param( my $cities = Koha::Cities->search( {}, { order_by => 'city_name' } ); my $roadtypes = C4::Koha::GetAuthorisedValues( 'ROADTYPE' ); +my $patron_titles = C4::Koha::GetAuthorisedValues( 'PATRON_TITLE' ); + $template->param( roadtypes => $roadtypes, cities => $cities, + patron_titles => $patron_titles, ); my $default_borrowertitle = ''; diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl index 62cdd0d2056..4d76844391a 100755 --- a/opac/opac-memberentry.pl +++ b/opac/opac-memberentry.pl @@ -28,6 +28,7 @@ use C4::Output; use C4::Members; use C4::Members::Attributes qw( GetBorrowerAttributes ); use C4::Form::MessagingPreferences; +use Koha::AuthorisedValues; use Koha::AuthUtils; use Koha::Patrons; use Koha::Patron::Consent; @@ -74,6 +75,7 @@ if ( $action eq q{} ) { } my $mandatory = GetMandatoryFields($action); +my $patron_titles = C4::Koha::GetAuthorisedValues( 'PATRON_TITLE' ); my @libraries = Koha::Libraries->search; if ( my @libraries_to_display = split '\|', C4::Context->preference('PatronSelfRegistrationLibraryList') ) { @@ -93,6 +95,7 @@ $template->param( mandatory => $mandatory, libraries => \@libraries, OPACPatronDetails => C4::Context->preference('OPACPatronDetails'), + patron_titles => $patron_titles, ); my $attributes = ParsePatronAttributes($borrowernumber,$cgi); -- 2.11.0