Exemplo n.º 1
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     global $timer;
     require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
     $overDriveDriver = OverDriveDriverFactory::getDriver();
     $overDriveWishList = $overDriveDriver->getOverDriveWishList($user);
     //Load the full record for each item in the wishlist
     foreach ($overDriveWishList['items'] as $key => $item) {
         if ($item['recordId'] != -1) {
             $econtentRecord = new EContentRecord();
             $econtentRecord->id = $item['recordId'];
             $econtentRecord->find(true);
             $item['record'] = clone $econtentRecord;
         } else {
             $item['record'] = null;
         }
         $item['numRows'] = count($item['formats']) + 1;
         $overDriveWishList['items'][$key] = $item;
     }
     $interface->assign('overDriveWishList', $overDriveWishList['items']);
     if (isset($overDriveWishList['error'])) {
         $interface->assign('error', $overDriveWishList['error']);
     }
     $interface->setTemplate('overDriveWishList.tpl');
     $interface->setPageTitle('OverDrive Wish List');
     $interface->display('layout.tpl');
 }
 function launch()
 {
     global $interface;
     $interface->setPageTitle('eContent Trial Records');
     //Load the list of eContent Reocrds that have more than 4 times as many holds as items
     $eContentRecord = new EContentRecord();
     if (isset($_REQUEST['sourceFilter'])) {
         $sourcesToShow = $_REQUEST['sourceFilter'];
         foreach ($sourcesToShow as $key => $item) {
             $sourcesToShow[$key] = "'" . mysql_escape_string(strip_tags($item)) . "'";
         }
         $sourceRestriction = " WHERE source IN (" . join(",", $sourcesToShow) . ") ";
     }
     $eContentRecord->query("SELECT econtent_record.id, title, author, source, count(DISTINCT econtent_checkout.userId) as numCheckouts FROM econtent_record LEFT JOIN econtent_checkout on econtent_record.id = econtent_checkout.recordId WHERE trialTitle = 1 GROUP BY econtent_record.id");
     $trialRecordsToPurchase = array();
     while ($eContentRecord->fetch()) {
         if ($eContentRecord->numCheckouts > 3) {
             $trialRecordsToPurchase[] = clone $eContentRecord;
         }
     }
     $interface->assign('trialRecordsToPurchase', $trialRecordsToPurchase);
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setTemplate('econtentTrialRecords.tpl');
     $interface->display('layout.tpl');
 }
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     global $timer;
     require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
     $overDriveDriver = OverDriveDriverFactory::getDriver();
     $overDriveCheckedOutItems = $overDriveDriver->getOverDriveCheckedOutItems($user);
     //Load the full record for each item in the wishlist
     foreach ($overDriveCheckedOutItems['items'] as $key => $item) {
         if ($item['recordId'] != -1) {
             $econtentRecord = new EContentRecord();
             $econtentRecord->id = $item['recordId'];
             $econtentRecord->find(true);
             $item['record'] = clone $econtentRecord;
         } else {
             $item['record'] = null;
         }
         $overDriveCheckedOutItems['items'][$key] = $item;
     }
     $interface->assign('overDriveCheckedOutItems', $overDriveCheckedOutItems['items']);
     $interface->assign('ButtonBack', true);
     $interface->assign('ButtonHome', true);
     $interface->assign('MobileTitle', 'OverDrive Checked Out Items');
     $interface->assign('showNotInterested', false);
     global $configArray;
     if (!isset($configArray['OverDrive']['interfaceVersion']) || $configArray['OverDrive']['interfaceVersion'] == 1) {
         $interface->setTemplate('overDriveCheckedOut.tpl');
     } else {
         $interface->setTemplate('overDriveCheckedOut2.tpl');
     }
     $interface->setPageTitle('OverDrive Checked Out Items');
     $interface->display('layout.tpl');
 }
 function launch()
 {
     global $interface;
     global $configArray;
     $purchaseRatio = $configArray['EContent']['holdRatioForPurchase'];
     $interface->setPageTitle('eContent Purchase Alert');
     //Load the list of eContent Reocrds that have more than 4 times as many holds as items
     $eContentRecord = new EContentRecord();
     if (isset($_REQUEST['sourceFilter'])) {
         $sourcesToShow = $_REQUEST['sourceFilter'];
         foreach ($sourcesToShow as $key => $item) {
             $sourcesToShow[$key] = "'" . mysql_escape_string(strip_tags($item)) . "'";
         }
         $sourceRestriction = " WHERE source IN (" . join(",", $sourcesToShow) . ") ";
     }
     $eContentRecord->query("SELECT econtent_record.id, title, author, isbn, ilsId, source, count(econtent_hold.id) as numHolds, availableCopies, onOrderCopies " . "FROM econtent_record " . "LEFT JOIN econtent_hold ON econtent_record.id = econtent_hold.recordId " . "WHERE econtent_hold.status " . "IN ( " . "'active', 'suspended' " . ") " . "GROUP BY econtent_record.id");
     $recordsToPurchase = array();
     while ($eContentRecord->fetch()) {
         $totalCopies = $eContentRecord->availableCopies + $eContentRecord->onOrderCopies;
         if ($eContentRecord->numHolds > $purchaseRatio * $totalCopies) {
             $eContentRecord->totalCopies = $totalCopies;
             $recordsToPurchase[] = clone $eContentRecord;
         }
     }
     $interface->assign('recordsToPurchase', $recordsToPurchase);
     //EXPORT To EXCEL
     if (isset($_REQUEST['exportToExcel'])) {
         $this->exportToExcel($recordsToPurchase);
     }
     $interface->assign('sidebar', 'MyAccount/account-sidebar.tpl');
     $interface->setTemplate('econtentPurchaseAlert.tpl');
     $interface->display('layout.tpl');
 }
Exemplo n.º 5
0
 /**
  * Retrieves the URL for the cover of the record by screen scraping OverDrive.
  * ..
  * @param EContentRecord $record
  * @return string
  */
 public function getCoverUrl($record)
 {
     $overDriveId = $record->getOverDriveId();
     //Get metadata for the record
     $metadata = $this->getProductMetadata($overDriveId);
     if (isset($metadata->images) && isset($metadata->images->cover)) {
         return $metadata->images->cover->href;
     } else {
         return "";
     }
 }
