Ejemplo n.º 1
0
 function launch()
 {
     global $interface;
     global $configArray;
     $rating = $_REQUEST['rating'];
     $interface->assign('rating', $rating);
     $id = $_REQUEST['id'];
     // Check if user is logged in
     if (!$this->user) {
         // Needed for "back to record" link in view-alt.tpl:
         $interface->assign('id', $id);
         //Display the login form
         $login = $interface->fetch('Record/ajax-rate-login.tpl');
         header('Content-type: text/plain');
         header('Cache-Control: no-cache, must-revalidate');
         // HTTP/1.1
         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
         echo json_encode(array('result' => 'true', 'loginForm' => $login));
         exit;
     }
     if (isset($_GET['submit'])) {
         global $user;
         //Save the rating
         $resource = new Resource();
         $resource->record_id = $id;
         $resource->source = 'VuFind';
         if (!$resource->find(true)) {
             $resource->insert();
         }
         $resource->addRating($rating, $user);
         return json_encode(array('result' => 'true', 'rating' => $rating));
     }
 }
Ejemplo n.º 2
0
 function clearUserRating()
 {
     global $user;
     $source = $_REQUEST['source'];
     $recordId = $_REQUEST['recordId'];
     $result = array('result' => false);
     if ($source == 'VuFind') {
         require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php';
         $resource = new Resource();
         $resource->record_id = $recordId;
         $resource->source = 'VuFind';
         if ($resource->find(true)) {
             $rating = new UserRating();
             $rating->userid = $user->id;
             $rating->resourceid = $resource->id;
             if ($rating->find(true)) {
                 if ($rating->delete()) {
                     $result = array('result' => true, 'message' => 'deleted user rating for resource ' . $rating->resourceid);
                 }
             }
         }
     } else {
         require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
         $econtentRating = new EContentRating();
         $econtentRating->userId = $user->id;
         $econtentRating->recordId = $recordId;
         if ($econtentRating->find(true)) {
             if ($econtentRating->delete()) {
                 $result = array('result' => true);
             }
         }
     }
     return json_encode($result);
 }
Ejemplo n.º 3
0
 public function launch()
 {
     global $interface;
     global $user;
     //Load user ratings
     require_once ROOT_DIR . '/Drivers/marmot_inc/UserRating.php';
     $rating = new UserRating();
     $resource = new Resource();
     $rating->joinAdd($resource);
     $rating->userid = $user->id;
     $rating->find();
     $ratings = array();
     while ($rating->fetch()) {
         if ($rating->deleted == 0) {
             $ratings[] = array('id' => $rating->id, 'title' => $rating->title, 'author' => $rating->author, 'format' => $rating->format, 'rating' => $rating->rating, 'resourceId' => $rating->resourceid, 'fullId' => $rating->record_id, 'shortId' => $rating->shortId, 'link' => '/Record/' . $rating->record_id . '/Home', 'dateRated' => $rating->dateRated, 'ratingData' => array('user' => $rating->rating), 'source' => 'VuFind');
         }
     }
     //Load econtent ratings
     require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
     $eContentRating = new EContentRating();
     $econtentRecord = new EContentRecord();
     $eContentRating->joinAdd($econtentRecord);
     $eContentRating->userId = $user->id;
     $eContentRating->find();
     while ($eContentRating->fetch()) {
         if ($eContentRating->status == 'active') {
             $resource = new Resource();
             $resource->record_id = $eContentRating->id;
             $resource->source = 'eContent';
             $resource->find(true);
             $ratings[] = array('id' => $eContentRating->id, 'title' => $eContentRating->title, 'author' => $eContentRating->author, 'format' => $resource->format_category, 'rating' => $eContentRating->rating, 'fullId' => $eContentRating->id, 'shortId' => $eContentRating->id, 'link' => '/EcontentRecord/' . $eContentRating->id . '/Home', 'dateRated' => $eContentRating->dateRated, 'ratingData' => array('user' => $eContentRating->rating), 'source' => 'eContent');
         }
     }
     asort($ratings);
     //Load titles the user is not interested in
     $notInterested = array();
     $notInterestedObj = new NotInterested();
     $resource = new Resource();
     $notInterestedObj->joinAdd($resource);
     $notInterestedObj->userId = $user->id;
     $notInterestedObj->deleted = 0;
     $notInterestedObj->selectAdd('user_not_interested.id as user_not_interested_id');
     $notInterestedObj->find();
     while ($notInterestedObj->fetch()) {
         if ($notInterestedObj->source == 'VuFind') {
             $link = '/Record/' . $notInterestedObj->record_id;
         } else {
             $link = '/EcontentRecord/' . $notInterestedObj->record_id;
         }
         if ($notInterestedObj->deleted == 0) {
             $notInterested[] = array('id' => $notInterestedObj->user_not_interested_id, 'title' => $notInterestedObj->title, 'author' => $notInterestedObj->author, 'dateMarked' => $notInterestedObj->dateMarked, 'link' => $link);
         }
     }
     $interface->assign('ratings', $ratings);
     $interface->assign('notInterested', $notInterested);
     $interface->setPageTitle('My Ratings');
     $interface->setTemplate('myRatings.tpl');
     $interface->display('layout.tpl');
 }
Ejemplo n.º 4
0
 /**
  * Retrieves a document specified by the ID.
  *
  * @param string $id The document to retrieve from the MetaLib API/cache
  *
  * @throws object    PEAR Error
  * @return string    The requested resource
  * @access public
  */
 public function getRecord($id)
 {
     if ($this->debug) {
         echo "<pre>Get Record: {$id}</pre>\n";
     }
     list($queryId, $index) = explode('_', $id);
     $result = $this->getCachedResults($queryId);
     if ($result === false) {
         // Check from database, this could be in a favorite list
         $resource = new Resource();
         $resource->record_id = $id;
         $resource->source = 'MetaLib';
         if ($resource->find(true) && $resource->data !== null) {
             $data = unserialize($resource->data);
             if ($data !== null) {
                 return $data;
             }
         }
         PEAR::raiseError(new PEAR_Error('Record not found'));
     }
     if ($index < 1 || $index > count($result['documents'])) {
         PEAR::raiseError(new PEAR_Error('Invalid record id'));
     }
     $result['documents'] = array_slice($result['documents'], $index - 1, 1);
     return $result['documents'][0];
 }
Ejemplo n.º 5
0
 function MarkNotInterested()
 {
     global $user;
     $recordId = $_REQUEST['recordId'];
     $source = $_REQUEST['source'];
     require_once ROOT_DIR . '/sys/NotInterested.php';
     $notInterested = new NotInterested();
     $notInterested->userId = $user->id;
     require_once ROOT_DIR . '/services/MyResearch/lib/Resource.php';
     $resource = new Resource();
     $resource->source = $source;
     $resource->record_id = $recordId;
     if ($resource->find(true)) {
         $notInterested->resourceId = $resource->id;
         if (!$notInterested->find(true)) {
             $notInterested->dateMarked = time();
             $notInterested->insert();
             $result = array('result' => true);
         } else {
             $result = array('result' => false, 'message' => "This record was already marked as something you aren't interested in.");
         }
     } else {
         $result = array('result' => false, 'message' => 'Unable to find the resource specified.');
     }
     return json_encode($result);
 }
Ejemplo n.º 6
0
 public function returnRecordInReadingHistory($eContentRecord, $user)
 {
     //Get the resource for the record
     $resource = new Resource();
     $resource->record_id = $eContentRecord->id;
     $resource->source = 'eContent';
     if ($resource->find(true)) {
         //Check to see if there is an existing entry
         require_once ROOT_DIR . '/sys/ReadingHistoryEntry.php';
         $readingHistoryEntry = new ReadingHistoryEntry();
         $readingHistoryEntry->userId = $user->id;
         $readingHistoryEntry->resourceId = $resource->id;
         if ($readingHistoryEntry->find(true)) {
             $readingHistoryEntry->lastCheckoutDate = date('Y-m-d');
             $ret = $readingHistoryEntry->update();
         }
     }
 }
 public function remove_photos($resourceId, $photoId)
 {
     $resource = Resource::find($resourceId);
     $resource->photos()->detach($photoId);
     return Redirect::to('resources/' . $resourceId)->with('success', "Successfully removed photos from {$resource->name}");
 }
Ejemplo n.º 8
0
 function getOtherEditions()
 {
     global $interface;
     global $analytics;
     $id = $_REQUEST['id'];
     $isEContent = $_REQUEST['isEContent'];
     if ($isEContent == 'true') {
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $econtentRecord = new EContentRecord();
         $econtentRecord->id = $id;
         if ($econtentRecord->find(true)) {
             $otherEditions = OtherEditionHandler::getEditions($econtentRecord->id, $econtentRecord->getIsbn(), $econtentRecord->getIssn(), 10);
         } else {
             $error = "Sorry we couldn't find that record in the catalog.";
         }
     } else {
         $resource = new Resource();
         $resource->record_id = $id;
         $resource->source = 'VuFind';
         $solrId = $id;
         if ($resource->find(true)) {
             $otherEditions = OtherEditionHandler::getEditions($solrId, $resource->isbn, null, 10);
         } else {
             $error = "Sorry we couldn't find that record in the catalog.";
         }
     }
     if (isset($otherEditions)) {
         //Get resource for each edition
         $editionResources = array();
         if (is_array($otherEditions)) {
             foreach ($otherEditions as $edition) {
                 /** @var Resource $editionResource */
                 $editionResource = new Resource();
                 if (preg_match('/econtentRecord(\\d+)/', $edition['id'], $matches)) {
                     $editionResource->source = 'eContent';
                     $editionResource->record_id = trim($matches[1]);
                 } else {
                     $editionResource->record_id = $edition['id'];
                     $editionResource->source = 'VuFind';
                 }
                 if ($editionResource->find(true)) {
                     $editionResources[] = $editionResource;
                 } else {
                     $logger = new Logger();
                     $logger->log("Could not find resource {$editionResource->source} {$editionResource->record_id} - {$edition['id']}", PEAR_LOG_DEBUG);
                 }
             }
             $analytics->addEvent('Enrichment', 'Other Editions', count($otherEditions));
         } else {
             $analytics->addEvent('Enrichment', 'Other Editions Error');
         }
         $interface->assign('otherEditions', $editionResources);
         $interface->assign('popupTitle', 'Other Editions');
         $interface->assign('popupTemplate', 'Resource/otherEditions.tpl');
         echo $interface->fetch('popup-wrapper.tpl');
     } elseif (isset($error)) {
         $analytics->addEvent('Enrichment', 'Other Editions Error', $error);
         echo $error;
     } else {
         echo "There are no other editions for this title currently in the catalog.";
         $analytics->addEvent('Enrichment', 'Other Editions', 0, 'No Other ISBNs');
     }
 }
Ejemplo n.º 9
0
 /**
  * Add titles to a user list.
  *
  * Parameters:
  * <ul>
  * <li>username - The barcode of the user.  Can be truncated to the last 7 or 9 digits.</li>
  * <li>password - The pin number for the user. </li>
  * <li>listId   - The id of the list to add items to.</li>
  * <li>recordIds - The id of the record(s) to add to the list.</li>
  * <li>tags   - A comma separated string of tags to apply to the titles within the list. (optional)</li>
  * <li>notes  - descriptive text to apply to the titles.  Can be viewed while on the list.  (optional)</li>
  * </ul>
  *
  * Note: You may also provide the parameters to addTitlesToList and titles will be added to the list
  * after the list is created.
  *
  * Returns:
  * <ul>
  * <li>success - true if the account is valid and the titles could be added to the list, false if the username or password were incorrect or the list could not be created.</li>
  * <li>listId - the id of the list that titles were added to.</li>
  * <li>numAdded - the number of titles that were added to the list.</li>
  * </ul>
  *
  * Sample Call:
  * <code>
  * http://catalog.douglascountylibraries.org/API/ListAPI?method=createList&username=23025003575917&password=1234&title=Test+List&description=Test&public=0
  * </code>
  *
  * Sample Response:
  * <code>
  * {"result":{"success":true,"listId":"1688"}}
  * </code>
  */
 function addTitlesToList()
 {
     $username = $_REQUEST['username'];
     $password = $_REQUEST['password'];
     if (!isset($_REQUEST['listId'])) {
         return array('success' => false, 'message' => 'You must provide the listId to add titles to.');
     }
     $recordIds = array();
     if (!isset($_REQUEST['recordIds'])) {
         return array('success' => false, 'message' => 'You must provide one or more records to add tot he list.');
     } else {
         if (!is_array($_REQUEST['recordIds'])) {
             $recordIds[] = $_REQUEST['recordIds'];
         } else {
             $recordIds = $_REQUEST['recordIds'];
         }
     }
     global $user;
     $user = UserAccount::validateAccount($username, $password);
     if ($user && !PEAR_Singleton::isError($user)) {
         $list = new User_list();
         $list->id = $_REQUEST['listId'];
         $list->user_id = $user->id;
         if (!$list->find(true)) {
             return array('success' => false, 'message' => 'Unable to find the list to add titles to.');
         } else {
             $recordIds = $_REQUEST['recordIds'];
             $numAdded = 0;
             foreach ($recordIds as $id) {
                 $source = 'VuFind';
                 if (preg_match('/econtentRecord\\d+/i', $id)) {
                     $id = substr($id, 14);
                     $source = 'eContent';
                 }
                 $resource = new Resource();
                 $resource->record_id = $id;
                 $resource->source = $source;
                 if (!$resource->find(true)) {
                     $resource->insert();
                 }
                 if (isset($_REQUEST['tags'])) {
                     preg_match_all('/"[^"]*"|[^,]+/', $_REQUEST['tags'], $tagArray);
                     $tags = $tagArray[0];
                 } else {
                     $tags = array();
                 }
                 if (isset($_REQUEST['notes'])) {
                     $notes = $_REQUEST['notes'];
                 } else {
                     $notes = '';
                 }
                 if ($user->addResource($resource, $list, $tags, $notes)) {
                     $numAdded++;
                 }
             }
             return array('success' => true, 'listId' => $list->id, 'numAdded' => $numAdded);
         }
     } else {
         return array('success' => false, 'message' => 'Login unsuccessful');
     }
 }
