function loginUser() { //Login the user. Must be called via Post parameters. global $user; global $interface; $user = UserAccount::isLoggedIn(); if (!$user || PEAR_Singleton::isError($user)) { $user = UserAccount::login(); $interface->assign('user', $user); if (!$user || PEAR_Singleton::isError($user)) { return array('success' => false, 'message' => translate("Sorry that login information was not recognized, please try again.")); } } $patronHomeBranch = Location::getUserHomeLocation(); //Check to see if materials request should be activated require_once ROOT_DIR . '/sys/MaterialsRequest.php'; return array('success' => true, 'name' => ucwords($user->firstname . ' ' . $user->lastname), 'phone' => $user->phone, 'email' => $user->email, 'homeLocation' => isset($patronHomeBranch) ? $patronHomeBranch->code : '', 'homeLocationId' => isset($patronHomeBranch) ? $patronHomeBranch->locationId : '', 'enableMaterialsRequest' => MaterialsRequest::enableMaterialsRequest(true)); }
function launch() { global $interface; global $configArray; global $timer; global $analytics; /** @var string|LibrarySearchSource|LocationSearchSource $searchSource */ $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local'; if (preg_match('/library\\d+/', $searchSource)) { $trimmedId = str_replace('library', '', $searchSource); $searchSourceObj = new LibrarySearchSource(); $searchSourceObj->id = $trimmedId; if ($searchSourceObj->find(true)) { $searchSource = $searchSourceObj; } } if (isset($_REQUEST['replacementTerm'])) { $replacementTerm = $_REQUEST['replacementTerm']; $interface->assign('replacementTerm', $replacementTerm); $oldTerm = $_REQUEST['lookfor']; $interface->assign('oldTerm', $oldTerm); $_REQUEST['lookfor'] = $replacementTerm; $_GET['lookfor'] = $replacementTerm; $oldSearchUrl = $_SERVER['REQUEST_URI']; $oldSearchUrl = str_replace('replacementTerm=' . urlencode($replacementTerm), 'disallowReplacements', $oldSearchUrl); $interface->assign('oldSearchUrl', $oldSearchUrl); } // Include Search Engine Class require_once ROOT_DIR . '/sys/Solr.php'; $timer->logTime('Include search engine'); //Check to see if the year has been set and if so, convert to a filter and resend. $dateFilters = array('publishDate'); foreach ($dateFilters as $dateFilter) { if (isset($_REQUEST[$dateFilter . 'yearfrom']) || isset($_REQUEST[$dateFilter . 'yearto'])) { $queryParams = $_GET; $yearFrom = preg_match('/^\\d{2,4}$/', $_REQUEST[$dateFilter . 'yearfrom']) ? $_REQUEST[$dateFilter . 'yearfrom'] : '*'; $yearTo = preg_match('/^\\d{2,4}$/', $_REQUEST[$dateFilter . 'yearto']) ? $_REQUEST[$dateFilter . 'yearto'] : '*'; if (strlen($yearFrom) == 2) { $yearFrom = '19' . $yearFrom; } else { if (strlen($yearFrom) == 3) { $yearFrom = '0' . $yearFrom; } } if (strlen($yearTo) == 2) { $yearTo = '19' . $yearTo; } else { if (strlen($yearFrom) == 3) { $yearTo = '0' . $yearTo; } } if ($yearTo != '*' && $yearFrom != '*' && $yearTo < $yearFrom) { $tmpYear = $yearTo; $yearTo = $yearFrom; $yearFrom = $tmpYear; } unset($queryParams['module']); unset($queryParams['action']); unset($queryParams[$dateFilter . 'yearfrom']); unset($queryParams[$dateFilter . 'yearto']); if (!isset($queryParams['sort'])) { $queryParams['sort'] = 'year'; } $queryParamStrings = array(); foreach ($queryParams as $paramName => $queryValue) { if (is_array($queryValue)) { foreach ($queryValue as $arrayValue) { if (strlen($arrayValue) > 0) { $queryParamStrings[] = $paramName . '[]=' . $arrayValue; } } } else { if (strlen($queryValue)) { $queryParamStrings[] = $paramName . '=' . $queryValue; } } } if ($yearFrom != '*' || $yearTo != '*') { $queryParamStrings[] = "&filter[]={$dateFilter}:[{$yearFrom}+TO+{$yearTo}]"; } $queryParamString = join('&', $queryParamStrings); header("Location: {$configArray['Site']['path']}/Search/Results?{$queryParamString}"); exit; } } $rangeFilters = array('lexile_score', 'accelerated_reader_reading_level', 'accelerated_reader_point_value'); foreach ($rangeFilters as $filter) { if (isset($_REQUEST[$filter . 'from']) && strlen($_REQUEST[$filter . 'from']) > 0 || isset($_REQUEST[$filter . 'to']) && strlen($_REQUEST[$filter . 'to']) > 0) { $queryParams = $_GET; $from = isset($_REQUEST[$filter . 'from']) && preg_match('/^\\d*(\\.\\d*)?$/', $_REQUEST[$filter . 'from']) ? $_REQUEST[$filter . 'from'] : '*'; $to = isset($_REQUEST[$filter . 'to']) && preg_match('/^\\d*(\\.\\d*)?$/', $_REQUEST[$filter . 'to']) ? $_REQUEST[$filter . 'to'] : '*'; if ($to != '*' && $from != '*' && $to < $from) { $tmpFilter = $to; $to = $from; $from = $tmpFilter; } unset($queryParams['module']); unset($queryParams['action']); unset($queryParams[$filter . 'from']); unset($queryParams[$filter . 'to']); $queryParamStrings = array(); foreach ($queryParams as $paramName => $queryValue) { if (is_array($queryValue)) { foreach ($queryValue as $arrayValue) { if (strlen($arrayValue) > 0) { $queryParamStrings[] = $paramName . '[]=' . $arrayValue; } } } else { if (strlen($queryValue)) { $queryParamStrings[] = $paramName . '=' . $queryValue; } } } if ($from != '*' || $to != '*') { $queryParamStrings[] = "&filter[]={$filter}:[{$from}+TO+{$to}]"; } $queryParamString = join('&', $queryParamStrings); header("Location: {$configArray['Site']['path']}/Search/Results?{$queryParamString}"); exit; } } // Initialise from the current search globals /** @var SearchObject_Solr $searchObject */ $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init($searchSource); $timer->logTime("Init Search Object"); // Build RSS Feed for Results (if requested) if ($searchObject->getView() == 'rss') { // Throw the XML to screen echo $searchObject->buildRSS(); // And we're done exit; } else { if ($searchObject->getView() == 'excel') { // Throw the Excel spreadsheet to screen for download echo $searchObject->buildExcel(); // And we're done exit; } } // TODO : Investigate this... do we still need // If user wants to print record show directly print-dialog box if (isset($_GET['print'])) { $interface->assign('print', true); } // Set Interface Variables // Those we can construct BEFORE the search is executed $interface->setPageTitle('Search Results'); $interface->assign('sortList', $searchObject->getSortList()); $interface->assign('rssLink', $searchObject->getRSSUrl()); $interface->assign('excelLink', $searchObject->getExcelUrl()); $timer->logTime('Setup Search'); // Process Search $result = $searchObject->processSearch(true, true); if (PEAR_Singleton::isError($result)) { PEAR_Singleton::raiseError($result->getMessage()); } $timer->logTime('Process Search'); // Some more variables // Those we can construct AFTER the search is executed, but we need // no matter whether there were any results $interface->assign('qtime', round($searchObject->getQuerySpeed(), 2)); $interface->assign('spellingSuggestions', $searchObject->getSpellingSuggestions()); $interface->assign('lookfor', $searchObject->displayQuery()); $interface->assign('searchType', $searchObject->getSearchType()); // Will assign null for an advanced search $interface->assign('searchIndex', $searchObject->getSearchIndex()); // We'll need recommendations no matter how many results we found: $interface->assign('topRecommendations', $searchObject->getRecommendationsTemplates('top')); $interface->assign('sideRecommendations', $searchObject->getRecommendationsTemplates('side')); // 'Finish' the search... complete timers and log search history. $searchObject->close(); $interface->assign('time', round($searchObject->getTotalSpeed(), 2)); // Show the save/unsave code on screen // The ID won't exist until after the search has been put in the search history // so this needs to occur after the close() on the searchObject $interface->assign('showSaved', true); $interface->assign('savedSearch', $searchObject->isSavedSearch()); $interface->assign('searchId', $searchObject->getSearchId()); $currentPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; $interface->assign('page', $currentPage); //Enable and disable functionality based on library settings //This must be done before we process each result global $library; /** @var Location $locationSingleton */ global $locationSingleton; $location = $locationSingleton->getActiveLocation(); $showHoldButton = 1; $showHoldButtonInSearchResults = 1; $interface->assign('showNotInterested', false); if (isset($library) && $location != null) { $interface->assign('showFavorites', $library->showFavorites); $interface->assign('showComments', $library->showComments); $showHoldButton = $location->showHoldButton == 1 && $library->showHoldButton == 1 ? 1 : 0; $showHoldButtonInSearchResults = $location->showHoldButton == 1 && $library->showHoldButtonInSearchResults == 1 ? 1 : 0; } else { if ($location != null) { $interface->assign('showFavorites', 1); $showHoldButton = $location->showHoldButton; } else { if (isset($library)) { $interface->assign('showFavorites', $library->showFavorites); $showHoldButton = $library->showHoldButton; $showHoldButtonInSearchResults = $library->showHoldButtonInSearchResults; $interface->assign('showComments', $library->showComments); } else { $interface->assign('showFavorites', 1); $interface->assign('showComments', 1); } } } if ($showHoldButton == 0) { $showHoldButtonInSearchResults = 0; } $interface->assign('showHoldButton', $showHoldButtonInSearchResults); $interface->assign('page_body_style', 'sidebar_left'); $interface->assign('overDriveVersion', isset($configArray['OverDrive']['interfaceVersion']) ? $configArray['OverDrive']['interfaceVersion'] : 1); //Check to see if we should show unscoped results $enableUnscopedSearch = false; $searchLibrary = Library::getSearchLibrary(); if ($searchLibrary != null && $searchLibrary->showMarmotResultsAtEndOfSearch) { if (is_object($searchSource)) { $enableUnscopedSearch = $searchSource->catalogScoping != 'unscoped'; $unscopedSearch = clone $searchObject; } else { $searchSources = new SearchSources(); $searchOptions = $searchSources->getSearchSources(); if (isset($searchOptions['marmot'])) { $unscopedSearch = clone $searchObject; $enableUnscopedSearch = true; } } } $enableProspectorIntegration = isset($configArray['Content']['Prospector']) ? $configArray['Content']['Prospector'] : false; $showRatings = 1; $showProspectorResultsAtEndOfSearch = true; if (isset($library)) { $enableProspectorIntegration = $library->enablePospectorIntegration == 1; $showRatings = $library->showRatings; $showProspectorResultsAtEndOfSearch = $library->showProspectorResultsAtEndOfSearch == 1; } $interface->assign('showRatings', $showRatings); $numProspectorTitlesToLoad = 0; $numUnscopedTitlesToLoad = 0; // Save the ID of this search to the session so we can return to it easily: $_SESSION['lastSearchId'] = $searchObject->getSearchId(); // Save the URL of this search to the session so we can return to it easily: $_SESSION['lastSearchURL'] = $searchObject->renderSearchUrl(); if (is_object($searchSource)) { $translatedSearch = $searchSource->label; } else { $allSearchSources = SearchSources::getSearchSources(); if (!isset($allSearchSources[$searchSource]) && $searchSource == 'marmot') { $searchSource = 'local'; } $translatedSearch = $allSearchSources[$searchSource]['name']; } $analytics->addSearch($translatedSearch, $searchObject->displayQuery(), $searchObject->isAdvanced(), $searchObject->getFullSearchType(), $searchObject->hasAppliedFacets(), $searchObject->getResultTotal()); if ($searchObject->getResultTotal() < 1) { //We didn't find anything. Look for search Suggestions //Don't try to find suggestions if facets were applied $autoSwitchSearch = false; $disallowReplacements = isset($_REQUEST['disallowReplacements']) || isset($_REQUEST['replacementTerm']); if (!$disallowReplacements && (!isset($facetSet) || count($facetSet) == 0)) { require_once ROOT_DIR . '/services/Search/lib/SearchSuggestions.php'; $searchSuggestions = new SearchSuggestions(); $commonSearches = $searchSuggestions->getCommonSearchesMySql($searchObject->displayQuery(), $searchObject->getSearchIndex()); //If the first search in the list is used 10 times more than the next, just show results for that $numSuggestions = count($commonSearches); if ($numSuggestions == 1) { $autoSwitchSearch = true; } elseif ($numSuggestions >= 2) { $firstTimesSearched = $commonSearches[0]['numSearches']; $secondTimesSearched = $commonSearches[1]['numSearches']; if ($firstTimesSearched / $secondTimesSearched > 10) { $autoSwitchSearch = true; } } $interface->assign('autoSwitchSearch', $autoSwitchSearch); if ($autoSwitchSearch) { //Get search results for the new search $interface->assign('oldTerm', $searchObject->displayQuery()); $interface->assign('newTerm', $commonSearches[0]['phrase']); $thisUrl = $_SERVER['REQUEST_URI']; $thisUrl = $thisUrl . "&replacementTerm=" . urlencode($commonSearches[0]['phrase']); header("Location: " . $thisUrl); exit; } $interface->assign('searchSuggestions', $commonSearches); } //Var for the IDCLREADER TEMPLATE $interface->assign('ButtonBack', true); $interface->assign('ButtonHome', true); $interface->assign('MobileTitle', 'No Results Found'); // No record found $interface->setTemplate('list-none.tpl'); $interface->assign('recordCount', 0); // Was the empty result set due to an error? $error = $searchObject->getIndexError(); if ($error !== false) { // If it's a parse error or the user specified an invalid field, we // should display an appropriate message: if (stristr($error, 'org.apache.lucene.queryParser.ParseException') || preg_match('/^undefined field/', $error)) { $interface->assign('parseError', true); // Unexpected error -- let's treat this as a fatal condition. } else { PEAR_Singleton::raiseError(new PEAR_Error('Unable to process query<br />' . 'Solr Returned: ' . $error)); } } $numProspectorTitlesToLoad = 10; $numUnscopedTitlesToLoad = 10; $timer->logTime('no hits processing'); } else { if ($searchObject->getResultTotal() == 1 && (strpos($searchObject->displayQuery(), 'id') === 0 || $searchObject->getSearchType() == 'id')) { //Redirect to the home page for the record $recordSet = $searchObject->getResultRecordSet(); $record = reset($recordSet); $_SESSION['searchId'] = $searchObject->getSearchId(); if ($record['recordtype'] == 'list') { $listId = substr($record['id'], 4); header("Location: " . $configArray['Site']['path'] . "/MyResearch/MyList/{$listId}"); exit; } elseif ($record['recordtype'] == 'econtentRecord') { $shortId = str_replace('econtentRecord', '', $record['id']); header("Location: " . $configArray['Site']['path'] . "/EcontentRecord/{$shortId}/Home"); exit; } else { header("Location: " . $configArray['Site']['path'] . "/Record/{$record['id']}/Home"); exit; } } else { $timer->logTime('save search'); // Assign interface variables $summary = $searchObject->getResultSummary(); $interface->assign('recordCount', $summary['resultTotal']); $interface->assign('recordStart', $summary['startRecord']); $interface->assign('recordEnd', $summary['endRecord']); $facetSet = $searchObject->getFacetList(); $interface->assign('facetSet', $facetSet); //Check to see if a format category is already set $categorySelected = false; if (isset($facetSet['top'])) { foreach ($facetSet['top'] as $cluster) { if ($cluster['label'] == 'Category') { foreach ($cluster['list'] as $thisFacet) { if ($thisFacet['isApplied']) { $categorySelected = true; } } } } } $interface->assign('categorySelected', $categorySelected); $timer->logTime('load selected category'); // Big one - our results $recordSet = $searchObject->getResultRecordHTML(); $interface->assign('recordSet', $recordSet); $timer->logTime('load result records'); // Setup Display $interface->assign('sitepath', $configArray['Site']['path']); $interface->assign('subpage', 'Search/list-list.tpl'); $interface->setTemplate('list.tpl'); //Var for the IDCLREADER TEMPLATE $interface->assign('ButtonBack', true); $interface->assign('ButtonHome', true); $interface->assign('MobileTitle', 'Search Results'); // Process Paging $link = $searchObject->renderLinkPageTemplate(); $options = array('totalItems' => $summary['resultTotal'], 'fileName' => $link, 'perPage' => $summary['perPage']); $pager = new VuFindPager($options); $interface->assign('pageLinks', $pager->getLinks()); if ($pager->isLastPage()) { $numProspectorTitlesToLoad = 5; $numUnscopedTitlesToLoad = 5; } $timer->logTime('finish hits processing'); } } if ($numProspectorTitlesToLoad > 0 && $enableProspectorIntegration && $showProspectorResultsAtEndOfSearch) { $interface->assign('prospectorNumTitlesToLoad', $numProspectorTitlesToLoad); $interface->assign('prospectorSavedSearchId', $searchObject->getSearchId()); } else { $interface->assign('prospectorNumTitlesToLoad', 0); } if ($enableUnscopedSearch && isset($unscopedSearch)) { $unscopedSearch->setLimit($numUnscopedTitlesToLoad * 4); $unscopedSearch->disableScoping(); $unscopedSearch->processSearch(false, false); $numUnscopedResults = $unscopedSearch->getResultTotal(); $interface->assign('numUnscopedResults', $numUnscopedResults); $unscopedSearchUrl = $unscopedSearch->renderSearchUrl(); if (preg_match('/searchSource=(.*?)(?:&|$)/', $unscopedSearchUrl)) { $unscopedSearchUrl = preg_replace('/(.*searchSource=)(.*?)(&|$)(.*)/', '$1marmot$3$4', $unscopedSearchUrl); $unscopedSearchUrl = preg_replace('/&/', '&', $unscopedSearchUrl); } else { $unscopedSearchUrl .= "&searchSource=marmot"; } $unscopedSearchUrl .= "&shard="; $interface->assign('unscopedSearchUrl', $unscopedSearchUrl); if ($numUnscopedTitlesToLoad > 0) { $unscopedResults = $unscopedSearch->getSupplementalResultRecordHTML($searchObject->getResultRecordSet(), $numUnscopedTitlesToLoad, $searchObject->getResultTotal()); $interface->assign('unscopedResults', $unscopedResults); } } //Determine whether or not materials request functionality should be enabled $interface->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest()); if ($configArray['Statistics']['enabled'] && isset($_GET['lookfor'])) { require_once ROOT_DIR . '/Drivers/marmot_inc/SearchStat.php'; $searchStat = new SearchStat(); $searchStat->saveSearch(strip_tags($_GET['lookfor']), strip_tags(isset($_GET['type']) ? $_GET['type'] : (isset($_GET['basicType']) ? $_GET['basicType'] : 'Keyword')), $searchObject->getResultTotal()); } // Done, display the page $interface->display('layout.tpl'); }
function __construct($subAction = false, $record_id = null) { global $interface; global $configArray; global $library; global $timer; global $logger; $interface->assign('page_body_style', 'sidebar_left'); $interface->assign('libraryThingUrl', $configArray['LibraryThing']['url']); //Determine whether or not materials request functionality should be enabled $interface->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest()); //Load basic information needed in subclasses if ($record_id == null || !isset($record_id)) { $this->id = $_GET['id']; } else { $this->id = $record_id; } //Check to see if the record exists within the resources table $resource = new Resource(); $resource->record_id = $this->id; $resource->source = 'VuFind'; $resource->deleted = 0; if (!$resource->find()) { //Check to see if the record has been converted to an eContent record require_once ROOT_DIR . '/sys/eContent/EContentRecord.php'; $econtentRecord = new EContentRecord(); $econtentRecord->ilsId = $this->id; $econtentRecord->status = 'active'; if ($econtentRecord->find(true)) { header("Location: /EcontentRecord/{$econtentRecord->id}/Home"); die; } $logger->log("Did not find a record for id {$this->id} in resources table.", PEAR_LOG_DEBUG); $interface->setTemplate('invalidRecord.tpl'); $interface->display('layout.tpl'); die; } if ($configArray['Catalog']['ils'] == 'Millennium') { $interface->assign('classicId', substr($this->id, 1, strlen($this->id) - 2)); $interface->assign('classicUrl', $configArray['Catalog']['linking_url']); } // Setup Search Engine Connection $class = $configArray['Index']['engine']; $url = $configArray['Index']['url']; $this->db = new $class($url); $this->db->disableScoping(); // Retrieve Full Marc Record if (!($record = $this->db->getRecord($this->id))) { $logger->log("Did not find a record for id {$this->id} in solr.", PEAR_LOG_DEBUG); $interface->setTemplate('invalidRecord.tpl'); $interface->display('layout.tpl'); die; } $this->db->enableScoping(); $this->record = $record; $interface->assign('record', $record); $this->recordDriver = RecordDriverFactory::initRecordDriver($record); $timer->logTime('Initialized the Record Driver'); $interface->assign('coreMetadata', $this->recordDriver->getCoreMetadata()); // Process MARC Data require_once ROOT_DIR . '/sys/MarcLoader.php'; $marcRecord = MarcLoader::loadMarcRecordFromRecord($record); if ($marcRecord) { $this->marcRecord = $marcRecord; $interface->assign('marc', $marcRecord); } else { $interface->assign('error', 'Cannot Process MARC Record'); } $timer->logTime('Processed the marc record'); //Load information for display in the template rather than processing specific fields in the template $marcField = $marcRecord->getField('245'); $recordTitle = $this->getSubfieldData($marcField, 'a'); $interface->assign('recordTitle', $recordTitle); $recordTitleSubtitle = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p'))); $recordTitleSubtitle = preg_replace('~\\s+[\\/:]$~', '', $recordTitleSubtitle); $interface->assign('recordTitleSubtitle', $recordTitleSubtitle); $recordTitleWithAuth = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p', 'c'))); $interface->assign('recordTitleWithAuth', $recordTitleWithAuth); $marcField = $marcRecord->getField('100'); if ($marcField) { $mainAuthor = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'd')); $interface->assign('mainAuthor', $mainAuthor); } $marcField = $marcRecord->getField('110'); if ($marcField) { $corporateAuthor = $this->getSubfieldData($marcField, 'a'); $interface->assign('corporateAuthor', $corporateAuthor); } $marcFields = $marcRecord->getFields('700'); if ($marcFields) { $contributors = array(); foreach ($marcFields as $marcField) { $contributors[] = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'd')); } $interface->assign('contributors', $contributors); } $published = $this->recordDriver->getPublicationDetails(); $interface->assign('published', $published); $marcFields = $marcRecord->getFields('250'); if ($marcFields) { $editionsThis = array(); foreach ($marcFields as $marcField) { $editionsThis[] = $this->getSubfieldData($marcField, 'a'); } $interface->assign('editionsThis', $editionsThis); } $marcFields = $marcRecord->getFields('300'); if ($marcFields) { $physicalDescriptions = array(); foreach ($marcFields as $marcField) { $description = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'e', 'f', 'g')); if ($description != 'p. cm.') { $description = preg_replace("/[\\/|;:]\$/", '', $description); $description = preg_replace("/p\\./", 'pages', $description); $physicalDescriptions[] = $description; } } $interface->assign('physicalDescriptions', $physicalDescriptions); } // Get ISBN for cover and review use $mainIsbnSet = false; /** @var File_MARC_Data_Field[] $isbnFields */ if ($isbnFields = $this->marcRecord->getFields('020')) { $isbns = array(); //Use the first good ISBN we find. foreach ($isbnFields as $isbnField) { /** @var File_MARC_Subfield $isbnSubfieldA */ if ($isbnSubfieldA = $isbnField->getSubfield('a')) { $tmpIsbn = trim($isbnSubfieldA->getData()); if (strlen($tmpIsbn) > 0) { $isbns[] = $isbnSubfieldA->getData(); $pos = strpos($tmpIsbn, ' '); if ($pos > 0) { $tmpIsbn = substr($tmpIsbn, 0, $pos); } $tmpIsbn = trim($tmpIsbn); if (strlen($tmpIsbn) > 0) { if (strlen($tmpIsbn) < 10) { $tmpIsbn = str_pad($tmpIsbn, 10, "0", STR_PAD_LEFT); } if (!$mainIsbnSet) { $this->isbn = $tmpIsbn; $interface->assign('isbn', $tmpIsbn); $mainIsbnSet = true; } } } } } if (isset($this->isbn)) { if (strlen($this->isbn) == 13) { require_once ROOT_DIR . '/Drivers/marmot_inc/ISBNConverter.php'; $this->isbn10 = ISBNConverter::convertISBN13to10($this->isbn); } else { $this->isbn10 = $this->isbn; } $interface->assign('isbn10', $this->isbn10); } $interface->assign('isbns', $isbns); } if ($upcField = $this->marcRecord->getField('024')) { /** @var File_MARC_Data_Field $upcField */ if ($upcSubField = $upcField->getSubfield('a')) { $this->upc = trim($upcSubField->getData()); $interface->assign('upc', $this->upc); } } if ($issnField = $this->marcRecord->getField('022')) { /** @var File_MARC_Data_Field $issnField */ if ($issnSubField = $issnField->getSubfield('a')) { $this->issn = trim($issnSubField->getData()); if ($pos = strpos($this->issn, ' ')) { $this->issn = substr($this->issn, 0, $pos); } $interface->assign('issn', $this->issn); //Also setup GoldRush link if (isset($library) && strlen($library->goldRushCode) > 0) { $interface->assign('goldRushLink', "http://goldrush.coalliance.org/index.cfm?fuseaction=Search&inst_code={$library->goldRushCode}&search_type=ISSN&search_term={$this->issn}"); } } } $timer->logTime("Got basic data from Marc Record subaction = {$subAction}, record_id = {$record_id}"); //stop if this is not the main action. if ($subAction == true) { return; } //Get street date if ($streetDateField = $this->marcRecord->getField('263')) { $streetDate = $this->getSubfieldData($streetDateField, 'a'); if ($streetDate != '') { $interface->assign('streetDate', $streetDate); } } /** @var File_MARC_Data_Field[] $marcField440 */ $marcField440 = $marcRecord->getFields('440'); /** @var File_MARC_Data_Field[] $marcField490 */ $marcField490 = $marcRecord->getFields('490'); /** @var File_MARC_Data_Field[] $marcField830 */ $marcField830 = $marcRecord->getFields('830'); if ($marcField440 || $marcField490 || $marcField830) { $series = array(); foreach ($marcField440 as $field) { $series[] = $this->getSubfieldData($field, 'a'); } foreach ($marcField490 as $field) { if ($field->getIndicator(1) == 0) { $series[] = $this->getSubfieldData($field, 'a'); } } foreach ($marcField830 as $field) { $series[] = $this->getSubfieldData($field, 'a'); } $interface->assign('series', $series); } //Load description from Syndetics $useMarcSummary = true; if ($this->isbn || $this->upc) { if ($library && $library->preferSyndeticsSummary == 1) { require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php'; $summaryInfo = GoDeeperData::getSummary($this->isbn, $this->upc); if (isset($summaryInfo['summary'])) { $interface->assign('summaryTeaser', $summaryInfo['summary']); $interface->assign('summary', $summaryInfo['summary']); $useMarcSummary = false; } } } if ($useMarcSummary) { if ($summaryField = $this->marcRecord->getField('520')) { $interface->assign('summary', $this->getSubfieldData($summaryField, 'a')); $interface->assign('summaryTeaser', $this->getSubfieldData($summaryField, 'a')); } elseif ($library && $library->preferSyndeticsSummary == 0) { require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php'; $summaryInfo = GoDeeperData::getSummary($this->isbn, $this->upc); if (isset($summaryInfo['summary'])) { $interface->assign('summaryTeaser', $summaryInfo['summary']); $interface->assign('summary', $summaryInfo['summary']); $useMarcSummary = false; } } } if ($mpaaField = $this->marcRecord->getField('521')) { $interface->assign('mpaaRating', $this->getSubfieldData($mpaaField, 'a')); } if (isset($configArray['Content']['subjectFieldsToShow'])) { $subjectFieldsToShow = $configArray['Content']['subjectFieldsToShow']; $subjectFields = explode(',', $subjectFieldsToShow); $subjects = array(); foreach ($subjectFields as $subjectField) { /** @var File_MARC_Data_Field[] $marcFields */ $marcFields = $marcRecord->getFields($subjectField); if ($marcFields) { foreach ($marcFields as $marcField) { $searchSubject = ""; $subject = array(); foreach ($marcField->getSubFields() as $subField) { /** @var File_MARC_Subfield $subField */ if ($subField->getCode() != 2) { $searchSubject .= " " . $subField->getData(); $subject[] = array('search' => trim($searchSubject), 'title' => $subField->getData()); } } $subjects[] = $subject; } } $interface->assign('subjects', $subjects); } } $format = $record['format']; $interface->assign('recordFormat', $record['format']); $format_category = isset($record['format_category'][0]) ? $record['format_category'][0] : ''; $interface->assign('format_category', $format_category); $interface->assign('recordLanguage', isset($record['language']) ? $record['language'] : null); $timer->logTime('Got detailed data from Marc Record'); $tableOfContents = array(); $marcFields505 = $marcRecord->getFields('505'); if ($marcFields505) { $tableOfContents = $this->processTableOfContentsFields($marcFields505); } $notes = array(); $marcFields500 = $marcRecord->getFields('500'); $marcFields504 = $marcRecord->getFields('504'); $marcFields511 = $marcRecord->getFields('511'); $marcFields518 = $marcRecord->getFields('518'); $marcFields520 = $marcRecord->getFields('520'); if ($marcFields500 || $marcFields504 || $marcFields505 || $marcFields511 || $marcFields518 || $marcFields520) { $allFields = array_merge($marcFields500, $marcFields504, $marcFields511, $marcFields518, $marcFields520); $notes = $this->processNoteFields($allFields); } if (isset($library) && $library->showTableOfContentsTab == 0 || count($tableOfContents) == 0) { $notes = array_merge($notes, $tableOfContents); } else { $interface->assign('tableOfContents', $tableOfContents); } if (isset($library) && strlen($library->notesTabName) > 0) { $interface->assign('notesTabName', $library->notesTabName); } else { $interface->assign('notesTabName', 'Notes'); } $additionalNotesFields = array('310' => 'Current Publication Frequency', '321' => 'Former Publication Frequency', '351' => 'Organization & arrangement of materials', '362' => 'Dates of publication and/or sequential designation', '501' => '"With"', '502' => 'Dissertation', '506' => 'Restrictions on Access', '507' => 'Scale for Graphic Material', '508' => 'Creation/Production Credits', '510' => 'Citation/References', '511' => 'Participant or Performer', '513' => 'Type of Report an Period Covered', '515' => 'Numbering Peculiarities', '518' => 'Date/Time and Place of Event', '521' => 'Target Audience', '522' => 'Geographic Coverage', '525' => 'Supplement', '526' => 'Study Program Information', '530' => 'Additional Physical Form', '533' => 'Reproduction', '534' => 'Original Version', '536' => 'Funding Information', '538' => 'System Details', '545' => 'Biographical or Historical Data', '546' => 'Language', '547' => 'Former Title Complexity', '550' => 'Issuing Body', '555' => 'Cumulative Index/Finding Aids', '556' => 'Information About Documentation', '561' => 'Ownership and Custodial History', '563' => 'Binding Information', '580' => 'Linking Entry Complexity', '581' => 'Publications About Described Materials', '586' => 'Awards', '590' => 'Local note', '599' => 'Differentiable Local note'); foreach ($additionalNotesFields as $tag => $label) { $marcFields = $marcRecord->getFields($tag); foreach ($marcFields as $marcField) { $noteText = array(); foreach ($marcField->getSubFields() as $subfield) { /** @var File_MARC_Subfield $subfield */ $noteText[] = $subfield->getData(); } $note = implode(',', $noteText); if (strlen($note) > 0) { $notes[] = "<b>{$label}</b>: " . $note; } } } if (count($notes) > 0) { $interface->assign('notes', $notes); } /** @var File_MARC_Data_Field[] $linkFields */ $linkFields = $marcRecord->getFields('856'); if ($linkFields) { $internetLinks = array(); $purchaseLinks = array(); $field856Index = 0; foreach ($linkFields as $marcField) { $field856Index++; //Get the link if ($marcField->getSubfield('u')) { $link = $marcField->getSubfield('u')->getData(); if ($marcField->getSubfield('3')) { $linkText = $marcField->getSubfield('3')->getData(); } elseif ($marcField->getSubfield('y')) { $linkText = $marcField->getSubfield('y')->getData(); } elseif ($marcField->getSubfield('z')) { $linkText = $marcField->getSubfield('z')->getData(); } else { $linkText = $link; } $showLink = true; //Process some links differently so we can either hide them //or show them in different areas of the catalog. if (preg_match('/purchase|buy/i', $linkText) || preg_match('/barnesandnoble|tatteredcover|amazon|smashwords\\.com/i', $link)) { $showLink = false; } $isBookLink = preg_match('/acs\\.dcl\\.lan|vufind\\.douglascountylibraries\\.org|catalog\\.douglascountylibraries\\.org/i', $link); if ($isBookLink == 1) { //e-book link, don't show $showLink = false; } if ($showLink) { //Rewrite the link so we can track usage $link = $configArray['Site']['path'] . '/Record/' . $this->id . '/Link?index=' . $field856Index; $internetLinks[] = array('link' => $link, 'linkText' => $linkText); } } } if (count($internetLinks) > 0) { $interface->assign('internetLinks', $internetLinks); } } if (isset($purchaseLinks) && count($purchaseLinks) > 0) { $interface->assign('purchaseLinks', $purchaseLinks); } //Determine the cover to use $bookCoverUrl = $configArray['Site']['coverUrl'] . "/bookcover.php?id={$this->id}&isn={$this->isbn}&issn={$this->issn}&size=large&upc={$this->upc}&category=" . urlencode($format_category) . "&format=" . urlencode(isset($format[0]) ? $format[0] : ''); $interface->assign('bookCoverUrl', $bookCoverUrl); //Load accelerated reader data if (isset($record['accelerated_reader_interest_level'])) { $arData = array('interestLevel' => $record['accelerated_reader_interest_level'], 'pointValue' => $record['accelerated_reader_point_value'], 'readingLevel' => $record['accelerated_reader_reading_level']); $interface->assign('arData', $arData); } if (isset($record['lexile_score']) && $record['lexile_score'] > -1) { $lexileScore = $record['lexile_score']; if (isset($record['lexile_code'])) { $lexileScore = $record['lexile_code'] . $lexileScore; } $interface->assign('lexileScore', $lexileScore . 'L'); } //Do actions needed if this is the main action. //$interface->caching = 1; $interface->assign('id', $this->id); if (substr($this->id, 0, 1) == '.') { $interface->assign('shortId', substr($this->id, 1)); } else { $interface->assign('shortId', $this->id); } $interface->assign('addHeader', '<link rel="alternate" type="application/rdf+xml" title="RDF Representation" href="' . $configArray['Site']['path'] . '/Record/' . urlencode($this->id) . '/RDF" />'); // Define Default Tab $tab = isset($_GET['action']) ? $_GET['action'] : 'Description'; $interface->assign('tab', $tab); if (isset($_REQUEST['detail'])) { $detail = strip_tags($_REQUEST['detail']); $interface->assign('defaultDetailsTab', $detail); } // Define External Content Provider if ($this->marcRecord->getField('020')) { if (isset($configArray['Content']['reviews'])) { $interface->assign('hasReviews', true); } if (isset($configArray['Content']['excerpts'])) { $interface->assign('hasExcerpt', true); } } // Retrieve User Search History $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false); // Retrieve tags associated with the record $limit = 5; $resource = new Resource(); $resource->record_id = $_GET['id']; $resource->source = 'VuFind'; $resource->find(true); $tags = $resource->getTags($limit); $interface->assign('tagList', $tags); $timer->logTime('Got tag list'); $this->cacheId = 'Record|' . $_GET['id'] . '|' . get_class($this); // Find Similar Records /** @var Memcache $memCache */ global $memCache; $similar = $memCache->get('similar_titles_' . $this->id); if ($similar == false) { $similar = $this->db->getMoreLikeThis($this->id); // Send the similar items to the template; if there is only one, we need // to force it to be an array or things will not display correctly. if (isset($similar) && count($similar['response']['docs']) > 0) { $similar = $similar['response']['docs']; } else { $similar = array(); $timer->logTime("Did not find any similar records"); } $memCache->set('similar_titles_' . $this->id, $similar, 0, $configArray['Caching']['similar_titles']); } $this->similarTitles = $similar; $interface->assign('similarRecords', $similar); $timer->logTime('Loaded similar titles'); // Find Other Editions if ($configArray['Content']['showOtherEditionsPopup'] == false) { $editions = OtherEditionHandler::getEditions($this->id, $this->isbn, isset($this->record['issn']) ? $this->record['issn'] : null); if (!PEAR_Singleton::isError($editions)) { $interface->assign('editions', $editions); } else { $timer->logTime("Did not find any other editions"); } $timer->logTime('Got Other editions'); } $interface->assign('showStrands', isset($configArray['Strands']['APID']) && strlen($configArray['Strands']['APID']) > 0); // Send down text for inclusion in breadcrumbs $interface->assign('breadcrumbText', $this->recordDriver->getBreadcrumb()); // Send down OpenURL for COinS use: $interface->assign('openURL', $this->recordDriver->getOpenURL()); // Send down legal export formats (if any): $interface->assign('exportFormats', $this->recordDriver->getExportFormats()); // Set AddThis User $interface->assign('addThis', isset($configArray['AddThis']['key']) ? $configArray['AddThis']['key'] : false); // Set Proxy URL if (isset($configArray['EZproxy']['host'])) { $interface->assign('proxy', $configArray['EZproxy']['host']); } //setup 5 star ratings global $user; $ratingData = $resource->getRatingData($user); $interface->assign('ratingData', $ratingData); $timer->logTime('Got 5 star data'); //Get Next/Previous Links $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local'; $searchObject = SearchObjectFactory::initSearchObject(); $searchObject->init($searchSource); $searchObject->getNextPrevLinks(); //Load Staff Details $interface->assign('staffDetails', $this->recordDriver->getStaffView()); }
function loadDisplayOptions() { global $library; global $locationSingleton; global $configArray; $location = $locationSingleton->getActiveLocation(); $showHoldButton = 1; $showHoldButtonInSearchResults = 1; $this->assign('logoLink', $configArray['Site']['path']); if (isset($library) && $library->useHomeLinkForLogo) { if (isset($location) && strlen($location->homeLink) > 0 && $location->homeLink != 'default') { $this->assign('logoLink', $location->homeLink); } elseif (isset($library) && strlen($library->homeLink) > 0 && $library->homeLink != 'default') { $this->assign('logoLink', $library->homeLink); } } if (isset($location) && strlen($location->homeLink) > 0 && $location->homeLink != 'default') { $this->assign('homeLink', $location->homeLink); } elseif (isset($library) && strlen($library->homeLink) > 0 && $library->homeLink != 'default') { $this->assign('homeLink', $library->homeLink); } if (isset($library)) { $this->assign('facebookLink', $library->facebookLink); $this->assign('twitterLink', $library->twitterLink); $this->assign('youtubeLink', $library->youtubeLink); $this->assign('instagramLink', $library->instagramLink); $this->assign('goodreadsLink', $library->goodreadsLink); $this->assign('generalContactLink', $library->generalContactLink); $this->assign('showLoginButton', $library->showLoginButton); $this->assign('showAdvancedSearchbox', $library->showAdvancedSearchbox); $this->assign('enablePurchaseLinks', count($library->getBookStores()) > 0); $this->assign('enablePospectorIntegration', $library->enablePospectorIntegration); $this->assign('showTagging', $library->showTagging); $this->assign('showRatings', $library->showRatings); $this->assign('show856LinksAsTab', $library->show856LinksAsTab); $this->assign('showSearchTools', $library->showSearchTools); $this->assign('showExpirationWarnings', $library->showExpirationWarnings); $this->assign('showSimilarTitles', $library->showSimilarTitles); $this->assign('showSimilarAuthors', $library->showSimilarAuthors); $this->assign('showItsHere', $library->showItsHere); } else { $this->assign('showLoginButton', 1); $this->assign('showAdvancedSearchbox', 1); $this->assign('enablePurchaseLinks', 1); $this->assign('enablePospectorIntegration', isset($configArray['Content']['Prospector']) && $configArray['Content']['Prospector'] == true ? 1 : 0); $this->assign('showTagging', 1); $this->assign('showRatings', 1); $this->assign('show856LinksAsTab', 1); $this->assign('showSearchTools', 1); $this->assign('showExpirationWarnings', 1); $this->assign('showSimilarTitles', 1); $this->assign('showSimilarAuthors', 1); $this->assign('showItsHere', 0); } if (isset($library) && $location != null) { $this->assign('showFavorites', $location->showFavorites && $library->showFavorites); $this->assign('showComments', $location->showComments && $library->showComments); $this->assign('showTextThis', $location->showTextThis && $library->showTextThis); $this->assign('showEmailThis', $location->showEmailThis && $library->showEmailThis); $this->assign('showStaffView', $location->showStaffView && $library->showStaffView); $this->assign('showShareOnExternalSites', $location->showShareOnExternalSites && $library->showShareOnExternalSites); $this->assign('showQRCode', $location->showQRCode && $library->showQRCode); $this->assign('showStaffView', $location->showStaffView && $library->showStaffView); $this->assign('showGoodReadsReviews', $location->showGoodReadsReviews && $library->showGoodReadsReviews); $showHoldButton = $location->showHoldButton == 1 && $library->showHoldButton == 1 ? 1 : 0; $showHoldButtonInSearchResults = $location->showHoldButton == 1 && $library->showHoldButtonInSearchResults == 1 ? 1 : 0; $this->assign('showSimilarTitles', $library->showSimilarTitles); $this->assign('showSimilarAuthors', $library->showSimilarAuthors); } else { if ($location != null) { $this->assign('showFavorites', $location->showFavorites); $this->assign('showComments', $location->showComments); $this->assign('showTextThis', $location->showTextThis); $this->assign('showEmailThis', $location->showEmailThis); $this->assign('showShareOnExternalSites', $location->showShareOnExternalSites); $this->assign('showStaffView', $location->showStaffView); $this->assign('showQRCode', $location->showQRCode); $this->assign('showStaffView', $location->showStaffView); $this->assign('showGoodReadsReviews', $location->showGoodReadsReviews); $showHoldButton = $location->showHoldButton; } else { if (isset($library)) { $this->assign('showFavorites', $library->showFavorites); $showHoldButton = $library->showHoldButton; $showHoldButtonInSearchResults = $library->showHoldButtonInSearchResults; $this->assign('showComments', $library->showComments); $this->assign('showTextThis', $library->showTextThis); $this->assign('showEmailThis', $library->showEmailThis); $this->assign('showShareOnExternalSites', $library->showShareOnExternalSites); $this->assign('showStaffView', $library->showStaffView); $this->assign('showQRCode', $library->showQRCode); $this->assign('showStaffView', $library->showStaffView); $this->assign('showGoodReadsReviews', $library->showGoodReadsReviews); } else { $this->assign('showFavorites', 1); $this->assign('showComments', 1); $this->assign('showTextThis', 1); $this->assign('showEmailThis', 1); $this->assign('showShareOnExternalSites', 1); $this->assign('showQRCode', 1); $this->assign('showStaffView', 1); $this->assign('showGoodReadsReviews', 1); } } } if ($showHoldButton == 0) { $showHoldButtonInSearchResults = 0; } if ($library && $library->additionalCss) { $this->assign('additionalCss', $library->additionalCss); } if ($location != null && $location->additionalCss) { $this->assign('additionalCss', $location->additionalCss); } $this->assign('showHoldButton', $showHoldButton); $this->assign('showHoldButtonInSearchResults', $showHoldButtonInSearchResults); $this->assign('showNotInterested', true); $this->assign('librarySystemName', 'Marmot'); if (isset($library)) { $this->assign('showRatings', $library->showRatings); $this->assign('allowPinReset', $library->allowPinReset); $this->assign('librarySystemName', $library->displayName); $this->assign('showLibraryHoursAndLocationsLink', $library->showLibraryHoursAndLocationsLink); //Check to see if we should just call it library location $numLocations = $library->getNumLocationsForLibrary(); $this->assign('numLocations', $numLocations); if ($numLocations == 1) { $locationForLibrary = new Location(); $locationForLibrary->libraryId = $library->libraryId; $locationForLibrary->find(true); $numHours = $locationForLibrary->getNumHours(); $this->assign('numHours', $numHours); } $this->assign('showDisplayNameInHeader', $library->showDisplayNameInHeader); $this->assign('externalMaterialsRequestUrl', $library->externalMaterialsRequestUrl); } else { $this->assign('showLibraryHoursAndLocationsLink', 1); $this->assign('showRatings', 1); $this->assign('allowPinReset', 0); $this->assign('showDisplayNameInHeader', 0); } if ($location != null) { $this->assign('showDisplayNameInHeader', $location->showDisplayNameInHeader); $this->assign('librarySystemName', $location->displayName); } //Determine whether or not materials request functionality should be enabled require_once ROOT_DIR . '/sys/MaterialsRequest.php'; $this->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest()); //Load library links if (isset($library)) { $links = $library->libraryLinks; $libraryLinks = array(); foreach ($links as $libraryLink) { if (!array_key_exists($libraryLink->category, $libraryLinks)) { $libraryLinks[$libraryLink->category] = array(); } $libraryLinks[$libraryLink->category][$libraryLink->linkText] = $libraryLink->url; } $this->assign('libraryLinks', $libraryLinks); $topLinks = $library->libraryTopLinks; $this->assign('topLinks', $topLinks); } }
$analytics->setLanguage($interface->getLanguage()); $analytics->setTheme($interface->getPrimaryTheme()); $analytics->setMobile($interface->isMobile() ? 1 : 0); $analytics->setDevice(get_device_name()); $analytics->setPhysicalLocation($physicalLocation); if ($user) { $analytics->setPatronType($user->patronType); $analytics->setHomeLocationId($user->homeLocationId); } else { $analytics->setPatronType('logged out'); $analytics->setHomeLocationId(-1); } } //Determine whether or not materials request functionality should be enabled require_once ROOT_DIR . '/sys/MaterialsRequest.php'; $interface->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest()); // Process Authentication, must be done here so we can redirect based on user information // immediately after logging in. if ($user) { $interface->assign('user', $user); //Create a cookie for the user's home branch so we can sort holdings even if they logout. //Cookie expires in 1 week. setcookie('home_location', $user->homeLocationId, time() + 60 * 60 * 24 * 7, '/'); } else { if ($configArray['Authentication']['method'] == 'Shibboleth' && $module == 'MyResearch' || isset($_POST['username']) && isset($_POST['password']) && ($action != 'Account' && $module != 'AJAX')) { $user = UserAccount::login(); if (PEAR_Singleton::isError($user)) { require_once ROOT_DIR . '/services/MyResearch/Login.php'; Login::launch($user->getMessage()); exit; }
function __construct() { global $interface; global $configArray; global $user; //If the user isn't logged in, take them to the login page if (!$user) { header("Location: {$configArray['Site']['path']}/MyResearch/Login"); die; } //Make sure the user has permission to access the page $allowableRoles = $this->getAllowableRoles(); $userCanAccess = false; foreach ($allowableRoles as $roleId => $roleName) { if ($user->hasRole($roleName)) { $userCanAccess = true; break; } } $interface->assign('ils', $configArray['Catalog']['ils']); //Determine whether or not materials request functionality should be enabled $interface->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest()); //Check to see if we have any acs or single use eContent in the catalog //to enable the holds and wishlist appropriately if (isset($configArray['EContent']['hasProtectedEContent'])) { $interface->assign('hasProtectedEContent', $configArray['EContent']['hasProtectedEContent']); } else { $interface->assign('hasProtectedEContent', false); } //This code is also in Search/History since that page displays in the My Account menu as well. //It is also in MyList.php if ($user !== false) { $this->catalog = new CatalogConnection($configArray['Catalog']['driver']); $interface->assign('user', $user); // Get My Profile if ($this->catalog->status) { if ($user->cat_username) { $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password); if (PEAR_Singleton::isError($patron)) { PEAR_Singleton::raiseError($patron); } $profile = $this->catalog->getMyProfile($patron); if (!PEAR_Singleton::isError($profile)) { $interface->assign('profile', $profile); } } } //Figure out if we should show a link to classic opac to pay holds. $ecommerceLink = $configArray['Site']['ecommerceLink']; $homeLibrary = Library::getLibraryForLocation($user->homeLocationId); if (strlen($ecommerceLink) > 0 && isset($homeLibrary) && $homeLibrary->showEcommerceLink == 1) { $interface->assign('showEcommerceLink', true); $interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount); $interface->assign('ecommerceLink', $ecommerceLink); } else { $interface->assign('showEcommerceLink', false); $interface->assign('minimumFineAmount', 0); } } if (!$userCanAccess) { $interface->setTemplate('../Admin/noPermission.tpl'); $interface->display('layout.tpl'); exit; } }
function __construct() { global $interface; global $configArray; global $user; $interface->assign('page_body_style', 'sidebar_left'); $interface->assign('ils', $configArray['Catalog']['ils']); if ($this->requireLogin && !UserAccount::isLoggedIn()) { require_once 'Login.php'; Login::launch(); exit; } //$interface->assign('userNoticeFile', 'MyResearch/listNotice.tpl'); // Setup Search Engine Connection $class = $configArray['Index']['engine']; $this->db = new $class($configArray['Index']['url']); if ($configArray['System']['debugSolr']) { $this->db->debug = true; } // Connect to Database $this->catalog = new CatalogConnection($configArray['Catalog']['driver']); // Register Library Catalog Account if (isset($_POST['submit']) && !empty($_POST['submit'])) { if ($this->catalog && isset($_POST['cat_username']) && isset($_POST['cat_password'])) { $result = $this->catalog->patronLogin($_POST['cat_username'], $_POST['cat_password']); if ($result && !PEAR_Singleton::isError($result)) { $user->cat_username = $_POST['cat_username']; $user->cat_password = $_POST['cat_password']; $user->update(); UserAccount::updateSession($user); $interface->assign('user', $user); } else { $interface->assign('loginError', 'Invalid Patron Login'); } } } //Determine whether or not materials request functionality should be enabled $interface->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest()); //Check to see if we have any acs or single use eContent in the catalog //to enable the holds and wishlist appropriately if (isset($configArray['EContent']['hasProtectedEContent'])) { $interface->assign('hasProtectedEContent', $configArray['EContent']['hasProtectedEContent']); } else { $interface->assign('hasProtectedEContent', false); } global $library; if (isset($library)) { $interface->assign('showFavorites', $library->showFavorites); $interface->assign('showRatings', $library->showRatings); $interface->assign('showComments', $library->showComments); } else { $interface->assign('showFavorites', 1); $interface->assign('showRatings', 1); $interface->assign('showComments', 1); } //This code is also in Search/History since that page displays in the My Account menu as well. //It is also in MyList.php and Admin.php if ($user !== false) { $interface->assign('user', $user); // Get My Profile if ($this->catalog->status) { if ($user->cat_username) { $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password); if (PEAR_Singleton::isError($patron)) { PEAR_Singleton::raiseError($patron); } $profile = $this->catalog->getMyProfile($patron); //global $logger; //$logger->log("Patron profile phone number in MyResearch = " . $profile['phone'], PEAR_LOG_INFO); if (!PEAR_Singleton::isError($profile)) { $interface->assign('profile', $profile); } } } //Figure out if we should show a link to classic opac to pay holds. $ecommerceLink = $configArray['Site']['ecommerceLink']; $homeLibrary = Library::getLibraryForLocation($user->homeLocationId); if (strlen($ecommerceLink) > 0 && isset($homeLibrary) && $homeLibrary->showEcommerceLink == 1) { $interface->assign('showEcommerceLink', true); $interface->assign('minimumFineAmount', $homeLibrary->minimumFineAmount); if ($homeLibrary->payFinesLink == 'default') { $interface->assign('ecommerceLink', $ecommerceLink); } else { $interface->assign('ecommerceLink', $homeLibrary->payFinesLink); } $interface->assign('payFinesLinkText', $homeLibrary->payFinesLinkText); } else { $interface->assign('showEcommerceLink', false); $interface->assign('minimumFineAmount', 0); } //Load a list of lists $lists = array(); if ($user->disableRecommendations == 0) { $lists[] = array('name' => 'Recommended For You', 'url' => '/MyResearch/SuggestedTitles', 'id' => 'suggestions'); } $tmpList = new User_list(); $tmpList->user_id = $user->id; $tmpList->orderBy("title ASC"); $tmpList->find(); if ($tmpList->N > 0) { while ($tmpList->fetch()) { $lists[$tmpList->id] = array('name' => $tmpList->title, 'url' => '/MyResearch/MyList/' . $tmpList->id, 'id' => $tmpList->id); } } else { $lists[-1] = array('name' => "My Favorites", 'url' => '/MyResearch/MyList/-1', 'id' => -1); } $interface->assign('lists', $lists); // Get My Tags $tagList = $user->getTags(); $interface->assign('tagList', $tagList); } }