Exemplo n.º 6
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     global $timer;
     require_once ROOT_DIR . '/Drivers/OverDriveDriverFactory.php';
     $overDriveDriver = OverDriveDriverFactory::getDriver();
     $overDriveHolds = $overDriveDriver->getOverDriveHolds($user);
     //Load the full record for each item in the wishlist
     foreach ($overDriveHolds['holds'] as $sectionKey => $sectionData) {
         foreach ($sectionData as $key => $item) {
             if ($item['recordId'] != -1) {
                 $econtentRecord = new EContentRecord();
                 $econtentRecord->id = $item['recordId'];
                 $econtentRecord->find(true);
                 $item['record'] = clone $econtentRecord;
             } else {
                 $item['record'] = null;
             }
             if ($sectionKey == 'available') {
                 if (isset($item['formats'])) {
                     $item['numRows'] = count($item['formats']) + 1;
                 }
             }
             $overDriveHolds['holds'][$sectionKey][$key] = $item;
         }
     }
     $interface->assign('overDriveHolds', $overDriveHolds['holds']);
     $interface->assign('ButtonBack', true);
     $interface->assign('ButtonHome', true);
     $interface->assign('MobileTitle', 'OverDrive Holds');
     $hasSeparateTemplates = $interface->template_exists('MyResearch/overDriveAvailableHolds.tpl');
     if ($hasSeparateTemplates) {
         $section = isset($_REQUEST['section']) ? $_REQUEST['section'] : 'available';
         if ($section == 'available') {
             $interface->setPageTitle('Available Holds from OverDrive');
             if (!isset($configArray['OverDrive']['interfaceVersion']) || $configArray['OverDrive']['interfaceVersion'] == 1) {
                 $interface->setTemplate('overDriveAvailableHolds.tpl');
             } else {
                 $interface->setTemplate('overDriveAvailableHolds2.tpl');
             }
         } else {
             $interface->setPageTitle('On Hold in OverDrive');
             $interface->setTemplate('overDriveUnavailableHolds.tpl');
         }
     } else {
         $interface->setTemplate('overDriveHolds.tpl');
         $interface->setPageTitle('OverDrive Holds');
     }
     $interface->display('layout.tpl');
 }
Exemplo n.º 7
0
 function getSourceFilter()
 {
     $eContentRecord = new EContentRecord();
     //Populate the Source Filter
     $querySourceFilter = "select distinct source from econtent_record where econtent_record.id not in (select recordId from econtent_item) and status = 'active' " . "ORDER BY source ASC";
     $eContentRecord->query($querySourceFilter);
     $resultsSourceFilter = array();
     $i = 0;
     while ($eContentRecord->fetch()) {
         $tmp = array('SourceValue' => $eContentRecord->source);
         $resultsSourceFilter[$i++] = $tmp;
     }
     return $resultsSourceFilter;
 }
Exemplo n.º 8
0
 function launch()
 {
     global $configArray;
     global $interface;
     global $user;
     //Build the actual view
     $interface->setTemplate('../Record/view-series.tpl');
     $eContentRecord = new EContentRecord();
     $id = strip_tags($_REQUEST['id']);
     $eContentRecord->id = $id;
     $eContentRecord->find(true);
     require_once 'Enrichment.php';
     $enrichment = new EcontentRecord_Enrichment();
     $enrichmentData = $enrichment->loadEnrichment($eContentRecord->getIsbn());
     $seriesTitle = '';
     $seriesAuthors = array();
     $seriesTitles = array();
     $resourceList = array();
     if (isset($enrichmentData['novelist']) && isset($enrichmentData['novelist']['series'])) {
         $seriesTitles = $enrichmentData['novelist']['series'];
         //Loading the series title is not reliable.  Do not try to load it.
         if (isset($seriesTitles) && is_array($seriesTitles)) {
             foreach ($seriesTitles as $title) {
                 if (isset($title['series']) && strlen($title['series']) > 0 && !isset($seriesTitle)) {
                     $seriesTitle = $title['series'];
                     $interface->assign('seriesTitle', $seriesTitle);
                 }
                 if (isset($title['author'])) {
                     $seriesAuthors[$title['author']] = $title['author'];
                 }
                 if ($title['libraryOwned']) {
                     $record = RecordDriverFactory::initRecordDriver($title);
                     $resourceList[] = $interface->fetch($record->getSearchResult($user, null, false));
                 } else {
                     $interface->assign('record', $title);
                     $resourceList[] = $interface->fetch('RecordDrivers/Index/nonowned_result.tpl');
                 }
             }
         }
     }
     $interface->assign('seriesAuthors', $seriesAuthors);
     $interface->assign('recordSet', $seriesTitles);
     $interface->assign('resourceList', $resourceList);
     $interface->assign('recordStart', 1);
     $interface->assign('recordEnd', count($seriesTitles));
     $interface->assign('recordCount', count($seriesTitles));
     $interface->setPageTitle($seriesTitle);
     // Display Page
     $interface->display('layout.tpl');
 }
Exemplo n.º 9
0
 function launch()
 {
     global $configArray;
     global $interface;
     $libraryName = $configArray['Site']['title'];
     //Grab the tracking data
     $store = urldecode(strip_tags($_GET['store']));
     $recordId = $_REQUEST['id'];
     $ipAddress = $_SERVER['REMOTE_ADDR'];
     // Retrieve Full Marc Record
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $recordId;
     if (!$eContentRecord->find(true)) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $title = str_replace("/", "", $eContentRecord->title);
     if ($eContentRecord->purchaseUrl == null) {
         switch ($store) {
             case "Tattered Cover":
                 $purchaseLinkUrl = "http://www.tatteredcover.com/search/apachesolr_search/" . urlencode($title) . "?source=" . urlencode($libraryName);
                 break;
             case "Barnes and Noble":
                 $purchaseLinkUrl = "http://www.barnesandnoble.com/s/?title=" . urlencode($title) . "&source=" . urlencode($libraryName);
                 break;
             case "Amazon":
                 $purchaseLinkUrl = "http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=" . urlencode($title) . "&source=" . urlencode($libraryName);
                 break;
         }
     } else {
         // Process MARC Data
         $purchaseLinkUrl = $eContentRecord->purchaseUrl;
     }
     //Do not track purchases from Bots
     require_once ROOT_DIR . '/sys/BotChecker.php';
     if (!BotChecker::isRequestFromBot()) {
         require_once ROOT_DIR . '/sys/PurchaseLinkTracking.php';
         $tracking = new PurchaseLinkTracking();
         $tracking->ipAddress = $ipAddress;
         $tracking->recordId = 'econtentRecord' . $recordId;
         $tracking->store = $store;
         $insertResult = $tracking->insert();
     }
     //redirects them to the link they clicked
     if ($purchaseLinkUrl != "") {
         header("Location:" . $purchaseLinkUrl);
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error("Failed to load link for this title."));
     }
 }
Exemplo n.º 10
0
 public function getCitation($format)
 {
     require_once ROOT_DIR . '/sys/CitationBuilder.php';
     // Build author list:
     $authors = array();
     $primary = $this->eContentRecord->author;
     if (!empty($primary)) {
         $authors[] = $primary;
     }
     $authors = array_unique(array_merge($authors, $this->eContentRecord->getPropertyArray('author2')));
     // Collect all details for citation builder:
     $publishers = array($this->eContentRecord->publisher);
     $pubDates = $this->eContentRecord->getPropertyArray('publishDate');
     $pubPlaces = array();
     $details = array('authors' => $authors, 'title' => $this->eContentRecord->title, 'subtitle' => $this->eContentRecord->subTitle, 'pubPlace' => count($pubPlaces) > 0 ? $pubPlaces[0] : null, 'pubName' => count($publishers) > 0 ? $publishers[0] : null, 'pubDate' => count($pubDates) > 0 ? $pubDates[0] : null, 'edition' => $this->eContentRecord->getPropertyArray('edition'), 'source' => $this->eContentRecord->source, 'format' => $this->eContentRecord->format());
     // Build the citation:
     $citation = new CitationBuilder($details);
     switch ($format) {
         case 'APA':
             return $citation->getAPA();
         case 'MLA':
             return $citation->getMLA();
         case 'AMA':
             return $citation->getAMA();
         case 'ChicagoAuthDate':
             return $citation->getChicagoAuthDate();
         case 'ChicagoHumanities':
             return $citation->getChicagoHumanities();
     }
     return '';
 }
