[Koha-patches] [PATCH] bug Fixing 2081

Henri-Damien LAURENT henridamien at koha-fr.org
Tue May 6 17:27:32 CEST 2008


Editing authorisedvalue now checks if OTHER value has the same authorised_value
before storing
id is now passed to the form so that it is used when editing authorised_value
when imageurl it is passed as '' not empty parameter
---
 admin/authorised_values.pl                         |    7 ++++---
 .../prog/en/modules/admin/authorised_values.tmpl   |    1 +
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/admin/authorised_values.pl b/admin/authorised_values.pl
index 42291b8..0a672a6 100755
--- a/admin/authorised_values.pl
+++ b/admin/authorised_values.pl
@@ -109,6 +109,7 @@ if ($op eq 'add_form') {
 	my $dbh = C4::Context->dbh;
     my $new_category = $input->param('category');
     my $new_authorised_value = $input->param('authorised_value');
+    my $imageurl=$input->param( 'imageurl' )|'';   
     my $duplicate_entry = 0;
 
     if ( $id ) { # Update
@@ -118,7 +119,7 @@ if ($op eq 'add_form') {
         $sth->finish;
         if ( $authorised_value ne $new_authorised_value ) {
             my $sth = $dbh->prepare_cached( "SELECT COUNT(*) FROM authorised_values " .
-                "WHERE category = '$new_category' AND authorised_value = '$new_authorised_value' ");
+                "WHERE category = '$new_category' AND authorised_value = '$new_authorised_value' and id<>$id");
             $sth->execute();
             ($duplicate_entry) = $sth->fetchrow_array();
             warn "**** duplicate_entry = $duplicate_entry";
@@ -132,7 +133,7 @@ if ($op eq 'add_form') {
                                       WHERE id=?' );
             my $lib = $input->param('lib');
             undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
-            $sth->execute($new_category, $new_authorised_value, $lib, $input->param( 'imageurl' ), $id);          
+            $sth->execute($new_category, $new_authorised_value, $lib, $imageurl, $id);          
             print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=".$new_category."\"></html>";
             exit;
         }
@@ -149,7 +150,7 @@ if ($op eq 'add_form') {
                                     values (?, ?, ?, ?, ?)' );
     	    my $lib = $input->param('lib');
     	    undef $lib if ($lib eq ""); # to insert NULL instead of a blank string
-    	    $sth->execute($id, $new_category, $new_authorised_value, $lib, $input->param( 'imageurl' ) );
+    	    $sth->execute($id, $new_category, $new_authorised_value, $lib, $imageurl );
     	    $sth->finish;
     	    print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=authorised_values.pl?searchfield=".$input->param('category')."\"></html>";
     	    exit;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl
index f51a668..b82b6e9 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authorised_values.tmpl
@@ -40,6 +40,7 @@
         </li>
         <li>
             <label for="authorised_value">Authorized value</label>
+     <!-- TMPL_IF name="action_modify" --><input type="hidden" id="id" name="id" value="<!-- TMPL_VAR name="id" -->" /><!-- /TMPL_IF -->
             <input type="text" id="authorised_value" name="authorised_value" value="<!-- TMPL_VAR name="authorised_value" -->" />
         </li>
         <li>
-- 
1.5.4.3




More information about the Koha-patches mailing list