Exemplo n.º 1
0
 static function getSearchSources()
 {
     $activeLibrary = Library::getActiveLibrary();
     if ($activeLibrary == null || count($activeLibrary->searchSources) == 0) {
         $searchSources = SearchSources::getSearchSourcesDefault();
     } else {
         $searchSources = SearchSources::getSearchSourcesLibrary($activeLibrary);
     }
     return $searchSources;
 }
Exemplo n.º 2
0
 public function __construct($searchObject, $params)
 {
     global $library;
     global $configArray;
     // Save the basic parameters:
     $this->searchObject = $searchObject;
     // Parse the additional parameters:
     $params = explode(':', $params);
     $section = empty($params[0]) ? 'ResultsTop' : $params[0];
     $iniFile = isset($params[1]) ? $params[1] : 'facets';
     // Load the desired facet information:
     $searchLibrary = Library::getActiveLibrary();
     $searchLocation = Location::getActiveLocation();
     $config = getExtraConfigArray($iniFile);
     if ($searchObject->getSearchType() == 'genealogy') {
         $this->mainFacets = array();
     } else {
         $searchLibrary = Library::getActiveLibrary();
         $searchLocation = Location::getActiveLocation();
         $userLocation = Location::getUserHomeLocation();
         $hasSearchLibraryFacets = $searchLibrary != null && count($searchLibrary->facets) > 0;
         $hasSearchLocationFacets = $searchLocation != null && count($searchLocation->facets) > 0;
         if ($hasSearchLocationFacets) {
             $facets = $searchLocation->facets;
         } elseif ($hasSearchLibraryFacets) {
             $facets = $searchLibrary->facets;
         } else {
             $facets = Library::getDefaultFacets();
         }
         foreach ($facets as $facet) {
             if ($facet->showAboveResults == 1) {
                 $facetName = $facet->facetName;
                 if (isset($searchLibrary)) {
                     if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                         $facetName = 'availability_toggle_' . $searchLibrary->subdomain;
                     }
                 }
                 if (isset($userLocation)) {
                     if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                         $facetName = 'availability_toggle_' . $userLocation->code;
                     }
                 }
                 if (isset($searchLocation)) {
                     if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                         $facetName = 'availability_toggle_' . $searchLocation->code;
                     }
                 }
                 $this->facets[$facetName] = $facet->displayName;
                 $this->facetSettings[$facetName] = $facet;
             }
         }
     }
     // Load other relevant settings:
     $this->baseSettings = array('rows' => $config['Results_Settings']['top_rows'], 'cols' => $config['Results_Settings']['top_cols']);
 }
Exemplo n.º 3
0
 public function __construct($searchObject, $params)
 {
     global $configArray;
     // Save the basic parameters:
     /** @var SearchObject_Solr|SearchObject_Base searchObject */
     $this->searchObject = $searchObject;
     // Parse the additional parameters:
     $params = explode(':', $params);
     $iniFile = isset($params[1]) ? $params[1] : 'facets';
     // Load the desired facet information:
     $config = getExtraConfigArray($iniFile);
     if ($this->searchObject->getSearchType() == 'genealogy') {
         $this->mainFacets = array();
     } else {
         $searchLibrary = Library::getActiveLibrary();
         global $locationSingleton;
         $searchLocation = $locationSingleton->getActiveLocation();
         $userLocation = Location::getUserHomeLocation();
         $hasSearchLibraryFacets = $searchLibrary != null && count($searchLibrary->facets) > 0;
         $hasSearchLocationFacets = $searchLocation != null && count($searchLocation->facets) > 0;
         if ($hasSearchLocationFacets) {
             $facets = $searchLocation->facets;
         } elseif ($hasSearchLibraryFacets) {
             $facets = $searchLibrary->facets;
         } else {
             $facets = Library::getDefaultFacets();
         }
         global $solrScope;
         foreach ($facets as $facet) {
             if ($facet->showAboveResults == 1) {
                 $facetName = $facet->facetName;
                 if ($solrScope) {
                     if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                         $facetName = 'availability_toggle_' . $solrScope;
                     } else {
                         if ($facet->facetName == 'format_category' && $configArray['Index']['enableDetailedFormats']) {
                             $facetName = 'format_category_' . $solrScope;
                         }
                     }
                 }
                 $this->facets[$facetName] = $facet->displayName;
                 $this->facetSettings[$facetName] = $facet;
                 if (!$solrScope && $facet->facetName == 'availability_toggle') {
                     //Don't do availability toggles in the global scope.
                     //TODO: Base this off the default scope (i.e. mercury/responsive).
                     unset($this->facets[$facetName]);
                     unset($this->facetSettings[$facetName]);
                 }
             }
         }
     }
     // Load other relevant settings:
     $this->baseSettings = array('rows' => $config['Results_Settings']['top_rows'], 'cols' => $config['Results_Settings']['top_cols']);
 }