Exemplo n.º 11
0
 function launch()
 {
     global $interface;
     $id = $_REQUEST['id'];
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $id;
     $eContentRecord->find(true);
     $goDeeperOptions = GoDeeperData::getGoDeeperOptions($eContentRecord->getIsbn(), $eContentRecord->upc, true);
     $interface->assign('options', $goDeeperOptions['options']);
     if (isset($goDeeperOptions['defaultOption'])) {
         $defaultData = GoDeeperData::getHtmlData($goDeeperOptions['defaultOption'], 'eContentRecord', $eContentRecord->getIsbn(), $eContentRecord->upc);
         $interface->assign('defaultGoDeeperData', $defaultData);
     }
     $interface->assign('title', translate("Additional information about this title"));
     echo $interface->fetch('Record/goDeeper.tpl');
 }
Exemplo n.º 12
0
 /**
  * @param array $record An array of record data from Solr
  * @return File_MARC_Record
  */
 public static function loadMarcRecordFromRecord($record)
 {
     if ($record['recordtype'] == 'marc') {
         return MarcLoader::loadMarcRecordByILSId($record['id'], $record['recordtype']);
     } elseif ($record['recordtype'] == 'econtentRecord') {
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $econtentRecord = new EContentRecord();
         $econtentRecord->id = $record['id'];
         if ($econtentRecord->find(true)) {
             return MarcLoader::loadMarcRecordByILSId($econtentRecord->ilsId, $record['recordtype']);
         } else {
             return null;
         }
     } else {
         return null;
     }
 }
Exemplo n.º 13
0
 public function getRecordsListAvgRating($orderBy = "DESC", $limit = 30)
 {
     SwitchDatabase::switchToEcontent();
     $records = array();
     $sql = "SELECT ei.*, AVG(rating) as rate\n\t\t\t\tFROM econtent_rating er join econtent_item ei on er.recordId = ei.id\n\t\t\t\tWHERE 1 GROUP BY recordId ORDER BY rate " . $orderBy . ", recordId DESC LIMIT " . $limit;
     $result = mysql_query($sql);
     while ($row = mysql_fetch_assoc($result)) {
         unset($row['rate']);
         $econtentRecord = new EContentRecord();
         $econtentRecord->get($row['id']);
         $econtentRecord->setFrom($row, '');
         $records[] = $econtentRecord;
         unset($econtentRecord);
     }
     SwitchDatabase::restoreDatabase();
     return $records;
 }
Exemplo n.º 14
0
 function launch()
 {
     global $interface;
     global $user;
     global $configArray;
     // Process Delete Comment
     if (isset($_GET['delete']) && is_object($user)) {
         $comment = new Comments();
         $comment->id = $_GET['delete'];
         if ($comment->find(true)) {
             if ($user->id == $comment->user_id) {
                 $comment->delete();
             }
         }
     }
     $interface->assign('id', $_GET['id']);
     if (isset($_REQUEST['comment'])) {
         if (!$user) {
             $interface->assign('recordId', $_GET['id']);
             $interface->assign('comment', $_REQUEST['comment']);
             $interface->assign('followup', true);
             $interface->assign('followupModule', 'EContentRecord');
             $interface->assign('followupAction', 'UserComments');
             $interface->setPageTitle('You must be logged in first');
             $interface->assign('subTemplate', '../MyResearch/login.tpl');
             $interface->setTemplate('view-alt.tpl');
             $interface->display('layout.tpl', 'UserComments' . $_GET['id']);
             exit;
         }
         $result = $this->saveComment();
     }
     $interface->assign('user', $user);
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $_GET['id'];
     $eContentRecord->find(true);
     $recordDriver = new EcontentRecordDriver();
     $recordDriver->setDataObject($eContentRecord);
     $interface->setPageTitle(translate('Comments') . ': ' . $recordDriver->getBreadcrumb());
     $this->loadEContentComments();
     $interface->assign('subTemplate', 'view-comments.tpl');
     $interface->setTemplate('view.tpl');
     // Display Page
     $interface->display('layout.tpl');
 }
 function launch()
 {
     global $interface;
     $interface->setPageTitle('eContent WishList');
     //Load the list of eContent Records that people have added to their wishlist
     $eContentRecord = new EContentRecord();
     $eContentRecord->query("SELECT econtent_record.id, title, author, source, ilsId, isbn, count(DISTINCT econtent_wishlist.userId) as numWishList FROM econtent_record INNER JOIN econtent_wishlist on econtent_record.id = econtent_wishlist.recordId WHERE econtent_wishlist.status = 'active' GROUP BY econtent_record.id ORDER BY numWishList DESC, title ASC");
     $recordsOnWishList = array();
     while ($eContentRecord->fetch()) {
         $recordsOnWishList[] = clone $eContentRecord;
     }
     $interface->assign('recordsOnWishList', $recordsOnWishList);
     //EXPORT To EXCEL
     if (isset($_REQUEST['exportToExcel'])) {
         $this->exportToExcel($recordsOnWishList);
     }
     $interface->setTemplate('econtentWishlist.tpl');
     $interface->display('layout.tpl');
 }
Exemplo n.º 16
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     $recordId = $_REQUEST['id'];
     $quick = isset($_REQUEST['quick']) ? true : false;
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $recordId;
     if ($eContentRecord->find(true)) {
         $ret = $eContentRecord->saveToSolr($quick);
         if ($ret) {
             echo json_encode(array("success" => true));
         } else {
             echo json_encode(array("success" => false, "error" => "Could not update solr"));
         }
     } else {
         echo json_encode(array("success" => false, "error" => "Could not find a record with that id"));
     }
 }
Exemplo n.º 17
0
 function sendEmail($to, $from, $message)
 {
     global $interface;
     global $configArray;
     $id = $_REQUEST['id'];
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $id;
     $eContentRecord->find(true);
     $subject = translate("Library Catalog Record") . ": " . $eContentRecord->title;
     $interface->assign('from', $from);
     $emailDetails = $eContentRecord->title . "\n";
     if (strlen($eContentRecord->author) > 0) {
         $emailDetails .= "by: {$eContentRecord->author}\n";
     }
     $interface->assign('emailDetails', $emailDetails);
     $interface->assign('id', $id);
     $interface->assign('message', $message);
     $body = $interface->fetch('Emails/eContent-record.tpl');
     $mail = new VuFindMailer();
     return $mail->send($to, $configArray['Site']['email'], $subject, $body, $from);
 }
