Skip to content

Commit

Permalink
Merge pull request #61 from AlexanderBlanchardAC/24.06.00_add-to-econ…
Browse files Browse the repository at this point in the history
…tent

24.06.00 add to econtent
  • Loading branch information
AlexanderBlanchardAC authored May 30, 2024
2 parents a119181 + 656fd2f commit 0d2ef7c
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 1 deletion.
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
10 changes: 9 additions & 1 deletion code/web/release_notes/24.06.00.MD
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,18 @@
- Added new Documentation links to several settings pages (*MKD*)
- Updates to default user roles: removed testing roles and a couple uncommonly used roles; updated role titles (*MKD*)

//alexander
### Other Updates
- Added eResource to iType so that it displays as an access online button


## This release includes code contributions from
- ByWater Solutions
- Mark Noble (MDN)
- Kirstin Kroeger (KK)
- Kodi Lein (KL)
- Liz Rea (LR)
- Morgan Daigneault (MKD)
- Morgan Daigneault (MKD)

- PTFS Europe
- Alexander Blanchard(AB)
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;
}
}
9 changes: 9 additions & 0 deletions code/web/sys/DBMaintenance/version_updates/24.06.00.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ function getUpdates24_06_00(): array {
],
], //full_text_limiter

//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',
]
],
//other


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

0 comments on commit 0d2ef7c

Please sign in to comment.