Bugzilla – Attachment 21181 Details for
Bug 10602
Set a default value for authorities
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10602: Set a default value for authorities
Bug-10602-Set-a-default-value-for-authorities.patch (text/plain), 8.38 KB, created by
Jonathan Druart
on 2013-09-18 12:01:51 UTC
(
hide
)
Description:
Bug 10602: Set a default value for authorities
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-09-18 12:01:51 UTC
Size:
8.38 KB
patch
obsolete
>From c0666bccff8deaee1c6d0d06f3ece2419693c705 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >Date: Wed, 17 Jul 2013 14:38:55 +0200 >Subject: [PATCH] Bug 10602: Set a default value for authorities > >Some code already exist but the feature does not work. > >This patch allows to define default values in the authorities framework. > >Test plan: >1/ Choose a framework, field and subfields. >2/ Define a default value. >3/ Create a new authority and check that the subfield is >automatically filled with the default value. >--- > C4/AuthoritiesMarc.pm | 6 ++++-- > admin/auth_subfields_structure.pl | 9 +++++++-- > installer/data/mysql/kohastructure.sql | 1 + > installer/data/mysql/updatedatabase.pl | 12 ++++++++++++ > .../prog/en/modules/admin/auth_subfields_structure.tt | 13 ++++++++++++- > 5 files changed, 36 insertions(+), 5 deletions(-) > >diff --git a/C4/AuthoritiesMarc.pm b/C4/AuthoritiesMarc.pm >index 9ea3b2d..7bfaf00 100644 >--- a/C4/AuthoritiesMarc.pm >+++ b/C4/AuthoritiesMarc.pm >@@ -520,7 +520,7 @@ sub GetTagsLabels { > $res->{$tag}->{repeatable} = $repeatable; > } > $sth= $dbh->prepare( >-"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,frameworkcode as authtypecode,value_builder,kohafield,seealso,hidden,isurl >+"SELECT tagfield,tagsubfield,liblibrarian,libopac,tab, mandatory, repeatable,authorised_value,frameworkcode as authtypecode,value_builder,kohafield,seealso,hidden,isurl,defaultvalue > FROM auth_subfield_structure > WHERE authtypecode=? > ORDER BY tagfield,tagsubfield" >@@ -535,12 +535,13 @@ ORDER BY tagfield,tagsubfield" > my $hidden; > my $isurl; > my $link; >+ my $defaultvalue; > > while ( > ( $tag, $subfield, $liblibrarian, , $libopac, $tab, > $mandatory, $repeatable, $authorised_value, $authtypecode, > $value_builder, $kohafield, $seealso, $hidden, >- $isurl, $link ) >+ $isurl, $defaultvalue, $link ) > = $sth->fetchrow > ) > { >@@ -556,6 +557,7 @@ ORDER BY tagfield,tagsubfield" > $res->{$tag}->{$subfield}->{hidden} = $hidden; > $res->{$tag}->{$subfield}->{isurl} = $isurl; > $res->{$tag}->{$subfield}->{link} = $link; >+ $res->{$tag}->{$subfield}->{defaultvalue} = $defaultvalue; > } > return $res; > } >diff --git a/admin/auth_subfields_structure.pl b/admin/auth_subfields_structure.pl >index 537f0ea..1e45c14 100755 >--- a/admin/auth_subfields_structure.pl >+++ b/admin/auth_subfields_structure.pl >@@ -139,6 +139,7 @@ if ($op eq 'add_form') { > while ($data =$sth->fetchrow_hashref) { > > my %row_data; # get a fresh hash for the row data >+ $row_data{defaultvalue} = $data->{defaultvalue}; > $row_data{tab} = CGI::scrolling_list(-name=>'tab', > -id=>"tab$i", > -values => >@@ -386,9 +387,9 @@ if ($op eq 'add_form') { > $template->param(tagfield => "$input->param('tagfield')"); > # my $sth=$dbh->prepare("replace auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl) > # values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); >- my $sth_insert = $dbh->prepare("insert into auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl) >+ my $sth_insert = $dbh->prepare("insert into auth_subfield_structure (authtypecode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,seealso,authorised_value,frameworkcode,value_builder,hidden,isurl,defaultvalue) > values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); >- my $sth_update = $dbh->prepare("update auth_subfield_structure set authtypecode=?, tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, frameworkcode=?, value_builder=?, hidden=?, isurl=? >+ my $sth_update = $dbh->prepare("update auth_subfield_structure set authtypecode=?, tagfield=?, tagsubfield=?, liblibrarian=?, libopac=?, repeatable=?, mandatory=?, kohafield=?, tab=?, seealso=?, authorised_value=?, frameworkcode=?, value_builder=?, hidden=?, isurl=?, defaultvalue=? > where authtypecode=? and tagfield=? and tagsubfield=?"); > my @tagsubfield = $input->param('tagsubfield'); > my @liblibrarian = $input->param('liblibrarian'); >@@ -404,6 +405,7 @@ if ($op eq 'add_form') { > my $authtypecode = $input->param('authtypecode'); > my @frameworkcodes = $input->param('frameworkcode'); > my @value_builder =$input->param('value_builder'); >+ my @defaultvalue = $input->param('defaultvalue'); > for (my $i=0; $i<= $#tagsubfield ; $i++) { > my $tagfield =$input->param('tagfield'); > my $tagsubfield =$tagsubfield[$i]; >@@ -418,6 +420,7 @@ if ($op eq 'add_form') { > my $authorised_value =$authorised_values[$i]; > my $frameworkcode =$frameworkcodes[$i]; > my $value_builder=$value_builder[$i]; >+ my $defaultvalue = $value_builder[$i]; > #my $hidden = $ohidden[$i].$ihidden[$i].$ehidden[$i]; #collate from 3 hiddens; > my $hidden = $ohidden[$i]; #collate from 3 hiddens; > my $isurl = $input->param("isurl$i")?1:0; >@@ -440,6 +443,7 @@ if ($op eq 'add_form') { > $value_builder, > $hidden, > $isurl, >+ $defaultvalue, > ( > $authtypecode, > $tagfield, >@@ -463,6 +467,7 @@ if ($op eq 'add_form') { > $value_builder, > $hidden, > $isurl, >+ $defaultvalue, > ); > } > } >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index fdab879..36cb26e 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -56,6 +56,7 @@ CREATE TABLE `auth_subfield_structure` ( > `linkid` tinyint(1) NOT NULL default 0, > `kohafield` varchar(45) NULL default '', > `frameworkcode` varchar(10) NOT NULL default '', >+ `defaultvalue` TEXT DEFAULT '', > PRIMARY KEY (`authtypecode`,`tagfield`,`tagsubfield`), > KEY `tab` (`authtypecode`,`tab`) > ) ENGINE=InnoDB DEFAULT CHARSET=utf8; >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 31f494a..35dc091 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7139,6 +7139,18 @@ if ( CheckVersion($DBversion) ) { > SetVersion ($DBversion); > } > >+ >+ >+ >+$DBversion = "3.13.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do(q| >+ ALTER TABLE auth_subfield_structure ADD COLUMN defaultvalue TEXT DEFAULT NULL AFTER frameworkcode >+ |); >+ print "Upgrade to $DBversion done (Bug 10602: Add the column auth_subfield_structure.defaultvalue)\n"; >+ SetVersion($DBversion); >+} >+ > =head1 FUNCTIONS > > =head2 TableExists($table) >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt >index 688bd71..3d22192 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/auth_subfields_structure.tt >@@ -99,7 +99,18 @@ function displayMoreConstraint(numlayer){ > </ol> > </fieldset> > </li> >- <li><label for="isurl[% loo.row %]">Is a URL:</label>[% loo.isurl %] (if checked, it means that the subfield is a URL and can be clicked)</li> >+ <li> >+ <fieldset class="rows"> >+ <legend>Advanced constraints:</legend> >+ <ol> >+ <li><label for="isurl[% loo.row %]">Is a URL:</label>[% loo.isurl %] (if checked, it means that the subfield is a URL and can be clicked)</li> >+ <li> >+ <label for="defaultvalue[% loo.row %]">Default value:</label> >+ <input type="text" name="defaultvalue" id="defaultvalue[% loo.row %]" value="[% loo.defaultvalue %]" /> >+ </li> >+ </ol> >+ </fieldset> >+ </li> > <li> > <fieldset><legend>Help input</legend> > <ol> >-- >1.7.10.4
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 10602
:
19718
|
21181
|
21566
|
21659
|
21664
|
21665
|
21679
|
21680