Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 13 additions & 21 deletions Koha/Plugin/OAKoha.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ use Cwd qw( abs_path );
use File::Basename qw( dirname );
use JSON qw/decode_json encode_json/;



my $PluginDir = C4::Context->config("pluginsdir");
$PluginDir = $PluginDir.'/Koha/Plugin/OAKoha';

## Here we set our plugin version
our $VERSION = 16.1105;
our $VERSION = 21.1101;

## Here is our metadata, some keys are required, some are optional
our $metadata = {
Expand All @@ -25,8 +23,8 @@ our $metadata = {
description =>
'This plugin integrates Open Athens(OA) in Koha.<p>Go to Actions:Configure to set the API connection then go to the Actions:Run to configure attributes.</p>',
date_authored => '2017-03-28',
date_updated => '2017-05-16',
minimum_version => '16.11',
date_updated => '2022-07-27',
minimum_version => '21.11',
maximum_version => '',
version => $VERSION,
};
Expand Down Expand Up @@ -93,7 +91,6 @@ sub configure {
}
}


sub SetupTool {
my ( $self, $args ) = @_;
my $cgi = $self->{'cgi'};
Expand Down Expand Up @@ -123,7 +120,7 @@ sub SetupTool {
#use Data::Dumper; die Dumper @borrower_fields;

my $enableOA = 0;
if($OpacUserJS =~m/\/\*oa{\*\/.*\/\*\}oa\*\//){$enableOA=1;}
if($OpacUserJS =~m/\/\*oa\{\*\/.*\/\*\}oa\*\//){$enableOA=1;}



Expand All @@ -141,17 +138,19 @@ sub SetupTool {
my $oaJS = '/*oa{*/var oas=document.createElement( "script" );oas.type = "text/javascript";oas.src="/plugin/Koha/Plugin/OAKoha/OAKoha.js";document.body.appendChild(oas);/*}oa*/';

if($oaEnableSetting==1){
if($OpacUserJS =~m/\/\*oa{\*\/.*\/\*\}oa\*\//){}else{
if($OpacUserJS =~m/\/\*oa\{\*\/.*\/\*\}oa\*\//){}else{
$OpacUserJS = $OpacUserJS.$oaJS;
}
}else{
if($OpacUserJS =~m/\/\*oa{\*\/.*\/\*\}oa\*\//){
$OpacUserJS=~s/\/\*oa{\*\/.*\/\*\}oa\*\///g;
if($OpacUserJS =~m/\/\*oa\{\*\/.*\/\*\}oa\*\//){
$OpacUserJS=~s/\/\*oa\{\*\/.*\/\*\}oa\*\///g;
}
}

my $enableOAQuery = C4::Context->dbh->do("UPDATE `systempreferences` SET `value`='".$OpacUserJS."' WHERE `variable`='OpacUserJS'");

my $dbh = C4::Context->dbh;
my $update_sql = "UPDATE systempreferences SET value = ? WHERE variable = 'OpacUserJS'";
my $update_sth = $dbh->prepare($update_sql);
$update_sth->execute($OpacUserJS);

$self->store_data(
{
Expand All @@ -162,22 +161,15 @@ sub SetupTool {
}
}


sub install() {
my ( $self, $args ) = @_;

my $pluginSQL = C4::Context->dbh->do("INSERT INTO `plugin_data` (`plugin_class`, `plugin_key`, `plugin_value`) VALUES ('OA::Plugin', 'installedversion', '".$VERSION."')");
my $pluginSQL = C4::Context->dbh->do("INSERT IGNORE INTO `plugin_data` (`plugin_class`, `plugin_key`, `plugin_value`) VALUES ('OA::Plugin', 'installedversion', '".$VERSION."')");
$pluginSQL = C4::Context->dbh->do("UPDATE `plugin_data` SET `plugin_value` ='".$VERSION."' WHERE `plugin_class` = 'OA::Plugin' AND `plugin_key`= 'installedversion'");
}




sub uninstall() {
my ( $self, $args ) = @_;

my $enableOA = C4::Context->dbh->do("INSERT INTO `systempreferences` (`variable`, `value`, `explanation`, `type`) VALUES ('OAEnabled', '1', 'If ON, enables OA Authentication on Koha login.', 'YesNo') ON DUPLICATE KEY UPDATE `variable`='OAEnabled', `value`=1, `explanation`='If ON, enables OA Authentication on Koha login.', `type`='YesNo'");


my $enableOAUpdate = C4::Context->dbh->do("UPDATE `systempreferences` SET `value`='1' WHERE `variable`='OAEnabled'");
}
1;
14 changes: 8 additions & 6 deletions Koha/Plugin/OAKoha/OAKoha.pl
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@

use CGI qw ( -utf8 );

use C4::Auth;
use Koha::Patrons;

use C4::Auth qw/get_template_and_user/;
use C4::Koha;
use C4::Output;
use C4::Output qw/output_html_with_http_headers/;
use JSON;
use Encode qw( encode is_utf8);
use MIME::Base64;
Expand All @@ -49,7 +51,8 @@
$sth->execute( $PluginClass );
$sth->execute();

my $PluginDir = dirname(abs_path($0));
my $PluginDir = C4::Context->config("pluginsdir");
$PluginDir = $PluginDir.'/Koha/Plugin/OAKoha';

my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
{
Expand Down Expand Up @@ -87,16 +90,15 @@
when('params') {$params=$r->{plugin_value};}
}
}
require C4::Members;
my $base_url = $oaconnectionurl;
my $api_key = $oaapikey;

#Get Koha borrower details according to params specified
#Borrower details are obtained in context of a logged in user.
my @params_arr = split /,/, $params;
my $attrib_json = {};
my $borrow = C4::Members::GetMember( borrowernumber => $borrowernumber );

my $borrow = Koha::Patrons->find( $borrowernumber )->unblessed;
if (defined $query->param("borrower")){use Data::Dumper; die Dumper $borrow;}

if (scalar @params_arr > 0){
Expand Down
Empty file modified Koha/Plugin/OAKoha/configure.tt
100644 → 100755
Empty file.
Empty file modified Koha/Plugin/OAKoha/opac-oa.tt
100644 → 100755
Empty file.
Empty file modified Koha/Plugin/OAKoha/setuptool.tt
100644 → 100755
Empty file.
13 changes: 12 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ openathens-koha-plugin

openathens-koha-plugin

Tested on Koha v 16.11+
Tested on Koha v 21.11

Quick Installation steps
==================
Expand All @@ -17,3 +17,14 @@ Upload Plugin
Click on Run Tool and follow instructions.

Click on Configure and enter required details from OA admin.

Troubleshooting
==================
Apache may need to be configured to correctly run the plugin

See https://github.com/ebsco/edsapi-koha-plugin/wiki/Apache-Setup for more details

Technical
==================
TLS 1.2+ is required on the Koha server.
See http://docs.openathens.net/display/public/MD/Implementing+the+API+connector+in+your+code
Binary file removed oa_plugin_16.1105.kpz
Binary file not shown.
Binary file added oa_plugin_21.1101.kpz
Binary file not shown.