Exemplo n.º 4
0
 function saveSearch($phrase, $type, $numResults)
 {
     if (!isset($numResults)) {
         //This only happens if there is an error parsing the query.
         return;
     }
     $activeLibrary = Library::getActiveLibrary();
     $libraryId = -1;
     if ($activeLibrary != null && $activeLibrary->useScope) {
         $libraryId = $activeLibrary->libraryId;
     }
     /** @var $locationSingleton Location */
     global $locationSingleton;
     $locationId = -1;
     $activeLocation = $locationSingleton->getActiveLocation();
     if ($activeLocation != null && $activeLocation->useScope) {
         $locationId = $activeLocation->locationId;
     }
     $searchStat = new SearchStat();
     $searchStat->phrase = strtolower($phrase);
     $searchStat->type = $type;
     $searchStat->libraryId = $libraryId;
     $searchStat->locationId = $locationId;
     $searchStat->find();
     $isNew = true;
     if ($searchStat->N > 0) {
         $searchStat->fetch();
         $searchStat->numSearches++;
         $isNew = false;
     } else {
         $searchStat->numSearches = 1;
     }
     $searchStat->numResults = $numResults;
     $searchStat->lastSearch = time();
     if ($isNew) {
         $searchStat->insert();
     } else {
         $searchStat->update();
     }
 }
