From 421b36ae628155d1a1f24492da56f64000040f72 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. Signed-off-by: David Nind --- ...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 | 12 +++++------ .../bootstrap/en/modules/opac-memberentry.tt | 10 +++++----- members/memberentry.pl | 3 +++ opac/opac-memberentry.pl | 3 +++ 8 files changed, 42 insertions(+), 17 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 0000000000..57a00a3e42 --- /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 cfa295e197..8bb7ec8378 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 d267838dd0..99dc4c199d 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 @@ -420,6 +420,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 9e37372f4e..02be9e532b 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 cbb8ae2d0e..6847243863 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -240,7 +240,7 @@
    [% UNLESS ( I ) %] [% UNLESS notitle %] - [% IF Koha.Preference('BorrowersTitles') %] + [% IF ( patron_titles ) %]
  1. [% IF ( mandatorytitle ) %] @@ -262,7 +262,7 @@ Required [% END %]
  2. - [% END # /IF Koha.Preference('BorrowersTitles') %] + [% END # /IF ( patron_titles ) %] [% END # /UNLESS notitle %] [% END # /UNLESS ( I ) %] 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 8761cc88ae..70970abc24 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 902beeb0e8..2fa2a88b16 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -654,9 +654,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 40ab844c4a..f110848355 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