X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=C4%2FKoha.pm;h=95244bd91efe7969f082ddbd78f933b2302bab08;hb=1e7c5166aa4fa8f983cce549803c8ddc8893c846;hp=4f7b50f7a3c43880effacb82c1a9cfa8706fa313;hpb=73f0857003a049a2359c42a99d34760330153a73;p=koha_fer diff --git a/C4/Koha.pm b/C4/Koha.pm index 4f7b50f7a3..95244bd91e 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -2,6 +2,7 @@ package C4::Koha; # Copyright 2000-2002 Katipo Communications # Parts Copyright 2010 Nelsonville Public Library +# Parts copyright 2010 BibLibre # # This file is part of Koha. # @@ -57,6 +58,8 @@ BEGIN { &GetKohaAuthorisedValues &GetKohaAuthorisedValuesFromField &GetKohaAuthorisedValueLib + &GetAuthorisedValueByCode + &GetKohaImageurlFromAuthorisedValues &GetAuthValCode &GetNormalizedUPC &GetNormalizedISBN @@ -570,8 +573,9 @@ sub getImageSets { my @imagesets = (); # list of hasrefs of image set data to pass to template my @subdirectories = _getSubdirectoryNames( $paths->{'staff'}{'filesystem'} ); - +warn $paths->{'staff'}{'filesystem'}; foreach my $imagesubdir ( @subdirectories ) { + warn $imagesubdir; my @imagelist = (); # hashrefs of image info my @imagenames = _getImagesFromDirectory( File::Spec->catfile( $paths->{'staff'}{'filesystem'}, $imagesubdir ) ); my $imagesetactive = 0; @@ -940,6 +944,25 @@ sub displayServers { return \@primaryserverloop; } + +=head2 GetKohaImageurlFromAuthorisedValues + +$authhorised_value = GetKohaImageurlFromAuthorisedValues( $category, $authvalcode ); + +Return the first url of the authorised value image represented by $lib. + +=cut + +sub GetKohaImageurlFromAuthorisedValues { + my ( $category, $lib ) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT imageurl FROM authorised_values WHERE category=? AND lib =?"); + $sth->execute( $category, $lib ); + while ( my $data = $sth->fetchrow_hashref ) { + return $data->{'imageurl'}; + } +} + =head2 GetAuthValCode $authvalcode = GetAuthValCode($kohafield,$frameworkcode); @@ -1028,12 +1051,32 @@ sub GetAuthorisedValueCategories { my $sth = $dbh->prepare("SELECT DISTINCT category FROM authorised_values ORDER BY category"); $sth->execute; my @results; - while (my $category = $sth->fetchrow_array) { + while (defined (my $category = $sth->fetchrow_array) ) { push @results, $category; } return \@results; } +=head2 GetAuthorisedValueByCode + +$authhorised_value = GetAuthorisedValueByCode( $category, $authvalcode ); + +Return the lib attribute from authorised_values from the row identified +by the passed category and code + +=cut + +sub GetAuthorisedValueByCode { + my ( $category, $authvalcode ) = @_; + + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT lib FROM authorised_values WHERE category=? AND authorised_value =?"); + $sth->execute( $category, $authvalcode ); + while ( my $data = $sth->fetchrow_hashref ) { + return $data->{'lib'}; + } +} + =head2 GetKohaAuthorisedValues Takes $kohafield, $fwcode as parameters.