Skip to content

Commit

Permalink
Merge pull request #45 from AlexanderBlanchardAC/summon_new_features
Browse files Browse the repository at this point in the history
Summon new features
  • Loading branch information
AlexanderBlanchardAC authored May 13, 2024
2 parents 0bdbf63 + 82f1205 commit e5e37f8
Show file tree
Hide file tree
Showing 18 changed files with 270 additions and 26 deletions.
Binary file added code/folio_export/folio_export.jar
Binary file not shown.
27 changes: 18 additions & 9 deletions code/web/RecordDrivers/SummonRecordDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ public function isValid() {
}

public function getBookcoverUrl($size='large', $absolutePath = false) {
// require_once ROOT_DIR . '/sys/LibraryLocation/Library.php';
global $library;

global $configArray;
if ($size == 'small' || $size == 'medium'){
$sizeInArray = 'thumbnail_m';
}else{
$sizeInArray = 'thumbnail_l';
}
if (!empty($this->record[$sizeInArray][0])) {
$imageDimensions = getimagesize($this->record[$sizeInArray][0]);
if ($sizeInArray == 'thumbnail_m' && $imageDimensions[0] > 10) {
return $this->record[$sizeInArray][0];
} elseif ($sizeInArray == 'thumbnail_l' && $imageDimensions[0] > 10) {
return $this->record[$sizeInArray][0];
}

if ($library->showAvailableCoversInSummon) {
if(!empty($this->record[$sizeInArray][0])){
$imagePath = $this->record[$sizeInArray][0];

$imageDimensions = getImageSize($imagePath);
if($imageDimensions[0] > 10){
return $imagePath;
}
}
}
if ($absolutePath) {
$bookCoverUrl = $configArray['Site']['url'];
Expand Down Expand Up @@ -236,6 +242,9 @@ public function getStaffView() {
public function getTitle() {
if (isset($this->record['Title'])) {
$title=$this->record['Title'][0];
if (isset($this->record['Subtitle'])) {
$title .= ': ' . $this->record['Subtitle'][0];
}
} else {
$title='Unknown Title';
}
Expand Down Expand Up @@ -333,8 +342,8 @@ public function getPrimaryAuthor() {
}

public function getAuthor() {
if(isset($this->record['Author'][0])) {
$author=$this->record['Author'][0];
if(isset($this->record['Author_xml'][0]['fullname'])) {
$author=$this->record['Author_xml'][0]['fullname'];
} else {
$author='Unknown Title';
}
Expand Down
8 changes: 8 additions & 0 deletions code/web/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,14 @@
}
header("Location: " . $followupUrl);
exit();
} elseif ($_REQUEST['followupAction'] == 'AccessOnline' && $_REQUEST['followupModule'] == 'Summon') {
$followupUrl = "/" . strip_tags($_REQUEST['followupModule']);
$followupUrl .= "/" . strip_tags($_REQUEST['followupAction']);
if (!empty($_REQUEST['recordId'])) {
$followupUrl .= "?id=" . strip_tags($_REQUEST['recordId']);
}
header("Location: " . $followupUrl);
exit();
} elseif ($_REQUEST['followupModule'] == 'WebBuilder') {
echo("Redirecting to followup location");
$followupUrl = "/" . strip_tags($_REQUEST['followupModule']);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{strip}
{* TODO: Consider renaming classes to assume they are under the exploreMoreBar class *}
{if !empty($showExploreMoreOptions)}
<div class="exploreMoreBar row">
{*<div class="label-left">*}
<div class="label-top">
Expand Down Expand Up @@ -50,4 +51,9 @@
</div>

</div>
{/strip}
{else}
<div>
</div>
{/if}
{/strip}

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{if !empty($showMoreInfo)}
{if $showMoreInfo !== false}
<div class="btn-group btn-group-sm">
<a href="{if !empty($summUrl)}{$summUrl}{else}{$recordDriver->getLinkUrl()}{/if}" class="btn btn-sm btn-tools" onclick="AspenDiscovery.EBSCO.trackEdsUsage('{$recordDriver->getPermanentId()}')" target="_blank" aria-label="{translate text='More Info' isPublicFacing=true} ({translate text='opens in new window' isPublicFacing=true})"><i class="fas fa-external-link-alt" role="presentation"></i> {translate text="More Info" isPublicFacing=true}</a>
<a href="{if !empty($summUrl)}{$summUrl}{else}{$recordDriver->getLinkUrl()}{/if}" class="btn btn-sm btn-tools" onclick="AspenDiscovery.Summon.trackSummonUsage('{$recordDriver->getPermanentId()}')" target="_blank" aria-label="{translate text='More Info' isPublicFacing=true} ({translate text='opens in new window' isPublicFacing=true})"><i class="fas fa-external-link-alt" role="presentation"></i> {translate text="More Info" isPublicFacing=true}</a>
</div>
{/if}
{if $showFavorites == 1}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[ZoneTransfer]
ZoneId=3
ReferrerUrl=https://www.google.com/
HostUrl=https://files.mtstatic.com/site_11811/55152/0?Expires=1708452791&Signature=O-eIysOYl-1drJTT2f6LTnuDXMhKycAnvuWBQT53Y5WC-uFeYwIE744-kFoVgc-gDsc1ODNBFX1G09SEdxs6NAzaBLFM1c9V0Xq3GZiKsUMivxIQC8YNpa9VHLWM0KE-snOgnMcGuuzuqvpFNAZA5J7FNpYuE~F2eWzOKKYIdhw_&Key-Pair-Id=APKAJ5Y6AV4GI7A555NA
90 changes: 90 additions & 0 deletions code/web/services/Summon/AccessOnline.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

require_once ROOT_DIR . '/RecordDrivers/SummonRecordDriver.php';

class Summon_AccessOnline extends Action {

private $recordDriver;

function launch() {
global $interface;
$id = urldecode($_REQUEST['id']);

$this->recordDriver = new SummonRecordDriver($id);

if ($this->recordDriver->isValid()) {
$activeIP = IPAddress::getActiveIp();
$subnet = IPAddress::getIPAddressForIp($activeIP);
$okToAccess = false;
if ($subnet != false && $subnet->authenticatedForSummon) {
$okToAccess = UserAccount::isLoggedIn();
}

if ($okToAccess) {
require_once ROOT_DIR . '/sys/Summon/SummonRecordUsage.php';
$summonRecordUsage = new SummonRecordUsage();
global $aspenUsage;
$summonRecordUsage->instance = $aspenUsage->getInstance();
$summonRecordUsage->summonId = $id;
$summonRecordUsage->year = date('Y');
$summonRecordUsage->month = date('n');
if ($summonRecordUsage->find(true)) {
$summonRecordUsage->timesUsed++;
$ret = $summonRecordUsage->update();
if ($ret == 0) {
echo("Unable to update times used");
}
} else {
$summonRecordUsage->timesViewedInSearch = 0;
$summonRecordUsage->timesUsed = 1;
$summonRecordUsage->insert();
}

$userId = UserAccount::getActiveUserId();
if ($userId) {
require_once ROOT_DIR . '/sys/Summon/UserSummonUsage.php';
$userSummonUsage = new UserSummonUsage();
global $aspenUsage;
$userSummonUsage->instance = $aspenUsage->getInstance();
$userSummonUsage->userId = $userId;
$userSummonUsage->year = date('Y');
$userSummonUsage->month = date('n');

if ($userSummonUsage->find(true)) {
$userSummonUsage->usageCount++;
$userSummonUsage->update();
} else {
$userSummonUsage->usageCount = 1;
$userSummonUsage->insert();
}
}
header('Location:' . $this->recordDriver->getRecordUrl());
die();
} else {
require_once ROOT_DIR . '/services/MyAccount/Login.php';
$launchAction = new MyAccount_Login();
$_REQUEST['followupModule'] = 'Summon';
$_REQUEST['followUpAction'] = 'AccessOnline';
$_REQUEST['recordId'] = $id;

$error_msg = translate([
'text' => 'You must be logged in to access content from Summon',
'isPublicFacing' => true,
]);
$launchAction->launch($error_msg);
}
} else {
$this->display('../Record/invalidRecord.tpl', 'Invalid Record', '');
die();
}
}

function getBreadcrumbs(): array {
$breadcrumbs = [];
if (!empty($this->lastSearch)) {
$breadcrumbs[] = new Breadcrumb($this->lastSearch, 'Articles and Databases Search Results');
}
$breadcrumbs[] = new Breadcrumb('', $this->recordDriver->getTitle());
return $breadcrumbs;
}
}
7 changes: 7 additions & 0 deletions code/web/sys/DBMaintenance/summon_updates.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,12 @@ function getSummonUpdates() {
'ALTER TABLE library ADD COLUMN summonApiPassword VARCHAR(50)',
],
],
'add_book_cover_display_control_in_library_settings' => [
'title' => 'Display Available Book Covers in Summon',
'description' => 'Whether to display available book covers in Summon Searcher',
'sql' => [
"ALTER TABLE library ADD COLUMN showAvailableCoversInSummon TINYINT(1) DEFAULT 0",
],
],
];
}
2 changes: 1 addition & 1 deletion code/web/sys/DBMaintenance/version_updates/23.12.01.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ function getUpdates23_12_01(): array {
'UPDATE overdrive_settings SET runFullUpdate = 1',
]
], //force_overdrive_full_update
];
];
}
19 changes: 17 additions & 2 deletions code/web/sys/DBMaintenance/version_updates/24.05.00.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,22 @@ function getUpdates24_05_00(): array {
'ALTER TABLE javascript_snippets ADD COLUMN containsAnalyticsCookies TINYINT(1)'
]
], //Snippet_Contains_Marketing_Cookies