Exemplo n.º 18
0
 function launch()
 {
     global $interface;
     global $configArray;
     $eContentRecord = EContentRecord::staticGet('id', $_REQUEST['id']);
     $eContentRecord->status = 'deleted';
     $eContentRecord->date_updated = time();
     $eContentRecord->update();
     //Redirect back to the PMDA home page
     header('Location:' . $configArray['Site']['path'] . "/");
     exit;
 }
Exemplo n.º 19
0
 function launch()
 {
     global $configArray;
     global $interface;
     //Grab the tracking data
     $recordId = $_REQUEST['id'];
     $ipAddress = $_SERVER['REMOTE_ADDR'];
     $itemId = $_REQUEST['itemId'];
     // Retrieve Full Marc Record
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $recordId;
     if (!$eContentRecord->find(true)) {
         PEAR_Singleton::raiseError(new PEAR_Error('Record Does Not Exist'));
     }
     $eContentItem = new EContentItem();
     $eContentItem->id = $itemId;
     if (!$eContentItem->find(true)) {
         PEAR_Singleton::raiseError(new PEAR_Error('Item Does Not Exist'));
     }
     $linkUrl = $eContentItem->link;
     $linkParts = parse_url($linkUrl);
     $title = str_replace("/", "", $eContentRecord->title);
     //Insert into the externalLinkTracking table
     require_once ROOT_DIR . '/sys/BotChecker.php';
     if (!BotChecker::isRequestFromBot()) {
         require_once ROOT_DIR . '/sys/ExternalLinkTracking.php';
         $externalLinkTracking = new ExternalLinkTracking();
         $externalLinkTracking->ipAddress = $ipAddress;
         $externalLinkTracking->recordId = "econtentRecord" . $recordId;
         $externalLinkTracking->linkUrl = $linkUrl;
         $externalLinkTracking->linkHost = $linkParts['host'];
         $result = $externalLinkTracking->insert();
     }
     //redirects them to the link they clicked
     if ($linkUrl != "") {
         header("Location:" . $linkUrl);
     } else {
         PEAR_Singleton::raiseError(new PEAR_Error("Failed to load link for this title."));
     }
 }
Exemplo n.º 20
0
 function launch()
 {
     global $interface;
     global $configArray;
     global $user;
     //If the user isn't logged in, take them to the login page
     if (!$user) {
         header("Location: {$configArray['Site']['path']}/MyAccount/Login");
         die;
     }
     //Make sure the user has permission to access the page
     if (!$user->hasRole('epubAdmin')) {
         $interface->setTemplate('../Admin/noPermission.tpl');
         $interface->display('layout.tpl');
         exit;
     }
     $structure = EContentRecord::getObjectStructure();
     if (isset($_REQUEST['submitStay']) || isset($_REQUEST['submit']) || isset($_REQUEST['submitReturnToList']) || isset($_REQUEST['submitAddAnother'])) {
         //Save the object
         $results = DataObjectUtil::saveObject($structure, 'EContentRecord');
         $eContentRecord = $results['object'];
         //redirect to the view of the eContentRecord if we saved ok.
         if (!$results['validatedOk'] || !$results['saveOk']) {
             //Display the errors for the user.
             $interface->assign('errors', $results['errors']);
             $interface->assign('object', $eContentRecord);
             $_REQUEST['id'] = ${$eContentRecord}->id;
         } else {
             //Show the new tip that was created
             header('Location:' . $configArray['Site']['path'] . "/EcontentRecord/{$eContentRecord->id}/Home");
             exit;
         }
     }
     $isNew = true;
     if (isset($_REQUEST['id']) && strlen($_REQUEST['id']) > 0 && is_numeric($_REQUEST['id'])) {
         $object = EContentRecord::staticGet('id', strip_tags($_REQUEST['id']));
         $interface->assign('object', $object);
         $interface->setPageTitle('Edit EContentRecord');
         $isNew = false;
     } else {
         $interface->setPageTitle('Submit a New EContentRecord');
     }
     //Manipulate the structure as needed
     if ($isNew) {
     } else {
     }
     $interface->assign('isNew', $isNew);
     $interface->assign('submitUrl', $configArray['Site']['path'] . '/EcontentRecord/Edit');
     $interface->assign('editForm', DataObjectUtil::getEditForm($structure));
     $interface->setTemplate('edit.tpl');
     $interface->display('layout.tpl');
 }
Exemplo n.º 21
0
 function loadCollectionSummary()
 {
     $collectionSummary = array();
     $epubFile = new EContentRecord();
     $query = "SELECT COUNT(DISTINCT id) as numTitles FROM `econtent_record` where status = 'active'";
     $epubFile->query($query);
     if ($epubFile->N > 0) {
         $epubFile->fetch();
         $collectionSummary['numTitles'] = $epubFile->numTitles;
     }
     $statsByDRM = new EContentRecord();
     $query = "SELECT accessType, COUNT(DISTINCT id) as numTitles FROM `econtent_record` where status = 'active' GROUP BY accessType ORDER BY accessType ASC";
     $statsByDRM->query($query);
     while ($statsByDRM->fetch()) {
         $collectionSummary['statsByDRM'][$statsByDRM->accessType] = $statsByDRM->numTitles;
     }
     $statsBySource = new EContentRecord();
     $query = "SELECT source, COUNT(DISTINCT id) as numTitles FROM `econtent_record` where status = 'active' GROUP BY source ORDER BY source ASC";
     $statsBySource->query($query);
     while ($statsBySource->fetch()) {
         $collectionSummary['statsBySource'][$statsBySource->source] = $statsBySource->numTitles;
     }
     return $collectionSummary;
 }
Exemplo n.º 22
0
 function sendSMS()
 {
     global $configArray;
     global $interface;
     // Get Holdings
     $driver = new EContentDriver();
     $id = strip_tags($_REQUEST['id']);
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $id;
     $eContentRecord->find(true);
     $holdings = $driver->getHolding($id);
     $holdingsSummary = $driver->getStatusSummary($id, $holdings);
     if (PEAR_Singleton::isError($holdingsSummary)) {
         return $holdingsSummary;
     }
     if ($holdingsSummary['status']) {
         $interface->assign('status', $holdingsSummary['status']);
     }
     $interface->assign('title', $eContentRecord->title);
     $interface->assign('author', $eContentRecord->author);
     $interface->assign('recordID', $_GET['id']);
     $message = $interface->fetch('Emails/eContent-sms.tpl');
     return $this->sms->text($_REQUEST['provider'], $_REQUEST['to'], $configArray['Site']['email'], $message);
 }