Exemplo n.º 5
0
 public function getLibraryScopingId()
 {
     //For econtent, we need to be more specific when restricting copies
     //since patrons can't use copies that are only available to other libraries.
     $searchLibrary = Library::getSearchLibrary();
     $searchLocation = Location::getSearchLocation();
     $activeLibrary = Library::getActiveLibrary();
     $activeLocation = Location::getActiveLocation();
     $homeLibrary = Library::getPatronHomeLibrary();
     //Load the holding label for the branch where the user is physically.
     if (!is_null($homeLibrary)) {
         return $homeLibrary->includeOutOfSystemExternalLinks ? -1 : $homeLibrary->libraryId;
     } else {
         if (!is_null($activeLocation)) {
             $activeLibrary = Library::getLibraryForLocation($activeLocation->locationId);
             return $activeLibrary->includeOutOfSystemExternalLinks ? -1 : $activeLibrary->libraryId;
         } else {
             if (isset($activeLibrary)) {
                 return $activeLibrary->includeOutOfSystemExternalLinks ? -1 : $activeLibrary->libraryId;
             } else {
                 if (!is_null($searchLocation)) {
                     $searchLibrary = Library::getLibraryForLocation($searchLibrary->locationId);
                     return $searchLibrary->includeOutOfSystemExternalLinks ? -1 : $searchLocation->libraryId;
                 } else {
                     if (isset($searchLibrary)) {
                         return $searchLibrary->includeOutOfSystemExternalLinks ? -1 : $searchLibrary->libraryId;
                     } else {
                         return -1;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 6
0
 function placeHold()
 {
     global $interface;
     global $configArray;
     global $user;
     global $logger;
     //TODO: Clean this up so there is only ever one id.
     if (isset($_REQUEST['recordId'])) {
         $recordId = $_REQUEST['recordId'];
     } else {
         $recordId = $_REQUEST['id'];
     }
     $interface->assign('id', $recordId);
     //Get title information for the record.
     $holding = $this->catalog->getHolding($recordId);
     if (PEAR_Singleton::isError($holding)) {
         PEAR_Singleton::raiseError($holding);
     }
     $interface->assign('holding', $holding);
     if (isset($_REQUEST['autologout'])) {
         $_SESSION['autologout'] = true;
     }
     $showMessage = false;
     $type = isset($_REQUEST['holdType']) ? $_REQUEST['holdType'] : '';
     if (isset($_POST['submit']) || $type == 'recall' || $type == 'update' || $type == 'hold') {
         if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
             //Log the user in
             $user = UserAccount::login();
         }
         if ($user) {
             //The user is already logged in
             $barcodeProperty = $configArray['Catalog']['barcodeProperty'];
             $return = $this->catalog->placeHold($recordId, $user->{$barcodeProperty}, '', $type);
             $interface->assign('result', $return['result']);
             $message = $return['message'];
             $interface->assign('message', $message);
             $showMessage = true;
         } else {
             $message = 'Incorrect Patron Information';
             $interface->assign('message', $message);
             $interface->assign('focusElementId', 'username');
             $showMessage = true;
         }
     } else {
         //Get the referrer so we can go back there.
         if (isset($_SERVER['HTTP_REFERER'])) {
             $referer = $_SERVER['HTTP_REFERER'];
             $_SESSION['hold_referrer'] = $referer;
         }
         //Showing place hold form.
         if ($user) {
             $profile = $this->catalog->getMyProfile($user);
             $interface->assign('profile', $profile);
             //Get information to show a warning if the user does not have sufficient holds
             require_once ROOT_DIR . '/Drivers/marmot_inc/PType.php';
             $maxHolds = -1;
             //Determine if we should show a warning
             $ptype = new PType();
             $ptype->pType = $user->patronType;
             if ($ptype->find(true)) {
                 $maxHolds = $ptype->maxHolds;
             }
             $currentHolds = $profile['numHolds'];
             if ($maxHolds != -1 && $currentHolds + 1 > $maxHolds) {
                 $interface->assign('showOverHoldLimit', true);
                 $interface->assign('maxHolds', $maxHolds);
                 $interface->assign('currentHolds', $currentHolds);
             }
             global $locationSingleton;
             //Get the list of pickup branch locations for display in the user interface.
             $locations = $locationSingleton->getPickupBranches($profile, $profile['homeLocationId']);
             $interface->assign('pickupLocations', $locations);
             //set focus to the submit button if the user is logged in since the campus will be correct most of the time.
             $interface->assign('focusElementId', 'submit');
         } else {
             //set focus to the username field by default.
             $interface->assign('focusElementId', 'username');
         }
         global $library;
         $patronHomeBranch = Library::getPatronHomeLibrary();
         if ($patronHomeBranch != null) {
             if ($patronHomeBranch->defaultNotNeededAfterDays > 0) {
                 $interface->assign('defaultNotNeededAfterDays', date('m/d/Y', time() + $patronHomeBranch->defaultNotNeededAfterDays * 60 * 60 * 24));
             } else {
                 $interface->assign('defaultNotNeededAfterDays', '');
             }
             $interface->assign('showHoldCancelDate', $patronHomeBranch->showHoldCancelDate);
         } else {
             if ($library) {
                 //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
                 if ($library->defaultNotNeededAfterDays > 0) {
                     $interface->assign('defaultNotNeededAfterDays', date('m/d/Y', time() + $library->defaultNotNeededAfterDays * 60 * 60 * 24));
                 } else {
                     $interface->assign('defaultNotNeededAfterDays', '');
                 }
                 $interface->assign('showHoldCancelDate', $library->showHoldCancelDate);
             } else {
                 //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
                 $interface->assign('showHoldCancelDate', 1);
                 $interface->assign('defaultNotNeededAfterDays', '');
             }
         }
         $activeLibrary = Library::getActiveLibrary();
         if ($activeLibrary != null) {
             $interface->assign('holdDisclaimer', $activeLibrary->holdDisclaimer);
         } else {
             //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
             $interface->assign('holdDisclaimer', '');
         }
     }
     $record = RecordDriverFactory::initRecordDriverById('ils:' . $_GET['id']);
     if ($record) {
         $interface->assign('record', $record);
     } else {
         PEAR_Singleton::raiseError('Cannot find record ' . $_GET['id']);
     }
     $interface->assign('id', $_GET['id']);
     if ($showMessage && isset($return)) {
         $hold_message_data = array('successful' => $return['result'] == true ? 'all' : 'none', 'error' => isset($return['error']) ? $return['error'] : '', 'titles' => array($return), 'campus' => $_REQUEST['campus']);
         //Check to see if there are item level holds that need follow-up by the user
         if (isset($return['items']) && count($return['items']) > 0) {
             $hold_message_data['showItemForm'] = true;
             $hold_message_data['items'] = $return['items'];
         }
         $_SESSION['hold_message'] = $hold_message_data;
         if (isset($_SESSION['hold_referrer'])) {
             $logger->log('Hold Referrer is set, redirecting to there. location ' . $_SESSION['hold_referrer'], PEAR_LOG_INFO);
             if ($_REQUEST['type'] != 'recall' && $_REQUEST['type'] != 'cancel' && $_REQUEST['type'] != 'update') {
                 header("Location: " . $_SESSION['hold_referrer']);
             } else {
                 //Redirect for hold cancellation or update
                 $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : 'unavailable';
                 header("Location: " . '/MyResearch/Holds?section=' . $section);
             }
             if (!isset($hold_message_data['showItemForm']) || $hold_message_data['showItemForm'] == false) {
                 unset($_SESSION['hold_referrer']);
                 if (isset($_SESSION['autologout'])) {
                     unset($_SESSION['autologout']);
                     UserAccount::softLogout();
                 }
             }
         } else {
             $logger->log('No referrer set, but there is a message to show, go to the main holds page', PEAR_LOG_INFO);
             header("Location: " . '/MyResearch/Holds');
             die;
         }
     } else {
         //$logger->log('placeHold finished, do not need to show a message', PEAR_LOG_INFO);
         $interface->setPageTitle('Request an Item');
         $interface->assign('subTemplate', 'hold.tpl');
         $interface->setTemplate('hold.tpl');
         $interface->display('layout.tpl', 'RecordHold' . $_GET['id']);
     }
 }
Exemplo n.º 7
0
 static function getBookStores()
 {
     $library = Library::getActiveLibrary();
     if ($library) {
         return NearbyBookStore::getBookStores($library->libraryId);
     } else {
         return NearbyBookStore::getDefaultBookStores();
     }
 }
Exemplo n.º 8
0
 public function __construct($searchObject, $params)
 {
     global $configArray;
     // Save the passed-in SearchObject:
     $this->searchObject = $searchObject;
     // Parse the additional settings:
     $params = explode(':', $params);
     $mainSection = empty($params[0]) ? 'Results' : $params[0];
     $checkboxSection = isset($params[1]) ? $params[1] : false;
     $iniName = isset($params[2]) ? $params[2] : 'facets';
     if ($searchObject->getSearchType() == 'genealogy') {
         $config = getExtraConfigArray($iniName);
         $this->mainFacets = isset($config[$mainSection]) ? $config[$mainSection] : array();
     } else {
         $searchLibrary = Library::getActiveLibrary();
         global $locationSingleton;
         $searchLocation = $locationSingleton->getActiveLocation();
         $userLocation = Location::getUserHomeLocation();
         $hasSearchLibraryFacets = $searchLibrary != null && count($searchLibrary->facets) > 0;
         $hasSearchLocationFacets = $searchLocation != null && count($searchLocation->facets) > 0;
         if ($hasSearchLocationFacets) {
             $facets = $searchLocation->facets;
         } elseif ($hasSearchLibraryFacets) {
             $facets = $searchLibrary->facets;
         } else {
             $facets = Library::getDefaultFacets();
         }
         $this->facetSettings = array();
         $this->mainFacets = array();
         foreach ($facets as $facet) {
             $facetName = $facet->facetName;
             //Adjust facet name for local scoping
             if (isset($searchLibrary)) {
                 if ($facet->facetName == 'time_since_added') {
                     $facetName = 'local_time_since_added_' . $searchLibrary->subdomain;
                 } elseif ($facet->facetName == 'itype') {
                     $facetName = 'itype_' . $searchLibrary->subdomain;
                 } elseif ($facet->facetName == 'detailed_location') {
                     $facetName = 'detailed_location_' . $searchLibrary->subdomain;
                 } elseif ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                     $facetName = 'availability_toggle_' . $searchLibrary->subdomain;
                 }
             }
             if (isset($userLocation)) {
                 if ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                     $facetName = 'availability_toggle_' . $userLocation->code;
                 }
             }
             if (isset($searchLocation)) {
                 if ($facet->facetName == 'time_since_added' && $searchLocation->restrictSearchByLocation) {
                     $facetName = 'local_time_since_added_' . $searchLocation->code;
                 } elseif ($facet->facetName == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                     $facetName = 'availability_toggle_' . $searchLocation->code;
                 }
             }
             //Figure out if the facet should be included
             if ($mainSection == 'Results') {
                 if ($facet->showInResults == 1 && $facet->showAboveResults == 0) {
                     $this->facetSettings[$facetName] = $facet;
                     $this->mainFacets[$facetName] = $facet->displayName;
                 } elseif ($facet->showInAdvancedSearch == 1 && $facet->showAboveResults == 0) {
                     $this->facetSettings[$facetName] = $facet->displayName;
                 }
             } elseif ($mainSection == 'Author') {
                 if ($facet->showInAuthorResults == 1 && $facet->showAboveResults == 0) {
                     $this->facetSettings[$facetName] = $facet;
                     $this->mainFacets[$facetName] = $facet->displayName;
                 }
             }
         }
     }
     $this->checkboxFacets = $checkboxSection && isset($config[$checkboxSection]) ? $config[$checkboxSection] : array();
 }
Exemplo n.º 9
0
 /**
  * Process facets from the results object
  *
  * @access  public
  * @param   array   $filter         Array of field => on-screen description
  *                                  listing all of the desired facet fields;
  *                                  set to null to get all configured values.
  * @param   bool    $expandingLinks If true, we will include expanding URLs
  *                                  (i.e. get all matches for a facet, not
  *                                  just a limit to the current search) in
  *                                  the return array.
  * @return  array   Facets data arrays
  */
 public function getFacetList($filter = null, $expandingLinks = false)
 {
     // If there is no filter, we'll use all facets as the filter:
     if (is_null($filter)) {
         $filter = $this->facetConfig;
     }
     // Start building the facet list:
     $list = array();
     // If we have no facets to process, give up now
     if (!isset($this->indexResult['facet_counts'])) {
         return $list;
     } elseif (!is_array($this->indexResult['facet_counts']['facet_fields']) && !is_array($this->indexResult['facet_counts']['facet_dates'])) {
         return $list;
     }
     // Loop through every field returned by the result set
     $validFields = array_keys($filter);
     global $locationSingleton;
     /** @var Library $currentLibrary */
     $currentLibrary = Library::getActiveLibrary();
     $activeLocationFacet = null;
     $activeLocation = $locationSingleton->getActiveLocation();
     if (!is_null($activeLocation)) {
         $activeLocationFacet = $activeLocation->facetLabel;
     }
     $relatedLocationFacets = null;
     $relatedHomeLocationFacets = null;
     if (!is_null($currentLibrary)) {
         $relatedLocationFacets = $locationSingleton->getLocationsFacetsForLibrary($currentLibrary->libraryId);
     }
     $homeLibrary = Library::getPatronHomeLibrary();
     if (!is_null($homeLibrary)) {
         $relatedHomeLocationFacets = $locationSingleton->getLocationsFacetsForLibrary($homeLibrary->libraryId);
     }
     $allFacets = array_merge($this->indexResult['facet_counts']['facet_fields'], $this->indexResult['facet_counts']['facet_dates']);
     foreach ($allFacets as $field => $data) {
         // Skip filtered fields and empty arrays:
         if (!in_array($field, $validFields) || count($data) < 1) {
             continue;
         }
         // Initialize the settings for the current field
         $list[$field] = array();
         // Add the on-screen label
         $list[$field]['label'] = $filter[$field];
         // Build our array of values for this field
         $list[$field]['list'] = array();
         $foundInstitution = false;
         $doInstitutionProcessing = false;
         $foundBranch = false;
         $doBranchProcessing = false;
         //Marmot specific processing to do custom resorting of facets.
         if ($field == 'institution' && isset($currentLibrary) && !is_null($currentLibrary)) {
             $doInstitutionProcessing = true;
         }
         if ($field == 'building' && (!is_null($relatedLocationFacets) || !is_null($activeLocationFacet))) {
             $doBranchProcessing = true;
         } elseif ($field == 'available_at') {
             $doBranchProcessing = true;
         }
         // Should we translate values for the current facet?
         $translate = in_array($field, $this->translatedFacets);
         $numValidRelatedLocations = 0;
         $numValidLibraries = 0;
         // Loop through values:
         foreach ($data as $facet) {
             // Initialize the array of data about the current facet:
             $currentSettings = array();
             $currentSettings['value'] = $facet[0];
             $currentSettings['display'] = $translate ? translate($facet[0]) : $facet[0];
             $currentSettings['count'] = $facet[1];
             $currentSettings['isApplied'] = false;
             $currentSettings['url'] = $this->renderLinkWithFilter("{$field}:" . $facet[0]);
             // If we want to have expanding links (all values matching the facet)
             // in addition to limiting links (filter current search with facet),
             // do some extra work:
             if ($expandingLinks) {
                 $currentSettings['expandUrl'] = $this->getExpandingFacetLink($field, $facet[0]);
             }
             // Is this field a current filter?
             if (in_array($field, array_keys($this->filterList))) {
                 // and is this value a selected filter?
                 if (in_array($facet[0], $this->filterList[$field])) {
                     $currentSettings['isApplied'] = true;
                     $currentSettings['removalUrl'] = $this->renderLinkWithoutFilter("{$field}:{$facet[0]}");
                 }
             }
             //Setup the key to allow sorting alphabetically if needed.
             $valueKey = $facet[0];
             $okToAdd = true;
             if ($doInstitutionProcessing) {
                 //Special processing for Marmot digital library
                 if ($facet[0] == $currentLibrary->facetLabel) {
                     $valueKey = '1' . $valueKey;
                     $numValidLibraries++;
                     $foundInstitution = true;
                 } elseif ($facet[0] == $currentLibrary->facetLabel . ' Online') {
                     $valueKey = '1' . $valueKey;
                     $foundInstitution = true;
                     $numValidLibraries++;
                 } elseif ($facet[0] == $currentLibrary->facetLabel . ' On Order' || $facet[0] == $currentLibrary->facetLabel . ' Under Consideration') {
                     $valueKey = '1' . $valueKey;
                     $foundInstitution = true;
                     $numValidLibraries++;
                 } elseif ($facet[0] == 'Digital Collection' || $facet[0] == 'Marmot Digital Library') {
                     $valueKey = '2' . $valueKey;
                     $foundInstitution = true;
                     $numValidLibraries++;
                 } else {
                     if (!is_null($currentLibrary) && $currentLibrary->restrictOwningBranchesAndSystems == 1) {
                         $okToAdd = false;
                     }
                 }
             } else {
                 if ($doBranchProcessing) {
                     if (strlen($facet[0]) > 0) {
                         if ($activeLocationFacet != null && $facet[0] == $activeLocationFacet) {
                             $valueKey = '1' . $valueKey;
                             $foundBranch = true;
                             $numValidRelatedLocations++;
                         } elseif (isset($currentLibrary) && $facet[0] == $currentLibrary->facetLabel . ' Online') {
                             $valueKey = '1' . $valueKey;
                             $numValidRelatedLocations++;
                         } elseif (isset($currentLibrary) && ($facet[0] == $currentLibrary->facetLabel . ' On Order' || $facet[0] == $currentLibrary->facetLabel . ' Under Consideration')) {
                             $valueKey = '1' . $valueKey;
                             $numValidRelatedLocations++;
                         } else {
                             if (!is_null($relatedLocationFacets) && in_array($facet[0], $relatedLocationFacets)) {
                                 $valueKey = '2' . $valueKey;
                                 $numValidRelatedLocations++;
                             } else {
                                 if (!is_null($relatedLocationFacets) && in_array($facet[0], $relatedLocationFacets)) {
                                     $valueKey = '2' . $valueKey;
                                     $numValidRelatedLocations++;
                                 } else {
                                     if (!is_null($relatedHomeLocationFacets) && in_array($facet[0], $relatedHomeLocationFacets)) {
                                         $valueKey = '2' . $valueKey;
                                         $numValidRelatedLocations++;
                                     } elseif (!is_null($currentLibrary) && $facet[0] == $currentLibrary->facetLabel . ' Online') {
                                         $valueKey = '3' . $valueKey;
                                         $numValidRelatedLocations++;
                                     } elseif ($facet[0] == 'Marmot Digital Library' || $facet[0] == 'Digital Collection' || $facet[0] == 'OverDrive' || $facet[0] == 'Online') {
                                         $valueKey = '4' . $valueKey;
                                         $numValidRelatedLocations++;
                                     } else {
                                         if (!is_null($currentLibrary) && $currentLibrary->restrictOwningBranchesAndSystems == 1) {
                                             $okToAdd = false;
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             // Store the collected values:
             if ($okToAdd) {
                 $list[$field]['list'][$valueKey] = $currentSettings;
             }
         }
         if (!$foundInstitution && $doInstitutionProcessing) {
             $list[$field]['list']['1' . $currentLibrary->facetLabel] = array('value' => $currentLibrary->facetLabel, 'display' => $currentLibrary->facetLabel, 'count' => 0, 'isApplied' => false, 'url' => null, 'expandUrl' => null);
         }
         if (!$foundBranch && $doBranchProcessing && !is_null($activeLocationFacet)) {
             $list[$field]['list']['1' . $activeLocationFacet] = array('value' => $activeLocationFacet, 'display' => $activeLocationFacet, 'count' => 0, 'isApplied' => false, 'url' => null, 'expandUrl' => null);
             $numValidRelatedLocations++;
         }
         //How many facets should be shown by default
         //Only show one system unless we are in the global scope
         if ($field == 'institution' && isset($currentLibrary)) {
             $list[$field]['valuesToShow'] = $numValidLibraries;
         } else {
             if ($field == 'building' && isset($relatedLocationFacets) && $numValidRelatedLocations > 0) {
                 $list[$field]['valuesToShow'] = $numValidRelatedLocations;
             } else {
                 if ($field == 'available_at') {
                     $list[$field]['valuesToShow'] = count($list[$field]['list']);
                 } else {
                     $list[$field]['valuesToShow'] = 5;
                 }
             }
         }
         //Sort the facet alphabetically?
         //Sort the system and location alphabetically unless we are in the global scope
         if (in_array($field, array('institution', 'building', 'available_at')) && isset($currentLibrary)) {
             $list[$field]['showAlphabetically'] = true;
         } else {
             $list[$field]['showAlphabetically'] = false;
         }
         if ($list[$field]['showAlphabetically']) {
             ksort($list[$field]['list']);
         }
     }
     return $list;
 }
Exemplo n.º 10
0
 /**
  * Take a filter string and add it into the protected
  *   array checking for duplicates.
  *
  * @access  public
  * @param   string  $newFilter   A filter string from url : "field:value"
  */
 public function addFilter($newFilter)
 {
     global $configArray;
     // Extract field and value from URL string:
     list($field, $value) = $this->parseFilter($newFilter);
     $searchLibrary = Library::getActiveLibrary();
     global $locationSingleton;
     $searchLocation = $locationSingleton->getActiveLocation();
     $userLocation = Location::getUserHomeLocation();
     global $solrScope;
     // Check for duplicates -- if it's not in the array, we can add it
     if (!$this->hasFilter($newFilter)) {
         if ($field == 'literary-form') {
             $field = 'literary_form';
         } else {
             if ($field == 'literary-form-full') {
                 $field = 'literary_form_full';
             } else {
                 if ($field == 'target-audience') {
                     $field = 'target_audience';
                 } else {
                     if ($field == 'target-audience-full') {
                         $field = 'target_audience_full';
                     }
                 }
             }
         }
         //See if the filter should be localized
         if (isset($searchLibrary)) {
             if ($field == 'time_since_added') {
                 $field = 'local_time_since_added_' . $searchLibrary->subdomain;
             } elseif ($field == 'itype') {
                 $field = 'itype_' . $searchLibrary->subdomain;
             } elseif ($field == 'detailed_location') {
                 $field = 'detailed_location_' . $searchLibrary->subdomain;
             }
         }
         if ($solrScope) {
             if ($field == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                 $field = 'availability_toggle_' . $solrScope;
             } elseif ($field == 'format' && $configArray['Index']['enableDetailedFormats']) {
                 $field = 'format_' . $solrScope;
             } elseif ($field == 'format_category' && $configArray['Index']['enableDetailedFormats']) {
                 $field = 'format_category_' . $solrScope;
             } elseif ($field == 'econtent_source' && $configArray['Index']['enableDetailedEContentSources']) {
                 $field = 'econtent_source_' . $solrScope;
             } elseif ($field == 'econtent_protection_type' && $configArray['Index']['enableDetailedEContentSources']) {
                 $field = 'econtent_protection_type_' . $solrScope;
             }
         }
         if (isset($userLocation)) {
             if ($field == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                 $field = 'availability_toggle_' . $userLocation->code;
             }
         }
         if (isset($searchLocation)) {
             if ($field == 'time_since_added' && $searchLocation->restrictSearchByLocation) {
                 $field = 'local_time_since_added_' . $searchLocation->code;
             } elseif ($field == 'availability_toggle' && $configArray['Index']['enableDetailedAvailability']) {
                 $field = 'availability_toggle_' . $searchLocation->code;
             }
         }
         $this->filterList[$field][] = $value;
     }
 }
Exemplo n.º 11
0
 function placeHolds()
 {
     global $interface;
     global $configArray;
     global $user;
     if (!isset($_REQUEST['selected'])) {
         $hold_message_data = array('successful' => 'none', 'error' => 'No titles were selected', 'titles' => array());
         $showMessage = true;
     } else {
         $selectedIds = $_REQUEST['selected'];
         $eContentDriver = null;
         $showMessage = false;
         $holdings = array();
         //Check to see if all items are eContent
         $ids = array();
         $allItemsEContent = true;
         foreach ($selectedIds as $recordId => $onOff) {
             $ids[] = $recordId;
             //Get the title for the item
             $resource = new Resource();
             if (strpos($recordId, 'econtentRecord') !== 0) {
                 $allItemsEContent = false;
                 $resource->record_id = '.' . $recordId;
                 $resource->source = 'VuFind';
                 $resource->deleted = 0;
             } else {
                 $shortId = str_replace('econtentRecord', '', $recordId);
                 $resource->record_id = $shortId;
                 $resource->source = 'eContent';
                 $resource->deleted = 0;
             }
             if ($resource->find(true)) {
                 $holdings[] = $resource->title;
             } else {
                 echo "Could not find resource for record id {$recordId}";
             }
         }
         $interface->assign('ids', $ids);
         $interface->assign('holdings', $holdings);
         $hold_message_data = array('successful' => 'all', 'titles' => array());
         if (isset($_REQUEST['autologout'])) {
             $_SESSION['autologout'] = true;
         }
         //Check to see if we are ready to place the hold.
         $placeHold = false;
         if (isset($_REQUEST['holdType']) && isset($_REQUEST['campus'])) {
             $placeHold = true;
         } else {
             if ($user && $allItemsEContent) {
                 $placeHold = true;
             }
         }
         if ($placeHold) {
             $hold_message_data['campus'] = $_REQUEST['campus'];
             //This is a new login
             if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
                 $user = UserAccount::login();
             }
             if ($user == false) {
                 $hold_message_data['error'] = 'Incorrect Patron Information';
                 $showMessage = true;
             } else {
                 $atLeast1Successful = false;
                 foreach ($selectedIds as $recordId => $onOff) {
                     if (strpos($recordId, 'econtentRecord', 0) === 0) {
                         if ($eContentDriver == null) {
                             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
                             $eContentDriver = new EContentDriver();
                         }
                         $return = $eContentDriver->placeHold($recordId, $user);
                     } else {
                         $return = $this->catalog->placeHold($recordId, $user->password, '', $_REQUEST['holdType']);
                     }
                     $hold_message_data['titles'][] = $return;
                     if (!$return['result']) {
                         $hold_message_data['successful'] = 'partial';
                     } else {
                         $atLeast1Successful = true;
                     }
                     //Check to see if there are item level holds that need follow-up by the user
                     if (isset($return['items'])) {
                         $hold_message_data['showItemForm'] = true;
                     }
                     $showMessage = true;
                 }
                 if (!$atLeast1Successful) {
                     $hold_message_data['successful'] = 'none';
                 }
             }
         } else {
             //Get the referrer so we can go back there.
             if (isset($_SERVER['HTTP_REFERER'])) {
                 $referer = $_SERVER['HTTP_REFERER'];
                 $_SESSION['hold_referrer'] = $referer;
             }
             //Showing place hold form.
             if ($user) {
                 $profile = $this->catalog->getMyProfile($user);
                 $interface->assign('profile', $profile);
                 //Get information to show a warning if the user does not have sufficient holds
                 require_once ROOT_DIR . '/Drivers/marmot_inc/PType.php';
                 $maxHolds = -1;
                 //Determine if we should show a warning
                 $ptype = new PType();
                 $ptype->pType = $user->patronType;
                 if ($ptype->find(true)) {
                     $maxHolds = $ptype->maxHolds;
                 }
                 $currentHolds = $profile['numHolds'];
                 if ($maxHolds != -1 && $currentHolds + count($selectedIds) > $maxHolds) {
                     $interface->assign('showOverHoldLimit', true);
                     $interface->assign('maxHolds', $maxHolds);
                     $interface->assign('currentHolds', $currentHolds);
                 }
                 global $locationSingleton;
                 //Get the list of pickup branch locations for display in the user interface.
                 $locations = $locationSingleton->getPickupBranches($profile, $profile['homeLocationId']);
                 $interface->assign('pickupLocations', $locations);
                 //set focus to the submit button if the user is logged in since the campus will be correct most of the time.
                 $interface->assign('focusElementId', 'submit');
             } else {
                 //set focus to the username field by default.
                 $interface->assign('focusElementId', 'username');
             }
             global $library;
             $patronHomeBranch = Library::getPatronHomeLibrary();
             if ($patronHomeBranch != null) {
                 if ($patronHomeBranch->defaultNotNeededAfterDays > 0) {
                     $interface->assign('defaultNotNeededAfterDays', date('m/d/Y', time() + $patronHomeBranch->defaultNotNeededAfterDays * 60 * 60 * 24));
                 } else {
                     $interface->assign('defaultNotNeededAfterDays', '');
                 }
                 $interface->assign('showHoldCancelDate', $patronHomeBranch->showHoldCancelDate);
             } else {
                 if ($library) {
                     //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
                     if ($library->defaultNotNeededAfterDays > 0) {
                         $interface->assign('defaultNotNeededAfterDays', date('m/d/Y', time() + $library->defaultNotNeededAfterDays * 60 * 60 * 24));
                     } else {
                         $interface->assign('defaultNotNeededAfterDays', '');
                     }
                     $interface->assign('showHoldCancelDate', $library->showHoldCancelDate);
                 } else {
                     //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
                     $interface->assign('showHoldCancelDate', 1);
                     $interface->assign('defaultNotNeededAfterDays', '');
                 }
             }
             $activeLibrary = Library::getActiveLibrary();
             if ($activeLibrary != null) {
                 $interface->assign('holdDisclaimer', $activeLibrary->holdDisclaimer);
             } else {
                 //Show the hold cancellation date for now.  It may be hidden later when the user logs in.
                 $interface->assign('holdDisclaimer', '');
             }
         }
     }
     if ($showMessage) {
         $hold_message_data['fromCart'] = isset($_REQUEST['fromCart']);
         $_SESSION['hold_message'] = $hold_message_data;
         if (isset($_SESSION['hold_referrer'])) {
             if ($_REQUEST['type'] != 'recall' && $_REQUEST['type'] != 'cancel' && $_REQUEST['type'] != 'update') {
                 header("Location: " . $_SESSION['hold_referrer']);
             } else {
                 //Redirect for hold cancellation or update
                 header("Location: " . $configArray['Site']['path'] . '/MyResearch/Holds');
             }
             if (!isset($hold_message_data['showItemForm']) || $hold_message_data['showItemForm'] == false) {
                 unset($_SESSION['hold_referrer']);
                 if (isset($_SESSION['autologout'])) {
                     unset($_SESSION['autologout']);
                     UserAccount::softLogout();
                 }
             }
         } else {
             header("Location: " . $configArray['Site']['path'] . '/MyResearch/Holds');
         }
     } else {
         $interface->assign('fromCart', isset($_REQUEST['fromCart']));
         $interface->setPageTitle('Request Items');
         $interface->setTemplate('holdMultiple.tpl');
         $interface->display('layout.tpl', 'RecordHolds');
     }
 }