Bug 29897: Remove 'linkage' leftover
[koha-ffzg.git] / Koha / Authority.pm
index b4cf946..ff45d20 100644 (file)
@@ -4,18 +4,18 @@ package Koha::Authority;
 #
 # This file is part of Koha.
 #
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
 #
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License along
-# with Koha; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 use Modern::Perl;
 
@@ -114,6 +114,35 @@ sub controlled_indicators {
     });
 }
 
+=head3 get_identifiers
+
+    my $identifiers = $author->get_identifiers;
+
+Return a list of identifiers of the authors which are in 024$2$a
+
+=cut
+
+sub get_identifiers {
+    my ( $self, $params ) = @_;
+
+    my $flavour =
+      C4::Context->preference('marcflavour') eq 'UNIMARC'
+      ? 'UNIMARCAUTH'
+      : 'MARC21';
+    my $record =
+      MARC::Record->new_from_xml( $self->marcxml, 'UTF-8', $flavour );
+
+    my @identifiers;
+    for my $field ( $record->field('024') ) {
+        my $sf_2 = $field->subfield('2');
+        my $sf_a = $field->subfield('a');
+        next unless $sf_2 && $sf_a;
+        push @identifiers, {source => $sf_2, number => $sf_a, };
+    }
+
+    return \@identifiers;
+}
+
 =head2 Class Methods
 
 =head3 type