Exemplo n.º 23
0
 function launch()
 {
     global $interface;
     global $configArray;
     $results = array();
     $epubFile = new EContentItem();
     $currentPage = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1;
     $recordsPerPage = 25;
     $searchUrl = $configArray['Site']['path'] . '/EContent/Search';
     $searchParams = array();
     foreach ($_REQUEST as $key => $value) {
         if (!in_array($key, array('module', 'action', 'page'))) {
             $searchParams[] = "{$key}={$value}";
         }
     }
     $searchUrl = $searchUrl . '?page=%d&' . implode('&', $searchParams);
     $interface->assign('page', $currentPage);
     $epubFile = new EContentRecord();
     if (isset($_REQUEST['sortOptions'])) {
         $epubFile->orderBy($_REQUEST['sortOptions']);
         $interface->assign('sort', $_REQUEST['sortOptions']);
     }
     $numTotalFiles = $epubFile->count();
     $epubFile->limit(($currentPage - 1) * $recordsPerPage, 20);
     $epubFile->find();
     if ($epubFile->N > 0) {
         while ($epubFile->fetch()) {
             $results[] = clone $epubFile;
         }
     }
     $interface->assign('results', $results);
     $options = array('totalItems' => $numTotalFiles, 'fileName' => $searchUrl, 'perPage' => $recordsPerPage);
     $pager = new VuFindPager($options);
     $interface->assign('pageLinks', $pager->getLinks());
     $interface->setTemplate('search.tpl');
     $interface->display('layout.tpl');
 }
Exemplo n.º 24
0
 function update()
 {
     //Check to see if we are adding copies.
     //If so, we wil need to process the hold queue after
     //The tile is saved
     $currentValue = new EContentRecord();
     $currentValue->id = $this->id;
     $currentValue->find(true);
     //Don't update solr, rely on the nightly reindex
     $ret = parent::update();
     if ($ret) {
         $this->clearCachedCover();
         if ($currentValue->N == 1 && $currentValue->availableCopies != $this->availableCopies) {
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $eContentDriver = new EContentDriver();
             $eContentDriver->processHoldQueue($this->id);
         }
     }
     return $ret;
 }
Exemplo n.º 25
0
 function launch()
 {
     global $interface;
     global $configArray;
     $id = $_REQUEST['id'];
     $interface->assign('id', $id);
     $item = $_REQUEST['item'];
     $interface->assign('item', $item);
     $viewer = 'custom';
     $errorOccurred = false;
     if ($this->user == false) {
         $interface->assign('errorMessage', 'User is not logged in.');
         $errorOccurred = true;
         $interface->assign('showLogin', true);
     } else {
         require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
         $eContentRecord = new EContentRecord();
         $eContentRecord->id = $id;
         if ($eContentRecord->find(true)) {
             //Check the database to see if there is an existing title
             require_once ROOT_DIR . '/sys/eContent/EContentItem.php';
             $eContentItem = new EContentItem();
             $eContentItem->id = $_REQUEST['item'];
             if ($eContentItem->find(true)) {
                 $bookFile = null;
                 $libraryPath = $configArray['EContent']['library'];
                 if ($eContentItem->item_type == 'mp3') {
                     $bookFile = "{$libraryPath}/{$eContentItem->folder}";
                 } else {
                     $bookFile = "{$libraryPath}/{$eContentItem->filename}";
                 }
                 if (!file_exists($bookFile)) {
                     $bookFile = null;
                 }
             }
         } else {
             $errorOccurred = true;
             $interface->assign('errorMessage', 'Could not find the selected title.');
         }
         if (file_exists($bookFile) && $errorOccurred == false) {
             require_once ROOT_DIR . '/Drivers/EContentDriver.php';
             $driver = new EContentDriver();
             //Check to see if the user has access to the title.
             $isCheckedOut = $driver->isRecordCheckedOutToUser($id);
             if (!$isCheckedOut) {
                 $errorOccurred = true;
                 $interface->assign('errorMessage', "Sorry, you do not have access to that title, please <a href='{$configArray['Site']['path']}/Record/{$id}/Hold'>place a hold</a> on the title and you will be notified when it is ready for pickup.");
             }
             if (!$errorOccurred) {
                 //Record that the e-pub file is being opened.
                 if (strcasecmp($eContentItem->item_type, 'epub') === 0) {
                     $driver->recordEContentAction($id, "Read Online", $eContentRecord->accessType);
                     require_once ROOT_DIR . '/sys/eReader/ebook.php';
                     $ebook = new ebook($bookFile);
                     if ($ebook->readErrorOccurred()) {
                         $errorOccurred = true;
                         $interface->assign('errorMessage', $ebook->readError());
                     } else {
                         $spineInfo = $ebook->getSpine();
                         $toc = $ebook->getTOC();
                         if ($viewer == 'monocle') {
                             $spineData = addslashes(json_encode($spineInfo));
                             $interface->assign('spineData', $spineData);
                             $contents = addslashes(json_encode($toc));
                             $interface->assign('contents', $contents);
                             $metaData = addslashes(json_encode(array("title" => $ebook->getTitle(), "creator" => $ebook->getDcCreator())));
                             $interface->assign('metaData', $metaData);
                         } else {
                             $interface->assign('spineData', $spineInfo);
                             $interface->assign('contents', $toc);
                             $interface->assign('bookCreator', $ebook->getDcCreator());
                             //Load a translation map to translate locations into ids
                             $manifest = array();
                             for ($i = 0; $i < $ebook->getManifestSize(); $i++) {
                                 $manifestId = $ebook->getManifestItem($i, 'id');
                                 $manifestHref = $ebook->getManifestItem($i, 'href');
                                 $manifestType = $ebook->getManifestItem($i, 'type');
                                 $manifest[$manifestHref] = $manifestId;
                             }
                             $interface->assign('manifest', $manifest);
                         }
                         $interface->assign('bookTitle', $ebook->getTitle());
                         $errorOccurred = false;
                     }
                 } else {
                     if ($eContentItem->item_type == 'mp3') {
                         //Display information so patron can listen to the recording.
                         //Table of contents is based on the actual files uploaded.
                         $viewer = 'mp3';
                         $dirHnd = opendir($bookFile);
                         $mp3Files = array();
                         while (false !== ($file = readdir($dirHnd))) {
                             if (preg_match('/^.*?\\.mp3$/i', $file)) {
                                 $mp3Files[] = preg_replace('/\\.mp3/i', '', $file);
                             }
                         }
                         $files = readdir($dirHnd);
                         closedir($dirHnd);
                         //Sort the mp3 files by name.
                         sort($mp3Files);
                         $interface->assign('mp3Filenames', $mp3Files);
                     } else {
                         $errorOccurred = true;
                         $interface->assign('errorMessage', "Sorry, we could not find a viewer for that type of item, please contact support.");
                     }
                 }
             }
         } else {
             $errorOccurred = true;
             $interface->assign('errorMessage', 'Sorry, we could not find that book in our online library.');
         }
     }
     $interface->assign('errorOccurred', $errorOccurred);
     if ($viewer == 'mp3') {
         $interface->display('EcontentRecord/viewer-mp3.tpl');
     } else {
         $interface->display('EcontentRecord/viewer-custom.tpl');
     }
 }
