static function getObjectStructure()
 {
     global $user;
     //Load Libraries for lookup values
     $library = new Library();
     $library->orderBy('displayName');
     if ($user->hasRole('libraryAdmin')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $library->libraryId = $homeLibrary->libraryId;
     }
     $library->find();
     $libraryList = array();
     while ($library->fetch()) {
         $libraryList[$library->libraryId] = $library->displayName;
     }
     require_once ROOT_DIR . '/sys/Browse/BrowseCategory.php';
     $browseCategories = new BrowseCategory();
     $browseCategories->orderBy('label');
     $browseCategories->find();
     $browseCategoryList = array();
     while ($browseCategories->fetch()) {
         $browseCategoryList[$browseCategories->textId] = $browseCategories->label . " ({$browseCategories->textId})";
     }
     $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the hours within the database'), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'A link to the library which the location belongs to'), 'browseCategoryTextId' => array('property' => 'browseCategoryTextId', 'type' => 'enum', 'values' => $browseCategoryList, 'label' => 'Browse Category', 'description' => 'The browse category to display '), 'weight' => array('property' => 'weight', 'type' => 'numeric', 'label' => 'Weight', 'weight' => 'Defines how lists are sorted within the widget.  Lower weights are displayed to the left of the screen.', 'required' => true));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
 function getLibraryName()
 {
     if ($this->libraryId == -1) {
         return 'Shared Digital Collection';
     } else {
         $library = new Library();
         $library->libraryId = $this->libraryId;
         $library->find(true);
         return $library->displayName;
     }
 }
Esempio n. 3
0
 static function getObjectStructure()
 {
     $library = new Library();
     $library->orderBy('displayName');
     $library->find();
     $libraryList = array();
     while ($library->fetch()) {
         $libraryList[$library->libraryId] = $library->displayName;
     }
     $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the holiday within the database'), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'A link to the library'), 'date' => array('property' => 'date', 'type' => 'date', 'label' => 'Date', 'description' => 'The date of a holiday.', 'required' => true), 'name' => array('property' => 'name', 'type' => 'text', 'label' => 'Holiday Name', 'description' => 'The name of a holiday'));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
 static function getObjectStructure()
 {
     global $user;
     $library = new Library();
     $library->orderBy('displayName');
     if ($user->hasRole('libraryAdmin')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $library->libraryId = $homeLibrary->libraryId;
     }
     $library->find();
     while ($library->fetch()) {
         $libraryList[$library->libraryId] = $library->displayName;
     }
     $structure = parent::getObjectStructure();
     $structure['libraryId'] = array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'The id of a library');
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
 function getObjectStructure()
 {
     global $user;
     $library = new Library();
     $library->orderBy('displayName');
     if ($user->hasRole('library_material_requests')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $library->libraryId = $homeLibrary->libraryId;
     } else {
         $libraryList[-1] = 'Default';
     }
     $library->find();
     while ($library->fetch()) {
         $libraryList[$library->libraryId] = $library->displayName;
     }
     $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the libary within the database'), 'description' => array('property' => 'description', 'type' => 'text', 'size' => 80, 'label' => 'Description', 'description' => 'A unique name for the Status'), 'isDefault' => array('property' => 'isDefault', 'type' => 'checkbox', 'label' => 'Default Status?', 'description' => 'Whether or not this status is the default status to apply to new requests'), 'isPatronCancel' => array('property' => 'isPatronCancel', 'type' => 'checkbox', 'label' => 'Set When Patron Cancels?', 'description' => 'Whether or not this status should be set when the patron cancels their request'), 'isOpen' => array('property' => 'isOpen', 'type' => 'checkbox', 'label' => 'Open Status?', 'description' => 'Whether or not this status needs further processing'), 'sendEmailToPatron' => array('property' => 'sendEmailToPatron', 'type' => 'checkbox', 'label' => 'Send Email To Patron?', 'description' => 'Whether or not an email should be sent to the patron when this status is set'), 'emailTemplate' => array('property' => 'emailTemplate', 'type' => 'textarea', 'rows' => 6, 'cols' => 60, 'label' => 'Email Template', 'description' => 'The template to use when sending emails to the user', 'hideInLists' => true), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'The id of a library'));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
Esempio n. 6
0
 static function getObjectStructure()
 {
     global $user;
     //Load Libraries for lookup values
     $library = new Library();
     $library->orderBy('displayName');
     if ($user->hasRole('libraryAdmin')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $library->libraryId = $homeLibrary->libraryId;
     }
     $library->find();
     $libraryList = array();
     while ($library->fetch()) {
         $libraryList[$library->libraryId] = $library->displayName;
     }
     $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the hours within the database'), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'A link to the library which the location belongs to'), 'category' => array('property' => 'category', 'type' => 'text', 'label' => 'Category', 'description' => 'The category of the link', 'size' => '80', 'maxLength' => 100), 'linkText' => array('property' => 'linkText', 'type' => 'text', 'label' => 'Link Text', 'description' => 'The text to display for the link ', 'size' => '80', 'maxLength' => 100), 'url' => array('property' => 'url', 'type' => 'text', 'label' => 'URL', 'description' => 'The url to link to', 'size' => '80', 'maxLength' => 255), 'weight' => array('property' => 'weight', 'type' => 'numeric', 'label' => 'Weight', 'weight' => 'Defines how lists are sorted within the widget.  Lower weights are displayed to the left of the screen.', 'required' => true));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
Esempio n. 7
0
 static function getObjectStructure()
 {
     $library = new Library();
     $library->orderBy('displayName');
     $library->find();
     $libraryList = array('-1' => 'Default');
     while ($library->fetch()) {
         $libraryList[$library->libraryId] = $library->displayName;
     }
     $store = new BookStore();
     $store->orderBy('storeName');
     $store->find();
     $storeList = array();
     while ($store->fetch()) {
         $storeList[$store->id] = $store->storeName;
     }
     $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of this association'), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'The id of a library'), 'storeId' => array('property' => 'storeId', 'type' => 'enum', 'values' => $storeList, 'label' => 'Book Store', 'description' => 'The id of a book store'), 'weight' => array('property' => 'weight', 'type' => 'text', 'label' => 'Weight', 'description' => 'The sort order of the book store'));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
 static function getObjectStructure()
 {
     global $user;
     //Load Libraries for lookup values
     $library = new Library();
     $library->orderBy('displayName');
     if ($user->hasRole('libraryAdmin')) {
         $homeLibrary = Library::getPatronHomeLibrary();
         $library->libraryId = $homeLibrary->libraryId;
     }
     $library->find();
     $libraryList = array();
     while ($library->fetch()) {
         $libraryList[$library->libraryId] = $library->displayName;
     }
     require_once ROOT_DIR . '/RecordDrivers/Interface.php';
     $validSources = RecordInterface::getValidMoreDetailsSources();
     $structure = array('id' => array('property' => 'id', 'type' => 'label', 'label' => 'Id', 'description' => 'The unique id of the hours within the database'), 'libraryId' => array('property' => 'libraryId', 'type' => 'enum', 'values' => $libraryList, 'label' => 'Library', 'description' => 'A link to the library which the location belongs to'), 'source' => array('property' => 'source', 'type' => 'enum', 'label' => 'Source', 'values' => $validSources, 'description' => 'The source of the data to display'), 'collapseByDefault' => array('property' => 'collapseByDefault', 'type' => 'checkbox', 'label' => 'Collapse By Default', 'description' => 'Whether or not the section should be collapsed by default', 'default' => true), 'weight' => array('property' => 'weight', 'type' => 'numeric', 'label' => 'Weight', 'weight' => 'Defines how lists are sorted within the widget.  Lower weights are displayed to the left of the screen.', 'required' => true));
     foreach ($structure as $fieldName => $field) {
         $field['propertyOld'] = $field['property'] . 'Old';
         $structure[$fieldName] = $field;
     }
     return $structure;
 }
Esempio n. 9
0
 function copySearchSourcesFromLibrary()
 {
     $libraryId = $_REQUEST['id'];
     if (isset($_REQUEST['submit'])) {
         $library = new Library();
         $library->libraryId = $libraryId;
         $library->find(true);
         $library->clearSearchSources();
         $libraryToCopyFromId = $_REQUEST['libraryToCopyFrom'];
         $libraryToCopyFrom = new Library();
         $libraryToCopyFrom->libraryId = $libraryToCopyFromId;
         $library->find(true);
         $searchSourcesToCopy = $libraryToCopyFrom->searchSources;
         foreach ($searchSourcesToCopy as $searchKey => $searchSources) {
             $searchSources->libraryId = $libraryId;
             $searchSources->id = null;
             $searchSourcesToCopy[$searchKey] = $searchSources;
         }
         $library->searchSources = $searchSourcesToCopy;
         $library->update();
         header("Location: /Admin/Libraries?objectAction=edit&id=" . $libraryId);
     } else {
         //Prompt user for the library to copy from
         $allLibraries = $this->getAllObjects();
         unset($allLibraries[$libraryId]);
         foreach ($allLibraries as $key => $library) {
             if (count($library->searchSources) == 0) {
                 unset($allLibraries[$key]);
             }
         }
         global $interface;
         $interface->assign('allLibraries', $allLibraries);
         $interface->assign('id', $libraryId);
         $interface->setTemplate('../Admin/copyLibrarySearchSources.tpl');
     }
 }
Esempio n. 10
0
 private static function getSearchSourcesDefault()
 {
     $searchOptions = array();
     //Check to see if marmot catalog is a valid option
     global $library;
     global $interface;
     $repeatSearchSetting = '';
     $repeatInWorldCat = false;
     $repeatInProspector = true;
     $repeatInAmazon = true;
     $repeatInOverdrive = false;
     $systemsToRepeatIn = array();
     $searchGenealogy = true;
     $repeatCourseReserves = false;
     /** @var $locationSingleton Location */
     global $locationSingleton;
     $location = $locationSingleton->getActiveLocation();
     if ($location != null && $location->useScope && $location->restrictSearchByLocation) {
         $repeatSearchSetting = $location->repeatSearchOption;
         $repeatInWorldCat = $location->repeatInWorldCat == 1;
         $repeatInProspector = $location->repeatInProspector == 1;
         $repeatInOverdrive = $location->repeatInOverdrive == 1;
         if (strlen($location->systemsToRepeatIn) > 0) {
             $systemsToRepeatIn = explode('|', $location->systemsToRepeatIn);
         } else {
             $systemsToRepeatIn = explode('|', $library->systemsToRepeatIn);
         }
     } elseif (isset($library)) {
         $repeatSearchSetting = $library->repeatSearchOption;
         $repeatInWorldCat = $library->repeatInWorldCat == 1;
         $repeatInProspector = $library->repeatInProspector == 1;
         $repeatInOverdrive = $library->repeatInOverdrive == 1;
         $systemsToRepeatIn = explode('|', $library->systemsToRepeatIn);
     }
     if (isset($library)) {
         $repeatInAmazon = $library->repeatInAmazon;
         $searchGenealogy = $library->enableGenealogy;
         $repeatCourseReserves = $library->enableCourseReserves == 1;
     }
     $marmotAdded = false;
     //Local search
     if (isset($location) && $location != null && $location->useScope && $location->restrictSearchByLocation) {
         $searchOptions['local'] = array('name' => $location->displayName, 'description' => "The {$location->displayName} catalog.");
     } elseif (isset($library)) {
         $searchOptions['local'] = array('name' => $library->displayName, 'description' => "The {$library->displayName} catalog.");
     } else {
         $marmotAdded = true;
         $searchOptions['local'] = array('name' => 'Marmot Catalog', 'description' => "The entire Marmot catalog.");
     }
     if ($location != null && ($repeatSearchSetting == 'marmot' || $repeatSearchSetting == 'librarySystem') && ($location->useScope && $location->restrictSearchByLocation)) {
         $searchOptions[$library->subdomain] = array('name' => $library->displayName, 'description' => "The entire {$library->displayName} catalog not limited to a particular branch.");
     }
     //Process additional systems to repeat in
     if (count($systemsToRepeatIn) > 0) {
         foreach ($systemsToRepeatIn as $system) {
             if (strlen($system) > 0) {
                 $repeatInLibrary = new Library();
                 $repeatInLibrary->subdomain = $system;
                 $repeatInLibrary->find();
                 if ($repeatInLibrary->N == 1) {
                     $repeatInLibrary->fetch();
                     $searchOptions[$repeatInLibrary->subdomain] = array('name' => $repeatInLibrary->displayName, 'description' => '');
                 } else {
                     //See if this is a repeat within a location
                     $repeatInLocation = new Location();
                     $repeatInLocation->code = $system;
                     $repeatInLocation->find();
                     if ($repeatInLocation->N == 1) {
                         $repeatInLocation->fetch();
                         $searchOptions[$repeatInLocation->code] = array('name' => $repeatInLocation->displayName, 'description' => '');
                     }
                 }
             }
         }
     }
     //eContent Search
     $searchOptions['econtent'] = array('name' => 'Online Collection', 'description' => 'Digital Media available for use online and with portable devices');
     //Marmot Global search
     if (isset($library) && $repeatSearchSetting == 'marmot' && $library->restrictSearchByLibrary && $marmotAdded == false) {
         $searchOptions['marmot'] = array('name' => 'Marmot Catalog', 'description' => 'A shared catalog of public, academic, and school libraries on the Western Slope.');
     }
     //Genealogy Search
     if ($searchGenealogy && !$interface->isMobile()) {
         $searchOptions['genealogy'] = array('name' => 'Genealogy Records', 'description' => 'Genealogy Records from Colorado');
     }
     //Overdrive
     if ($repeatInOverdrive && !$interface->isMobile()) {
         $searchOptions['overdrive'] = array('name' => 'OverDrive Digital Catalog', 'description' => 'Downloadable Books, Videos, Music, and eBooks with free use for library card holders.', 'external' => true);
     }
     if ($repeatInProspector && !$interface->isMobile()) {
         $searchOptions['prospector'] = array('name' => 'Prospector Catalog', 'description' => 'A shared catalog of academic, public, and special libraries all over Colorado.', 'external' => true);
     }
     //Course reserves for colleges
     if ($repeatCourseReserves) {
         //Mesa State
         $searchOptions['course-reserves-course-name'] = array('name' => 'Course Reserves by Name or Number', 'description' => 'Search course reserves by course name or number', 'external' => true);
         $searchOptions['course-reserves-instructor'] = array('name' => 'Course Reserves by Instructor', 'description' => 'Search course reserves by professor, lecturer, or instructor name', 'external' => true);
     }
     if ($repeatInWorldCat && !$interface->isMobile()) {
         $searchOptions['worldcat'] = array('name' => 'WorldCat', 'description' => 'A shared catalog of libraries all over the world.', 'external' => true);
     }
     //Check to see if Gold Rush is a valid option
     if (isset($library) && strlen($library->goldRushCode) > 0 && !$interface->isMobile()) {
         $searchOptions['goldrush'] = array('name' => 'Gold Rush Magazine Finder', 'description' => 'A catalog of online journals and full text articles.', 'external' => true);
     }
     if ($repeatInAmazon && !$interface->isMobile()) {
         $searchOptions['amazon'] = array('name' => 'Amazon', 'description' => 'Online retailer selling a wide variety of books, movies, music, and more.', 'external' => true);
     }
     return $searchOptions;
 }
Esempio n. 11
0
 function launch()
 {
     global $interface;
     global $user;
     global $logger;
     $libraries = array();
     $library = new Library();
     $library->orderBy('displayName');
     $library->find();
     while ($library->fetch()) {
         $libraries[$library->libraryId] = array('id' => $library->libraryId, 'displayName' => $library->displayName, 'subdomain' => $library->subdomain);
     }
     $interface->assign('libraries', $libraries);
     global $locationSingleton;
     $physicalLocation = $locationSingleton->getActiveLocation();
     if (isset($_REQUEST['gotoModule'])) {
         $gotoModule = $_REQUEST['gotoModule'];
         $interface->assign('gotoModule', $gotoModule);
     }
     if (isset($_REQUEST['gotoAction'])) {
         $gotoAction = $_REQUEST['gotoAction'];
         $interface->assign('gotoAction', $gotoAction);
     }
     $redirectLibrary = null;
     if (isset($_REQUEST['library'])) {
         $redirectLibrary = $_REQUEST['library'];
     } elseif (!is_null($physicalLocation)) {
         $redirectLibrary = $physicalLocation->libraryId;
     } elseif ($user && isset($user->preferredLibraryInterface) && is_numeric($user->preferredLibraryInterface)) {
         $redirectLibrary = $user->preferredLibraryInterface;
     } elseif (isset($_COOKIE['PreferredLibrarySystem'])) {
         $redirectLibrary = $_COOKIE['PreferredLibrarySystem'];
     }
     if ($redirectLibrary != null) {
         $logger->log("Selected library {$redirectLibrary}", PEAR_LOG_DEBUG);
         $selectedLibrary = $libraries[$redirectLibrary];
         global $configArray;
         $baseUrl = $configArray['Site']['url'];
         $urlPortions = explode('://', $baseUrl);
         //Get rid of extra portions of the url
         $subdomain = $selectedLibrary['subdomain'];
         if (strpos($urlPortions[1], 'opac2') !== false) {
             $urlPortions[1] = str_replace('opac2.', '', $urlPortions[1]);
             $subdomain .= '2';
         }
         $urlPortions[1] = str_replace('opac.', '', $urlPortions[1]);
         $baseUrl = $urlPortions[0] . '://' . $subdomain . '.' . $urlPortions[1];
         if ($gotoModule) {
             $baseUrl .= '/' . $gotoModule;
         }
         if ($gotoAction) {
             $baseUrl .= '/' . $gotoAction;
         }
         if (isset($_REQUEST['rememberThis']) && isset($_REQUEST['submit'])) {
             if ($user) {
                 $user->preferredLibraryInterface = $redirectLibrary;
                 $user->update();
                 $_SESSION['userinfo'] = serialize($user);
             }
             //Set a cookie to remember the location when not logged in
             //Remember for a year
             setcookie('PreferredLibrarySystem', $redirectLibrary, time() + 60 * 60 * 24 * 365, '/');
         }
         header('Location:' . $baseUrl);
         die;
     }
     //Build the actual view
     $interface->setTemplate('selectInterface.tpl');
     $interface->setPageTitle('Select Library Catalog');
     // Display Page
     $interface->display('layout.tpl');
 }
Esempio n. 12
0
 /**
  * Returns a summary of the holdings information for a single id. Used to display
  * within the search results and at the top of a full record display to ensure
  * the holding information makes sense to all users.
  *
  * @param string $id the id of the bid to load holdings for
  * @return array an associative array with a summary of the holdings.
  */
 public function getStatusSummary($id, $record = null, $mysip = null)
 {
     global $timer;
     global $library;
     global $locationSingleton;
     global $configArray;
     global $memCache;
     //Holdings summaries need to be cached based on the actual location since part of the information
     //includes local call numbers and statuses.
     $ipLocation = $locationSingleton->getPhysicalLocation();
     $location = $ipLocation;
     if (!isset($location) && $location == null) {
         $location = $locationSingleton->getUserHomeLocation();
     }
     $ipLibrary = null;
     if (isset($ipLocation)) {
         $ipLibrary = new Library();
         $ipLibrary->libraryId = $ipLocation->getLibraryId;
         if (!$ipLibrary->find(true)) {
             $ipLibrary = null;
         }
     }
     if (!isset($location) && $location == null) {
         $locationId = -1;
     } else {
         $locationId = $location->locationId;
     }
     $summaryInformation = $memCache->get("holdings_summary_{$id}_{$locationId}");
     if ($summaryInformation == false) {
         $canShowHoldButton = true;
         if ($library && $library->showHoldButton == 0) {
             $canShowHoldButton = false;
         }
         if ($location != null && $location->showHoldButton == 0) {
             $canShowHoldButton = false;
         }
         $holdings = $this->getStatus($id, $record, $mysip, true);
         $timer->logTime('Retrieved Status of holding');
         $counter = 0;
         $summaryInformation = array();
         $summaryInformation['recordId'] = $id;
         $summaryInformation['shortId'] = $id;
         $summaryInformation['isDownloadable'] = false;
         //Default value, reset later if needed.
         $summaryInformation['holdQueueLength'] = 0;
         //Check to see if we are getting issue summaries or actual holdings
         $isIssueSummary = false;
         $numSubscriptions = 0;
         if (count($holdings) > 0) {
             $lastHolding = end($holdings);
             if (isset($lastHolding['type']) && ($lastHolding['type'] == 'issueSummary' || $lastHolding['type'] == 'issue')) {
                 $isIssueSummary = true;
                 $issueSummaries = $holdings;
                 $numSubscriptions = count($issueSummaries);
                 $holdings = array();
                 foreach ($issueSummaries as $issueSummary) {
                     if (isset($issueSummary['holdings'])) {
                         $holdings = array_merge($holdings, $issueSummary['holdings']);
                     } else {
                         //Create a fake holding for subscriptions so something
                         //will be displayed in the holdings summary.
                         $holdings[$issueSummary['location']] = array('availability' => '1', 'location' => $issueSummary['location'], 'libraryDisplayName' => $issueSummary['location'], 'callnumber' => $issueSummary['cALL'], 'status' => 'Lib Use Only', 'statusfull' => 'In Library Use Only');
                     }
                 }
             }
         }
         $timer->logTime('Processed for subscriptions');
         //Valid statuses are:
         //Available by Request
         //  - not at the user's home branch or preferred location, but at least one copy is not checked out
         //  - do not show the call number
         //  - show place hold button
         //Checked Out
         //  - all copies are checked out
         //  - show the call number for the local library if any
         //  - show place hold button
         //Downloadable
         //  - there is at least one download link for the record.
         $numAvailableCopies = 0;
         $numHoldableCopies = 0;
         $numCopies = 0;
         $numCopiesOnOrder = 0;
         $availableLocations = array();
         $unavailableStatus = null;
         //The status of all items.  Will be set to an actual status if all are the same
         //or null if the item statuses are inconsistent
         $allItemStatus = '';
         $firstAvailableBarcode = '';
         $availableHere = false;
         foreach ($holdings as $holdingKey => $holding) {
             if (is_null($allItemStatus)) {
                 //Do nothing, the status is not distinct
             } else {
                 if ($allItemStatus == '') {
                     $allItemStatus = $holding['statusfull'];
                 } elseif ($allItemStatus != $holding['statusfull']) {
                     $allItemStatus = null;
                 }
             }
             if ($holding['availability'] == true) {
                 if ($ipLocation && strcasecmp($holding['locationCode'], $ipLocation->code) == 0) {
                     $availableHere = true;
                 }
                 $numAvailableCopies++;
                 $addToAvailableLocation = false;
                 $addToAdditionalAvailableLocation = false;
                 //Check to see if the location should be listed in the list of locations that the title is available at.
                 //Can only be in this system if there is a system active.
                 if (!in_array($holding['locationCode'], array_keys($availableLocations))) {
                     $locationMapLink = $this->getLocationMapLink($holding['locationCode']);
                     if (strlen($locationMapLink) > 0) {
                         $availableLocations[$holding['locationCode']] = "<a href='{$locationMapLink}' target='_blank'>" . preg_replace('/\\s/', '&nbsp;', $holding['location']) . "</a>";
                     } else {
                         $availableLocations[$holding['locationCode']] = $holding['location'];
                     }
                 }
             } else {
                 if ($unavailableStatus == null) {
                     $unavailableStatus = $holding['statusfull'];
                 }
             }
             if (isset($holding['holdable']) && $holding['holdable'] == 1) {
                 $numHoldableCopies++;
             }
             $numCopies++;
             //Check to see if the holding has a download link and if so, set that info.
             if (isset($holding['link'])) {
                 foreach ($holding['link'] as $link) {
                     if ($link['isDownload']) {
                         $summaryInformation['status'] = "Available for Download";
                         $summaryInformation['class'] = 'here';
                         $summaryInformation['isDownloadable'] = true;
                         $summaryInformation['downloadLink'] = $link['link'];
                         $summaryInformation['downloadText'] = $link['linkText'];
                     }
                 }
             }
             //Only show a call number if the book is at the user's home library, one of their preferred libraries, or in the library they are in.
             if (!isset($summaryInformation['callnumber'])) {
                 $summaryInformation['callnumber'] = $holding['callnumber'];
             }
             if ($holding['availability'] == 1) {
                 //The item is available within the physical library.  Patron should go get it off the shelf
                 $summaryInformation['status'] = "Available At";
                 if ($numHoldableCopies > 0) {
                     $summaryInformation['showPlaceHold'] = $canShowHoldButton;
                 } else {
                     $summaryInformation['showPlaceHold'] = 0;
                 }
                 $summaryInformation['class'] = 'available';
             }
             if ($holding['holdQueueLength'] > $summaryInformation['holdQueueLength']) {
                 $summaryInformation['holdQueueLength'] = $holding['holdQueueLength'];
             }
             if ($firstAvailableBarcode == '' && $holding['availability'] == true) {
                 $firstAvailableBarcode = $holding['barcode'];
             }
         }
         $timer->logTime('Processed copies');
         //If all items are checked out the status will still be blank
         $summaryInformation['availableCopies'] = $numAvailableCopies;
         $summaryInformation['holdableCopies'] = $numHoldableCopies;
         $summaryInformation['numCopiesOnOrder'] = $numCopiesOnOrder;
         //Do some basic sanity checking to make sure that we show the total copies
         //With at least as many copies as the number of copies on order.
         if ($numCopies < $numCopiesOnOrder) {
             $summaryInformation['numCopies'] = $numCopiesOnOrder;
         } else {
             $summaryInformation['numCopies'] = $numCopies;
         }
         if ($unavailableStatus != 'ONLINE') {
             $summaryInformation['unavailableStatus'] = $unavailableStatus;
         }
         //Status is not set, check to see if the item is downloadable
         if (!isset($summaryInformation['status']) && !isset($summaryInformation['downloadLink'])) {
             // Retrieve Full Marc Record
             $recordURL = null;
             // Process MARC Data
             require_once ROOT_DIR . '/sys/MarcLoader.php';
             $marcRecord = MarcLoader::loadMarcRecordByILSId($id);
             if ($marcRecord) {
                 //Check the 856 tag to see if there is a URL
                 if ($linkField = $marcRecord->getField('856')) {
                     if ($linkURLField = $linkField->getSubfield('u')) {
                         $linkURL = $linkURLField->getData();
                     }
                     if ($linkTextField = $linkField->getSubfield('3')) {
                         $linkText = $linkTextField->getData();
                     } else {
                         if ($linkTextField = $linkField->getSubfield('y')) {
                             $linkText = $linkTextField->getData();
                         } else {
                             if ($linkTextField = $linkField->getSubfield('z')) {
                                 $linkText = $linkTextField->getData();
                             }
                         }
                     }
                 }
             } else {
                 //Can't process the marc record, ignore it.
             }
             //If there is a link, add that status information.
             if (isset($linkURL)) {
                 $isImageLink = preg_match('/.*\\.(?:gif|jpg|jpeg|tif|tiff)/i', $linkURL);
                 $isInternalLink = preg_match('/vufind|catalog/i', $linkURL);
                 $isPurchaseLink = preg_match('/amazon|barnesandnoble/i', $linkURL);
                 if ($isImageLink == 0 && $isInternalLink == 0 && $isPurchaseLink == 0) {
                     $linkTestText = $linkText . ' ' . $linkURL;
                     $isDownload = preg_match('/SpringerLink|NetLibrary|digital media|Online version\\.|ebrary|gutenberg|emedia2go/i', $linkTestText);
                     if ($linkTestText == 'digital media') {
                         $linkText = 'OverDrive';
                     }
                     if (preg_match('/netlibrary/i', $linkURL)) {
                         $isDownload = true;
                         $linkText = 'NetLibrary';
                     } elseif (preg_match('/ebscohost/i', $linkURL)) {
                         $isDownload = true;
                         $linkText = 'Ebsco';
                     } elseif (preg_match('/overdrive|emedia2go/i', $linkURL)) {
                         $isDownload = true;
                         $linkText = 'OverDrive';
                     } elseif (preg_match('/ebrary/i', $linkURL)) {
                         $isDownload = true;
                         $linkText = 'ebrary';
                     } elseif (preg_match('/gutenberg/i', $linkURL)) {
                         $isDownload = true;
                         $linkText = 'Gutenberg Project';
                     } elseif (preg_match('/ezproxy/i', $linkURL)) {
                         $isDownload = true;
                     } elseif (preg_match('/.*\\.[pdf]/', $linkURL)) {
                         $isDownload = true;
                     }
                     if ($isDownload) {
                         $summaryInformation['status'] = "Available for Download";
                         $summaryInformation['class'] = 'here';
                         $summaryInformation['isDownloadable'] = true;
                         $summaryInformation['downloadLink'] = $linkURL;
                         $summaryInformation['downloadText'] = isset($linkText) ? $linkText : 'Download';
                         //Check to see if this is an eBook or eAudio book.  We can get this from the 245h tag
                         $isEBook = true;
                         $resource = new Resource();
                         $resource->record_id = $id;
                         $resource->source = 'VuFind';
                         if ($resource->find(true)) {
                             $formatCategory = $resource->format_category;
                             if (strcasecmp($formatCategory, 'eBooks') === 0) {
                                 $summaryInformation['eBookLink'] = $linkURL;
                             } elseif (strcasecmp($formatCategory, 'eAudio') === 0) {
                                 $summaryInformation['eAudioLink'] = $linkURL;
                             }
                         }
                     }
                 }
             }
             $timer->logTime('Checked for downloadable link in 856 tag');
         }
         $showItsHere = empty($ipLibrary) ? TRUE : $ipLibrary->showItsHere == 1;
         if ($availableHere && $showItsHere) {
             $summaryInformation['status'] = "It's Here";
             $summaryInformation['class'] = 'here';
             unset($availableLocations[$location->code]);
             $summaryInformation['currentLocation'] = $location->displayName;
             $summaryInformation['availableAt'] = join(', ', $availableLocations);
             $summaryInformation['numAvailableOther'] = count($availableLocations);
         } else {
             //Replace all spaces in the name of a location with no break spaces
             $summaryInformation['availableAt'] = join(', ', $availableLocations);
             $summaryInformation['numAvailableOther'] = count($availableLocations);
         }
         //If Status is still not set, apply some logic based on number of copies
         if (!isset($summaryInformation['status'])) {
             if ($numCopies == 0) {
                 if ($numCopiesOnOrder > 0) {
                     //No copies are currently available, but we do have some that are on order.
                     //show the status as on order and make it available.
                     $summaryInformation['status'] = "On Order";
                     $summaryInformation['class'] = 'available';
                     $summaryInformation['showPlaceHold'] = $canShowHoldButton;
                 } else {
                     //Deal with weird cases where there are no items by saying it is unavailable
                     $summaryInformation['status'] = "Unavailable";
                     $summaryInformation['showPlaceHold'] = false;
                     $summaryInformation['class'] = 'unavailable';
                 }
             } else {
                 if ($numHoldableCopies == 0 && $canShowHoldButton && (isset($summaryInformation['showPlaceHold']) && $summaryInformation['showPlaceHold'] != true)) {
                     $summaryInformation['status'] = "Not Available For Checkout";
                     $summaryInformation['showPlaceHold'] = false;
                     $summaryInformation['class'] = 'reserve';
                 } else {
                     $summaryInformation['status'] = "Checked Out";
                     $summaryInformation['showPlaceHold'] = $canShowHoldButton;
                     $summaryInformation['class'] = 'checkedOut';
                 }
             }
         }
         //Reset status if the status for all items is consistent.
         //That way it will jive with the actual full record display.
         if ($allItemStatus != null && $allItemStatus != '') {
             //Only override this for statuses that don't have special meaning
             if ($summaryInformation['status'] != 'Marmot' && $summaryInformation['status'] != 'Available At' && $summaryInformation['status'] != "It's Here") {
                 $summaryInformation['status'] = $allItemStatus;
             }
         }
         if ($allItemStatus == 'In Library Use Only') {
             $summaryInformation['inLibraryUseOnly'] = true;
         } else {
             $summaryInformation['inLibraryUseOnly'] = false;
         }
         if ($summaryInformation['availableCopies'] == 0 && $summaryInformation['isDownloadable'] == true) {
             $summaryInformation['showAvailabilityLine'] = false;
         } else {
             $summaryInformation['showAvailabilityLine'] = true;
         }
         $timer->logTime('Finished building summary');
         $memCache->set("holdings_summary_{$id}_{$locationId}", $summaryInformation, 0, $configArray['Caching']['holdings_summary']);
     }
     return $summaryInformation;
 }
Esempio n. 13
0
 /**
  * Returns a summary of the holdings information for a single id. Used to display
  * within the search results and at the top of a full record display to ensure
  * the holding information makes sense to all users.
  *
  * @param string $id the id of the bid to load holdings for
  *
  * @return array an associative array with a summary of the holdings.
  */
 public function getStatusSummary($id)
 {
     global $timer;
     global $library;
     global $locationSingleton;
     global $configArray;
     /** @var Memcache $memCache */
     global $memCache;
     //Holdings summaries need to be cached based on the actual location since part of the information
     //includes local call numbers and statuses.
     $ipLocation = $locationSingleton->getPhysicalLocation();
     $location = $ipLocation;
     if (!isset($location) && $location == null) {
         $location = $locationSingleton->getUserHomeLocation();
     }
     $ipLibrary = null;
     if (isset($ipLocation)) {
         $ipLibrary = new Library();
         $ipLibrary->libraryId = $ipLocation->libraryId;
         if (!$ipLibrary->find(true)) {
             $ipLibrary = null;
         }
     }
     if (!isset($location) && $location == null) {
         $locationId = -1;
     } else {
         $locationId = $location->locationId;
     }
     $summaryInformation = $memCache->get("holdings_summary_{$id}_{$locationId}");
     if ($summaryInformation == false) {
         $canShowHoldButton = true;
         if ($library && $library->showHoldButton == 0) {
             $canShowHoldButton = false;
         }
         if ($location != null && $location->showHoldButton == 0) {
             $canShowHoldButton = false;
         }
         $holdings = $this->getStatus($id);
         $timer->logTime('Retrieved Status of holding');
         $summaryInformation = array();
         $summaryInformation['recordId'] = $id;
         $summaryInformation['shortId'] = $id;
         $summaryInformation['isDownloadable'] = false;
         //Default value, reset later if needed.
         $summaryInformation['holdQueueLength'] = 0;
         //Check to see if we are getting issue summaries or actual holdings
         if (count($holdings) > 0) {
             $lastHolding = end($holdings);
             if (isset($lastHolding['type']) && ($lastHolding['type'] == 'issueSummary' || $lastHolding['type'] == 'issue')) {
                 $issueSummaries = $holdings;
                 $holdings = array();
                 foreach ($issueSummaries as $issueSummary) {
                     if (isset($issueSummary['holdings'])) {
                         $holdings = array_merge($holdings, $issueSummary['holdings']);
                     } else {
                         //Create a fake holding for subscriptions so something
                         //will be displayed in the holdings summary.
                         $holdings[$issueSummary['location']] = array('availability' => '1', 'location' => $issueSummary['location'], 'libraryDisplayName' => $issueSummary['location'], 'callnumber' => $issueSummary['cALL'], 'status' => 'Lib Use Only', 'statusfull' => 'In Library Use Only');
                     }
                 }
             }
         }
         $timer->logTime('Processed for subscriptions');
         //Valid statuses are:
         //Available by Request
         //  - not at the user's home branch or preferred location, but at least one copy is not checked out
         //  - do not show the call number
         //  - show place hold button
         //Checked Out
         //  - all copies are checked out
         //  - show the call number for the local library if any
         //  - show place hold button
         //Downloadable
         //  - there is at least one download link for the record.
         $numAvailableCopies = 0;
         $numHoldableCopies = 0;
         $numCopies = 0;
         $numCopiesOnOrder = 0;
         $availableLocations = array();
         $unavailableStatus = null;
         //The status of all items.  Will be set to an actual status if all are the same
         //or null if the item statuses are inconsistent
         $allItemStatus = '';
         $firstAvailableBarcode = '';
         $availableHere = false;
         foreach ($holdings as $holding) {
             if (is_null($allItemStatus)) {
                 //Do nothing, the status is not distinct
             } else {
                 if ($allItemStatus == '') {
                     $allItemStatus = $holding['statusfull'];
                 } elseif ($allItemStatus != $holding['statusfull']) {
                     $allItemStatus = null;
                 }
             }
             if ($holding['availability'] == true) {
                 if ($ipLocation && strcasecmp($holding['locationCode'], $ipLocation->code) == 0) {
                     $availableHere = true;
                 }
                 $numAvailableCopies++;
                 //Check to see if the location should be listed in the list of locations that the title is available at.
                 //Can only be in this system if there is a system active.
                 if (!in_array($holding['locationCode'], array_keys($availableLocations))) {
                     $availableLocations[$holding['locationCode']] = $holding['location'];
                 }
             } else {
                 if ($unavailableStatus == null) {
                     $unavailableStatus = $holding['statusfull'];
                 }
             }
             if (isset($holding['holdable']) && $holding['holdable'] == 1) {
                 $numHoldableCopies++;
             }
             $numCopies++;
             //Check to see if the holding has a download link and if so, set that info.
             if (isset($holding['link'])) {
                 foreach ($holding['link'] as $link) {
                     if ($link['isDownload']) {
                         $summaryInformation['status'] = "Available for Download";
                         $summaryInformation['class'] = 'here';
                         $summaryInformation['isDownloadable'] = true;
                         $summaryInformation['downloadLink'] = $link['link'];
                         $summaryInformation['downloadText'] = $link['linkText'];
                     }
                 }
             }
             //Only show a call number if the book is at the user's home library, one of their preferred libraries, or in the library they are in.
             if (!isset($summaryInformation['callnumber'])) {
                 $summaryInformation['callnumber'] = $holding['callnumber'];
             }
             if ($holding['availability'] == 1) {
                 //The item is available within the physical library.  Patron should go get it off the shelf
                 $summaryInformation['status'] = "Available At";
                 if ($numHoldableCopies > 0) {
                     $summaryInformation['showPlaceHold'] = $canShowHoldButton;
                 } else {
                     $summaryInformation['showPlaceHold'] = 0;
                 }
                 $summaryInformation['class'] = 'available';
             }
             if ($holding['holdQueueLength'] > $summaryInformation['holdQueueLength']) {
                 $summaryInformation['holdQueueLength'] = $holding['holdQueueLength'];
             }
             if ($firstAvailableBarcode == '' && $holding['availability'] == true) {
                 $firstAvailableBarcode = $holding['barcode'];
             }
         }
         $timer->logTime('Processed copies');
         //If all items are checked out the status will still be blank
         $summaryInformation['availableCopies'] = $numAvailableCopies;
         $summaryInformation['holdableCopies'] = $numHoldableCopies;
         $summaryInformation['numCopiesOnOrder'] = $numCopiesOnOrder;
         //Do some basic sanity checking to make sure that we show the total copies
         //With at least as many copies as the number of copies on order.
         if ($numCopies < $numCopiesOnOrder) {
             $summaryInformation['numCopies'] = $numCopiesOnOrder;
         } else {
             $summaryInformation['numCopies'] = $numCopies;
         }
         if ($unavailableStatus != 'ONLINE') {
             $summaryInformation['unavailableStatus'] = $unavailableStatus;
         }
         $showItsHere = $ipLibrary == null ? true : $ipLibrary->showItsHere == 1;
         if ($availableHere && $showItsHere) {
             $summaryInformation['status'] = "It's Here";
             $summaryInformation['class'] = 'here';
             unset($availableLocations[$location->code]);
             $summaryInformation['currentLocation'] = $location->displayName;
             $summaryInformation['availableAt'] = join(', ', $availableLocations);
             $summaryInformation['numAvailableOther'] = count($availableLocations);
         } else {
             //Replace all spaces in the name of a location with no break spaces
             $summaryInformation['availableAt'] = join(', ', $availableLocations);
             $summaryInformation['numAvailableOther'] = count($availableLocations);
         }
         //If Status is still not set, apply some logic based on number of copies
         if (!isset($summaryInformation['status'])) {
             if ($numCopies == 0) {
                 if ($numCopiesOnOrder > 0) {
                     //No copies are currently available, but we do have some that are on order.
                     //show the status as on order and make it available.
                     $summaryInformation['status'] = "On Order";
                     $summaryInformation['class'] = 'available';
                     $summaryInformation['showPlaceHold'] = $canShowHoldButton;
                 } else {
                     //Deal with weird cases where there are no items by saying it is unavailable
                     $summaryInformation['status'] = "Unavailable";
                     $summaryInformation['showPlaceHold'] = false;
                     $summaryInformation['class'] = 'unavailable';
                 }
             } else {
                 if ($numHoldableCopies == 0 && $canShowHoldButton && (isset($summaryInformation['showPlaceHold']) && $summaryInformation['showPlaceHold'] != true)) {
                     $summaryInformation['status'] = "Not Available For Checkout";
                     $summaryInformation['showPlaceHold'] = false;
                     $summaryInformation['class'] = 'reserve';
                 } else {
                     $summaryInformation['status'] = "Checked Out";
                     $summaryInformation['showPlaceHold'] = $canShowHoldButton;
                     $summaryInformation['class'] = 'checkedOut';
                 }
             }
         }
         //Reset status if the status for all items is consistent.
         //That way it will jive with the actual full record display.
         if ($allItemStatus != null && $allItemStatus != '') {
             //Only override this for statuses that don't have special meaning
             if ($summaryInformation['status'] != 'Marmot' && $summaryInformation['status'] != 'Available At' && $summaryInformation['status'] != "It's Here") {
                 $summaryInformation['status'] = $allItemStatus;
             }
         }
         if ($allItemStatus == 'In Library Use Only') {
             $summaryInformation['inLibraryUseOnly'] = true;
         } else {
             $summaryInformation['inLibraryUseOnly'] = false;
         }
         if ($summaryInformation['availableCopies'] == 0 && $summaryInformation['isDownloadable'] == true) {
             $summaryInformation['showAvailabilityLine'] = false;
         } else {
             $summaryInformation['showAvailabilityLine'] = true;
         }
         $timer->logTime('Finished building summary');
         $memCache->set("holdings_summary_{$id}_{$locationId}", $summaryInformation, 0, $configArray['Caching']['holdings_summary']);
     }
     return $summaryInformation;
 }
Esempio n. 14
0
/**
 * Update the configuration array as needed based on scoping rules defined
 * by the subdomain.
 *
 * @param array $configArray the existing main configuration options.
 *
 * @return array the configuration options adjusted based on the scoping rules.
 */
function updateConfigForScoping($configArray)
{
    global $timer;
    //Get the subdomain for the request
    global $serverName;
    //split the servername based on
    global $subdomain;
    $subdomain = null;
    if (strpos($_SERVER['SERVER_NAME'], '.')) {
        $serverComponents = explode('.', $_SERVER['SERVER_NAME']);
        if (count($serverComponents) >= 3) {
            //URL is probably of the form subdomain.marmot.org or subdomain.opac.marmot.org
            $subdomain = $serverComponents[0];
        } else {
            if (count($serverComponents) == 2) {
                //URL could be either subdomain.localhost or marmot.org. Only use the subdomain
                //If the second component is localhost.
                if (strcasecmp($serverComponents[1], 'localhost') == 0) {
                    $subdomain = $serverComponents[0];
                }
            }
        }
        //Trim off test indicator when doing lookups for library/location
        if (substr($subdomain, -1) == '2' || substr($subdomain, -1) == '3') {
            $subdomain = substr($subdomain, 0, -1);
        }
    }
    $timer->logTime('got subdomain');
    //Load the library system information
    global $library;
    global $locationSingleton;
    if (isset($_SESSION['library']) && isset($_SESSION['location'])) {
        $library = $_SESSION['library'];
        $locationSingleton = $_SESSION['library'];
    } else {
        $Library = new Library();
        $Library->whereAdd("subdomain = '{$subdomain}'");
        $Library->find();
        if ($Library->N == 1) {
            $Library->fetch();
            //Make the library information global so we can work with it later.
            $library = $Library;
        } else {
            //The subdomain can also indicate a location.
            $Location = new Location();
            $Location->whereAdd("code = '{$subdomain}'");
            $Location->find();
            if ($Location->N == 1) {
                $Location->fetch();
                //We found a location for the subdomain, get the library.
                /** @var Library $librarySingleton */
                global $librarySingleton;
                $library = $librarySingleton->getLibraryForLocation($Location->locationId);
                $locationSingleton->setActiveLocation(clone $Location);
            } else {
                //Check to see if there is only one library in the system
                $Library = new Library();
                $Library->find();
                if ($Library->N == 1) {
                    $Library->fetch();
                    $library = $Library;
                }
            }
        }
    }
    if (isset($library) && $library != null) {
        //Update the title
        $configArray['Site']['theme'] = $library->themeName . ',' . $configArray['Site']['theme'] . ',default';
        $configArray['Site']['title'] = $library->displayName;
        $location = $locationSingleton->getActiveLocation();
        //Add an extra css file for the location if it exists.
        $themes = explode(',', $library->themeName);
        foreach ($themes as $themeName) {
            if ($location != null && file_exists('./interface/themes/' . $themeName . '/images/' . $location->code . '_logo_responsive.png')) {
                $configArray['Site']['responsiveLogo'] = '/interface/themes/' . $themeName . '/images/' . $location->code . '_logo_responsive.png';
            }
            if ($subdomain != null && file_exists('./interface/themes/' . $themeName . '/images/' . $subdomain . '_logo_responsive.png')) {
                $configArray['Site']['responsiveLogo'] = '/interface/themes/' . $themeName . '/images/' . $subdomain . '_logo_responsive.png';
            }
            if ($location != null && file_exists('./interface/themes/' . $themeName . '/images/' . $location->code . '_logo_small.png')) {
                $configArray['Site']['smallLogo'] = '/interface/themes/' . $themeName . '/images/' . $location->code . '_logo_small.png';
            }
            if ($location != null && file_exists('./interface/themes/' . $themeName . '/images/' . $location->code . '_logo_large.png')) {
                $configArray['Site']['largeLogo'] = '/interface/themes/' . $themeName . '/images/' . $location->code . '_logo_large.png';
            }
        }
    }
    $timer->logTime('finished update config for scoping');
    return $configArray;
}
Esempio n. 15
0
 function getObjectStructure()
 {
     $structure = array('id' => array('property' => 'id', 'type' => 'hidden', 'label' => 'Id', 'primaryKey' => true, 'description' => 'The unique id of the e-pub file.', 'storeDb' => true, 'storeSolr' => false), 'recordtype' => array('property' => 'recordtype', 'type' => 'method', 'methodName' => 'recordtype', 'storeDb' => false, 'storeSolr' => true), 'solrId' => array('property' => 'id', 'type' => 'method', 'methodName' => 'solrId', 'storeDb' => false, 'storeSolr' => true), 'title' => array('property' => 'title', 'type' => 'text', 'size' => 100, 'maxLength' => 255, 'label' => 'Title', 'description' => 'The title of the item.', 'required' => true, 'storeDb' => true, 'storeSolr' => true), 'title_proper' => array('property' => 'title_proper', 'type' => 'method', 'storeDb' => false, 'storeSolr' => true), 'title_sort' => array('property' => 'title_sort', 'type' => 'method', 'storeDb' => false, 'storeSolr' => true), 'format_category' => array('property' => 'format_category', 'type' => 'method', 'storeDb' => false, 'storeSolr' => true), 'format' => array('property' => 'format', 'type' => 'method', 'storeDb' => false, 'storeSolr' => true), 'description' => array('property' => 'description', 'type' => 'textarea', 'label' => 'Description', 'rows' => 3, 'cols' => 80, 'description' => 'A brief description of the file for indexing and display if there is not an existing record within the catalog.', 'required' => false, 'storeDb' => true, 'storeSolr' => true), 'num_titles' => array('property' => 'num_titles', 'type' => 'method', 'storeDb' => false, 'storeSolr' => true), 'num_holdings' => array('property' => 'num_holdings', 'type' => 'method', 'storeDb' => false, 'storeSolr' => true), 'format_boost' => array('property' => 'format_boost', 'type' => 'method', 'storeDb' => false, 'storeSolr' => true), 'language_boost' => array('property' => 'language_boost', 'type' => 'method', 'storeDb' => false, 'storeSolr' => true), 'contents' => array('property' => 'contents', 'type' => 'method', 'required' => false, 'storeDb' => false, 'storeSolr' => true), 'bib_suppression' => array('property' => 'bib_suppression', 'type' => 'method', 'storeDb' => false, 'storeSolr' => true), 'owning_library' => array('property' => 'owning_library', 'type' => 'method', 'methodName' => 'institution', 'storeDb' => false, 'storeSolr' => true), 'owning_location' => array('property' => 'owning_location', 'type' => 'method', 'methodName' => 'building', 'storeDb' => false, 'storeSolr' => true), 'usable_by' => array('property' => 'usable_by', 'type' => 'method', 'methodName' => 'usable_by', 'storeDb' => false, 'storeSolr' => true));
     //Add local formats
     $library = new Library();
     $library->find();
     while ($library->fetch() == true) {
         $structure['format_' . $library->subdomain] = array('property' => 'format_' . $library->subdomain, 'type' => 'method', 'methodName' => 'format', 'storeDb' => false, 'storeSolr' => true);
     }
     $location = new Location();
     $location->find();
     while ($location->fetch() == true) {
         $structure['format_' . $location->code] = array('property' => 'format_' . $location->code, 'type' => 'method', 'methodName' => 'format', 'storeDb' => false, 'storeSolr' => true);
     }
     return $structure;
 }
Esempio n. 16
0
 public function getItemsFast()
 {
     global $configArray;
     if ($this->fastItems == null) {
         $searchLibrary = Library::getSearchLibrary();
         if ($searchLibrary) {
             $libraryLocationCode = $searchLibrary->ilsCode;
         }
         $searchLocation = Location::getSearchLocation();
         if ($searchLocation) {
             $homeLocationCode = $searchLocation->code;
         } else {
             $homeLocation = Location::getUserHomeLocation();
             if ($homeLocation) {
                 $homeLocationCode = $homeLocation->code;
             }
         }
         $this->fastItems = array();
         if ($this->itemsFromIndex) {
             $this->fastItems = array();
             foreach ($this->itemsFromIndex as $itemData) {
                 $isLocalItem = false;
                 $isLibraryItem = false;
                 if (array_key_exists('item', $itemData)) {
                     $itemId = $itemData['item'][0];
                     $locationCode = $itemData['item'][1];
                     $shelfLocation = mapValue('shelf_location', $locationCode);
                     $sharing = $itemData['item'][3];
                     $source = $itemData['item'][4];
                     $fileOrUrl = '';
                     if (count($itemData['item']) > 5) {
                         $fileOrUrl = $itemData['item'][5];
                     }
                     if (array_key_exists('scope', $itemData)) {
                         $isLocalItem = $itemData['scope'][1] == 'true';
                         $isLibraryItem = $itemData['scope'][2] == 'true';
                     }
                 } else {
                     $itemId = $itemData[1];
                     $locationCode = $itemData[2];
                     $shelfLocation = mapValue('shelf_location', $itemData[2]);
                     $sharing = $itemData[4];
                     $source = $itemData[5];
                     $fileOrUrl = '';
                     if (count($itemData) > 6) {
                         $fileOrUrl = $itemData[6];
                     }
                     $isLocalItem = isset($libraryLocationCode) && strlen($libraryLocationCode) > 0 && strpos($locationCode, $libraryLocationCode) === 0;
                     $isLibraryItem = isset($homeLocationCode) && strlen($homeLocationCode) > 0 && strpos($locationCode, $homeLocationCode) === 0;
                 }
                 $actions = $this->getActionsForItem($itemId, $fileOrUrl, null);
                 $libraryLabelObj = new Library();
                 $libraryLabelObj->whereAdd("'{$locationCode}' LIKE CONCAT(ilsCode, '%') and ilsCode <> ''");
                 $libraryLabelObj->selectAdd();
                 $libraryLabelObj->selectAdd('displayName');
                 if ($libraryLabelObj->find(true)) {
                     $libraryLabel = $libraryLabelObj->displayName;
                 } else {
                     $libraryLabel = $locationCode . ' Online';
                 }
                 //TODO: Get the correct number of available copies
                 $totalCopies = 1;
                 $this->fastItems[] = array('itemId' => $itemId, 'location' => $locationCode, 'callnumber' => '', 'availability' => $this->isItemAvailable($itemId, $totalCopies), 'holdable' => $this->isEContentHoldable($locationCode, $itemData), 'inLibraryUseOnly' => false, 'isLocalItem' => $isLocalItem, 'isLibraryItem' => $isLibraryItem, 'locationLabel' => 'Online', 'libraryLabel' => $libraryLabel, 'shelfLocation' => $shelfLocation, 'source' => 'Online ' . $source, 'sharing' => $sharing, 'actions' => $actions);
             }
         } else {
             /** @var File_MARC_Data_Field[] $itemFields */
             $itemFields = $this->getMarcRecord()->getFields('989');
             foreach ($itemFields as $itemField) {
                 $locationCode = trim($itemField->getSubfield('d') != null ? $itemField->getSubfield('d')->getData() : '');
                 //Each item can have multiple item fields
                 /** @var File_MARC_Subfield[] $eContentFields */
                 $eContentFields = $itemField->getSubfields('w');
                 $itemId = $itemField->getSubfield('1')->getData();
                 $iType = $itemField->getSubfield($configArray['Reindex']['iTypeSubfield'])->getData();
                 foreach ($eContentFields as $eContentField) {
                     $eContentData = trim($eContentField->getData() != null ? $eContentField->getData() : '');
                     if ($eContentData && strpos($eContentData, ':') > 0) {
                         $eContentFieldData = explode(':', $eContentData);
                         $source = trim($eContentFieldData[0]);
                         $protectionType = strtolower(trim($eContentFieldData[1]));
                         $totalCopies = 1;
                         if ($this->isValidProtectionType($protectionType)) {
                             if ($this->isValidForUser($locationCode, $eContentFieldData)) {
                                 $libraryLabelObj = new Library();
                                 $libraryLabelObj->whereAdd("'{$locationCode}' LIKE CONCAT(ilsCode, '%') and ilsCode <> ''");
                                 $libraryLabelObj->selectAdd();
                                 $libraryLabelObj->selectAdd('displayName');
                                 if ($libraryLabelObj->find(true)) {
                                     $libraryLabel = $libraryLabelObj->displayName;
                                 } else {
                                     $libraryLabel = $locationCode . ' Online';
                                 }
                                 $locationLabelObj = new Location();
                                 $locationLabelObj->whereAdd("'{$locationCode}' LIKE CONCAT(code, '%') and code <> ''");
                                 if ($locationLabelObj->find(true)) {
                                     $locationLabel = $locationLabelObj->displayName;
                                 } else {
                                     $locationLabel = $locationCode . ' Online';
                                 }
                                 //Get the file or url that is related to this item.
                                 $fileOrUrl = '';
                                 $acsId = null;
                                 if ($protectionType == 'external') {
                                     $urlSubfield = $itemField->getSubfield('u');
                                     if ($urlSubfield != null) {
                                         $fileOrUrl = $urlSubfield->getData();
                                     } else {
                                         //Get from the 856 field
                                         /** @var File_MARC_Data_Field[] $linkFields */
                                         $linkFields = $this->getMarcRecord()->getFields('856');
                                         foreach ($linkFields as $link) {
                                             $urlSubfield = $link->getSubfield('u');
                                             if ($urlSubfield != null) {
                                                 $fileOrUrl = $urlSubfield->getData();
                                             }
                                         }
                                     }
                                 } else {
                                     if (count($eContentFieldData) > 3) {
                                         $fileOrUrl = trim($eContentFieldData[3]);
                                     }
                                     if (count($eContentFieldData) > 4) {
                                         $acsId = trim($eContentFieldData[4]);
                                     }
                                     if (count($eContentFieldData) > 5) {
                                         $totalCopies = trim($eContentFieldData[5]);
                                     }
                                 }
                                 $fileOrUrl = trim($fileOrUrl);
                                 $actions = $this->getActionsForItem($itemId, $fileOrUrl, $acsId);
                                 $format = $this->getEContentFormat($fileOrUrl, $iType);
                                 $sharing = $this->getSharing($locationCode, $eContentFieldData);
                                 //Add an item
                                 $item = array('itemId' => $itemId, 'location' => $locationCode, 'locationLabel' => $locationLabel, 'libraryLabel' => $libraryLabel, 'callnumber' => '', 'availability' => $this->isItemAvailable($itemId, $totalCopies), 'holdable' => $this->isEContentHoldable($locationCode, $eContentFieldData), 'isLocalItem' => $this->isLocalItem($locationCode, $eContentFieldData), 'isLibraryItem' => $this->isLibraryItem($locationCode, $eContentFieldData), 'shelfLocation' => 'Online ' . $source, 'source' => $source, 'sharing' => $sharing, 'fileOrUrl' => $fileOrUrl, 'format' => $format, 'helpText' => $this->getHelpText($fileOrUrl), 'usageNotes' => $this->getUsageRestrictions($sharing, $libraryLabel, $locationLabel), 'formatNotes' => $this->getFormatNotes($fileOrUrl), 'size' => $this->getFileSize($fileOrUrl), 'actions' => $actions);
                                 $this->fastItems[] = $item;
                             }
                         }
                     }
                 }
             }
         }
     }
     return $this->fastItems;
 }
Esempio n. 17
0
 static function getLibraryForLocation($locationId)
 {
     if (isset($locationId)) {
         $libLookup = new Library();
         require_once ROOT_DIR . '/Drivers/marmot_inc/Location.php';
         $libLookup->whereAdd('libraryId = (SELECT libraryId FROM location WHERE locationId = ' . $libLookup->escape($locationId) . ')');
         $libLookup->find();
         if ($libLookup->N > 0) {
             $libLookup->fetch();
             return clone $libLookup;
         }
     }
     return null;
 }
Esempio n. 18
0
 function getPickupBranches($patronProfile, $selectedBranchId)
 {
     //Get the library for the patron's home branch.
     /** @var Library $librarySingleton */
     global $librarySingleton;
     if ($patronProfile) {
         if (is_object($patronProfile)) {
             $patronProfile = get_object_vars($patronProfile);
         }
     }
     $homeLibrary = $librarySingleton->getLibraryForLocation($patronProfile['homeLocationId']);
     if (isset($homeLibrary) && $homeLibrary->inSystemPickupsOnly == 1) {
         if (strlen($homeLibrary->validPickupSystems) > 0) {
             $pickupIds = array();
             $pickupIds[] = $homeLibrary->libraryId;
             $validPickupSystems = explode('|', $homeLibrary->validPickupSystems);
             foreach ($validPickupSystems as $pickupSystem) {
                 $pickupLocation = new Library();
                 $pickupLocation->subdomain = $pickupSystem;
                 $pickupLocation->find();
                 if ($pickupLocation->N == 1) {
                     $pickupLocation->fetch();
                     $pickupIds[] = $pickupLocation->libraryId;
                 }
             }
             $this->whereAdd("libraryId IN (" . implode(',', $pickupIds) . ")", 'AND');
             //Deal with Steamboat Springs Juvenile which is a special case.
             $this->whereAdd("code <> 'ssjuv'", 'AND');
         } else {
             $this->whereAdd("libraryId = {$homeLibrary->libraryId}", 'AND');
             $this->whereAdd("validHoldPickupBranch = 1", 'AND');
             //$this->whereAdd("locationId = {$patronProfile['homeLocationId']}", 'OR');
         }
     } else {
         $this->whereAdd("validHoldPickupBranch = 1");
     }
     /*if (isset($selectedBranchId) && is_numeric($selectedBranchId)){
     			$this->whereAdd("locationId = $selectedBranchId", 'OR');
     		}*/
     $this->orderBy('displayName');
     $this->find();
     //Load the locations and sort them based on the user profile information as well as their physical location.
     $physicalLocation = $this->getPhysicalLocation();
     $locationList = array();
     while ($this->fetch()) {
         if ($this->locationId == $selectedBranchId) {
             $selected = 'selected';
         } else {
             $selected = '';
         }
         $this->selected = $selected;
         if (isset($physicalLocation) && $physicalLocation->locationId == $this->locationId) {
             //If the user is in a branch, those holdings come first.
             $locationList['1' . $this->displayName] = clone $this;
         } else {
             if ($this->locationId == $patronProfile['homeLocationId']) {
                 //Next come the user's home branch if the user is logged in or has the home_branch cookie set.
                 $locationList['2' . $this->displayName] = clone $this;
             } else {
                 if (isset($patronProfile['myLocation1Id']) && $this->locationId == $patronProfile['myLocation1Id']) {
                     //Next come nearby locations for the user
                     $locationList['3' . $this->displayName] = clone $this;
                 } else {
                     if (isset($patronProfile['myLocation2Id']) && $this->locationId == $patronProfile['myLocation2Id']) {
                         //Next come nearby locations for the user
                         $locationList['4' . $this->displayName] = clone $this;
                     } else {
                         if (isset($homeLibrary) && $this->libraryId == $homeLibrary->libraryId) {
                             //Other locations that are within the same library system
                             $locationList['5' . $this->displayName] = clone $this;
                         } else {
                             //Finally, all other locations are shown sorted alphabetically.
                             $locationList['6' . $this->displayName] = clone $this;
                         }
                     }
                 }
             }
         }
     }
     ksort($locationList);
     return $locationList;
 }
Esempio n. 19
0
 function getUsageNotes()
 {
     $notes = '';
     if ($this->libraryId != -1) {
         $library = new Library();
         $library->libraryId = $this->libraryId;
         if ($library->find(true)) {
             $notes = "Available to <b>{$library->displayName} patrons</b> only.";
         } else {
             $notes = "Could not load library information.";
         }
     }
     return $notes;
 }
Esempio n. 20
0
 public function getLibraryName()
 {
     if ($this->libraryId == -1) {
         return 'All libraries';
     } else {
         $library = new Library();
         $library->libraryId = $this->libraryId;
         $library->find(true);
         return $library->displayName;
     }
 }
<?php

include_once 'bootstrap.php';
global $logger;
global $configArray;
require_once ROOT_DIR . '/Drivers/marmot_inc/Library.php';
$library = new Library();
$library->find();
ob_start();
echo "<br>Starting to build indexes\r\n";
$logger->log('Starting to alpha browse indexes', PEAR_LOG_INFO);
ob_flush();
set_time_limit(300);
$ret = mysql_query('set @r=0; UPDATE author_browse SET alphaRank = @r:=(@r + 1) ORDER BY `sortValue`;');
$logger->log('Updated Alpha Rank for Author browse index ret = ' . $ret, PEAR_LOG_INFO);
mysql_query('TRUNCATE author_browse_metadata;');
mysql_query('INSERT INTO author_browse_metadata (SELECT 0, -1, MIN(alphaRank) as minAlphaRank, MAX(alphaRank) as maxAlphaRank, count(id) as numResults FROM author_browse inner join author_browse_scoped_results_global ON id = browseValueId where alphaRank > 0)');
echo "<br>Built Author browse index\r\n";
$logger->log('Built Author browse index ret = ' . $ret, PEAR_LOG_INFO);
ob_flush();
set_time_limit(300);
mysql_query('set @r=0; UPDATE title_browse SET alphaRank = @r:=(@r + 1) ORDER BY `sortValue`;');
$logger->log('Updated Alpha Rank for Title browse index', PEAR_LOG_INFO);
mysql_query('TRUNCATE title_browse_metadata;');
mysql_query('INSERT INTO title_browse_metadata (SELECT 0, -1, MIN(alphaRank) as minAlphaRank, MAX(alphaRank) as maxAlphaRank, count(id) as numResults FROM title_browse inner join title_browse_scoped_results_global ON id = browseValueId where alphaRank > 0)');
echo "<br>Built Title browse index\r\n";
$logger->log('Built Title browse index', PEAR_LOG_INFO);
ob_flush();
set_time_limit(300);
mysql_query('set @r=0; UPDATE subject_browse SET alphaRank = @r:=(@r + 1) ORDER BY `sortValue`;');
$logger->log('Updated Alpha Rank for Subject browse index', PEAR_LOG_INFO);
Esempio n. 22
0
 function removeScopingTableIndex(&$update)
 {
     $this->runSQLStatement($update, "TRUNCATE TABLE title_browse_scoped_results_global");
     $this->runSQLStatement($update, "ALTER TABLE `title_browse_scoped_results_global` DROP INDEX `record`");
     $this->runSQLStatement($update, "ALTER TABLE `title_browse_scoped_results_global` ENGINE = MYISAM");
     $this->runSQLStatement($update, "TRUNCATE TABLE author_browse_scoped_results_global");
     $this->runSQLStatement($update, "ALTER TABLE `author_browse_scoped_results_global` DROP INDEX `record`");
     $this->runSQLStatement($update, "ALTER TABLE `author_browse_scoped_results_global` ENGINE = MYISAM");
     $this->runSQLStatement($update, "TRUNCATE TABLE subject_browse_scoped_results_global");
     $this->runSQLStatement($update, "ALTER TABLE `subject_browse_scoped_results_global` DROP INDEX `record`");
     $this->runSQLStatement($update, "ALTER TABLE `subject_browse_scoped_results_global` ENGINE = MYISAM");
     $this->runSQLStatement($update, "TRUNCATE TABLE callnumber_browse_scoped_results_global");
     $this->runSQLStatement($update, "ALTER TABLE `callnumber_browse_scoped_results_global` DROP INDEX `record`");
     $this->runSQLStatement($update, "ALTER TABLE `callnumber_browse_scoped_results_global` ENGINE = MYISAM");
     $library = new Library();
     $library->find();
     while ($library->fetch()) {
         $this->runSQLStatement($update, "TRUNCATE TABLE `title_browse_scoped_results_library_{$library->subdomain}`");
         $this->runSQLStatement($update, "ALTER TABLE `title_browse_scoped_results_library_{$library->subdomain}` DROP INDEX `record`");
         $this->runSQLStatement($update, "ALTER TABLE `title_browse_scoped_results_library_{$library->subdomain}` ENGINE = MYISAM");
         $this->runSQLStatement($update, "TRUNCATE TABLE `author_browse_scoped_results_library_{$library->subdomain}`");
         $this->runSQLStatement($update, "ALTER TABLE `author_browse_scoped_results_library_{$library->subdomain}` DROP INDEX `record`");
         $this->runSQLStatement($update, "ALTER TABLE `author_browse_scoped_results_library_{$library->subdomain}` ENGINE = MYISAM");
         $this->runSQLStatement($update, "TRUNCATE TABLE `subject_browse_scoped_results_library_{$library->subdomain}`");
         $this->runSQLStatement($update, "ALTER TABLE `subject_browse_scoped_results_library_{$library->subdomain}` DROP INDEX `record`");
         $this->runSQLStatement($update, "ALTER TABLE `subject_browse_scoped_results_library_{$library->subdomain}` ENGINE = MYISAM");
         $this->runSQLStatement($update, "TRUNCATE TABLE `callnumber_browse_scoped_results_library_{$library->subdomain}`");
         $this->runSQLStatement($update, "ALTER TABLE `callnumber_browse_scoped_results_library_{$library->subdomain}` DROP INDEX `record`");
         $this->runSQLStatement($update, "ALTER TABLE `callnumber_browse_scoped_results_library_{$library->subdomain}` ENGINE = MYISAM");
     }
 }
Esempio n. 23
0
 function getAvailability()
 {
     global $configArray;
     if ($this->availability == null) {
         $this->availability = array();
         require_once ROOT_DIR . '/sys/eContent/EContentAvailability.php';
         $eContentAvailability = new EContentAvailability();
         $eContentAvailability->recordId = $this->id;
         $eContentAvailability->find();
         while ($eContentAvailability->fetch()) {
             $this->availability[] = clone $eContentAvailability;
         }
         if (strcasecmp($this->source, "OverDrive") == 0) {
             require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
             $driver = OverDriveDriverFactory::getDriver();
             //echo("Loading availability from overdrive, part of " . count($this->availability) . " collections");
             foreach ($this->availability as $key => $tmpAvailability) {
                 //echo("\r\n{$tmpAvailability->libraryId}");
                 //Get updated availability for each library from overdrive
                 $productKey = $configArray['OverDrive']['productsKey'];
                 if ($tmpAvailability->libraryId != -1) {
                     $library = new Library();
                     $library->libraryId = $tmpAvailability->libraryId;
                     $library->find(true);
                     $productKey = $library->overdriveAdvantageProductsKey;
                 }
                 $realtimeAvailability = $driver->getProductAvailability($this->externalId, $productKey);
                 $tmpAvailability->copiesOwned = $realtimeAvailability->copiesOwned;
                 $tmpAvailability->availableCopies = $realtimeAvailability->copiesAvailable;
                 $tmpAvailability->numberOfHolds = $realtimeAvailability->numberOfHolds;
                 $this->availability[$key] = $tmpAvailability;
             }
         }
         if (count($this->availability) == 0) {
             //Did not get availability from the Availability table
             if ($this->itemLevelOwnership) {
                 //Ownership is determined at the item level based on library ids set for the item.  Assume unlimited availability
                 $items = $this->getItems();
                 foreach ($items as $item) {
                     $eContentAvailability = new EContentAvailability();
                     $eContentAvailability->recordId = $this->id;
                     $eContentAvailability->copiesOwned = 1;
                     $eContentAvailability->availableCopies = 1;
                     $eContentAvailability->numberOfHolds = 0;
                     $eContentAvailability->libraryId = $item->libraryId;
                     $this->availability[] = $eContentAvailability;
                 }
             } else {
                 //Ownership is shared, based on information at record level
                 $eContentAvailability = new EContentAvailability();
                 $eContentAvailability->recordId = $this->id;
                 $eContentAvailability->copiesOwned = $this->availableCopies;
                 $checkouts = new EContentCheckout();
                 $checkouts->status = 'out';
                 $checkouts->recordId = $this->id;
                 $checkouts->find();
                 $curCheckouts = $checkouts->N;
                 if ($this->accessType == 'free') {
                     $this->availableCopies = 999999;
                 }
                 $eContentAvailability->availableCopies = $this->availableCopies - $curCheckouts;
                 $eContentAvailability->copiesOwned = $this->availableCopies;
                 $holds = new EContentHold();
                 $holds->whereAdd("status in ('active', 'suspended', 'available')");
                 $holds->recordId = $this->id;
                 $holds->find();
                 $eContentAvailability->numberOfHolds = $holds->N;
                 $eContentAvailability->onOrderCopies = $this->onOrderCopies;
                 $eContentAvailability->libraryId = -1;
             }
         }
     }
     return $this->availability;
 }
Esempio n. 24
0
 /**
  * Retrieve details about a record within prospector
  *
  * @param $record - The full record information from Prospector
  * @return Associative array with the record number in prospector and the list of libraries that own the title in prospector
  */
 function getProspectorDetailsForLocalRecord($record)
 {
     //Disable prospector details for now.
     return false;
     global $logger;
     //Check to see if one of our libraries has a copy in Prospector.
     $shortId = substr($record['id'], 1, -1);
     $library = new Library();
     $institutions = '';
     foreach ($record['institution'] as $institution) {
         if (strlen($institutions) > 0) {
             $institutions .= ', ';
         }
         $institutions .= "'" . mysql_escape_string($institution) . "'";
     }
     $library->whereAdd("facetLabel IN ({$institutions})");
     $library->whereAdd("prospectorCode != ''");
     $library->find();
     $results = array('recordId' => '', 'title' => $record['title'], 'author' => isset($record['author']) ? $record['author'] : null, 'numLibraries' => 0, 'owningLibraries' => array(), 'prospectorClassicUrl' => '', 'prospectorEncoreUrl' => '');
     if ($library->N > 0) {
         while ($library->fetch()) {
             $prospectorCode = $library->prospectorCode;
             //Call the url for the record using a local call number search
             $curl_url = "http://prospector.coalliance.org/search~S0?/z{$prospectorCode}+{$shortId}/z{$prospectorCode}+{$shortId}/1,1,1,B/detlframeset&FF=z{$prospectorCode}+{$shortId}";
             $cookieJar = tempnam("/tmp", "CURLCOOKIE");
             $logger->log('Loading page ' . $curl_url, PEAR_LOG_INFO);
             $curl_connection = curl_init($curl_url);
             curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
             curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
             curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
             curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
             curl_setopt($curl_connection, CURLOPT_UNRESTRICTED_AUTH, true);
             curl_setopt($curl_connection, CURLOPT_COOKIEJAR, $cookieJar);
             curl_setopt($curl_connection, CURLOPT_COOKIESESSION, false);
             $sresult = curl_exec($curl_connection);
             //We are getting bad results from Prospector from some local call number searches
             if (preg_match('/Prehistoric Europe, from stone age man to the early Greeks/', $sresult)) {
                 continue;
             }
             //Parse the page to extract the owning libraries and the record id
             //Record Id can be extracted from the save link
             if (preg_match('/save=(.*?)"/s', $sresult, $matches)) {
                 $results['recordId'] = $matches[1];
             }
             //Owning libraries can be extracted with this regex
             $libraries = array();
             if (preg_match_all('/<tr class="holdings(.*?)"><td><a name="(.*?)"><\\/a>(.*?)<\\/td>/s', $sresult, $matches)) {
                 foreach ($matches[1] as $index => $libraryCode) {
                     $libraries[$libraryCode] = $matches[3][$index];
                 }
             } else {
                 $fineInfo = "";
             }
             $results['numLibraries'] = count($libraries);
             $results['owningLibraries'] = $libraries;
             $prospectorUrl = "http://prospector.coalliance.org/search~S0/.{$results['recordId']}/.{$results['recordId']}/1,1,1,B/frameset~.{$results['recordId']}";
             $results['prospectorClassicUrl'] = $prospectorUrl;
             $prospectorUrl = "http://encore.coalliance.org/iii/encore/record/C__R" . urlencode($results['recordId']) . "?lang=eng&amp;suite=def";
             $results['prospectorEncoreUrl'] = $prospectorUrl;
             $requestUrl = "http://encore.coalliance.org/iii/encore/InnreachRequestPage.external?lang=eng&sp=S" . urlencode($results['recordId']) . "&suite=def";
             $results['requestUrl'] = $requestUrl;
             break;
         }
     }
     return $results;
 }