Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #226 from hgq/gpo_14_pt16851435

Gpo 14 pt16851435
  • Loading branch information...
commit 5c2303426d6f7f9a032c9f37d320c1983201963d 2 parents bcffb85 + 6b21316
@ctfliblime ctfliblime authored
View
12 admin/biblio_framework.pl
@@ -69,14 +69,18 @@
################## ADD_VALIDATE ##################################
# called by add_form, used to insert/modify data in DB
} elsif ($op eq 'add_validate') {
- if ($input->param('modif')) {
- my $sth=$dbh->prepare("UPDATE biblio_framework SET frameworktext=? WHERE frameworkcode=?");
+ ## dupecheck
+ my $sth = $dbh->prepare('SELECT 1 FROM biblio_framework WHERE frameworkcode=?');
+ $sth->execute($input->param('frameworkcode'));
+ my($dupe) = $sth->fetchrow_array;
+ if ($input->param('modif') || $dupe) {
+ $sth=$dbh->prepare("UPDATE biblio_framework SET frameworktext=? WHERE frameworkcode=?");
$sth->execute($input->param('frameworktext'),$input->param('frameworkcode'));
} else {
- my $sth=$dbh->prepare("INSERT into biblio_framework (frameworkcode,frameworktext) values (?,?)");
+ $sth=$dbh->prepare("INSERT into biblio_framework (frameworkcode,frameworktext) values (?,?)");
$sth->execute($input->param('frameworkcode'),$input->param('frameworktext'));
}
- print $input->redirect($script_name); # FIXME: unnecessary redirect
+ print $input->redirect($script_name);
exit;
# END $OP eq ADD_VALIDATE
################## DELETE_CONFIRM ##################################
View
28 admin/marctagstructure.pl
@@ -69,7 +69,7 @@
}
# check that framework is defined in marc_tag_structure
-our $sth=$dbh->prepare("select count(*) from marc_tag_structure where frameworkcode=?");
+my $sth=$dbh->prepare("select count(*) from marc_tag_structure where frameworkcode=?");
$sth->execute($frameworkcode);
our ($frameworkexist) = $sth->fetchrow;
unless ($frameworkexist) {
@@ -292,7 +292,7 @@
loop => \@loop_data);
} else {
#here, normal old style : display every tags
- my ($count,$results)=StringSearch($searchfield,$frameworkcode);
+ my ($count,$results) = StringSearch($searchfield,$frameworkcode);
$cnt = $count;
my @loop_data = ();
for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
@@ -350,18 +350,16 @@ sub StringSearch {
#
sub duplicate_framework {
my ($newframeworkcode,$oldframeworkcode) = @_;
- my $sth = $dbh->prepare("select tagfield,liblibrarian,libopac,repeatable,mandatory,authorised_value from marc_tag_structure where frameworkcode=?");
- $sth->execute($oldframeworkcode);
- my $sth_insert = $dbh->prepare("insert into marc_tag_structure (tagfield, liblibrarian, libopac, repeatable, mandatory, authorised_value, frameworkcode) values (?,?,?,?,?,?,?)");
- while ( my ($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value) = $sth->fetchrow) {
- $sth_insert->execute($tagfield,$liblibrarian,$libopac,$repeatable,$mandatory,$authorised_value,$newframeworkcode);
- }
-
- $sth = $dbh->prepare("select frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden from marc_subfield_structure where frameworkcode=?");
- $sth->execute($oldframeworkcode);
- $sth_insert = $dbh->prepare("insert into marc_subfield_structure (frameworkcode,tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,kohafield,tab,authorised_value,authtypecode,value_builder,seealso,hidden) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
- while ( my ($frameworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso,$hidden) = $sth->fetchrow) {
- $sth_insert->execute($newframeworkcode, $tagfield, $tagsubfield, $liblibrarian, $libopac, $repeatable, $mandatory, $kohafield, $tab, $authorised_value, $thesaurus_category, $value_builder, $seealso, $hidden);
- }
+ $oldframeworkcode ||= '';
+ $dbh->do("INSERT INTO marc_tag_structure (SELECT tagfield,liblibrarian,libopac,
+ repeatable,mandatory,authorised_value,'$newframeworkcode'
+ FROM marc_tag_structure WHERE frameworkcode=?)",undef,$oldframeworkcode
+ );
+ $dbh->do("INSERT into marc_subfield_structure (
+ SELECT tagfield,tagsubfield,liblibrarian,libopac,repeatable,mandatory,
+ kohafield,`tab`,authorised_value,authtypecode,value_builder,isurl,hidden,
+ '$newframeworkcode',seealso,link,defaultvalue
+ FROM marc_subfield_structure WHERE frameworkcode=?)",undef,$oldframeworkcode
+ );
}
View
4 koha-tmpl/intranet-tmpl/prog/en/modules/admin/biblio_framework.tmpl
@@ -74,7 +74,7 @@ $(document).ready(function() {
<!-- TMPL_IF NAME="add_form" -->
<h1><!-- TMPL_IF NAME="frameworkcode" -->Modify framework text<!-- TMPL_ELSE -->Add framework<!-- /TMPL_IF --></h1>
- <form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" method="post">
+ <form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" method="post" onsubmit="return false">
<input type="hidden" name="op" value="add_validate" />
<fieldset class="rows">
<ol>
@@ -87,7 +87,7 @@ $(document).ready(function() {
<!-- /TMPL_IF -->
<li><label for="description">Description</label>
<input type="text" name="frameworktext" id="description" size="40" maxlength="80" value="<!-- TMPL_VAR NAME="frameworktext" ESCAPE="HTML" -->" /></li></ol></fieldset>
- <fieldset class="action"> <input type="submit" value="Submit" class="submit" onclick="Check(this.form)" /></fieldset>
+ <fieldset class="action"> <input type="button" value="Submit" class="submit" onclick="Check(this.form)" /></fieldset>
</form>
<!-- /TMPL_IF -->
View
4 koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tmpl
@@ -64,7 +64,7 @@ $(document).ready(function() {
<!-- TMPL_IF NAME="add_form" -->
- <form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" method="post">
+ <form action="<!-- TMPL_VAR NAME="script_name" -->" name="Aform" method="post" onsubmit="return false;">
<fieldset class="rows"><legend><!-- TMPL_IF NAME="use-heading-flags-p" --><!-- TMPL_IF NAME="heading-modify-tag-p" -->Modify tag <input type="hidden" name="modif" value="1" /><!-- TMPL_VAR NAME="searchfield" --><!-- /TMPL_IF --><!-- TMPL_IF NAME="heading-add-tag-p" -->Add tag<!-- /TMPL_IF --><!-- TMPL_ELSE --><!-- TMPL_VAR NAME="action" --><!-- /TMPL_IF --></legend> <input type="hidden" name="op" value="add_validate" />
<input type="hidden" name="frameworkcode" value="<!-- TMPL_VAR NAME="frameworkcode" -->" />
@@ -77,7 +77,7 @@ $(document).ready(function() {
<li><label for="authorised_value">Authorized value: </label><!-- TMPL_VAR NAME="authorised_value" --> (if you select a value here, the indicators will be limited to the authorized value list)</li>
</ol></fieldset>
<fieldset class="action">
- <input type="submit" value="Save Changes" onclick="Check(this.form)" />
+ <input type="button" value="Save Changes" onclick="Check(this.form)" />
<a class="cancel" href="<!-- TMPL_VAR NAME="script_name" -->?frameworkcode=<!-- TMPL_VAR NAME="frameworkcode" -->">Cancel</a>
</fieldset>
</form>
Please sign in to comment.
Something went wrong with that request. Please try again.