Exemplo n.º 26
0
 /**
  * Places a hold on an item within OverDrive
  *
  * @param string $overDriveId
  * @param int $format
  * @param User $user
  *
  * @return array (result, message)
  */
 public function placeOverDriveHold($overDriveId, $format, $user)
 {
     /** @var Memcache $memCache */
     global $memCache;
     global $configArray;
     global $logger;
     $holdResult = array();
     $holdResult['result'] = false;
     $holdResult['message'] = '';
     $ch = curl_init();
     $overDriveInfo = $this->_loginToOverDrive($ch, $user);
     if ($overDriveInfo['result'] == false) {
         $holdResult = $overDriveInfo;
     } else {
         //Switch back to get method
         curl_setopt($overDriveInfo['ch'], CURLOPT_HTTPGET, true);
         //Open the record page
         $contentInfoPage = $overDriveInfo['contentInfoPage'] . "?ID=" . $overDriveId;
         curl_setopt($overDriveInfo['ch'], CURLOPT_URL, $contentInfoPage);
         $recordPage = curl_exec($overDriveInfo['ch']);
         curl_getinfo($overDriveInfo['ch']);
         $logger->log("View record " . $contentInfoPage, PEAR_LOG_DEBUG);
         //Navigate to place a hold page
         $waitingListUrl = $overDriveInfo['waitingListUrl'];
         if ($format == "" || $format == 'undefined') {
             if (preg_match('/<a href="BANGAuthenticate\\.dll\\?Action=AuthCheck&ForceLoginFlag=0&URL=WaitingListForm.htm%3FID=(.*?)%26Format=(.*?)" class="radius large button details-title-button" data-checkedout="(.*?)" data-contentstatus="(.*?)">Place a Hold<\\/a>/si', $recordPage, $formatInfo)) {
                 $format = $formatInfo[2];
             } else {
                 $logger->log("Did not find hold button for this title to retrieve format", PEAR_LOG_INFO);
                 $holdResult['result'] = false;
                 $holdResult['message'] = "This title is available for checkout.";
                 $holdResult['availableForCheckout'] = true;
                 return $holdResult;
             }
         }
         $waitingListUrl .= '%3FID=' . $overDriveId . '%26Format=' . $format;
         //echo($waitingListUrl . "\r\n");
         curl_setopt($overDriveInfo['ch'], CURLOPT_URL, $waitingListUrl);
         $logger->log("Click place a hold button " . $waitingListUrl, PEAR_LOG_DEBUG);
         $setEmailPage = curl_exec($overDriveInfo['ch']);
         $setEmailPageInfo = curl_getinfo($ch);
         if (preg_match('/already placed a hold or borrowed this title/', $setEmailPage)) {
             $holdResult['result'] = false;
             $holdResult['message'] = "We're sorry, but you are already on the waiting list for the selected title or have it checked out.";
         } else {
             $secureBaseUrl = preg_replace('~[^/.]+?.htm.*~', '', $setEmailPageInfo['url']);
             //Login (again)
             curl_setopt($overDriveInfo['ch'], CURLOPT_POST, true);
             $barcodeProperty = isset($configArray['Catalog']['barcodeProperty']) ? $configArray['Catalog']['barcodeProperty'] : 'cat_username';
             $barcode = $user->{$barcodeProperty};
             $postParams = array('LibraryCardNumber' => $barcode, 'URL' => 'MyAccount.htm');
             if (isset($configArray['OverDrive']['LibraryCardILS']) && strlen($configArray['OverDrive']['LibraryCardILS']) > 0) {
                 $postParams['LibraryCardILS'] = $configArray['OverDrive']['LibraryCardILS'];
             }
             $post_items = array();
             foreach ($postParams as $key => $value) {
                 $post_items[] = $key . '=' . urlencode($value);
             }
             $post_string = implode('&', $post_items);
             curl_setopt($overDriveInfo['ch'], CURLOPT_POSTFIELDS, $post_string);
             curl_setopt($overDriveInfo['ch'], CURLOPT_URL, $secureBaseUrl . 'BANGAuthenticate.dll');
             $waitingListPage = curl_exec($overDriveInfo['ch']);
             $waitingListPageInfo = curl_getinfo($overDriveInfo['ch']);
             //echo($waitingListPage);
             if (preg_match('/already on/', $waitingListPage)) {
                 $holdResult['result'] = false;
                 $holdResult['message'] = "We're sorry, but you are already on the waiting list for the selected title or have it checked out.";
             } else {
                 //Get the format from the form
                 //Fill out the email address to use for notification
                 //echo($user->overdriveEmail . "\r\n");
                 $postParams = array('ID' => $overDriveId, 'Format' => $format, 'URL' => 'WaitingListConfirm.htm', 'Email' => $user->overdriveEmail, 'Email2' => $user->overdriveEmail);
                 $post_items = array();
                 foreach ($postParams as $key => $value) {
                     $post_items[] = $key . '=' . urlencode($value);
                 }
                 $post_string = implode('&', $post_items);
                 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
                 curl_setopt($overDriveInfo['ch'], CURLOPT_URL, $secureBaseUrl . "BANGAuthenticate.dll?Action=LibraryWaitingList");
                 $waitingListConfirm = curl_exec($overDriveInfo['ch']);
                 $logger->log("Submitting email for notification {$secureBaseUrl}BANGAuthenticate.dll?Action=LibraryWaitingList  {$post_string}", PEAR_LOG_INFO);
                 //$logger->log($waitingListConfirm, PEAR_LOG_INFO);
                 $waitingListConfirm = strip_tags($waitingListConfirm, "'<p><a><li><ul><div><em><b>'");
                 if (preg_match('/<section id="mainContent" class=".*?">(.*?)<\\/section>/is', $waitingListConfirm, $matches)) {
                     $logger->log("Found main content section", PEAR_LOG_INFO);
                     $mainSection = $matches[1];
                     if (preg_match('/already on/si', $mainSection)) {
                         $holdResult['result'] = false;
                         $holdResult['message'] = 'This title is already on hold or checked out to you.';
                     } elseif (preg_match('/did not complete all of the required fields/', $mainSection)) {
                         $holdResult['result'] = false;
                         $holdResult['message'] = 'You must provide an e-mail address to request titles from OverDrive.  Please add an e-mail address to your profile.';
                     } elseif (preg_match('/reached the request \\(hold\\) limit of \\d+ titles./', $mainSection)) {
                         $holdResult['result'] = false;
                         $holdResult['message'] = 'You have reached the maximum number of holds for your account.';
                     } elseif (preg_match('/Some of our digital titles are only available for a limited time\\. This title may be available in the future\\. Be sure to check back/', $waitingListConfirm)) {
                         $holdResult['result'] = false;
                         $holdResult['message'] = 'This title is no longer available.  Some of our digital titles are only available for a limited time. This title may be available in the future. Be sure to check back.';
                     } else {
                         $holdResult['result'] = false;
                         $holdResult['message'] = 'There was an error placing your hold.';
                         global $logger;
                         $logger->log("Placing hold on OverDrive item. OverDriveId " . $overDriveId, PEAR_LOG_INFO);
                         $logger->log('URL: ' . $secureBaseUrl . "BANGAuthenticate.dll?Action=LibraryWaitingList {$post_string}\r\n" . $mainSection, PEAR_LOG_INFO);
                     }
                 } elseif (preg_match('/Unfortunately this title is not available to your library at this time./', $waitingListConfirm)) {
                     $holdResult['result'] = false;
                     $holdResult['message'] = 'This title is not available to your library at this time.';
                 } elseif (preg_match('/You will receive an email when the title becomes available./', $waitingListConfirm)) {
                     $holdResult['result'] = true;
                     $holdResult['message'] = 'Your hold was placed successfully.';
                     $memCache->delete('overdrive_summary_' . $user->id);
                     //Record that the entry was checked out in strands
                     global $configArray;
                     if (isset($configArray['Strands']['APID']) && $user->disableRecommendations == 0) {
                         //Get the record for the item
                         $eContentRecord = new EContentRecord();
                         $eContentRecord->whereAdd("sourceUrl like '%{$overDriveId}'");
                         if ($eContentRecord->find(true)) {
                             $orderId = $user->id . '_' . time();
                             $strandsUrl = "http://bizsolutions.strands.com/api2/event/addshoppingcart.sbs?needresult=true&apid={$configArray['Strands']['APID']}&item=econtentRecord{$eContentRecord->id}::0.00::1&user={$user->id}&orderid={$orderId}";
                             $ret = file_get_contents($strandsUrl);
                             /*global $logger;
                             		$logger->log("Strands Hold\r\n$ret", PEAR_LOG_INFO);*/
                         }
                     }
                     //Delete the cache for the record
                     $memCache->delete('overdrive_record_' . $overDriveId);
                 } else {
                     global $logger;
                     $holdResult['result'] = false;
                     $holdResult['message'] = 'Unknown error placing your hold.';
                     $logger->log("Placing hold on OverDrive item. OverDriveId " . $overDriveId, PEAR_LOG_INFO);
                     $logger->log('URL: ' . $secureBaseUrl . "BANGAuthenticate.dll?Action=LibraryWaitingList {$post_string}\r\n" . $waitingListConfirm, PEAR_LOG_INFO);
                 }
             }
         }
     }
     curl_close($ch);
     return $holdResult;
 }