Ejemplo n.º 10
0
 function saveRecord()
 {
     if ($this->user) {
         $list = new User_list();
         if ($_GET['list'] != '') {
             $list->id = $_GET['list'];
             $list->find(true);
         } else {
             $list->user_id = $this->user->id;
             $list->title = "My Favorites";
             $list->insert();
         }
         $resource = new Resource();
         $resource->record_id = $_GET['id'];
         if (isset($_GET['service'])) {
             $resource->source = $_GET['service'];
         } else {
             $resource->source = $_GET['source'];
         }
         if (!$resource->find(true)) {
             PEAR_Singleton::raiseError(new PEAR_Error('Unable find a resource for that title.'));
         }
         preg_match_all('/"[^"]*"|[^,]+/', $_GET['mytags'], $tagArray);
         $this->user->addResource($resource, $list, $tagArray[0], $_GET['notes']);
     } else {
         return false;
     }
 }
Ejemplo n.º 11
0
 function launch()
 {
     global $interface;
     global $timer;
     global $configArray;
     global $user;
     // Load Supplemental Information
     Record_UserComments::loadComments();
     $timer->logTime('Loaded Comments');
     Record_Cite::loadCitation();
     $timer->logTime('Loaded Citations');
     if (isset($_REQUEST['id'])) {
         $recordId = $_REQUEST['id'];
     }
     if (isset($_REQUEST['strandsReqId']) && isset($configArray['Strands']['APID'])) {
         $url = "http://bizsolutions.strands.com/api2/event/clickedrecommendation.sbs?apid={$configArray['Strands']['APID']}&item={$recordId}&user={$user->id}&rrq={$_REQUEST['strandsReqId']}&tpl={$_REQUEST['strandsTpl']}";
         $response = file_get_contents($url);
     }
     if (isset($_REQUEST['searchId'])) {
         $_SESSION['searchId'] = $_REQUEST['searchId'];
         $interface->assign('searchId', $_SESSION['searchId']);
     } else {
         if (isset($_SESSION['searchId'])) {
             $interface->assign('searchId', $_SESSION['searchId']);
         }
     }
     //Load the Editorial Reviews
     //Populate an array of editorialReviewIds that match up with the recordId
     $editorialReview = new EditorialReview();
     $editorialReviewResults = array();
     $editorialReview->recordId = $recordId;
     $editorialReview->find();
     $editorialReviewResults['reviews'] = array('tabName' => 'Reviews', 'reviews' => array());
     if ($editorialReview->N > 0) {
         $ctr = 0;
         while ($editorialReview->fetch()) {
             $reviewKey = preg_replace('/\\W/', '_', strtolower($editorialReview->tabName));
             if (!array_key_exists($reviewKey, $editorialReviewResults)) {
                 $editorialReviewResults[$reviewKey] = array('tabName' => $editorialReview->tabName, 'reviews' => array());
             }
             $editorialReviewResults[$reviewKey]['reviews'][$ctr++] = get_object_vars($editorialReview);
         }
     }
     $interface->assign('editorialReviews', $editorialReviewResults);
     $interface->assign('recordId', $recordId);
     //Enable and disable functionality based on library settings
     global $library;
     global $locationSingleton;
     $location = $locationSingleton->getActiveLocation();
     if (isset($library)) {
         $interface->assign('showTextThis', $library->showTextThis);
         $interface->assign('showEmailThis', $library->showEmailThis);
         $interface->assign('showFavorites', $library->showFavorites);
         $interface->assign('linkToAmazon', $library->linkToAmazon);
         $interface->assign('enablePurchaseLinks', $library->linkToAmazon);
         $interface->assign('enablePospectorIntegration', $library->enablePospectorIntegration);
         if ($location != null) {
             $interface->assign('showAmazonReviews', $location->showAmazonReviews == 1 && $library->showAmazonReviews == 1 ? 1 : 0);
             $interface->assign('showStandardReviews', $location->showStandardReviews == 1 && $library->showStandardReviews == 1 ? 1 : 0);
             $interface->assign('showHoldButton', $location->showHoldButton == 1 && $library->showHoldButton == 1 ? 1 : 0);
         } else {
             $interface->assign('showAmazonReviews', $library->showAmazonReviews);
             $interface->assign('showStandardReviews', $library->showStandardReviews);
             $interface->assign('showHoldButton', $library->showHoldButton);
         }
         $interface->assign('showTagging', $library->showTagging);
         $interface->assign('showRatings', $library->showRatings);
         $interface->assign('showComments', $library->showComments);
         $interface->assign('tabbedDetails', $library->tabbedDetails);
         $interface->assign('showSeriesAsTab', $library->showSeriesAsTab);
         $interface->assign('showOtherEditionsPopup', 0);
         $interface->assign('show856LinksAsTab', $library->show856LinksAsTab);
         $interface->assign('showProspectorTitlesAsTab', $library->showProspectorTitlesAsTab);
     } else {
         $interface->assign('showTextThis', 1);
         $interface->assign('showEmailThis', 1);
         $interface->assign('showFavorites', 1);
         $interface->assign('linkToAmazon', 1);
         $interface->assign('enablePospectorIntegration', isset($configArray['Content']['Prospector']) && $configArray['Content']['Prospector'] == true ? 1 : 0);
         $interface->assign('enablePurchaseLinks', 1);
         if ($location != null) {
             $interface->assign('showAmazonReviews', $location->showAmazonReviews);
             $interface->assign('showStandardReviews', $location->showStandardReviews);
             $interface->assign('showHoldButton', $location->showHoldButton);
         } else {
             $interface->assign('showAmazonReviews', 1);
             $interface->assign('showStandardReviews', 1);
             $interface->assign('showHoldButton', 1);
         }
         $interface->assign('showTagging', 1);
         $interface->assign('showRatings', 1);
         $interface->assign('showComments', 1);
         $interface->assign('tabbedDetails', !isset($configArray['Content']['tabbedDetails']) || $configArray['Content']['tabbedDetails'] == false ? 0 : 1);
         $interface->assign('showSeriesAsTab', 0);
         $interface->assign('showOtherEditionsPopup', 0);
         $interface->assign('show856LinksAsTab', 1);
         $interface->assign('showProspectorTitlesAsTab', 0);
     }
     if (!isset($this->isbn)) {
         $interface->assign('showOtherEditionsPopup', false);
     }
     $resource = new Resource();
     $resource->record_id = $this->id;
     $resource->source = 'VuFind';
     $solrId = $this->id;
     if ($resource->find(true)) {
         $otherEditions = OtherEditionHandler::getEditions($solrId, $resource->isbn, null, 10);
         if (is_array($otherEditions)) {
             foreach ($otherEditions as $edition) {
                 /** @var Resource $editionResource */
                 $editionResource = new Resource();
                 if (preg_match('/econtentRecord(\\d+)/', $edition['id'], $matches)) {
                     $editionResource->source = 'eContent';
                     $editionResource->record_id = trim($matches[1]);
                 } else {
                     $editionResource->record_id = $edition['id'];
                     $editionResource->source = 'VuFind';
                 }
                 if ($editionResource->find(true)) {
                     $editionResources[] = $editionResource;
                 } else {
                     $logger = new Logger();
                     $logger->log("Could not find resource {$editionResource->source} {$editionResource->record_id} - {$edition['id']}", PEAR_LOG_DEBUG);
                 }
             }
         } else {
             $editionResources = null;
         }
     } else {
         $otherEditions = null;
         $editionResources = null;
     }
     $interface->assign('otherEditions', $otherEditions);
     $interface->assign('editionResources', $editionResources);
     $interface->assign('chiliFreshAccount', $configArray['Content']['chiliFreshAccount']);
     $timer->logTime('Configure UI for library and location');
     //Build the actual view
     $interface->setTemplate('view.tpl');
     $titleField = $this->marcRecord->getField('245');
     if ($titleField) {
         if ($titleField->getSubfield('a')) {
             $mainTitle = $titleField->getSubfield('a')->getData();
         } else {
             $mainTitle = 'Title not available';
         }
         $interface->setPageTitle($mainTitle);
     }
     // Display Page
     $interface->display('layout.tpl');
 }
