1 # Copyright 2014 Catalyst
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 package Koha::ExternalContent;
22 use base qw(Class::Accessor);
28 __PACKAGE__->mk_accessors(qw(client koha_session_id koha_patron));
36 use Koha::ExternalContent;
37 my $externalcontent = Koha::ExternalContent->new();
41 Base class for interfacing with external content providers.
43 Subclasses provide clients for particular systems. This class provides
44 common methods for getting Koha patron.
51 return 'Koha/'.Koha::version();
56 my $params = shift || {};
57 return bless $params, $class;
62 my $session_id = $self->koha_session_id or return;
63 return C4::Auth::get_session($session_id);
66 sub get_from_koha_session {
68 my $key = shift or croak "No key";
69 my $session = $self->_koha_session or return;
70 return $session->param($key);
73 sub set_in_koha_session {
75 my $key = shift or croak "No key";
77 my $session = $self->_koha_session or croak "No Koha session";
78 return $session->param($key, $value);
84 if (my $patron = $self->_koha_patron_accessor) {
88 my $id = $self->get_from_koha_session('number')
90 my $patron = Koha::Patrons->find($id)
91 or die "Invalid patron number in session";
92 return $self->_koha_patron_accessor($patron);