Exemplo n.º 27
0
 /**
  * Get econtent information for a title.
  *
  * @param EContentRecord $eContentRecord
  * @return array
  */
 private function setEcontentRecordInfoForList($eContentRecord)
 {
     global $configArray;
     return array('id' => 'econtentRecord' . $eContentRecord->id, 'image' => $configArray['Site']['coverUrl'] . "/bookcover.php?id=" . $eContentRecord->id . "&issn=" . $eContentRecord->getissn() . "&isn=" . $eContentRecord->getIsbn() . "&size=medium&upc=" . $eContentRecord->getUpc() . "&category=EMedia&econtent=true", 'large_image' => $configArray['Site']['coverUrl'] . "/bookcover.php?id=" . $eContentRecord->id . "&issn=" . $eContentRecord->getissn() . "&isn=" . $eContentRecord->getIsbn() . "&size=large&upc=" . $eContentRecord->getUpc() . "&category=EMedia&econtent=true", 'small_image' => $configArray['Site']['coverUrl'] . "/bookcover.php?id=" . $eContentRecord->id . "&issn=" . $eContentRecord->getissn() . "&isn=" . $eContentRecord->getIsbn() . "&size=small&upc=" . $eContentRecord->getUpc() . "&category=EMedia&econtent=true", 'title' => $eContentRecord->title, 'author' => $eContentRecord->author, 'description' => $eContentRecord->description, 'length' => '', 'publisher' => $eContentRecord->publisher, 'dateSaved' => $eContentRecord->date_added);
 }
Exemplo n.º 28
0
 private function _parseOverDriveHolds($holdsSection)
 {
     global $user;
     $holds = array();
     $holds['available'] = array();
     $holds['unavailable'] = array();
     //Match holds
     //Get the individual holds by splitting the section based on each <li class="mobile-four">
     //Trim to the first li
     //$firstTitlePos = preg_match($holdsSection, '/<li .*?class="mobile-four">/');
     //$holdsSection = substr($holdsSection, $firstTitlePos);
     $heldTitles = preg_split('/<li[^>]*?class="mobile-four"[^>]*?>/', $holdsSection);
     foreach ($heldTitles as $titleHtml) {
         //echo("\r\nSection " . $i++ . "\r\n$titleHtml");
         if (preg_match('/<div class="coverID">.*?<a href="ContentDetails\\.htm\\?id=(.*?)">.*?<img class="lrgImg" src="(.*?)".*?<div class="trunc-title-line".*?title="(.*?)".*?<div class="trunc-author-line".*?title="(.*?)".*?<div class="(?:holds-info)?".*?>(.*)/si', $titleHtml, $holdInfo)) {
             $hold = array();
             $grpCtr = 1;
             $hold['overDriveId'] = $holdInfo[$grpCtr++];
             $hold['imageUrl'] = $holdInfo[$grpCtr++];
             $eContentRecord = new EContentRecord();
             $eContentRecord->externalId = $hold['overDriveId'];
             $eContentRecord->source = 'OverDrive';
             $eContentRecord->status = 'active';
             if ($eContentRecord->find(true)) {
                 $hold['recordId'] = $eContentRecord->id;
                 //Get Rating
                 require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
                 $econtentRating = new EContentRating();
                 $econtentRating->recordId = $eContentRecord->id;
                 $hold['ratingData'] = $econtentRating->getRatingData($user, false);
             } else {
                 $hold['recordId'] = -1;
             }
             $hold['title'] = $holdInfo[$grpCtr++];
             $hold['author'] = $holdInfo[$grpCtr++];
             $holdDetails = $holdInfo[$grpCtr++];
             if (preg_match('/<h6[^>]*?class="holds-wait-position"[^>]*?>(.*?)<\\/h6>.*?<h6[^>]*?class="holds-wait-email"[^>]*?>(.*?)<\\/h6>/si', $holdDetails, $holdDetailInfo)) {
                 $notificationInformation = $holdDetailInfo[1];
                 if (preg_match('/You are (?:patron|user) <b>(\\d+)<\\/b> out of <b>(\\d+)<\\/b> on the waiting list/si', $notificationInformation, $notifyInfo)) {
                     $hold['holdQueuePosition'] = $notifyInfo[1];
                     $hold['holdQueueLength'] = $notifyInfo[2];
                 } else {
                     echo $notificationInformation;
                 }
                 $hold['notifyEmail'] = $holdDetailInfo[2];
                 $hold['available'] = false;
             }
             if (preg_match('/This title can be borrowed(.*?)<\\/div>.*?new Date \\("(.*?)"\\)/si', $holdDetails, $holdDetailInfo)) {
                 ///print_r($holdDetails);
                 $hold['emailSent'] = $holdDetailInfo[2];
                 $hold['notificationDate'] = strtotime($hold['emailSent']);
                 $hold['expirationDate'] = $hold['notificationDate'] + 3 * 24 * 60 * 60;
                 $hold['available'] = true;
             }
             if ($hold['available']) {
                 $holds['available'][] = $hold;
             } else {
                 $holds['unavailable'][] = $hold;
             }
         }
     }
     return $holds;
 }