Ejemplo n.º 12
0
 function launch()
 {
     global $interface;
     global $timer;
     global $configArray;
     global $user;
     //Enable and disable functionality based on library settings
     global $library;
     global $locationSingleton;
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $url = $configArray['Index']['url'];
     $this->db = new $class($url);
     if ($configArray['System']['debugSolr']) {
         $this->db->debug = true;
     }
     if (isset($_REQUEST['searchId'])) {
         $_SESSION['searchId'] = $_REQUEST['searchId'];
         $interface->assign('searchId', $_SESSION['searchId']);
     } else {
         if (isset($_SESSION['searchId'])) {
             $interface->assign('searchId', $_SESSION['searchId']);
         }
     }
     $location = $locationSingleton->getActiveLocation();
     if (isset($library)) {
         $interface->assign('showTextThis', $library->showTextThis);
         $interface->assign('showEmailThis', $library->showEmailThis);
         $interface->assign('showFavorites', $library->showFavorites);
         $interface->assign('linkToAmazon', $library->linkToAmazon);
         $interface->assign('enablePurchaseLinks', $library->linkToAmazon);
         $interface->assign('enablePospectorIntegration', $library->enablePospectorIntegration);
         if ($location != null) {
             $interface->assign('showAmazonReviews', $location->showAmazonReviews == 1 && $library->showAmazonReviews == 1 ? 1 : 0);
             $interface->assign('showStandardReviews', $location->showStandardReviews == 1 && $library->showStandardReviews == 1 ? 1 : 0);
             $interface->assign('showHoldButton', $location->showHoldButton == 1 && $library->showHoldButton == 1 ? 1 : 0);
         } else {
             $interface->assign('showAmazonReviews', $library->showAmazonReviews);
             $interface->assign('showStandardReviews', $library->showStandardReviews);
             $interface->assign('showHoldButton', $library->showHoldButton);
         }
         $interface->assign('showTagging', $library->showTagging);
         $interface->assign('showRatings', $library->showRatings);
         $interface->assign('showComments', $library->showComments);
         $interface->assign('tabbedDetails', $library->tabbedDetails);
         $interface->assign('showOtherEditionsPopup', $library->showOtherEditionsPopup == 1 ? true : false);
         $interface->assign('showProspectorTitlesAsTab', $library->showProspectorTitlesAsTab);
     } else {
         $interface->assign('showTextThis', 1);
         $interface->assign('showEmailThis', 1);
         $interface->assign('showFavorites', 1);
         $interface->assign('linkToAmazon', 1);
         $interface->assign('enablePurchaseLinks', 1);
         $interface->assign('enablePospectorIntegration', 0);
         if ($location != null) {
             $interface->assign('showAmazonReviews', $location->showAmazonReviews);
             $interface->assign('showStandardReviews', $location->showStandardReviews);
             $interface->assign('showHoldButton', $location->showHoldButton);
         } else {
             $interface->assign('showAmazonReviews', 1);
             $interface->assign('showStandardReviews', 1);
             $interface->assign('showHoldButton', 1);
         }
         $interface->assign('showTagging', 1);
         $interface->assign('showRatings', 1);
         $interface->assign('showComments', 1);
         $interface->assign('tabbedDetails', 1);
         $interface->assign('showProspectorTitlesAsTab', 0);
     }
     $interface->assign('showOtherEditionsPopup', $configArray['Content']['showOtherEditionsPopup']);
     $interface->assign('chiliFreshAccount', $configArray['Content']['chiliFreshAccount']);
     $showCopiesLineInHoldingsSummary = true;
     if ($library && $library->showCopiesLineInHoldingsSummary == 0) {
         $showCopiesLineInHoldingsSummary = false;
     }
     $interface->assign('showCopiesLineInHoldingsSummary', $showCopiesLineInHoldingsSummary);
     $timer->logTime('Configure UI for library and location');
     $interface->assign('overDriveVersion', isset($configArray['OverDrive']['interfaceVersion']) ? $configArray['OverDrive']['interfaceVersion'] : 1);
     Record_UserComments::loadEContentComments();
     $timer->logTime('Loaded Comments');
     $eContentRecord = new EContentRecord();
     $this->id = strip_tags($_REQUEST['id']);
     $eContentRecord->id = $this->id;
     if (!$eContentRecord->find(true)) {
         //TODO: display record not found error
     } else {
         $this->recordDriver = new EcontentRecordDriver();
         $this->recordDriver->setDataObject($eContentRecord);
         if ($configArray['Catalog']['ils'] == 'Millennium') {
             if (isset($eContentRecord->ilsId) && strlen($eContentRecord->ilsId) > 0) {
                 $interface->assign('classicId', substr($eContentRecord->ilsId, 1, strlen($eContentRecord->ilsId) - 2));
                 $interface->assign('classicUrl', $configArray['Catalog']['linking_url']);
             }
         }
         $this->isbn = $eContentRecord->getIsbn();
         if (is_array($this->isbn)) {
             if (count($this->isbn) > 0) {
                 $this->isbn = $this->isbn[0];
             } else {
                 $this->isbn = "";
             }
         } elseif ($this->isbn == null || strlen($this->isbn) == 0) {
             $interface->assign('showOtherEditionsPopup', false);
         }
         $this->issn = $eContentRecord->getPropertyArray('issn');
         if (is_array($this->issn)) {
             if (count($this->issn) > 0) {
                 $this->issn = $this->issn[0];
             } else {
                 $this->issn = "";
             }
         }
         $interface->assign('additionalAuthorsList', $eContentRecord->getPropertyArray('author2'));
         $rawSubjects = $eContentRecord->getPropertyArray('subject');
         $subjects = array();
         foreach ($rawSubjects as $subject) {
             $explodedSubjects = explode(' -- ', $subject);
             $searchSubject = "";
             $subject = array();
             foreach ($explodedSubjects as $tmpSubject) {
                 $searchSubject .= $tmpSubject . ' ';
                 $subject[] = array('search' => trim($searchSubject), 'title' => $tmpSubject);
             }
             $subjects[] = $subject;
         }
         $interface->assign('subjects', $subjects);
         $interface->assign('lccnList', $eContentRecord->getPropertyArray('lccn'));
         $interface->assign('isbnList', $eContentRecord->getPropertyArray('isbn'));
         $interface->assign('isbn', $eContentRecord->getIsbn());
         $interface->assign('isbn10', $eContentRecord->getIsbn10());
         $interface->assign('issnList', $eContentRecord->getPropertyArray('issn'));
         $interface->assign('upcList', $eContentRecord->getPropertyArray('upc'));
         $interface->assign('seriesList', $eContentRecord->getPropertyArray('series'));
         $interface->assign('topicList', $eContentRecord->getPropertyArray('topic'));
         $interface->assign('genreList', $eContentRecord->getPropertyArray('genre'));
         $interface->assign('regionList', $eContentRecord->getPropertyArray('region'));
         $interface->assign('eraList', $eContentRecord->getPropertyArray('era'));
         $interface->assign('eContentRecord', $eContentRecord);
         $interface->assign('cleanDescription', strip_tags($eContentRecord->description, '<p><br><b><i><em><strong>'));
         $interface->assign('id', $eContentRecord->id);
         require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
         $eContentRating = new EContentRating();
         $eContentRating->recordId = $eContentRecord->id;
         $interface->assign('ratingData', $eContentRating->getRatingData($user, false));
         //Determine the cover to use
         $bookCoverUrl = $configArray['Site']['coverUrl'] . "/bookcover.php?id={$eContentRecord->id}&amp;econtent=true&amp;issn={$eContentRecord->getIssn()}&amp;isn={$eContentRecord->getIsbn()}&amp;size=large&amp;upc={$eContentRecord->getUpc()}&amp;category=" . urlencode($eContentRecord->format_category()) . "&amp;format=" . urlencode($eContentRecord->getFirstFormat());
         $interface->assign('bookCoverUrl', $bookCoverUrl);
         if (isset($_REQUEST['detail'])) {
             $detail = strip_tags($_REQUEST['detail']);
             $interface->assign('defaultDetailsTab', $detail);
         }
         // Find Similar Records
         $similar = $this->db->getMoreLikeThis('econtentRecord' . $eContentRecord->id);
         $timer->logTime('Got More Like This');
         // Find Other Editions
         if ($configArray['Content']['showOtherEditionsPopup'] == false) {
             $editions = OtherEditionHandler::getEditions($eContentRecord->solrId(), $eContentRecord->getIsbn(), null);
             if (!PEAR_Singleton::isError($editions)) {
                 $interface->assign('editions', $editions);
             }
             $timer->logTime('Got Other editions');
         }
         //Load the citations
         $this->loadCitation($eContentRecord);
         // Retrieve User Search History
         $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false);
         //Get Next/Previous Links
         $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local';
         $searchObject = SearchObjectFactory::initSearchObject();
         $searchObject->init($searchSource);
         $searchObject->getNextPrevLinks();
         // Retrieve tags associated with the record
         $limit = 5;
         $resource = new Resource();
         $resource->record_id = $_GET['id'];
         $resource->source = 'eContent';
         $resource->find(true);
         $tags = $resource->getTags($limit);
         $interface->assign('tagList', $tags);
         $timer->logTime('Got tag list');
         //Load notes if any
         $marcRecord = MarcLoader::loadEContentMarcRecord($eContentRecord);
         if ($marcRecord) {
             $tableOfContents = array();
             $marcFields505 = $marcRecord->getFields('505');
             if ($marcFields505) {
                 $tableOfContents = $this->processTableOfContentsFields($marcFields505);
             }
             $notes = array();
             $marcFields500 = $marcRecord->getFields('500');
             $marcFields504 = $marcRecord->getFields('504');
             $marcFields511 = $marcRecord->getFields('511');
             $marcFields518 = $marcRecord->getFields('518');
             $marcFields520 = $marcRecord->getFields('520');
             if ($marcFields500 || $marcFields504 || $marcFields505 || $marcFields511 || $marcFields518 || $marcFields520) {
                 $allFields = array_merge($marcFields500, $marcFields504, $marcFields511, $marcFields518, $marcFields520);
                 $notes = $this->processNoteFields($allFields);
             }
             if (isset($library) && $library->showTableOfContentsTab == 0 || count($tableOfContents) == 0) {
                 $notes = array_merge($notes, $tableOfContents);
             } else {
                 $interface->assign('tableOfContents', $tableOfContents);
             }
             if (isset($library) && strlen($library->notesTabName) > 0) {
                 $interface->assign('notesTabName', $library->notesTabName);
             } else {
                 $interface->assign('notesTabName', 'Notes');
             }
             $additionalNotesFields = array('310' => 'Current Publication Frequency', '321' => 'Former Publication Frequency', '351' => 'Organization & arrangement of materials', '362' => 'Dates of publication and/or sequential designation', '501' => '"With"', '502' => 'Dissertation', '506' => 'Restrictions on Access', '507' => 'Scale for Graphic Material', '508' => 'Creation/Production Credits', '510' => 'Citation/References', '511' => 'Participant or Performer', '513' => 'Type of Report an Period Covered', '515' => 'Numbering Peculiarities', '518' => 'Date/Time and Place of Event', '521' => 'Target Audience', '522' => 'Geographic Coverage', '525' => 'Supplement', '526' => 'Study Program Information', '530' => 'Additional Physical Form', '533' => 'Reproduction', '534' => 'Original Version', '536' => 'Funding Information', '538' => 'System Details', '545' => 'Biographical or Historical Data', '546' => 'Language', '547' => 'Former Title Complexity', '550' => 'Issuing Body', '555' => 'Cumulative Index/Finding Aids', '556' => 'Information About Documentation', '561' => 'Ownership and Custodial History', '563' => 'Binding Information', '580' => 'Linking Entry Complexity', '581' => 'Publications About Described Materials', '586' => 'Awards', '590' => 'Local note', '599' => 'Differentiable Local note');
             foreach ($additionalNotesFields as $tag => $label) {
                 $marcFields = $marcRecord->getFields($tag);
                 foreach ($marcFields as $marcField) {
                     $noteText = array();
                     foreach ($marcField->getSubFields() as $subfield) {
                         $noteText[] = $subfield->getData();
                     }
                     $note = implode(',', $noteText);
                     if (strlen($note) > 0) {
                         $notes[] = "<b>{$label}</b>: " . $note;
                     }
                 }
             }
             if (count($notes) > 0) {
                 $interface->assign('notes', $notes);
             }
         }
         $this->loadReviews($eContentRecord);
         if (isset($_REQUEST['subsection'])) {
             $subsection = $_REQUEST['subsection'];
             if ($subsection == 'Description') {
                 $interface->assign('extendedMetadata', $this->recordDriver->getExtendedMetadata());
                 $interface->assign('subTemplate', 'view-description.tpl');
             } elseif ($subsection == 'Reviews') {
                 $interface->assign('subTemplate', 'view-reviews.tpl');
             }
         }
         //Build the actual view
         $interface->setTemplate('view.tpl');
         $interface->setPageTitle($eContentRecord->title);
         //Var for the IDCLREADER TEMPLATE
         $interface->assign('ButtonBack', true);
         $interface->assign('ButtonHome', true);
         $interface->assign('MobileTitle', '&nbsp;');
         //Load Staff Details
         $interface->assign('staffDetails', $this->getStaffView($eContentRecord));
         // Display Page
         $interface->display('layout.tpl');
     }
 }
Ejemplo n.º 13
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     global $timer;
     // Get My Transactions
     $oneOrMoreRenewableItems = false;
     if ($this->catalog->status) {
         if ($user->cat_username) {
             $patron = $this->catalog->patronLogin($user->cat_username, $user->cat_password);
             $timer->logTime("Logged in patron to get checked out items.");
             if (PEAR_Singleton::isError($patron)) {
                 PEAR_Singleton::raiseError($patron);
             }
             $patronResult = $this->catalog->getMyProfile($patron);
             if (!PEAR_Singleton::isError($patronResult)) {
                 $interface->assign('profile', $patronResult);
             }
             $timer->logTime("Got patron profile to get checked out items.");
             $libraryHoursMessage = Location::getLibraryHoursMessage($patronResult['homeLocationId']);
             $interface->assign('libraryHoursMessage', $libraryHoursMessage);
             // Define sorting options
             $sortOptions = array('title' => 'Title', 'author' => 'Author', 'dueDate' => 'Due Date', 'format' => 'Format', 'renewed' => 'Times Renewed', 'holdQueueLength' => 'Wish List');
             $interface->assign('sortOptions', $sortOptions);
             $selectedSortOption = isset($_REQUEST['accountSort']) ? $_REQUEST['accountSort'] : 'dueDate';
             $interface->assign('defaultSortOption', $selectedSortOption);
             $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
             $recordsPerPage = isset($_REQUEST['pagesize']) && is_numeric($_REQUEST['pagesize']) ? $_REQUEST['pagesize'] : 25;
             $interface->assign('recordsPerPage', $recordsPerPage);
             if (isset($_GET['exportToExcel'])) {
                 $recordsPerPage = -1;
                 $page = 1;
             }
             $result = $this->catalog->getMyTransactions($page, $recordsPerPage, $selectedSortOption);
             $timer->logTime("Loaded transactions from catalog.");
             if (!PEAR_Singleton::isError($result)) {
                 $link = $_SERVER['REQUEST_URI'];
                 if (preg_match('/[&?]page=/', $link)) {
                     $link = preg_replace("/page=\\d+/", "page=%d", $link);
                 } else {
                     if (strpos($link, "?") > 0) {
                         $link .= "&page=%d";
                     } else {
                         $link .= "?page=%d";
                     }
                 }
                 if ($recordsPerPage != '-1') {
                     $options = array('totalItems' => $result['numTransactions'], 'fileName' => $link, 'perPage' => $recordsPerPage, 'append' => false);
                     $pager = new VuFindPager($options);
                     $interface->assign('pageLinks', $pager->getLinks());
                 }
                 $interface->assign('showNotInterested', false);
                 foreach ($result['transactions'] as $i => $data) {
                     //Get Rating
                     $resource = new Resource();
                     $resource->source = 'VuFind';
                     $resource->record_id = $data['id'];
                     $resource->find(true);
                     $data['ratingData'] = $resource->getRatingData($user);
                     $result['transactions'][$i] = $data;
                     $itemBarcode = isset($data['barcode']) ? $data['barcode'] : null;
                     $itemId = isset($data['itemid']) ? $data['itemid'] : null;
                     if ($itemBarcode != null && isset($_SESSION['renew_message'][$itemBarcode])) {
                         $renewMessage = $_SESSION['renew_message'][$itemBarcode]['message'];
                         $renewResult = $_SESSION['renew_message'][$itemBarcode]['result'];
                         $data['renewMessage'] = $renewMessage;
                         $data['renewResult'] = $renewResult;
                         $result['transactions'][$i] = $data;
                         unset($_SESSION['renew_message'][$itemBarcode]);
                         //$logger->log("Found renewal message in session for $itemBarcode", PEAR_LOG_INFO);
                     } else {
                         if ($itemId != null && isset($_SESSION['renew_message'][$itemId])) {
                             $renewMessage = $_SESSION['renew_message'][$itemId]['message'];
                             $renewResult = $_SESSION['renew_message'][$itemId]['result'];
                             $data['renewMessage'] = $renewMessage;
                             $data['renewResult'] = $renewResult;
                             $result['transactions'][$i] = $data;
                             unset($_SESSION['renew_message'][$itemId]);
                             //$logger->log("Found renewal message in session for $itemBarcode", PEAR_LOG_INFO);
                         } else {
                             $renewMessage = null;
                             $renewResult = null;
                         }
                     }
                 }
                 $interface->assign('transList', $result['transactions']);
                 unset($_SESSION['renew_message']);
             }
         }
     }
     //Determine which columns to show
     $ils = $configArray['Catalog']['ils'];
     $showOut = $ils == 'Horizon';
     $showRenewed = $ils == 'Horizon' || $ils == 'Millennium';
     $showWaitList = $ils == 'Horizon';
     $interface->assign('showOut', $showOut);
     $interface->assign('showRenewed', $showRenewed);
     $interface->assign('showWaitList', $showWaitList);
     if (isset($_GET['exportToExcel'])) {
         $this->exportToExcel($result['transactions'], $showOut, $showRenewed, $showWaitList);
     }
     $interface->setTemplate('checkedout.tpl');
     $interface->setPageTitle('Checked Out Items');
     $interface->display('layout.tpl');
 }
