From 44f2b41d6f3f6fd30ca412ea3e4a12258cacee35 Mon Sep 17 00:00:00 2001 From: Mark Noble Date: Fri, 29 Mar 2024 09:21:17 -0600 Subject: [PATCH] When determining the active search location, match the rules for determining scope. First check the subdomain against the active subdomain and then check the location code but only if the subdomain is blank. --- code/web/release_notes/24.04.00.MD | 3 ++ code/web/sys/ConfigArray.php | 59 ++++++++++++----------- code/web/sys/LibraryLocation/Location.php | 10 ++-- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/code/web/release_notes/24.04.00.MD b/code/web/release_notes/24.04.00.MD index 26a3121196..84c86eb742 100644 --- a/code/web/release_notes/24.04.00.MD +++ b/code/web/release_notes/24.04.00.MD @@ -15,6 +15,9 @@ ### Marc holdings updates - Update logic for determining the display name for an owning library for a marc holding. (Ticket 124256) (*MDN*) +### Search Updates +- When determining the active search location, match the rules for determining scope. First check the subdomain against the active subdomain and then check the location code but only if the subdomain is blank. (Ticket 128603) (*MDN*) + ### Sierra Updates - Update Sierra Export to handle MARC holdings that do not have a MARC tag associated with them. (Ticket 124256) (*MDN*) - Fix loading location for additional copies. (Ticket 124256) (*MDN*) diff --git a/code/web/sys/ConfigArray.php b/code/web/sys/ConfigArray.php index 0b87c87363..d45b5d92ba 100644 --- a/code/web/sys/ConfigArray.php +++ b/code/web/sys/ConfigArray.php @@ -327,38 +327,39 @@ function updateConfigForScoping($configArray) { if ($Location->getNumResults() == 1) { $Location->fetch(); //We found a location for the subdomain, get the library. + if (($Location->subdomain == $subdomain) || (empty($Location->subdomain))) { + global $librarySingleton; + $library = $librarySingleton->getLibraryForLocation($Location->locationId); + $locationSingleton->setActiveLocation(clone $Location); + $timer->logTime("found the location and library based on subdomain"); + break; + } + } - global $librarySingleton; - $library = $librarySingleton->getLibraryForLocation($Location->locationId); - $locationSingleton->setActiveLocation(clone $Location); - $timer->logTime("found the location and library based on subdomain"); + //Check to see if there is only one library in the system + $Library = new Library(); + $Library->find(); + if ($Library->getNumResults() == 1) { + $Library->fetch(); + $library = $Library; + $timer->logTime("there is only one library for this install"); break; } else { - //Check to see if there is only one library in the system - $Library = new Library(); - $Library->find(); - if ($Library->getNumResults() == 1) { - $Library->fetch(); - $library = $Library; - $timer->logTime("there is only one library for this install"); - break; - } else { - //If we are on the last subdomain to test, grab the default. - if ($i == count($subdomainsToTest) - 1) { - //Get the default library - $Library = new Library(); - $Library->isDefault = 1; - $Library->find(); - if ($Library->getNumResults() == 1) { - $Library->fetch(); - $library = $Library; - $timer->logTime("found the library based on the default"); - } else { - //Just grab the first library sorted alphabetically by subdomain - $library = new Library(); - $library->orderBy('subdomain'); - $library->find(true); - } + //If we are on the last subdomain to test, grab the default. + if ($i == count($subdomainsToTest) - 1) { + //Get the default library + $Library = new Library(); + $Library->isDefault = 1; + $Library->find(); + if ($Library->getNumResults() == 1) { + $Library->fetch(); + $library = $Library; + $timer->logTime("found the library based on the default"); + } else { + //Just grab the first library sorted alphabetically by subdomain + $library = new Library(); + $library->orderBy('subdomain'); + $library->find(true); } } } diff --git a/code/web/sys/LibraryLocation/Location.php b/code/web/sys/LibraryLocation/Location.php index 81c75f924d..a90596e6e1 100644 --- a/code/web/sys/LibraryLocation/Location.php +++ b/code/web/sys/LibraryLocation/Location.php @@ -1492,9 +1492,9 @@ function getActiveLocation() { Location::$activeLocation = null; } } else { - //Check to see if we can get the active location based off the sublocation + //Check to see if we can get the active location based off the subdomain $activeLocation = new Location(); - $activeLocation->code = $locationCode; + $activeLocation->subdomain = $locationCode; if ($activeLocation->find(true)) { //Only use the location if we are in the subdomain for the parent library if ($library->libraryId == $activeLocation->libraryId) { @@ -1504,10 +1504,10 @@ function getActiveLocation() { Location::$activeLocation = null; } } else { - //Check to see if we can get the active location based off the sublocation + //Check to see if we can get the active location based off the location code $activeLocation = new Location(); - $activeLocation->subdomain = $locationCode; - if ($activeLocation->find(true)) { + $activeLocation->code = $locationCode; + if ($activeLocation->find(true) && empty($activeLocation->subdomain)) { //Only use the location if we are in the subdomain for the parent library if ($library->libraryId == $activeLocation->libraryId) { Location::$activeLocation = clone $activeLocation;