Exemplo n.º 29
0
 function returnRecord($id)
 {
     global $user;
     global $logger;
     //Get the item information for the record
     require_once ROOT_DIR . '/sys/eContent/EContentCheckout.php';
     $checkout = new EContentCheckout();
     $checkout->userId = $user->id;
     $checkout->recordId = $id;
     $checkout->status = 'out';
     $return = array();
     //$trans->whereAdd('timeReturned = null');
     if ($checkout->find(true)) {
         $output = array();
         $checkout->dateReturned = time();
         $checkout->status = 'returned';
         $ret = $checkout->update();
         if ($ret != 0) {
             $this->processHoldQueue($id);
             $eContentRecord = new EContentRecord();
             $eContentRecord->id = $id;
             $eContentRecord->find(true);
             //Record that the title was checked in
             $this->recordEContentAction($id, "Checked In", $eContentRecord->accessType);
             $eContentRecord->saveToSolr();
             $return = array('success' => true, 'message' => "The title was returned successfully.");
         } else {
             $return = array('success' => false, 'message' => "Could not return the item");
         }
         $output['database-response'] = $ret;
     } else {
         $logger->log("Could not find a checked out item for that title in the database.", PEAR_LOG_INFO);
         $return = array('success' => false, 'message' => "Could not find a checked out item for that title in the database.  It may have already been returned.");
     }
     return $return;
 }
Exemplo n.º 30
0
 function launch()
 {
     global $interface;
     global $configArray;
     $interface->setPageTitle('eContent Help');
     $defaultFormat = "";
     require_once ROOT_DIR . '/sys/eContent/EContentRecord.php';
     if (isset($_REQUEST['id'])) {
         $id = $_REQUEST['id'];
         $interface->assign('id', $id);
         $eContentRecord = new EContentRecord();
         $eContentRecord->id = $id;
         if ($eContentRecord->find(true)) {
             require_once ROOT_DIR . '/sys/eContent/EContentItem.php';
             $eContentItem = new EContentItem();
             $eContentItem->id = $_REQUEST['itemId'];
             if ($eContentItem->find(true)) {
                 $displayFormat = $eContentItem->getDisplayFormat();
                 $popupContent = "Sorry, there is not detailed help available for this format yet.";
                 if ($eContentItem->item_type == 'mp3') {
                     $defaultFormat = 'mp3';
                 } else {
                     if ($eContentItem->item_type == 'epub') {
                         $defaultFormat = 'ebook';
                     } else {
                         if ($eContentItem->item_type == 'kindle') {
                             $defaultFormat = 'kindle';
                         } else {
                             if ($eContentItem->item_type == 'plucker') {
                                 $defaultFormat = 'other';
                             } else {
                                 if ($eContentItem->item_type == 'pdf') {
                                     $defaultFormat = 'other';
                                 } else {
                                     if ($eContentItem->item_type == 'externalMP3') {
                                         $defaultFormat = 'mp3';
                                     } else {
                                         if ($eContentItem->item_type == 'external_ebook') {
                                             if ($eContentItem->getSource() == 'SpringerLink') {
                                                 $defaultFormat = 'springerlink';
                                             } elseif (preg_match('/ebsco/i', $eContentItem->getSource())) {
                                                 $defaultFormat = 'ebsco';
                                             } else {
                                                 $defaultFormat = 'other';
                                             }
                                         } else {
                                             if ($eContentItem->item_type == 'externalLink') {
                                                 $defaultFormat = 'other';
                                             } else {
                                                 if ($eContentItem->item_type == 'overdrive') {
                                                     if ($eContentItem->externalFormatId == 'audiobook-mp3') {
                                                         $defaultFormat = 'mp3';
                                                     } else {
                                                         if ($eContentItem->externalFormatId == 'audiobook-wma') {
                                                             $defaultFormat = 'wma';
                                                         } else {
                                                             if ($eContentItem->externalFormatId == 'video-wmv') {
                                                                 $defaultFormat = 'eVideo';
                                                             } else {
                                                                 if ($eContentItem->externalFormatId == 'music-wma') {
                                                                     $defaultFormat = 'eMusic';
                                                                 } else {
                                                                     if ($eContentItem->externalFormatId == 'ebook-kindle') {
                                                                         $defaultFormat = 'kindle';
                                                                     } else {
                                                                         if ($eContentItem->externalFormatId == 'ebook-epub-adobe') {
                                                                             $defaultFormat = 'ebook';
                                                                         } else {
                                                                             if ($eContentItem->externalFormatId == 'ebook-pdf-adobe') {
                                                                                 $defaultFormat = 'other';
                                                                             } else {
                                                                                 if ($eContentItem->externalFormatId == 'ebook-epub-open') {
                                                                                     $defaultFormat = 'ebook';
                                                                                 } else {
                                                                                     if ($eContentItem->externalFormatId == 'ebook-pdf-open') {
                                                                                         $defaultFormat = 'other';
                                                                                     } else {
                                                                                         $defaultFormat = 'other';
                                                                                     }
                                                                                 }
                                                                             }
                                                                         }
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 } else {
                                                     if ($eContentItem->item_type == 'external_eaudio') {
                                                         $defaultFormat = 'other';
                                                     } else {
                                                         if ($eContentItem->item_type == 'external_emusic') {
                                                             $defaultFormat = 'eMusic';
                                                         } else {
                                                             if ($eContentItem->item_type == 'text') {
                                                                 $defaultFormat = 'other';
                                                             } else {
                                                                 if ($eContentItem->item_type == 'itunes') {
                                                                     $defaultFormat = 'other';
                                                                 } else {
                                                                     if ($eContentItem->item_type == 'gifs') {
                                                                         $defaultFormat = 'other';
                                                                     } else {
                                                                         $defaultFormat = 'other';
                                                                     }
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $interface->assign('defaultFormat', $defaultFormat);
     $device = get_device_name();
     $defaultDevice = '';
     if ($device == 'Kindle') {
         $defaultDevice = 'kindle';
     } elseif ($device == 'Kindle Fire') {
         $defaultDevice = 'kindle_fire';
     } elseif ($device == 'iPad' || $device == 'iPhone') {
         $defaultDevice = 'ios';
     } elseif ($device == 'Android Phone' || $device == 'Android Tablet') {
         $defaultDevice = 'android';
     } elseif ($device == 'Android Phone' || $device == 'Android Tablet' || $device == 'Google TV') {
         $defaultDevice = 'android';
     } elseif ($device == 'BlackBerry') {
         $defaultDevice = 'other';
     } elseif ($device == 'Mac') {
         $defaultDevice = 'mac';
     } elseif ($device == 'PC') {
         $defaultDevice = 'pc';
     }
     $interface->assign('defaultDevice', $defaultDevice);
     if (isset($_REQUEST['lightbox'])) {
         $interface->assign('popupTitle', 'Step by Step Instructions for using eContent');
         $popupContent = $interface->fetch('Help/eContentHelp.tpl');
         $interface->assign('popupContent', $popupContent);
         $interface->display('popup-wrapper.tpl');
     } else {
         $interface->setTemplate('eContentHelp.tpl');
         $interface->display('layout.tpl');
     }
 }