Ejemplo n.º 14
0
 function launch()
 {
     global $configArray;
     global $interface;
     //////////Populate the Date Filter Start
     //Grab the Selected Date Start
     if (isset($_REQUEST['dateFilterStart'])) {
         if (preg_match('/\\d{1,2}\\/\\d{1,2}\\/\\d{4}/', $_REQUEST['dateFilterStart'])) {
             $selectedDateStart = DateTime::createFromFormat('m/d/Y', $_REQUEST['dateFilterStart']);
             $selectedDateStart = $selectedDateStart->getTimestamp();
         } else {
             $selectedDateStart = strtotime($_REQUEST['dateFilterStart']);
         }
     } else {
         $selectedDateStart = strtotime('-30 days');
     }
     $selectedDateStart = date('Y-m-d', $selectedDateStart);
     $interface->assign('selectedDateStart', $selectedDateStart);
     //Populate the Date Filter End
     //Grab the Selected End Date
     if (isset($_REQUEST['dateFilterEnd'])) {
         if (preg_match('/\\d{1,2}\\/\\d{1,2}\\/\\d{4}/', $_REQUEST['dateFilterEnd'])) {
             $selectedDateEnd = DateTime::createFromFormat('m/d/Y', $_REQUEST['dateFilterEnd']);
             $selectedDateEnd = $selectedDateEnd->getTimestamp();
         } else {
             $selectedDateEnd = strtotime($_REQUEST['dateFilterEnd']);
         }
     } else {
         $selectedDateEnd = strtotime('today');
     }
     $selectedDateEnd = date('Y-m-d', $selectedDateEnd);
     $interface->assign('selectedDateEnd', $selectedDateEnd);
     //////////Populate the Stores Filter
     $queryHostsFilter = "SELECT DISTINCT linkHost AS linkHost FROM external_link_tracking ORDER BY linkHost ASC";
     $externalLinkTracking = new ExternalLinkTracking();
     $externalLinkTracking->query($queryHostsFilter);
     $allHosts = array();
     while ($externalLinkTracking->fetch()) {
         $allHosts[] = $externalLinkTracking->linkHost;
     }
     $interface->assign('hostFilter', $allHosts);
     //////////Grab the Selected Hosts Filter Value
     if (isset($_REQUEST['hostFilter'])) {
         $selectedHosts = $_REQUEST['hostFilter'];
     } else {
         $selectedHosts = $allHosts;
     }
     $interface->assign('selectedHosts', $selectedHosts);
     $baseQueryLinks = "SELECT COUNT(externalLinkId) AS timesFollowed, recordId, linkUrl, linkHost " . "FROM external_link_tracking " . "WHERE (DATE_FORMAT(trackingDate, '%Y-%m-%d')) BETWEEN '" . $selectedDateStart . "' AND '" . $selectedDateEnd . "' ";
     if (count($selectedHosts) > 0) {
         $hosts = join("','", $selectedHosts);
         $baseQueryLinks .= "AND linkHost IN ('" . $hosts . "') ";
     }
     $baseQueryLinks .= "GROUP BY recordId, linkUrl ";
     //////////Get a count of the page view data
     $queryPurchasesCount = "SELECT COUNT(*) AS RowCount from ( " . $baseQueryLinks . ") As ResultCount";
     $resPurchasesCount = mysql_query($queryPurchasesCount);
     if ($resPurchasesCount > 0) {
         $rowCount = mysql_fetch_object($resPurchasesCount);
         $totalResultCount = $rowCount->RowCount;
     } else {
         $totalResultCount = 0;
     }
     //////////Create the items per page array
     $itemsPerPageList = $this->getItemsPerPageList();
     ///////////////////PAGING
     $currentPage = 1;
     $resultTotal = $totalResultCount;
     $startRecord = 1;
     if (isset($_GET['itemsPerPage'])) {
         switch ($_GET['itemsPerPage']) {
             case "20":
                 $itemsPerPage = 20;
                 $itemsPerPageList["20"]["selected"] = true;
                 break;
             case "100":
                 $itemsPerPage = 100;
                 $itemsPerPageList["100"]["selected"] = true;
                 break;
             default:
                 $itemsPerPage = 50;
                 $itemsPerPageList["50"]["selected"] = true;
         }
     } else {
         $itemsPerPage = 50;
         $itemsPerPageList["50"]["selected"] = true;
     }
     $endRecord = $itemsPerPage;
     $interface->assign('itemsPerPageList', $itemsPerPageList);
     if (isset($_GET['page'])) {
         $currentPage = $_GET['page'];
         // 1st record is easy, work out the start of this page
         $startRecord = ($currentPage - 1) * $itemsPerPage + 1;
         // Last record needs more care
         if ($resultTotal < $itemsPerPage) {
             // There are less records returned then one page, use total results
             $endRecord = $resultTotal;
         } else {
             if ($currentPage * $itemsPerPage > $resultTotal) {
                 // The end of the current page runs past the last record, use total results
                 $endRecord = $resultTotal;
             } else {
                 // Otherwise use the last record on this page
                 $endRecord = $currentPage * $itemsPerPage;
             }
         }
     }
     //////////Get the Page View Data with paging and sorting
     if (isset($_GET['reportSort'])) {
         $sortValue = $_GET['reportSort'];
     }
     //Create values for how to sort the table.
     $sortList = $this->getSortList();
     if (!isset($sortValue)) {
         $sortValue = 'UrlASC';
     }
     $sortList[$sortValue]["selected"] = true;
     $baseQueryLinks .= $sortList[$sortValue]['sql'];
     //append on a limit to return a result
     if (!isset($_REQUEST['exportToExcel'])) {
         $baseQueryLinks .= "LIMIT " . ($startRecord - 1) . ", " . $itemsPerPage . " ";
     }
     $resPurchases = mysql_query($baseQueryLinks);
     $resultsPurchases = array();
     if ($resPurchases > 0) {
         //Build an array based on the data to dump out to the grid
         $i = 0;
         while ($r = mysql_fetch_array($resPurchases)) {
             $recordId = $r['recordId'];
             $fullId = $r['recordId'];
             if (preg_match('/econtentRecord(\\d+)/', $recordId, $matches)) {
                 require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
                 $econtentRecord = new EContentRecord();
                 $econtentRecord->id = $matches[1];
                 $econtentRecord->find(true);
                 $recordId = $econtentRecord->ilsId;
                 $title = $econtentRecord->title;
             } else {
                 $resource = new Resource();
                 $resource->record_id = $recordId;
                 $resource->source = 'VuFind';
                 $resource->find(true);
                 $title = $resource->title;
             }
             $tmp = array('recordId' => $recordId, 'recordUrl' => '/Record/' . $fullId, 'title' => $title, 'timesFollowed' => $r['timesFollowed'], 'linkHost' => $r['linkHost'], 'linkUrl' => $r['linkUrl']);
             $resultsPurchases[$i++] = $tmp;
         }
     }
     $interface->assign('resultLinks', $resultsPurchases);
     //////////Paging Array
     $summary = array('page' => $currentPage, 'perPage' => $itemsPerPage, 'resultTotal' => $totalResultCount, 'startRecord' => $startRecord, 'endRecord' => $endRecord);
     $interface->assign('recordCount', $summary['resultTotal']);
     $interface->assign('recordStart', $summary['startRecord']);
     $interface->assign('recordEnd', $summary['endRecord']);
     // Process Paging using VuFind Pager object
     if (strrpos($_SERVER["REQUEST_URI"], "page=")) {
         //replace the page variable with a new one
         $link = str_replace("page=" . $currentPage, "page=%d", $_SERVER["REQUEST_URI"]);
     } else {
         if (strrpos($_SERVER["REQUEST_URI"], "?")) {
             $link = $_SERVER["REQUEST_URI"] . "&page=%d";
         } else {
             $link = $_SERVER["REQUEST_URI"] . "?page=%d";
         }
     }
     $options = array('totalItems' => $summary['resultTotal'], 'fileName' => $link, 'perPage' => $summary['perPage']);
     $pager = new VuFindPager($options);
     $interface->assign('pageLinks', $pager->getLinks());
     ///////////////////END PAGING
     //////////Sorting
     $sortUrl = $_SERVER["REQUEST_URI"];
     if (isset($sortValue)) {
         //Set the URL for sorting
         if (strrpos($_SERVER["REQUEST_URI"], "reportSort=")) {
             //replace the page variable with a new one
             $sortUrl = str_replace("sort=" . $currentPage, "reportSort=" . $sortValue, $_SERVER["REQUEST_URI"]);
         } else {
             if (strrpos($_SERVER["REQUEST_URI"], "?")) {
                 $sortUrl = $_SERVER["REQUEST_URI"] . "&reportSort=" . $sortValue;
             } else {
                 $sortUrl = $_SERVER["REQUEST_URI"] . "?reportSort=" . $sortValue;
             }
         }
     }
     $interface->assign('sortUrl', $sortUrl);
     $interface->assign('sortList', $sortList);
     //////////CHART
     //Create the chart and load data into the results.
     $queryDailyPurchases = "SELECT DATE_FORMAT(trackingDate, '%Y-%m-%d') as date, COUNT(externalLinkId) AS timesFollowed, linkHost FROM external_link_tracking  " . "WHERE (DATE_FORMAT(trackingDate, '%Y-%m-%d')) BETWEEN '" . $selectedDateStart . "' AND '" . $selectedDateEnd . "' ";
     if (count($selectedHosts) > 0) {
         $hosts = join("','", $selectedHosts);
         $queryDailyPurchases .= "AND linkHost IN ('" . $hosts . "') ";
     }
     $queryDailyPurchases .= "GROUP BY DATE_FORMAT(trackingDate, '%Y-%m-%d'), linkHost ORDER BY trackingDate ASC";
     $dailyUsage = mysql_query($queryDailyPurchases);
     //Initialize data by loading all of the dates that we are looking at so we can show the correct counts or each series on the right day.
     $check_date = $selectedDateStart;
     $datesInReport = array();
     $linkUsageByHostByDay = array();
     foreach ($allHosts as $hostName) {
         $linkUsageByHostByDay[$hostName] = array();
     }
     while ($check_date != $selectedDateEnd) {
         $check_date = date("Y-m-d", strtotime("+1 day", strtotime($check_date)));
         $datesInReport[] = $check_date;
         //Default number of link usage for the day to 0
         foreach ($allHosts as $host) {
             $linkUsageByHostByDay[$host][$check_date] = 0;
         }
     }
     //Chart section
     $reportData = new pData();
     while ($r = mysql_fetch_array($dailyUsage)) {
         $linkHost = $r['linkHost'];
         $linkUsageByHostByDay[$linkHost][$r['date']] = $r['timesFollowed'];
     }
     foreach ($linkUsageByHostByDay as $hostName => $dailyResults) {
         $reportData->addPoints($dailyResults, $hostName);
     }
     $reportData->setAxisName(0, "Usage");
     $reportData->addPoints($datesInReport, "Dates");
     $reportData->setAbscissa("Dates");
     /* Create the pChart object */
     $myPicture = new pImage(700, 290, $reportData);
     /* Draw the background */
     $Settings = array("R" => 225, "G" => 225, "B" => 225);
     $myPicture->drawFilledRectangle(0, 0, 700, 290, $Settings);
     /* Add a border to the picture */
     $myPicture->drawRectangle(0, 0, 699, 289, array("R" => 0, "G" => 0, "B" => 0));
     $myPicture->setFontProperties(array("FontName" => "sys/pChart/Fonts/verdana.ttf", "FontSize" => 9));
     $myPicture->setGraphArea(50, 30, 670, 190);
     //$myPicture->drawFilledRectangle(30,30,670,150,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
     $myPicture->drawScale(array("DrawSubTicks" => TRUE, "LabelRotation" => 90));
     $myPicture->setFontProperties(array("FontName" => "sys/pChart/Fonts/verdana.ttf", "FontSize" => 9));
     $myPicture->drawLineChart(array("DisplayValues" => TRUE, "DisplayColor" => DISPLAY_AUTO));
     /* Write the chart legend */
     $myPicture->drawLegend(80, 20, array("Style" => LEGEND_NOBORDER, "Mode" => LEGEND_HORIZONTAL));
     /* Render the picture (choose the best way) */
     $time = time();
     $chartHref = "/images/charts/dailyPurchases{$time}.png";
     $chartPath = $configArray['Site']['local'] . $chartHref;
     $myPicture->render($chartPath);
     $interface->assign('chartPath', $chartHref);
     //////////EXPORT To EXCEL
     if (isset($_REQUEST['exportToExcel'])) {
         //PHPEXCEL
         // Create new PHPExcel object
         $objPHPExcel = new PHPExcel();
         // Set properties
         $objPHPExcel->getProperties()->setTitle("External Link Usage Report")->setCategory("External Link Usage Report");
         // Add some data
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', 'External Link Usage Report')->setCellValue('A3', 'Record Id')->setCellValue('B3', 'Url')->setCellValue('C3', 'Host')->setCellValue('D3', 'Usage');
         $a = 4;
         //Loop Through The Report Data
         foreach ($resultsPurchases as $resultsPurchase) {
             $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $a, $resultsPurchase['recordId'])->setCellValue('B' . $a, $resultsPurchase['linkUrl'])->setCellValue('C' . $a, $resultsPurchase['linkHost'])->setCellValue('D' . $a, $resultsPurchase['timesFollowed']);
             $a++;
         }
         $objPHPExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
         $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
         $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setAutoSize(true);
         // Rename sheet
         $objPHPExcel->getActiveSheet()->setTitle('Simple');
         // Set active sheet index to the first sheet, so Excel opens this as the first sheet
         $objPHPExcel->setActiveSheetIndex(0);
         // Redirect output to a client's web browser (Excel5)
         header('Content-Type: application/vnd.ms-excel');
         header('Content-Disposition: attachment;filename="ExternalLinkReport.xls"');
         header('Cache-Control: max-age=0');
         $objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
         $objWriter->save('php://output');
         exit;
     }
     $interface->setPageTitle('Report - External Link Tracking');
     $interface->setTemplate('reportExternalLinks.tpl');
     $interface->display('layout.tpl');
 }
Ejemplo n.º 15
0
 function save($source = 'eContent')
 {
     global $user;
     // Fail if we don't know what record we're working with:
     if (!isset($_GET['id'])) {
         return false;
     }
     // Create a resource entry for the current ID if necessary (or find the
     // existing one):
     $resource = new Resource();
     $resource->record_id = $_GET['id'];
     $resource->source = $source;
     if (!$resource->find(true)) {
         $resource->insert();
     }
     // Parse apart the tags and save them in association with the resource:
     preg_match_all('/"[^"]*"|[^,]+/', $_REQUEST['tag'], $words);
     foreach ($words[0] as $tag) {
         $tag = trim(strtolower(str_replace('"', '', $tag)));
         $resource->addTag($tag, $user);
     }
     // Done -- report success:
     return true;
 }