//alexander - PTFS Europe
'summon_ip_addresses' => [
'title' => 'Summon IP address configuration',
'description' => 'Allow configuration of which IP addresses should automatically authenticate with Summon',
'continueOnError' => true,
'sql' => [
'ALTER TABLE ip_lookup ADD COLUMN authenticatedForSummon TINYINT DEFAULT 0',
]
], //summon authentication
'explore_more_section_control' => [
'title' => 'Explore More Section Control',
'description' => 'Allow control over whether the Explore More Section is displayed',
'sql' => [
"ALTER TABLE layout_settings ADD COLUMN showExploreMoreOptions TINYINT DEFAULT '1'",
]
],//control_whether_the_explore_more_box_is_displayed
];
}
10 changes: 5 additions & 5 deletions code/web/sys/ExploreMore.php
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ public function loadSummonOptions($activeSection, $exploreMoreOptions, $searchTe
global $enabledModules;
if (!empty($searchTerm) && array_key_exists('Summon', $enabledModules) && $library->summonSettingsId != -1 && $activeSection != 'summon') {
//Load Summon Options
/** @var Search_Object_SummonSearcher $summonSearcher */
/** @var SearchObject_SummonSearcher $summonSearcher */
$summonSearcher = SearchObjectFactory::initSearchObject('Summon');
$summonSearcher->setSearchTerms([
'lookfor' => $searchTerm,
Expand All @@ -745,9 +745,9 @@ public function loadSummonOptions($activeSection, $exploreMoreOptions, $searchTe
$numMatches = $summonResults['recordCount'];
if ($numMatches > 1) {
if ($appliedTheme != null && !empty($appliedTheme->articlesDBImage)) {
//TODO path to image files
$image = '/files/origional/' . $appliedTheme->articlesDBImage;
} else {
//TODO inset path to default image
$image = '/interface/themes/responsive/images/summon.png';
}
$exploreMoreOptions['searchLinks'][] = [
'label' => translate([
Expand All @@ -760,8 +760,8 @@ public function loadSummonOptions($activeSection, $exploreMoreOptions, $searchTe
1 => $searchTerm,
'isPublicFacing' => true,
]),
//'image' => $image,
//'link' => TODO,
'image' => $image,
'link' => '/Summon/Results?lookfor=' . urlencode($searchTerm),
'openInNewWindow' => false,
];
}
Expand Down
1 change: 1 addition & 0 deletions code/web/sys/Grouping/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ function getSchemaOrgType() {
case 'eAudiobook':
case 'eBook':
case 'eMagazine':
case 'eResource':
case 'CD':
case 'Journal':
case 'Large Print':
Expand Down
10 changes: 10 additions & 0 deletions code/web/sys/IP/IPAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,23 @@ static function getObjectStructure($context = ''): array {
'label' => 'Allow Single Sign-on (SSO)',
'description' => 'Traffic from this IP will be allowed to use single sign-on.',
'default' => false,
],
'authenticatedForSummon' => [
'property' => 'authenticatedForSummon',
'type' => 'checkbox',
'label' => 'Authenticated For Summon',
'description' => 'Traffic from this IP will be automatically authenticated in Summon',
'default' => false,
]
];

global $enabledModules;
if (!array_key_exists('EBSCOhost', $enabledModules)) {
unset ($structure['authenticatedForEBSCOhost']);
}
if (!array_key_exists('Summon', $enabledModules)) {
unset ($structure['authenticatedForSummon']);
}
return $structure;
}

Expand Down
1 change: 1 addition & 0 deletions code/web/sys/Interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ function loadDisplayOptions($fromBookCoverProcessing = false) {
$this->assign('showDisplayNameInHeader', $library->showDisplayNameInHeader);
$this->assign('externalMaterialsRequestUrl', $library->externalMaterialsRequestUrl);
$this->assign('languageAndDisplayInHeader', $library->languageAndDisplayInHeader);
$this->assign('showExploreMoreOptions', $library->getLayoutSettings()->showExploreMoreOptions);

if ($location != null) {
$this->assign('showDisplayNameInHeader', $location->showDisplayNameInHeader);
Expand Down
11 changes: 10 additions & 1 deletion code/web/sys/LibraryLocation/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ class Library extends DataObject {

//Summon Settings
public $summonSettingsId;
public $showAvailableCoversInSummon;

//SSO
public /** @noinspection PhpUnused */
Expand Down Expand Up @@ -3702,7 +3703,6 @@ static function getObjectStructure($context = ''): array {
'label' => 'Summon',
'hideInLists' => true,
'renderAsHeading' => true,
// 'permissions' => ['A'],
'properties' => [
'summonSettingsId' => [
'property' => 'summonSettingsId',
Expand All @@ -3713,6 +3713,14 @@ static function getObjectStructure($context = ''): array {
'hideInLists' => true,
'default' => -1,
],
'showAvailableCoversInSummon' => [
'property' => 'showAvailableCoversInSummon',
'type' => 'checkbox',
'label' => 'Show Available Covers in Summon',
'description' => 'Determine whether or not available book covers should be displayed in Summon',
'hideInLists' => true,
'default' => 0,
],
],
],

Expand Down Expand Up @@ -4950,6 +4958,7 @@ public function getApiInfo(): array {
'passwordLabel' => $this->loginFormPasswordLabel ?? 'Library Card Number',
'code' => $this->ilsCode,
'finePaymentType' => (int)$this->finePaymentType,
'showAvailableCoversInSummon' => $this->showAvailableCoversInSummon,
];
if (empty($this->baseUrl)) {
$apiInfo['baseUrl'] = $configArray['Site']['url'];
Expand Down
Loading

0 comments on commit e5e37f8

Please sign in to comment.