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