Ejemplo n.º 16
0
 function saveRecord()
 {
     if ($this->user) {
         $list = new User_list();
         if ($_GET['list'] != '') {
             $list->id = $_GET['list'];
         } else {
             $list->user_id = $this->user->id;
             $list->title = "My Favorites";
             $list->insert();
         }
         $resource = new Resource();
         $resource->record_id = $_GET['id'];
         $resource->service = $_GET['service'];
         if (!$resource->find(true)) {
             $resource->insert();
         }
         preg_match_all('/"[^"]*"|[^,]+/', $_GET['mytags'], $tagArray);
         $this->user->addResource($resource, $list, $tagArray[0], $_GET['notes']);
     } else {
         return false;
     }
 }
Ejemplo n.º 17
0
 /**
  * Get all tags for a record.
  *
  * @return void
  * @access public
  */
 public function getRecordTags()
 {
     include_once 'services/MyResearch/lib/Resource.php';
     $tagList = array();
     $resource = new Resource();
     $resource->record_id = $_GET['id'];
     if ($resource->find(true)) {
         $tags = $resource->getTags();
         foreach ($tags as $tag) {
             $tagList[] = array('tag' => $tag->tag, 'cnt' => $tag->cnt);
         }
     }
     // If we don't have any tags, provide a user-appropriate message:
     if (empty($tagList)) {
         $msg = translate('No Tags') . ', ' . translate('Be the first to tag this record') . '!';
         return $this->output($msg, JSON::STATUS_ERROR);
     } else {
         return $this->output($tagList, JSON::STATUS_OK);
     }
 }
Ejemplo n.º 18
0
 function GetComments()
 {
     global $interface;
     require_once ROOT_DIR . '/services/MyResearch/lib/Resource.php';
     require_once ROOT_DIR . '/services/MyResearch/lib/Comments.php';
     $interface->assign('id', $_GET['id']);
     $resource = new Resource();
     $resource->record_id = $_GET['id'];
     $resource->source = 'eContent';
     $commentList = array();
     if ($resource->find(true)) {
         $commentList = $resource->getComments();
     }
     $interface->assign('commentList', $commentList['user']);
     $userComments = $interface->fetch('Record/view-comments-list.tpl');
     $interface->assign('staffCommentList', $commentList['staff']);
     $staffComments = $interface->fetch('Record/view-staff-reviews-list.tpl');
     return json_encode(array('staffComments' => $staffComments, 'userComments' => $userComments));
 }
Ejemplo n.º 19
0
 /**
  * Save the record specified by GET parameters.
  *
  * @param object $user User who is saving the record.
  *
  * @return bool        True on success, false on failure.
  * @access public
  */
 public static function saveRecord($user)
 {
     // Fail if the user is not logged in:
     if (!$user) {
         return false;
     }
     $list = new User_list();
     if (isset($_GET['list']) && $_GET['list'] != '') {
         $list->id = $_GET['list'];
     } else {
         if (isset($_POST['list']) && $_POST['list'] != '') {
             $list->id = $_POST['list'];
         } else {
             $list->user_id = $user->id;
             $list->title = "My Favorites";
             if (!$list->find(true)) {
                 $list->insert();
             }
         }
     }
     // Remember that the list was used so it can be the default in future
     // dialog boxes:
     $list->rememberLastUsed();
     // Setup Search Engine Connection
     $db = ConnectionManager::connectToIndex('MetaLib');
     // Get Record Information
     $record = $db->getRecord($_GET['id']);
     if (!$record) {
         return false;
     }
     $resource = new Resource();
     $resource->record_id = $_GET['id'];
     $resource->source = 'MetaLib';
     if (!$resource->find(true)) {
         $resource->data = serialize($record);
         $resource->insert();
     } else {
         $resource->data = serialize($record);
         $resource->update();
     }
     preg_match_all('/"[^"]*"|[^ ]+/', isset($_GET['mytags']) ? $_GET['mytags'] : '', $tagArray);
     return $user->addResource($resource, $list, $tagArray[0], isset($_GET['notes']) ? $_GET['notes'] : '');
 }
Ejemplo n.º 20
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 $librarySingleton;
             $patronHomeBranch = $librarySingleton->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 {
                 //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 = $librarySingleton->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');
     }
 }
Ejemplo n.º 21
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;
 }
Ejemplo n.º 22
0
 function launch($msg = null)
 {
     global $interface;
     global $configArray;
     if (!($user = UserAccount::isLoggedIn())) {
         require_once 'Login.php';
         Login::launch();
         exit;
     }
     // Save Data
     if (isset($_POST['submit'])) {
         $this->saveChanges($user);
         // After changes are saved, send the user back to an appropriate page;
         // either the list they were viewing when they started editing, or the
         // overall favorites list.
         if (isset($_REQUEST['list_id'])) {
             $nextAction = 'MyList/' . $_REQUEST['list_id'];
         } elseif (isset($_REQUEST['lists'])) {
             if (is_array($_REQUEST['lists'])) {
                 $nextAction = 'MyList/' . $_REQUEST['lists'][0];
             } else {
                 $nextAction = 'MyList/' . $_REQUEST['lists'];
             }
         } else {
             $nextAction = 'Home';
         }
         header('Location: ' . $configArray['Site']['path'] . '/MyResearch/' . $nextAction);
         exit;
     }
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $db = new $class($configArray['Index']['url']);
     if ($configArray['System']['debugSolr']) {
         $db->debug = true;
     }
     // Get Record Information
     $resource = new Resource();
     $resource->record_id = $_GET['id'];
     $resource->source = $_GET['source'];
     if ($resource->find(true)) {
         $interface->assign('resource', $resource);
     }
     // Record ID
     $interface->assign('recordId', $_GET['id']);
     // Retrieve saved information about record
     $saved = $user->getSavedData($_GET['id'], $_GET['source']);
     // Add tag information
     $savedData = array();
     foreach ($saved as $current) {
         // If we're filtering to a specific list, skip any other lists:
         if (isset($_GET['list_id']) && $current->list_id != $_GET['list_id']) {
             continue;
         }
         $savedData[] = array('listId' => $current->list_id, 'listTitle' => $current->list_title, 'notes' => $current->notes, 'tags' => $this->getTags($user, $current->list_id));
     }
     $interface->assign('savedData', $savedData);
     $interface->assign('listFilter', $_GET['list_id']);
     $interface->setTemplate('edit.tpl');
     $interface->display('layout.tpl');
 }
Ejemplo n.º 23
0
 public function getMyTransactions($page = 1, $recordsPerPage = -1, $sortOption = 'dueDate')
 {
     global $timer;
     $patronDump = $this->driver->_getPatronDump($this->driver->_getBarcode());
     $timer->logTime("Ready to load checked out titles from Millennium");
     //Load the information from millennium using CURL
     $sResult = $this->driver->_fetchPatronInfoPage($patronDump, 'items');
     $timer->logTime("Loaded checked out titles from Millennium");
     $sResult = preg_replace("/<[^<]+?>\\W<[^<]+?>\\W\\d* ITEM.? CHECKED OUT<[^<]+?>\\W<[^<]+?>/", "", $sResult);
     $s = substr($sResult, stripos($sResult, 'patFunc'));
     $s = substr($s, strpos($s, ">") + 1);
     $s = substr($s, 0, stripos($s, "</table"));
     $s = preg_replace("/<br \\/>/", "", $s);
     $sRows = preg_split("/<tr([^>]*)>/", $s);
     $sCount = 0;
     $sKeys = array_pad(array(), 10, "");
     $checkedOutTitles = array();
     //Get patron's location to determine if renewals are allowed.
     global $locationSingleton;
     /** @var Location $patronLocation */
     $patronLocation = $locationSingleton->getUserHomeLocation();
     if (isset($patronLocation)) {
         $patronPType = $this->driver->getPType();
         $patronCanRenew = false;
         if ($patronLocation->ptypesToAllowRenewals == '*') {
             $patronCanRenew = true;
         } else {
             if (preg_match("/^({$patronLocation->ptypesToAllowRenewals})\$/", $patronPType)) {
                 $patronCanRenew = true;
             }
         }
     } else {
         $patronCanRenew = true;
     }
     $timer->logTime("Determined if patron can renew");
     foreach ($sRows as $srow) {
         $scols = preg_split("/<t(h|d)([^>]*)>/", $srow);
         $curTitle = array();
         for ($i = 0; $i < sizeof($scols); $i++) {
             $scols[$i] = str_replace("&nbsp;", " ", $scols[$i]);
             $scols[$i] = preg_replace("/<br+?>/", " ", $scols[$i]);
             $scols[$i] = html_entity_decode(trim(substr($scols[$i], 0, stripos($scols[$i], "</t"))));
             //print_r($scols[$i]);
             if ($sCount == 1) {
                 $sKeys[$i] = $scols[$i];
             } else {
                 if ($sCount > 1) {
                     if (stripos($sKeys[$i], "TITLE") > -1) {
                         if (preg_match('/.*?<a href=\\"\\/record=(.*?)(?:~S\\d{1,2})\\">(.*?)<\\/a>.*/', $scols[$i], $matches)) {
                             $shortId = $matches[1];
                             $bibid = '.' . $matches[1];
                             $title = $matches[2];
                         } else {
                             $title = $scols[$i];
                             $shortId = '';
                             $bibid = '';
                         }
                         $curTitle['shortId'] = $shortId;
                         $curTitle['id'] = $bibid;
                         $curTitle['title'] = $title;
                     }
                     if (stripos($sKeys[$i], "STATUS") > -1) {
                         // $sret[$scount-2]['duedate'] = strip_tags($scols[$i]);
                         $due = trim(str_replace("DUE", "", strip_tags($scols[$i])));
                         $renewCount = 0;
                         if (preg_match('/FINE\\(up to now\\) (\\$\\d+\\.\\d+)/i', $due, $matches)) {
                             $curTitle['fine'] = trim($matches[1]);
                         }
                         if (preg_match('/(.*)Renewed (\\d+) time(?:s)?/i', $due, $matches)) {
                             $due = trim($matches[1]);
                             $renewCount = $matches[2];
                         } else {
                             if (preg_match('/(.*)\\+\\d+ HOLD.*/i', $due, $matches)) {
                                 $due = trim($matches[1]);
                             }
                         }
                         if (preg_match('/(\\d{2}-\\d{2}-\\d{2})/', $due, $dueMatches)) {
                             $dateDue = DateTime::createFromFormat('m-d-y', $dueMatches[1]);
                             if ($dateDue) {
                                 $dueTime = $dateDue->getTimestamp();
                             } else {
                                 $dueTime = null;
                             }
                         } else {
                             $dueTime = strtotime($due);
                         }
                         if ($dueTime != null) {
                             $daysUntilDue = ceil(($dueTime - time()) / (24 * 60 * 60));
                             $overdue = $daysUntilDue < 0;
                             $curTitle['duedate'] = $dueTime;
                             $curTitle['overdue'] = $overdue;
                             $curTitle['daysUntilDue'] = $daysUntilDue;
                         }
                         $curTitle['renewCount'] = $renewCount;
                     }
                     if (stripos($sKeys[$i], "BARCODE") > -1) {
                         $curTitle['barcode'] = strip_tags($scols[$i]);
                     }
                     if (stripos($sKeys[$i], "RENEW") > -1) {
                         $matches = array();
                         if (preg_match('/<input\\s*type="checkbox"\\s*name="renew(\\d+)"\\s*id="renew(\\d+)"\\s*value="(.*?)"\\s*\\/>/', $scols[$i], $matches)) {
                             $curTitle['canrenew'] = $patronCanRenew;
                             $curTitle['itemindex'] = $matches[1];
                             $curTitle['itemid'] = $matches[3];
                             $curTitle['renewIndicator'] = $curTitle['itemid'] . '|' . $curTitle['itemindex'];
                         } else {
                             $curTitle['canrenew'] = false;
                         }
                     }
                     if (stripos($sKeys[$i], "CALL NUMBER") > -1) {
                         $curTitle['request'] = "null";
                     }
                 }
             }
         }
         if ($sCount > 1) {
             //Get additional information from resources table
             if ($curTitle['shortId'] && strlen($curTitle['shortId']) > 0) {
                 /** @var Resource|object $resource */
                 $resource = new Resource();
                 $resource->source = 'VuFind';
                 $resource->shortId = $curTitle['shortId'];
                 if ($resource->find(true)) {
                     $timer->logTime("Found resource for " . $curTitle['shortId']);
                     $curTitle = array_merge($curTitle, get_object_vars($resource));
                     $curTitle['recordId'] = $resource->record_id;
                     $curTitle['id'] = $resource->record_id;
                 } else {
                     $timer->logTime("Did not find resource for " . $curTitle['shortId']);
                     //echo("Warning did not find resource for {$historyEntry['shortId']}");
                 }
             }
             $sortTitle = isset($curTitle['title_sort']) ? $curTitle['title_sort'] : $curTitle['title'];
             $sortKey = $sortTitle;
             if ($sortOption == 'title') {
                 $sortKey = $sortTitle;
             } elseif ($sortOption == 'author') {
                 $sortKey = (isset($curTitle['author']) ? $curTitle['author'] : "Unknown") . '-' . $sortTitle;
             } elseif ($sortOption == 'dueDate') {
                 if (isset($curTitle['duedate'])) {
                     if (preg_match('/.*?(\\d{1,2})[-\\/](\\d{1,2})[-\\/](\\d{2,4}).*/', $curTitle['duedate'], $matches)) {
                         $sortKey = $matches[3] . '-' . $matches[1] . '-' . $matches[2] . '-' . $sortTitle;
                     } else {
                         $sortKey = $curTitle['duedate'] . '-' . $sortTitle;
                     }
                 }
             } elseif ($sortOption == 'format') {
                 $sortKey = (isset($curTitle['format']) ? $curTitle['format'] : "Unknown") . '-' . $sortTitle;
             } elseif ($sortOption == 'renewed') {
                 $sortKey = (isset($curTitle['renewCount']) ? $curTitle['renewCount'] : 0) . '-' . $sortTitle;
             } elseif ($sortOption == 'holdQueueLength') {
                 $sortKey = (isset($curTitle['holdQueueLength']) ? $curTitle['holdQueueLength'] : 0) . '-' . $sortTitle;
             }
             $sortKey .= "_{$sCount}";
             $checkedOutTitles[$sortKey] = $curTitle;
         }
         $sCount++;
     }
     ksort($checkedOutTitles);
     $timer->logTime("Parsed checkout information");
     $numTransactions = count($checkedOutTitles);
     //Process pagination
     if ($recordsPerPage != -1) {
         $startRecord = ($page - 1) * $recordsPerPage;
         if ($startRecord > $numTransactions) {
             $startRecord = 0;
         }
         $checkedOutTitles = array_slice($checkedOutTitles, $startRecord, $recordsPerPage);
     }
     return array('transactions' => $checkedOutTitles, 'numTransactions' => $numTransactions);
 }
