Bugzilla – Attachment 54496 Details for
Bug 7045
Default-value substitution inconsistent
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7045: Use <<tag>> for default value placeholders
Bug-7045-Use-tag-for-default-value-placeholders.patch (text/plain), 3.93 KB, created by
Jonathan Druart
on 2016-08-16 08:20:57 UTC
(
hide
)
Description:
Bug 7045: Use <<tag>> for default value placeholders
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-08-16 08:20:57 UTC
Size:
3.93 KB
patch
obsolete
>From c6fb40cc4489fec91c74f017711e9dddf6eccab3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 16 Aug 2016 09:09:53 +0100 >Subject: [PATCH] Bug 7045: Use <<tag>> for default value placeholders > >When adding a biblio, the default value of a MARC subfield defined in >the frameworks can be used as placeholders to set the current date or >the surname of the logged in user (use cases?). >The different placeholders are 'YYYY', 'MM', 'DD', 'user'. >When adding an item, same behavior except that 'user' is not replaced. > >This patch makes behaviors consistent between the 2 editors and >surrounds placeholders with << >> >We will now have: <<YYYY>>, <<MM>>, <<DD>> and <<USER>> > >Test plan: >Define default values for biblio and item subfields. >Create a bibliographic record and attach it an item. >The default values should be used and replaced if you used placeholders. >--- > cataloguing/addbiblio.pl | 21 ++++++++++++--------- > cataloguing/additem.pl | 17 +++++++++++------ > 2 files changed, 23 insertions(+), 15 deletions(-) > >diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl >index 1e7cb61..3db9d8c 100755 >--- a/cataloguing/addbiblio.pl >+++ b/cataloguing/addbiblio.pl >@@ -36,6 +36,7 @@ use C4::ClassSource; > use C4::ImportBatch; > use C4::Charset; > use Koha::BiblioFrameworks; >+use Koha::DateUtils; > > use Date::Calc qw(Today); > use MARC::File::USMARC; >@@ -294,15 +295,17 @@ sub create_input { > if ( $value eq '' ) { > $value = $tagslib->{$tag}->{$subfield}->{defaultvalue}; > >- # get today date & replace YYYY, MM, DD if provided in the default value >- my ( $year, $month, $day ) = Today(); >- $month = sprintf( "%02d", $month ); >- $day = sprintf( "%02d", $day ); >- $value =~ s/YYYY/$year/g; >- $value =~ s/MM/$month/g; >- $value =~ s/DD/$day/g; >- my $username=(C4::Context->userenv?C4::Context->userenv->{'surname'}:"superlibrarian"); >- $value=~s/user/$username/g; >+ # get today date & replace <<YYYY>>, <<MM>>, <<DD>> if provided in the default value >+ my $today_dt = dt_from_string; >+ my $year = $today_dt->year; >+ my $month = $today_dt->month; >+ my $day = $today_dt->day; >+ $value =~ s/<<YYYY>>/$year/g; >+ $value =~ s/<<MM>>/$month/g; >+ $value =~ s/<<DD>>/$day/g; >+ # And <<USER>> with surname (?) >+ my $username=(C4::Context->userenv?C4::Context->userenv->{'surname'}:"superlibrarian"); >+ $value=~s/<<USER>>/$username/g; > > } > my $dbh = C4::Context->dbh; >diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl >index 28fd247..0a5e147 100755 >--- a/cataloguing/additem.pl >+++ b/cataloguing/additem.pl >@@ -128,12 +128,17 @@ sub generate_subfield_form { > $value =~ s/"/"/g; > if ( ! defined( $value ) || $value eq '') { > $value = $subfieldlib->{defaultvalue}; >- # get today date & replace YYYY, MM, DD if provided in the default value >- my $today_iso = output_pref( { dt=>dt_from_string, dateonly => 1, dateformat => 'iso' } ); >- my ( $year, $month, $day ) = split ('-', $today_iso); >- $value =~ s/YYYY/$year/g; >- $value =~ s/MM/$month/g; >- $value =~ s/DD/$day/g; >+ # get today date & replace <<YYYY>>, <<MM>>, <<DD>> if provided in the default value >+ my $today_dt = dt_from_string; >+ my $year = $today_dt->year; >+ my $month = $today_dt->month; >+ my $day = $today_dt->day; >+ $value =~ s/<<YYYY>>/$year/g; >+ $value =~ s/<<MM></$month/g; >+ $value =~ s/<<DD>>/$day/g; >+ # And <<USER>> with surname (?) >+ my $username=(C4::Context->userenv?C4::Context->userenv->{'surname'}:"superlibrarian"); >+ $value=~s/<<USER>>/$username/g; > } > > $subfield_data{visibility} = "display:none;" if (($subfieldlib->{hidden} > 4) || ($subfieldlib->{hidden} <= -4)); >-- >2.8.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 7045
:
5922
|
5923
|
5924
|
5925
|
5926
|
5927
|
5928
|
5929
|
5931
|
5932
|
54496
|
54497
|
54500
|
54501
|
54669
|
54670