Skip to content
This repository has been archived by the owner on Feb 26, 2025. It is now read-only.

Commit

Permalink
Merge pull request coral-erm#583 from queryluke/bc-ekb-option2
Browse files Browse the repository at this point in the history
SirsiDynix: EBSCO Kb Interface Updates
  • Loading branch information
andyp-uk authored Feb 5, 2020
2 parents 6cc256b + 42a080c commit bbb4e44
Show file tree
Hide file tree
Showing 17 changed files with 628 additions and 94 deletions.
54 changes: 45 additions & 9 deletions resources/admin/classes/domain/EbscoKbService.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class EbscoKbService {
'count' => 20,
'type' => 'titles',
'searchfield' => 0,
'selection' => 1,
'selection' => 0,
'resourcetype' => 0,
'contenttype' => 0,
'vendorId' => null,
Expand Down Expand Up @@ -264,21 +264,39 @@ public function getPackage($vendorId, $packageId)
return new EbscoKbPackage($this->response);
}

public function execute()
public function execute($method = 'GET')
{
array_unshift($this->queryPath,$this->config->settings->ebscoKbCustomerId);
$url = self::$apiUrl.implode('/',$this->queryPath);
if(!empty($this->queryParams)){
$url .= '?'.http_build_query($this->queryParams);
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
$headers = [
'Accept: application/json',
'x-api-key: '.$this->config->settings->ebscoKbApiKey,
]);
];

if ($method != 'GET') {
$headers[] = 'Content-Type: application/json';
if ($method == 'POST') {
curl_setopt($ch, CURLOPT_POST, 1);
}
if ($method == 'PUT') {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
}
}

if(!empty($this->queryParams)){
if ($method === 'GET') {
$url .= '?'.http_build_query($this->queryParams);
} else {
$params = json_encode($this->queryParams);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
$headers[] = 'Content-Length: '.strlen($params);
}
}
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$response = curl_exec($ch);
curl_close ($ch);
Expand Down Expand Up @@ -306,4 +324,22 @@ public function results()
return new $class($e);
}, $this->response[$listKey]);
}

/*
* Selection Functions
*/

public function setPackage($vendorId, $packageId, $selected = true) {
$this->queryPath = ['vendors', $vendorId, 'packages', $packageId];
$this->queryParams = ['isSelected' => $selected];
$this->execute('PUT');
return $this->response;
}

public function setTitle($vendorId, $packageId, $titleId, $selected = true) {
$this->queryPath = ['vendors', $vendorId, 'packages', $packageId, 'titles', $titleId];
$this->queryParams = ['isSelected' => $selected];
$this->execute('PUT');
return $this->response;
}
}
10 changes: 10 additions & 0 deletions resources/admin/classes/domain/EbscoKbTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ class EbscoKbTitle extends EbscoKbResult {

public $resource;
public $inCoral;
public $packages;

public function getIsPeerReviewed($value)
{
Expand Down Expand Up @@ -67,6 +68,15 @@ public function loadResource($resourceId = null)
}
}

public function getSelected()
{
foreach($this->customerResourcesList as $resource) {
if ($resource->isSelected) {
return true;
}
}
}