Ejemplo n.º 24
0
 function __construct($subAction = false, $record_id = null)
 {
     global $interface;
     global $configArray;
     global $library;
     global $timer;
     global $logger;
     $interface->assign('page_body_style', 'sidebar_left');
     $interface->assign('libraryThingUrl', $configArray['LibraryThing']['url']);
     //Determine whether or not materials request functionality should be enabled
     $interface->assign('enableMaterialsRequest', MaterialsRequest::enableMaterialsRequest());
     //Load basic information needed in subclasses
     if ($record_id == null || !isset($record_id)) {
         $this->id = $_GET['id'];
     } else {
         $this->id = $record_id;
     }
     //Check to see if the record exists within the resources table
     $resource = new Resource();
     $resource->record_id = $this->id;
     $resource->source = 'VuFind';
     $resource->deleted = 0;
     if (!$resource->find()) {
         //Check to see if the record has been converted to an eContent record
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $econtentRecord = new EContentRecord();
         $econtentRecord->ilsId = $this->id;
         $econtentRecord->status = 'active';
         if ($econtentRecord->find(true)) {
             header("Location: /EcontentRecord/{$econtentRecord->id}/Home");
             die;
         }
         $logger->log("Did not find a record for id {$this->id} in resources table.", PEAR_LOG_DEBUG);
         $interface->setTemplate('invalidRecord.tpl');
         $interface->display('layout.tpl');
         die;
     }
     if ($configArray['Catalog']['ils'] == 'Millennium') {
         $interface->assign('classicId', substr($this->id, 1, strlen($this->id) - 2));
         $interface->assign('classicUrl', $configArray['Catalog']['linking_url']);
     }
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $url = $configArray['Index']['url'];
     $this->db = new $class($url);
     $this->db->disableScoping();
     // Retrieve Full Marc Record
     if (!($record = $this->db->getRecord($this->id))) {
         $logger->log("Did not find a record for id {$this->id} in solr.", PEAR_LOG_DEBUG);
         $interface->setTemplate('invalidRecord.tpl');
         $interface->display('layout.tpl');
         die;
     }
     $this->db->enableScoping();
     $this->record = $record;
     $interface->assign('record', $record);
     $this->recordDriver = RecordDriverFactory::initRecordDriver($record);
     $timer->logTime('Initialized the Record Driver');
     $interface->assign('coreMetadata', $this->recordDriver->getCoreMetadata());
     // Process MARC Data
     require_once ROOT_DIR . '/sys/MarcLoader.php';
     $marcRecord = MarcLoader::loadMarcRecordFromRecord($record);
     if ($marcRecord) {
         $this->marcRecord = $marcRecord;
         $interface->assign('marc', $marcRecord);
     } else {
         $interface->assign('error', 'Cannot Process MARC Record');
     }
     $timer->logTime('Processed the marc record');
     //Load information for display in the template rather than processing specific fields in the template
     $marcField = $marcRecord->getField('245');
     $recordTitle = $this->getSubfieldData($marcField, 'a');
     $interface->assign('recordTitle', $recordTitle);
     $recordTitleSubtitle = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p')));
     $recordTitleSubtitle = preg_replace('~\\s+[\\/:]$~', '', $recordTitleSubtitle);
     $interface->assign('recordTitleSubtitle', $recordTitleSubtitle);
     $recordTitleWithAuth = trim($this->concatenateSubfieldData($marcField, array('a', 'b', 'h', 'n', 'p', 'c')));
     $interface->assign('recordTitleWithAuth', $recordTitleWithAuth);
     $marcField = $marcRecord->getField('100');
     if ($marcField) {
         $mainAuthor = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'd'));
         $interface->assign('mainAuthor', $mainAuthor);
     }
     $marcField = $marcRecord->getField('110');
     if ($marcField) {
         $corporateAuthor = $this->getSubfieldData($marcField, 'a');
         $interface->assign('corporateAuthor', $corporateAuthor);
     }
     $marcFields = $marcRecord->getFields('700');
     if ($marcFields) {
         $contributors = array();
         foreach ($marcFields as $marcField) {
             $contributors[] = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'd'));
         }
         $interface->assign('contributors', $contributors);
     }
     $published = $this->recordDriver->getPublicationDetails();
     $interface->assign('published', $published);
     $marcFields = $marcRecord->getFields('250');
     if ($marcFields) {
         $editionsThis = array();
         foreach ($marcFields as $marcField) {
             $editionsThis[] = $this->getSubfieldData($marcField, 'a');
         }
         $interface->assign('editionsThis', $editionsThis);
     }
     $marcFields = $marcRecord->getFields('300');
     if ($marcFields) {
         $physicalDescriptions = array();
         foreach ($marcFields as $marcField) {
             $description = $this->concatenateSubfieldData($marcField, array('a', 'b', 'c', 'e', 'f', 'g'));
             if ($description != 'p. cm.') {
                 $description = preg_replace("/[\\/|;:]\$/", '', $description);
                 $description = preg_replace("/p\\./", 'pages', $description);
                 $physicalDescriptions[] = $description;
             }
         }
         $interface->assign('physicalDescriptions', $physicalDescriptions);
     }
     // Get ISBN for cover and review use
     $mainIsbnSet = false;
     /** @var File_MARC_Data_Field[] $isbnFields */
     if ($isbnFields = $this->marcRecord->getFields('020')) {
         $isbns = array();
         //Use the first good ISBN we find.
         foreach ($isbnFields as $isbnField) {
             /** @var File_MARC_Subfield $isbnSubfieldA */
             if ($isbnSubfieldA = $isbnField->getSubfield('a')) {
                 $tmpIsbn = trim($isbnSubfieldA->getData());
                 if (strlen($tmpIsbn) > 0) {
                     $isbns[] = $isbnSubfieldA->getData();
                     $pos = strpos($tmpIsbn, ' ');
                     if ($pos > 0) {
                         $tmpIsbn = substr($tmpIsbn, 0, $pos);
                     }
                     $tmpIsbn = trim($tmpIsbn);
                     if (strlen($tmpIsbn) > 0) {
                         if (strlen($tmpIsbn) < 10) {
                             $tmpIsbn = str_pad($tmpIsbn, 10, "0", STR_PAD_LEFT);
                         }
                         if (!$mainIsbnSet) {
                             $this->isbn = $tmpIsbn;
                             $interface->assign('isbn', $tmpIsbn);
                             $mainIsbnSet = true;
                         }
                     }
                 }
             }
         }
         if (isset($this->isbn)) {
             if (strlen($this->isbn) == 13) {
                 require_once ROOT_DIR . '/Drivers/marmot_inc/ISBNConverter.php';
                 $this->isbn10 = ISBNConverter::convertISBN13to10($this->isbn);
             } else {
                 $this->isbn10 = $this->isbn;
             }
             $interface->assign('isbn10', $this->isbn10);
         }
         $interface->assign('isbns', $isbns);
     }
     if ($upcField = $this->marcRecord->getField('024')) {
         /** @var File_MARC_Data_Field $upcField */
         if ($upcSubField = $upcField->getSubfield('a')) {
             $this->upc = trim($upcSubField->getData());
             $interface->assign('upc', $this->upc);
         }
     }
     if ($issnField = $this->marcRecord->getField('022')) {
         /** @var File_MARC_Data_Field $issnField */
         if ($issnSubField = $issnField->getSubfield('a')) {
             $this->issn = trim($issnSubField->getData());
             if ($pos = strpos($this->issn, ' ')) {
                 $this->issn = substr($this->issn, 0, $pos);
             }
             $interface->assign('issn', $this->issn);
             //Also setup GoldRush link
             if (isset($library) && strlen($library->goldRushCode) > 0) {
                 $interface->assign('goldRushLink', "http://goldrush.coalliance.org/index.cfm?fuseaction=Search&amp;inst_code={$library->goldRushCode}&amp;search_type=ISSN&amp;search_term={$this->issn}");
             }
         }
     }
     $timer->logTime("Got basic data from Marc Record subaction = {$subAction}, record_id = {$record_id}");
     //stop if this is not the main action.
     if ($subAction == true) {
         return;
     }
     //Get street date
     if ($streetDateField = $this->marcRecord->getField('263')) {
         $streetDate = $this->getSubfieldData($streetDateField, 'a');
         if ($streetDate != '') {
             $interface->assign('streetDate', $streetDate);
         }
     }
     /** @var File_MARC_Data_Field[] $marcField440 */
     $marcField440 = $marcRecord->getFields('440');
     /** @var File_MARC_Data_Field[] $marcField490 */
     $marcField490 = $marcRecord->getFields('490');
     /** @var File_MARC_Data_Field[] $marcField830 */
     $marcField830 = $marcRecord->getFields('830');
     if ($marcField440 || $marcField490 || $marcField830) {
         $series = array();
         foreach ($marcField440 as $field) {
             $series[] = $this->getSubfieldData($field, 'a');
         }
         foreach ($marcField490 as $field) {
             if ($field->getIndicator(1) == 0) {
                 $series[] = $this->getSubfieldData($field, 'a');
             }
         }
         foreach ($marcField830 as $field) {
             $series[] = $this->getSubfieldData($field, 'a');
         }
         $interface->assign('series', $series);
     }
     //Load description from Syndetics
     $useMarcSummary = true;
     if ($this->isbn || $this->upc) {
         if ($library && $library->preferSyndeticsSummary == 1) {
             require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php';
             $summaryInfo = GoDeeperData::getSummary($this->isbn, $this->upc);
             if (isset($summaryInfo['summary'])) {
                 $interface->assign('summaryTeaser', $summaryInfo['summary']);
                 $interface->assign('summary', $summaryInfo['summary']);
                 $useMarcSummary = false;
             }
         }
     }
     if ($useMarcSummary) {
         if ($summaryField = $this->marcRecord->getField('520')) {
             $interface->assign('summary', $this->getSubfieldData($summaryField, 'a'));
             $interface->assign('summaryTeaser', $this->getSubfieldData($summaryField, 'a'));
         } elseif ($library && $library->preferSyndeticsSummary == 0) {
             require_once ROOT_DIR . '/Drivers/marmot_inc/GoDeeperData.php';
             $summaryInfo = GoDeeperData::getSummary($this->isbn, $this->upc);
             if (isset($summaryInfo['summary'])) {
                 $interface->assign('summaryTeaser', $summaryInfo['summary']);
                 $interface->assign('summary', $summaryInfo['summary']);
                 $useMarcSummary = false;
             }
         }
     }
     if ($mpaaField = $this->marcRecord->getField('521')) {
         $interface->assign('mpaaRating', $this->getSubfieldData($mpaaField, 'a'));
     }
     if (isset($configArray['Content']['subjectFieldsToShow'])) {
         $subjectFieldsToShow = $configArray['Content']['subjectFieldsToShow'];
         $subjectFields = explode(',', $subjectFieldsToShow);
         $subjects = array();
         foreach ($subjectFields as $subjectField) {
             /** @var File_MARC_Data_Field[] $marcFields */
             $marcFields = $marcRecord->getFields($subjectField);
             if ($marcFields) {
                 foreach ($marcFields as $marcField) {
                     $searchSubject = "";
                     $subject = array();
                     foreach ($marcField->getSubFields() as $subField) {
                         /** @var File_MARC_Subfield $subField */
                         if ($subField->getCode() != 2) {
                             $searchSubject .= " " . $subField->getData();
                             $subject[] = array('search' => trim($searchSubject), 'title' => $subField->getData());
                         }
                     }
                     $subjects[] = $subject;
                 }
             }
             $interface->assign('subjects', $subjects);
         }
     }
     $format = $record['format'];
     $interface->assign('recordFormat', $record['format']);
     $format_category = isset($record['format_category'][0]) ? $record['format_category'][0] : '';
     $interface->assign('format_category', $format_category);
     $interface->assign('recordLanguage', isset($record['language']) ? $record['language'] : null);
     $timer->logTime('Got detailed data from Marc Record');
     $tableOfContents = array();
     $marcFields505 = $marcRecord->getFields('505');
     if ($marcFields505) {
         $tableOfContents = $this->processTableOfContentsFields($marcFields505);
     }
     $notes = array();
     $marcFields500 = $marcRecord->getFields('500');
     $marcFields504 = $marcRecord->getFields('504');
     $marcFields511 = $marcRecord->getFields('511');
     $marcFields518 = $marcRecord->getFields('518');
     $marcFields520 = $marcRecord->getFields('520');
     if ($marcFields500 || $marcFields504 || $marcFields505 || $marcFields511 || $marcFields518 || $marcFields520) {
         $allFields = array_merge($marcFields500, $marcFields504, $marcFields511, $marcFields518, $marcFields520);
         $notes = $this->processNoteFields($allFields);
     }
     if (isset($library) && $library->showTableOfContentsTab == 0 || count($tableOfContents) == 0) {
         $notes = array_merge($notes, $tableOfContents);
     } else {
         $interface->assign('tableOfContents', $tableOfContents);
     }
     if (isset($library) && strlen($library->notesTabName) > 0) {
         $interface->assign('notesTabName', $library->notesTabName);
     } else {
         $interface->assign('notesTabName', 'Notes');
     }
     $additionalNotesFields = array('310' => 'Current Publication Frequency', '321' => 'Former Publication Frequency', '351' => 'Organization & arrangement of materials', '362' => 'Dates of publication and/or sequential designation', '501' => '"With"', '502' => 'Dissertation', '506' => 'Restrictions on Access', '507' => 'Scale for Graphic Material', '508' => 'Creation/Production Credits', '510' => 'Citation/References', '511' => 'Participant or Performer', '513' => 'Type of Report an Period Covered', '515' => 'Numbering Peculiarities', '518' => 'Date/Time and Place of Event', '521' => 'Target Audience', '522' => 'Geographic Coverage', '525' => 'Supplement', '526' => 'Study Program Information', '530' => 'Additional Physical Form', '533' => 'Reproduction', '534' => 'Original Version', '536' => 'Funding Information', '538' => 'System Details', '545' => 'Biographical or Historical Data', '546' => 'Language', '547' => 'Former Title Complexity', '550' => 'Issuing Body', '555' => 'Cumulative Index/Finding Aids', '556' => 'Information About Documentation', '561' => 'Ownership and Custodial History', '563' => 'Binding Information', '580' => 'Linking Entry Complexity', '581' => 'Publications About Described Materials', '586' => 'Awards', '590' => 'Local note', '599' => 'Differentiable Local note');
     foreach ($additionalNotesFields as $tag => $label) {
         $marcFields = $marcRecord->getFields($tag);
         foreach ($marcFields as $marcField) {
             $noteText = array();
             foreach ($marcField->getSubFields() as $subfield) {
                 /** @var File_MARC_Subfield $subfield */
                 $noteText[] = $subfield->getData();
             }
             $note = implode(',', $noteText);
             if (strlen($note) > 0) {
                 $notes[] = "<b>{$label}</b>: " . $note;
             }
         }
     }
     if (count($notes) > 0) {
         $interface->assign('notes', $notes);
     }
     /** @var File_MARC_Data_Field[] $linkFields */
     $linkFields = $marcRecord->getFields('856');
     if ($linkFields) {
         $internetLinks = array();
         $purchaseLinks = array();
         $field856Index = 0;
         foreach ($linkFields as $marcField) {
             $field856Index++;
             //Get the link
             if ($marcField->getSubfield('u')) {
                 $link = $marcField->getSubfield('u')->getData();
                 if ($marcField->getSubfield('3')) {
                     $linkText = $marcField->getSubfield('3')->getData();
                 } elseif ($marcField->getSubfield('y')) {
                     $linkText = $marcField->getSubfield('y')->getData();
                 } elseif ($marcField->getSubfield('z')) {
                     $linkText = $marcField->getSubfield('z')->getData();
                 } else {
                     $linkText = $link;
                 }
                 $showLink = true;
                 //Process some links differently so we can either hide them
                 //or show them in different areas of the catalog.
                 if (preg_match('/purchase|buy/i', $linkText) || preg_match('/barnesandnoble|tatteredcover|amazon|smashwords\\.com/i', $link)) {
                     $showLink = false;
                 }
                 $isBookLink = preg_match('/acs\\.dcl\\.lan|vufind\\.douglascountylibraries\\.org|catalog\\.douglascountylibraries\\.org/i', $link);
                 if ($isBookLink == 1) {
                     //e-book link, don't show
                     $showLink = false;
                 }
                 if ($showLink) {
                     //Rewrite the link so we can track usage
                     $link = $configArray['Site']['path'] . '/Record/' . $this->id . '/Link?index=' . $field856Index;
                     $internetLinks[] = array('link' => $link, 'linkText' => $linkText);
                 }
             }
         }
         if (count($internetLinks) > 0) {
             $interface->assign('internetLinks', $internetLinks);
         }
     }
     if (isset($purchaseLinks) && count($purchaseLinks) > 0) {
         $interface->assign('purchaseLinks', $purchaseLinks);
     }
     //Determine the cover to use
     $bookCoverUrl = $configArray['Site']['coverUrl'] . "/bookcover.php?id={$this->id}&amp;isn={$this->isbn}&amp;issn={$this->issn}&amp;size=large&amp;upc={$this->upc}&amp;category=" . urlencode($format_category) . "&amp;format=" . urlencode(isset($format[0]) ? $format[0] : '');
     $interface->assign('bookCoverUrl', $bookCoverUrl);
     //Load accelerated reader data
     if (isset($record['accelerated_reader_interest_level'])) {
         $arData = array('interestLevel' => $record['accelerated_reader_interest_level'], 'pointValue' => $record['accelerated_reader_point_value'], 'readingLevel' => $record['accelerated_reader_reading_level']);
         $interface->assign('arData', $arData);
     }
     if (isset($record['lexile_score']) && $record['lexile_score'] > -1) {
         $lexileScore = $record['lexile_score'];
         if (isset($record['lexile_code'])) {
             $lexileScore = $record['lexile_code'] . $lexileScore;
         }
         $interface->assign('lexileScore', $lexileScore . 'L');
     }
     //Do actions needed if this is the main action.
     //$interface->caching = 1;
     $interface->assign('id', $this->id);
     if (substr($this->id, 0, 1) == '.') {
         $interface->assign('shortId', substr($this->id, 1));
     } else {
         $interface->assign('shortId', $this->id);
     }
     $interface->assign('addHeader', '<link rel="alternate" type="application/rdf+xml" title="RDF Representation" href="' . $configArray['Site']['path'] . '/Record/' . urlencode($this->id) . '/RDF" />');
     // Define Default Tab
     $tab = isset($_GET['action']) ? $_GET['action'] : 'Description';
     $interface->assign('tab', $tab);
     if (isset($_REQUEST['detail'])) {
         $detail = strip_tags($_REQUEST['detail']);
         $interface->assign('defaultDetailsTab', $detail);
     }
     // Define External Content Provider
     if ($this->marcRecord->getField('020')) {
         if (isset($configArray['Content']['reviews'])) {
             $interface->assign('hasReviews', true);
         }
         if (isset($configArray['Content']['excerpts'])) {
             $interface->assign('hasExcerpt', true);
         }
     }
     // Retrieve User Search History
     $interface->assign('lastsearch', isset($_SESSION['lastSearchURL']) ? $_SESSION['lastSearchURL'] : false);
     // Retrieve tags associated with the record
     $limit = 5;
     $resource = new Resource();
     $resource->record_id = $_GET['id'];
     $resource->source = 'VuFind';
     $resource->find(true);
     $tags = $resource->getTags($limit);
     $interface->assign('tagList', $tags);
     $timer->logTime('Got tag list');
     $this->cacheId = 'Record|' . $_GET['id'] . '|' . get_class($this);
     // Find Similar Records
     /** @var Memcache $memCache */
     global $memCache;
     $similar = $memCache->get('similar_titles_' . $this->id);
     if ($similar == false) {
         $similar = $this->db->getMoreLikeThis($this->id);
         // Send the similar items to the template; if there is only one, we need
         // to force it to be an array or things will not display correctly.
         if (isset($similar) && count($similar['response']['docs']) > 0) {
             $similar = $similar['response']['docs'];
         } else {
             $similar = array();
             $timer->logTime("Did not find any similar records");
         }
         $memCache->set('similar_titles_' . $this->id, $similar, 0, $configArray['Caching']['similar_titles']);
     }
     $this->similarTitles = $similar;
     $interface->assign('similarRecords', $similar);
     $timer->logTime('Loaded similar titles');
     // Find Other Editions
     if ($configArray['Content']['showOtherEditionsPopup'] == false) {
         $editions = OtherEditionHandler::getEditions($this->id, $this->isbn, isset($this->record['issn']) ? $this->record['issn'] : null);
         if (!PEAR_Singleton::isError($editions)) {
             $interface->assign('editions', $editions);
         } else {
             $timer->logTime("Did not find any other editions");
         }
         $timer->logTime('Got Other editions');
     }
     $interface->assign('showStrands', isset($configArray['Strands']['APID']) && strlen($configArray['Strands']['APID']) > 0);
     // Send down text for inclusion in breadcrumbs
     $interface->assign('breadcrumbText', $this->recordDriver->getBreadcrumb());
     // Send down OpenURL for COinS use:
     $interface->assign('openURL', $this->recordDriver->getOpenURL());
     // Send down legal export formats (if any):
     $interface->assign('exportFormats', $this->recordDriver->getExportFormats());
     // Set AddThis User
     $interface->assign('addThis', isset($configArray['AddThis']['key']) ? $configArray['AddThis']['key'] : false);
     // Set Proxy URL
     if (isset($configArray['EZproxy']['host'])) {
         $interface->assign('proxy', $configArray['EZproxy']['host']);
     }
     //setup 5 star ratings
     global $user;
     $ratingData = $resource->getRatingData($user);
     $interface->assign('ratingData', $ratingData);
     $timer->logTime('Got 5 star data');
     //Get Next/Previous Links
     $searchSource = isset($_REQUEST['searchSource']) ? $_REQUEST['searchSource'] : 'local';
     $searchObject = SearchObjectFactory::initSearchObject();
     $searchObject->init($searchSource);
     $searchObject->getNextPrevLinks();
     //Load Staff Details
     $interface->assign('staffDetails', $this->recordDriver->getStaffView());
 }
