|
Lines 35-40
use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue;
Link Here
|
| 35 |
use Koha::Biblio::ItemGroups; |
35 |
use Koha::Biblio::ItemGroups; |
| 36 |
use Koha::Checkouts; |
36 |
use Koha::Checkouts; |
| 37 |
use Koha::CirculationRules; |
37 |
use Koha::CirculationRules; |
|
|
38 |
use Koha::ClassSources; |
| 38 |
use Koha::CoverImages; |
39 |
use Koha::CoverImages; |
| 39 |
use Koha::Exceptions::Item::Transfer; |
40 |
use Koha::Exceptions::Item::Transfer; |
| 40 |
use Koha::Item::Attributes; |
41 |
use Koha::Item::Attributes; |
|
Lines 2058-2063
sub is_denied_renewal {
Link Here
|
| 2058 |
return 0; |
2059 |
return 0; |
| 2059 |
} |
2060 |
} |
| 2060 |
|
2061 |
|
|
|
2062 |
=head3 api_strings_mapping |
| 2063 |
|
| 2064 |
Retrieves for each column name the unblessed authorised value. |
| 2065 |
|
| 2066 |
=cut |
| 2067 |
|
| 2068 |
sub api_strings_mapping { |
| 2069 |
my ( $self, $params ) = @_; |
| 2070 |
|
| 2071 |
my $columns_info = $self->_result->result_source->columns_info; |
| 2072 |
my $frameworkcode = $self->biblio->frameworkcode; |
| 2073 |
my $tagslib = C4::Biblio::GetMarcStructure( 1, $frameworkcode ); |
| 2074 |
my $mss = C4::Biblio::GetMarcSubfieldStructure( $frameworkcode, { unsafe => 1 } ); |
| 2075 |
|
| 2076 |
my ( $itemtagfield, $itemtagsubfield ) = C4::Biblio::GetMarcFromKohaField("items.itemnumber"); |
| 2077 |
|
| 2078 |
my $public_read_list = $params->{public} ? $self->public_read_list : []; |
| 2079 |
my $to_api_mapping = $self->to_api_mapping; |
| 2080 |
|
| 2081 |
# Hardcoded known 'authorised_value' values mapped to API codes |
| 2082 |
my $code_to_type = { |
| 2083 |
branches => 'library', |
| 2084 |
cn_source => 'call_number_source', |
| 2085 |
itemtypes => 'item_type', |
| 2086 |
}; |
| 2087 |
|
| 2088 |
# Handle not null and default values for integers and dates |
| 2089 |
my $strings = {}; |
| 2090 |
|
| 2091 |
foreach my $col ( keys %{$columns_info} ) { |
| 2092 |
|
| 2093 |
# Skip columns not in public read list |
| 2094 |
next |
| 2095 |
unless !$params->{public} |
| 2096 |
|| any { $col eq $_ } $public_read_list; |
| 2097 |
|
| 2098 |
# Skip columns that are not exposed on the API by to_api_mapping |
| 2099 |
# i.e. mapping exists but points to undef |
| 2100 |
next |
| 2101 |
if $col eq 'more_subfields_xml' # not dealt with as a regular field |
| 2102 |
|| ( exists $to_api_mapping->{$col} && !defined $to_api_mapping->{$col} ); |
| 2103 |
|
| 2104 |
# By now, we are done with known columns, now check the framework for mappings |
| 2105 |
my $field = $self->_result->result_source->name . '.' . $col; |
| 2106 |
|
| 2107 |
# Check there's an entry in the MARC subfield structure for the field |
| 2108 |
if ( exists $mss->{$field} |
| 2109 |
&& scalar @{ $mss->{$field} } > 0 |
| 2110 |
&& $mss->{$field}[0]->{authorised_value} ) |
| 2111 |
{ |
| 2112 |
my $subfield = $mss->{$field}[0]; |
| 2113 |
my $code = $subfield->{authorised_value}; |
| 2114 |
|
| 2115 |
my $str = C4::Biblio::GetAuthorisedValueDesc( $itemtagfield, $subfield->{tagsubfield}, $self->$col, '', $tagslib, undef, $params->{public} ); |
| 2116 |
my $type = exists $code_to_type->{$code} ? $code_to_type->{$code} : 'av'; |
| 2117 |
|
| 2118 |
# The _strings entry should match the API attribute name |
| 2119 |
my $mapped_attr = exists $to_api_mapping->{$col} ? $to_api_mapping->{$col} : $col; |
| 2120 |
|
| 2121 |
$strings->{$mapped_attr} = { |
| 2122 |
str => $str, |
| 2123 |
type => $type, |
| 2124 |
( $type eq 'av' ? ( category => $code ) : () ), |
| 2125 |
}; |
| 2126 |
} |
| 2127 |
} |
| 2128 |
|
| 2129 |
return $strings; |
| 2130 |
} |
| 2131 |
|
| 2061 |
=head3 _type |
2132 |
=head3 _type |
| 2062 |
|
2133 |
|
| 2063 |
=cut |
2134 |
=cut |