public function getCoverageTextArray()
{

Expand Down
14 changes: 12 additions & 2 deletions resources/ajax_forms/getEbscoKbPackageImportForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

$packageId = filter_input(INPUT_GET, 'packageId', FILTER_SANITIZE_STRING);
$vendorId = filter_input(INPUT_GET, 'vendorId', FILTER_SANITIZE_STRING);
$setAsSelected = filter_input(INPUT_GET, 'select', FILTER_VALIDATE_BOOLEAN);
$fallbackTitleId = filter_input(INPUT_GET, 'fallbackTitleId', FILTER_SANITIZE_NUMBER_INT);

if ($fallbackTitleId) {
$cancelJs = "tb_show(null,'ajax_htmldata.php?action=getEbscoKbTitleDetails&height=700&width=730&modal=true&titleId=$fallbackTitleId');";
} else {
$cancelJs = 'tb_remove()';
}

if(!isset($packageId) || !isset($vendorId)){
echo '<p>Missing Package or Vendor ID</p>';
Expand Down Expand Up @@ -72,7 +80,6 @@
}

?>
<?php include_once __DIR__.'/../css/ebscoKbCss.php'; ?>
<div class="ebsco-layout" style="width:745px; height: 650px;">

<div id="div_ebscoKbPackageImportForm" class="ebsco-layout">
Expand All @@ -93,6 +100,9 @@
<input type="hidden" id="organizationId" name="organizationId" value="<?php echo empty($organization) ? '' : $organization->primaryKey; ?>" />
<input type="hidden" id="packageId" name="packageId" value="<?php echo $package->packageId; ?>" />
<input type="hidden" id="vendorId" name="vendorId" value="<?php echo $package->vendorId; ?>" />
<?php if($setAsSelected): ?>
<input type="hidden" id="setAsSelected" name="setAsSelected" value="true" />
<?php endif; ?>
<input type="hidden" id="importType" name="importType" value="package" />
<div class="row">
<div class="col-6">
Expand Down Expand Up @@ -342,7 +352,7 @@
<button class="btn btn-primary" onclick="processEbscoKbImport('progress','#ebscoKbPackageImportForm')">
<?php echo _("import");?>
</button>
<button class="btn btn-primary ml-1" onclick="tb_remove()"><?php echo _("cancel");?></button>
<button class="btn btn-primary ml-1" onclick="<?php echo $cancelJs; ?>"><?php echo _("cancel");?></button>
</div>
</div>
</div>
Expand Down
72 changes: 72 additions & 0 deletions resources/ajax_forms/getEbscoKbRemoveConfirmation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
$resourceID = filter_input(INPUT_GET, 'resourceID', FILTER_SANITIZE_NUMBER_INT);
$vendorId = filter_input(INPUT_GET, 'vendorId', FILTER_SANITIZE_NUMBER_INT);
$packageId = filter_input(INPUT_GET, 'packageId', FILTER_SANITIZE_NUMBER_INT);
$titleId = filter_input(INPUT_GET, 'titleId', FILTER_SANITIZE_NUMBER_INT);
$page = filter_input(INPUT_GET, 'page', FILTER_SANITIZE_NUMBER_INT);
$fallbackTitleId = filter_input(INPUT_GET, 'fallbackTitleId', FILTER_SANITIZE_NUMBER_INT);
$resource = new Resource(new NamedArguments(array('primaryKey' => $resourceID)));
$childrenCount = count($resource->getChildResources());

$page = empty($page) ? 1 : $page;

if ($fallbackTitleId) {
$href = "ajax_htmldata.php?action=getEbscoKbTitleDetails&height=700&width=730&modal=true&titleId=$fallbackTitleId&page=$page";
$callback = "tb_show.bind(null,null,'$href')";
$cancelJs = "tb_show(null,'$href')";
} else {
$callback = "updateSearch.bind(null, $page, tb_remove)";
$cancelJs = 'tb_remove()';
}


$jsTitleId = empty($titleId) ? 'null' : $titleId;
$jsVars = [
empty($resourceID) ? 'null' : $resourceID,
empty($vendorId) ? 'null' : $vendorId,
empty($packageId) ? 'null' : $packageId,
$jsTitleId,
$callback
];

$title = _('You are about to deselect the following resource from Ebsco and delete it from Coral');
$option1 = _('deselect & delete');
$option2 = _("deselect & delete, including $childrenCount child records");

if (empty($packageId)) {
$title = _('Are you sure you want to delete the following resource from Coral?');
$option1 = _('yes, delete resource');
$option2 = _("yes, and delete all $childrenCount child records");
}


?>

<div id="div_ebscoKbConfirmDeletion" class="ebsco-layout" style="width:745px;">
<div id="deleteError"></div>
<div class="container" style="text-align: center">
<p class="bigDarkRedText">
<?php echo $title; ?>
</p>
<p style="font-size: 1.3em;"><?php echo $resource->titleText ?></p>
<div class="row" style="padding-top: 2em;">
<div class="col-3">
<button class="btn btn-primary" onclick="deleteEbscoKbResource(<?php echo implode(',',$jsVars); ?>,false)">
<?php echo $option1; ?>
</button>
</div>
<div class="col-6">
<?php if($childrenCount > 0): ?>
<button class="btn btn-primary" onclick="deleteEbscoKbResource(<?php echo implode(',',$jsVars); ?>,true)">
<?php echo $option2; ?>
</button>
<?php endif; ?>
</div>
<div class="col-3">
<button class="btn btn-primary ml-1" onclick="<?php echo $cancelJs; ?>">
<?php echo _('cancel'); ?>
</button>
</div>
</div>
</div>
</div>
12 changes: 11 additions & 1 deletion resources/ajax_forms/getEbscoKbTitleImportForm.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<?php

$titleId = filter_input(INPUT_GET, 'titleId', FILTER_SANITIZE_STRING);
$setAsSelected = filter_input(INPUT_GET, 'select', FILTER_VALIDATE_BOOLEAN);
$fallbackTitleId = filter_input(INPUT_GET, 'fallbackTitleId', FILTER_SANITIZE_NUMBER_INT);

if ($fallbackTitleId) {
$cancelJs = "tb_show(null,'ajax_htmldata.php?action=getEbscoKbTitleDetails&height=700&width=730&modal=true&titleId=$fallbackTitleId');";
} else {
$cancelJs = 'tb_remove()';
}

if(empty($titleId)){
echo '<p>No title ID provided</p>';
Expand All @@ -21,7 +29,6 @@
$resourceFormatArray = $resourceFormatObj->sortedArray();

?>
<?php include_once __DIR__.'/../css/ebscoKbCss.php'; ?>
<div id="div_ebscoKbTitleImportForm" class="ebsco-layout" style="width:745px;">
<div class="formTitle">
<span class="headerText"><?php echo _('Import').' '.$title->titleName.' '._(' from EBSCO Kb'); ?></span>
Expand All @@ -38,6 +45,9 @@
<input type="hidden" id="organizationId" name="organizationId" value="" />
<input type="hidden" id="importType" name="importType" value="title" />
<input type="hidden" id="titleId" name="titleId" value="<?php echo $title->titleId; ?>"/>
<?php if($setAsSelected): ?>
<input type="hidden" id="setAsSelected" name="setAsSelected" value="true" />
<?php endif; ?>
<div class="row">
<div class="col-6">

Expand Down
Loading

0 comments on commit bbb4e44

Please sign in to comment.