Ejemplo n.º 25
0
 /**
  * Save a user's changes.
  *
  * @param object $user Logged in user object
  *
  * @return void
  * @access private
  */
 private function _saveChanges($user)
 {
     $resource = new Resource();
     unset($resource->source);
     $resource->record_id = $_GET['id'];
     $resource->find(true);
     // Loop through the list of lists on the edit screen:
     foreach ($_POST['lists'] as $listId) {
         // Create a list object for the current list:
         $list = new User_list();
         if ($listId != '') {
             $list->id = $listId;
         } else {
             PEAR::raiseError(new PEAR_Error('List ID Missing'));
         }
         // Extract tags from the user input:
         preg_match_all('/"[^"]*"|[^ ]+/', $_POST['tags' . $listId], $tagArray);
         // Save extracted tags and notes:
         $user->addResource($resource, $list, $tagArray[0], $_POST['notes' . $listId]);
     }
 }
Ejemplo n.º 26
0
 function bulkAddTitles($list)
 {
     global $user;
     $numAdded = 0;
     $notes = array();
     $titlesToAdd = $_REQUEST['titlesToAdd'];
     $titleSearches[] = preg_split("/\\r\\n|\\r|\\n/", $titlesToAdd);
     foreach ($titleSearches[0] as $titleSearch) {
         $_REQUEST['lookfor'] = $titleSearch;
         $_REQUEST['type'] = 'Keyword';
         // Initialise from the current search globals
         $searchObject = SearchObjectFactory::initSearchObject();
         $searchObject->setLimit(1);
         $searchObject->init();
         $searchObject->clearFacets();
         $results = $searchObject->processSearch(false, false);
         if ($results['response'] && $results['response']['numFound'] >= 1) {
             $firstDoc = $results['response']['docs'][0];
             //Get the id of the document
             $id = $firstDoc['id'];
             if (preg_match('/eContentRecord/', $id)) {
                 $source = 'eContent';
                 $id = substr($id, 14);
             } else {
                 $source = 'VuFind';
             }
             //Get the resource for the id
             $resource = new Resource();
             $resource->record_id = $id;
             $resource->source = $source;
             if ($resource->find(true)) {
                 $numAdded++;
                 $user->addResource($resource, $list, null, false);
             } else {
                 //Could not find a resource for the id
                 $notes[] = "Could not find a resource matching " . $titleSearch;
             }
         } else {
             $notes[] = "Could not find a title matching " . $titleSearch;
         }
     }
     //Update solr
     $list->update();
     if ($numAdded > 0) {
         $notes[] = "Added {$numAdded} titles to the list";
     }
     return $notes;
 }
Ejemplo n.º 27
0
 public function getList()
 {
     $class = new Resource();
     return $class->find();
 }
