Fixes two bugs affecting Web installer when used with Unimarc/French
[koha.git] / C4 / Koha.pm
index 06ff7a3..6c6b6e0 100644 (file)
@@ -68,6 +68,7 @@ $VERSION = 3.00;
   &GetAuthorisedValues
   &FixEncoding
   &GetKohaAuthorisedValues
+  &GetAuthValCode
   &GetManagedTagSubfields
 
   $DEBUG
@@ -263,6 +264,7 @@ sub get_itemtypeinfos_of {
     my $query = '
 SELECT itemtype,
        description,
+       imageurl,
        notforloan
   FROM itemtypes
   WHERE itemtype IN (' . join( ',', map( { "'" . $_ . "'" } @itemtypes ) ) . ')
@@ -787,6 +789,22 @@ sub displaySecondaryServers {
     return;    #$secondary_servers_loop;
 }
 
+=head2 GetAuthValCode
+
+$authvalcode = GetAuthValCode($kohafield,$frameworkcode);
+
+=cut
+
+sub GetAuthValCode {
+       my ($kohafield,$fwcode) = @_;
+       my $dbh = C4::Context->dbh;
+       $fwcode='' unless $fwcode;
+       my $sth = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield=? and frameworkcode=?');
+       $sth->execute($kohafield,$fwcode);
+       my ($authvalcode) = $sth->fetchrow_array;
+       return $authvalcode;
+}
+
 =head2 GetAuthorisedValues
 
 $authvalues = GetAuthorisedValues($category);
@@ -879,18 +897,17 @@ sub FixEncoding {
 =cut
 
 sub GetKohaAuthorisedValues {
-  my ($kohafield) = @_;
+  my ($kohafield,$fwcode) = @_;
+  $fwcode='' unless $fwcode;
   my %values;
   my $dbh = C4::Context->dbh;
-  my $sthnflstatus = $dbh->prepare('select authorised_value from marc_subfield_structure where kohafield=?');
-  $sthnflstatus->execute($kohafield);
-  my $authorised_valuecode = $sthnflstatus->fetchrow;
-  if ($authorised_valuecode) {  
-    $sthnflstatus = $dbh->prepare("select authorised_value, lib from authorised_values where category=? ");
-    $sthnflstatus->execute($authorised_valuecode);
-    while ( my ($val, $lib) = $sthnflstatus->fetchrow_array ) { 
-      $values{$val}= $lib;
-    }
+  my $avcode = GetAuthValCode($kohafield,$fwcode);
+  if ($avcode) {  
+    my $sth = $dbh->prepare("select authorised_value, lib from authorised_values where category=? ");
+    $sth->execute($avcode);
+       while ( my ($val, $lib) = $sth->fetchrow_array ) { 
+               $values{$val}= $lib;
+       }
   }
   return \%values;
 }
@@ -901,13 +918,18 @@ sub GetKohaAuthorisedValues {
 
 $res = GetManagedTagSubfields();
 
+=back
+
 Returns a reference to a big hash of hash, with the Marc structure fro the given frameworkcode
-$forlibrarian  :if set to 1, the MARC descriptions are the librarians ones, otherwise it's the public (OPAC) ones
-$frameworkcode : the framework code to read
 
-=back
+NOTE: This function is used only by the (incomplete) bulk editing feature.  Since
+that feature currently does not deal with items and biblioitems changes 
+correctly, those tags are specifically excluded from the list prepared
+by this function.
 
-=back
+For future reference, if a bulk item editing feature is implemented at some point, it
+needs some design thought -- for example, circulation status fields should not 
+be changed willy-nilly.
 
 =cut
 
@@ -923,7 +945,11 @@ FROM marc_subfield_structure
     ON marc_tag_structure.tagfield = marc_subfield_structure.tagfield
     AND marc_tag_structure.frameworkcode = marc_subfield_structure.frameworkcode
 WHERE marc_subfield_structure.tab>=0
-ORDER BY tagsubfield|);
+AND marc_tag_structure.tagfield NOT IN (SELECT tagfield FROM marc_subfield_structure WHERE kohafield like 'items.%')
+AND marc_tag_structure.tagfield NOT IN (SELECT tagfield FROM marc_subfield_structure WHERE kohafield = 'biblioitems.itemtype')
+AND marc_subfield_structure.kohafield <> 'biblio.biblionumber'
+AND marc_subfield_structure.kohafield <>  'biblioitems.biblioitemnumber'
+ORDER BY marc_subfield_structure.tagfield, tagsubfield|);
   $rq->execute;
   my $data=$rq->fetchall_arrayref({});
   return $data;