Ejemplo n.º 28
0
 function loadNoveListTitle($originalIsbn, $item, &$titleList, &$titlesOwned, $seriesName = '')
 {
     global $user;
     $isbnList = array();
     /** @var SimpleXMLElement $titleItem */
     foreach ($item->TitleList->TitleItem as $titleItem) {
         $tmpIsbn = (string) $titleItem->attributes()->value;
         if (strlen($tmpIsbn) == 10 || strlen($tmpIsbn) == 13) {
             $isbnList[] = (string) $titleItem->attributes()->value;
         }
     }
     //If there is no ISBN, don't bother loading the title
     if (count($isbnList) == 0) {
         return;
     }
     //run a search to get the record id for the isbns.
     //TODO:  cache this info since it can take a really long time to load
     $searchObj = SearchObjectFactory::initSearchObject();
     $searchObj->setBasicQuery(implode(' OR ', $isbnList), 'ISN');
     $searchObj->disableScoping();
     //Add a filter to only include books and DVDs
     $searchObj->processSearch(false, false);
     $matchingRecords = $searchObj->getResultRecordSet();
     $isCurrent = in_array($originalIsbn, $isbnList);
     if (isset($seriesName)) {
         $series = $seriesName;
     } else {
         $series = null;
     }
     $volume = '';
     if ($item->Volume) {
         $volume = (string) $item->Volume;
     }
     if (count($matchingRecords) > 0) {
         $ownedRecord = $matchingRecords[0];
         if (strpos($ownedRecord['isbn'][0], ' ') > 0) {
             $isbnInfo = explode(' ', $ownedRecord['isbn'][0]);
             $isbn = $isbnInfo[0];
         } else {
             $isbn = $ownedRecord['isbn'][0];
         }
         $isbn13 = strlen($isbn) == 13 ? $isbn : ISBNConverter::convertISBN10to13($isbn);
         $isbn10 = strlen($isbn) == 10 ? $isbn : ISBNConverter::convertISBN13to10($isbn);
         if (!isset($series)) {
             if (isset($ownedRecord['series'])) {
                 $series = $ownedRecord['series'][0];
             }
         }
         //Load rating data
         if ($ownedRecord['recordtype'] == 'marc') {
             $resource = new Resource();
             $resource->source = 'VuFind';
             $resource->record_id = $ownedRecord['id'];
             $resource->find(true);
             $ratingData = $resource->getRatingData($user);
             $fullRecordLink = '/Record/' . $ownedRecord['id'] . '/Home';
         } else {
             require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
             $shortId = str_replace('econtentRecord', '', $ownedRecord['id']);
             $econtentRating = new EContentRating();
             $econtentRating->recordId = $shortId;
             $ratingData = $econtentRating->getRatingData($user, false);
             $fullRecordLink = '/EcontentRecord/' . $shortId . '/Home';
         }
         //See if we can get the series title from the record
         $titleList[] = array('title' => $ownedRecord['title'], 'title_short' => isset($ownedRecord['title_short']) ? $ownedRecord['title_short'] : $ownedRecord['title'], 'author' => isset($ownedRecord['author']) ? $ownedRecord['author'] : '', 'publicationDate' => (string) $item->PublicationDate, 'isbn' => $isbn13, 'isbn10' => $isbn10, 'upc' => isset($ownedRecord['upc'][0]) ? $ownedRecord['upc'][0] : '', 'recordId' => $ownedRecord['id'], 'recordtype' => $ownedRecord['recordtype'], 'id' => $ownedRecord['id'], 'libraryOwned' => true, 'isCurrent' => $isCurrent, 'shortId' => substr($ownedRecord['id'], 1), 'format_category' => $ownedRecord['format_category'], 'format' => $ownedRecord['format'], 'series' => $series, 'volume' => $volume, 'ratingData' => $ratingData, 'fullRecordLink' => $fullRecordLink);
         $titlesOwned++;
     } else {
         $isbn = $isbnList[0];
         $isbn13 = strlen($isbn) == 13 ? $isbn : ISBNConverter::convertISBN10to13($isbn);
         $isbn10 = strlen($isbn) == 10 ? $isbn : ISBNConverter::convertISBN13to10($isbn);
         $titleList[] = array('title' => (string) $item->Name, 'author' => (string) $item->Author, 'publicationDate' => (string) $item->PublicationDate, 'isbn' => $isbn13, 'isbn10' => $isbn10, 'recordId' => -1, 'libraryOwned' => false, 'isCurrent' => $isCurrent, 'series' => $series, 'volume' => $volume);
     }
 }
Ejemplo n.º 29
0
 static function getSuggestions($userId = -1)
 {
     global $configArray;
     if ($userId == -1) {
         global $user;
         $userId = $user->id;
     }
     //Load all titles the user is not interested in
     $notInterestedTitles = array();
     $notInterested = new NotInterested();
     $resource = new Resource();
     $notInterested->joinAdd($resource);
     $notInterested->userId = $userId;
     $notInterested->find();
     while ($notInterested->fetch()) {
         if ($notInterested->source == 'VuFind') {
             $fullId = $notInterested->record_id;
         } else {
             $fullId = 'econtentRecord' . $notInterested->record_id;
         }
         $notInterestedTitles[$fullId] = $fullId;
     }
     //Load all titles the user has rated (print)
     $allRatedTitles = array();
     $allLikedRatedTitles = array();
     $ratings = new UserRating();
     $ratings->userid = $userId;
     $resource = new Resource();
     $notInterested->joinAdd($resource);
     $ratings->joinAdd($resource);
     $ratings->find();
     while ($ratings->fetch()) {
         $allRatedTitles[$ratings->record_id] = $ratings->record_id;
         if ($ratings->rating >= 4) {
             $allLikedRatedTitles[] = $ratings->record_id;
         }
     }
     //Load all titles the user has rated (eContent)
     $econtentRatings = new EContentRating();
     $econtentRatings->userId = $userId;
     $econtentRatings->find();
     while ($econtentRatings->fetch()) {
         $allRatedTitles['econtentRecord' . $econtentRatings->recordId] = 'econtentRecord' . $econtentRatings->recordId;
         if ($econtentRatings->rating >= 4) {
             $allLikedRatedTitles[] = 'econtentRecord' . $econtentRatings->recordId;
         }
     }
     // Setup Search Engine Connection
     $class = $configArray['Index']['engine'];
     $url = $configArray['Index']['url'];
     $db = new $class($url);
     if ($configArray['System']['debugSolr']) {
         $db->debug = true;
     }
     //Get a list of all titles the user has rated (3 star and above)
     $ratings = new UserRating();
     $ratings->whereAdd("userId = {$userId}", 'AND');
     $ratings->whereAdd('rating >= 3', 'AND');
     $ratings->orderBy('rating DESC, dateRated DESC, id DESC');
     //Use the 20 highest ratings to make real-time recommendations faster
     $ratings->limit(0, 5);
     $ratings->find();
     $suggestions = array();
     //echo("User has rated {$ratings->N} titles<br/>");
     if ($ratings->N > 0) {
         while ($ratings->fetch()) {
             $resourceId = $ratings->resourceid;
             //Load the resource
             $resource = new Resource();
             $resource->id = $resourceId;
             $resource->find();
             if ($resource->N != 1) {
                 //echo("Did not find resource for $resourceId<br/>");
             } else {
                 $resource->fetch();
                 //echo("Found resource for $resourceId - {$resource->title}<br/>");
                 $ratedTitles[$resource->record_id] = clone $ratings;
                 $numRecommendations = 0;
                 if ($resource->isbn) {
                     //If there is an isbn for the title, we can load similar titles based on Novelist.
                     $isbn = $resource->isbn;
                     $numRecommendations = Suggestions::getNovelistRecommendations($ratings, $isbn, $resource, $allRatedTitles, $suggestions, $notInterestedTitles);
                     //echo("&nbsp;- Found $numRecommendations for $isbn from Novelist<br/>");
                 }
                 if ($numRecommendations == 0) {
                     Suggestions::getSimilarlyRatedTitles($db, $ratings, $userId, $allRatedTitles, $suggestions, $notInterestedTitles);
                     //echo("&nbsp;- Found $numRecommendations based on ratings from other users<br/>");
                 }
             }
         }
     }
     //Also get eContent the user has rated highly
     $econtentRatings = new EContentRating();
     $econtentRatings->userId = $userId;
     $econtentRatings->whereAdd('rating >= 3');
     $econtentRatings->orderBy('rating DESC, dateRated DESC');
     $econtentRatings->limit(0, 5);
     $econtentRatings->find();
     //echo("User has rated {$econtentRatings->N} econtent titles<br/>");
     if ($econtentRatings->N > 0) {
         while ($econtentRatings->fetch()) {
             //echo("Processing eContent Rating {$econtentRatings->recordId}<br/>");
             //Load the resource
             $resource = new Resource();
             $resource->record_id = $econtentRatings->recordId;
             $resource->source = 'eContent';
             $resource->find();
             if ($resource->N != 1) {
                 //echo("Did not find resource for $resourceId<br/>");
             } else {
                 $resource->fetch();
                 //echo("Found resource for $resourceId - {$resource->title}<br/>");
                 $ratedTitles[$resource->record_id] = clone $econtentRatings;
                 $numRecommendations = 0;
                 if ($resource->isbn) {
                     //If there is an isbn for the title, we can load similar titles based on Novelist.
                     $isbn = $resource->isbn;
                     $numRecommendations = Suggestions::getNovelistRecommendations($ratings, $isbn, $resource, $allRatedTitles, $suggestions, $notInterestedTitles);
                     //echo("&nbsp;- Found $numRecommendations for $isbn from Novelist<br/>");
                 }
                 if ($numRecommendations == 0) {
                     Suggestions::getSimilarlyRatedTitles($db, $ratings, $userId, $allRatedTitles, $suggestions, $notInterestedTitles);
                     //echo("&nbsp;- Found $numRecommendations based on ratings from other users<br/>");
                 }
             }
         }
     }
     $groupedTitles = array();
     foreach ($suggestions as $suggestion) {
         $groupingTerm = $suggestion['titleInfo']['grouping_term'];
         $groupedTitles[] = $groupingTerm;
     }
     //If the user has not rated anything, return nothing.
     if (count($allLikedRatedTitles) == 0) {
         return array();
     }
     //Get recommendations based on everything I've rated using more like this functionality
     $class = $configArray['Index']['engine'];
     $url = $configArray['Index']['url'];
     /** @var Solr $db */
     $db = new $class($url);
     //$db->debug = true;
     $moreLikeTheseSuggestions = $db->getMoreLikeThese($allLikedRatedTitles);
     //print_r($moreLikeTheseSuggestions);
     if (count($suggestions) < 30) {
         foreach ($moreLikeTheseSuggestions['response']['docs'] as $suggestion) {
             $groupingTerm = $suggestion['grouping_term'];
             if (array_key_exists($groupingTerm, $groupedTitles)) {
                 //echo ($suggestion['grouping_term'] . " is already in the suggestions");
                 continue;
             }
             $groupedTitles[$groupingTerm] = $groupingTerm;
             //print_r($suggestion);
             if (!array_key_exists($suggestion['id'], $allRatedTitles) && !array_key_exists($suggestion['id'], $notInterestedTitles)) {
                 $suggestions[$suggestion['id']] = array('rating' => $suggestion['rating'] - 2.5, 'titleInfo' => $suggestion, 'basedOn' => 'MetaData for all titles rated');
             }
             if (count($suggestions) == 30) {
                 break;
             }
         }
     }
     //print_r($groupedTitles);
     //sort suggestions based on score from ascending to descending
     uasort($suggestions, 'Suggestions::compareSuggestions');
     //Only return up to 50 suggestions to make the page size reasonable
     $suggestions = array_slice($suggestions, 0, 30, true);
     //Return suggestions for use in the user interface.
     return $suggestions;
 }
Ejemplo n.º 30
0
 /**
  * Process parameters and display the page.
  *
  * @return void
  * @access public
  */
 public function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     // Delete List and All Resources (but only if list owner is logged in!)
     if (isset($_POST['deleteList'])) {
         $listID = $_POST['listID'];
         $list = User_list::staticGet($listID);
         if ($user->id == $list->user_id) {
             // Remove the List
             $result = $list->emptyList();
             if ($result) {
                 $followupUrl = $configArray['Site']['url'] . "/MyResearch/Favorites";
                 header("Location: " . $followupUrl . "?infoMsg=fav_list_delete");
                 exit;
             }
         }
         // If we get this far, there's an error
         $this->errorMsg = "fav_list_delete_fail";
     }
     // Fetch List object
     $list = User_list::staticGet($_GET['id']);
     // Ensure user have privs to view the list
     if (!$list->public && !UserAccount::isLoggedIn()) {
         include_once 'Login.php';
         Login::launch();
         exit;
     }
     if (!$list->public && $list->user_id != $user->id) {
         PEAR::raiseError(new PEAR_Error(translate('list_access_denied')));
     }
     // Redirect anonymous users to public list URL
     if ($list->public && (!UserAccount::isLoggedIn() || $list->user_id != $user->id)) {
         header("Location: " . $configArray['Site']['url'] . "/List/" . $list->id);
     }
     $this->infoMsg = isset($_GET['infoMsg']) ? $_GET['infoMsg'] : false;
     $this->errorMsg = isset($_GET['errorMsg']) ? $_GET['errorMsg'] : false;
     $this->showExport = isset($_GET['showExport']) ? $_GET['showExport'] : false;
     // Delete Resource (but only if list owner is logged in!)
     if (isset($_GET['delete']) && $user->id == $list->user_id) {
         $resource = new Resource();
         $resource->record_id = $_GET['delete'];
         unset($resource->source);
         if ($resource->find(true)) {
             $list->removeResource($resource);
         }
     }
     // Send list to template so title/description can be displayed:
     $interface->assign('list', $list);
     // Build Favorites List
     $favorites = $list->getResources(isset($_GET['tag']) ? $_GET['tag'] : null);
     // Load the User object for the owner of the list (if necessary):
     if ($user && $user->id == $list->user_id) {
         $listUser = $user;
     } else {
         $listUser = User::staticGet($list->user_id);
     }
     // Create a handler for displaying favorites and use it to assign
     // appropriate template variables:
     $allowEdit = $user && $user->id == $list->user_id;
     $favList = new FavoriteHandler($favorites, $listUser, $list->id, $allowEdit);
     $favList->assign();
     if (!$this->infoMsg) {
         $this->infoMsg = $favList->getInfoMsg();
     }
     // Narrow by Tag
     if (isset($_GET['tag'])) {
         $interface->assign('tags', $_GET['tag']);
     }
     // Get My Lists
     $listList = $user ? $user->getLists() : array();
     $interface->assign('listList', $listList);
     // Get My Tags
     $tagList = $list->getTags();
     $interface->assign('tagList', $tagList);
     // Assign Error & Info Messages
     $interface->assign('infoMsg', $this->infoMsg);
     $interface->assign('errorMsg', $this->errorMsg);
     $interface->assign('showExport', $this->showExport);
     // Assign Exporter Options
     $exportOptions = array();
     if ($configArray['BulkExport']['enabled']) {
         $options = explode(':', $configArray['BulkExport']['options']);
         foreach ($options as $option) {
             if ($configArray['Export'][$option] == true) {
                 $exportOptions[] = $option;
             }
         }
         $interface->assign('exportOptions', $exportOptions);
     }
     $interface->setTemplate('list.tpl');
     $interface->setPageTitle($list->title);
     $interface->display('layout.tpl');
 }