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');
 }
Ejemplo n.º 2
0
 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');
 }
Ejemplo n.º 3
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;
 }
 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');
 }
Ejemplo n.º 5
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');
 }
Ejemplo n.º 6
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;
 }
Ejemplo n.º 7
0
 /**
  * Returns information about the titles within a list including:
  * - Title, Author, Bookcover URL, description, record id
  */
 function getListTitles($listId = NULL, Pagination $pagination = NULL)
 {
     global $configArray;
     if (!$listId) {
         if (!isset($_REQUEST['id'])) {
             return array('success' => false, 'message' => 'The id of the list to load must be provided as the id parameter.');
         }
         $listId = $_REQUEST['id'];
     }
     if (isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
         $username = $_REQUEST['username'];
         $password = $_REQUEST['password'];
         global $user;
         $user = UserAccount::validateAccount($username, $password);
     } else {
         global $user;
     }
     if ($user) {
         $userId = $user->id;
     }
     if (is_numeric($listId) || preg_match('/list[-:](.*)/', $listId, $listInfo)) {
         if (isset($listInfo)) {
             $listId = $listInfo[1];
         }
         return $this->_getUserListTitles($listId);
     } elseif (preg_match('/search:(.*)/', $listId, $searchInfo)) {
         if (is_numeric($searchInfo[1])) {
             $titles = $this->getSavedSearchTitles($searchInfo[1]);
             if ($titles && count($titles) > 0) {
                 return array('success' => true, 'listTitle' => $listId, 'listDescription' => "Search Results", 'titles' => $titles, 'cacheLength' => 4);
             } else {
                 return array('success' => false, 'message' => 'The specified search could not be found.');
             }
         } else {
             //Do a default search
             $titles = $this->getSystemListTitles($listId);
             if (count($titles) > 0) {
                 return array('success' => true, 'listTitle' => $listId, 'listDescription' => "System Generated List", 'titles' => $titles, 'cacheLength' => 4);
             } else {
                 return array('success' => false, 'message' => 'The specified list could not be found.');
             }
         }
     } else {
         $systemList = null;
         $systemLists = $this->getSystemLists();
         foreach ($systemLists['lists'] as $curSystemList) {
             if ($curSystemList['id'] == $listId) {
                 $systemList = $curSystemList;
                 break;
             }
         }
         //The list is a system generated list
         if ($listId == 'newEpub' || $listId == 'newebooks') {
             require_once ROOT_DIR . 'sys/eContent/EContentRecord.php';
             $eContentRecord = new EContentRecord();
             $eContentRecord->orderBy('date_added DESC');
             $eContentRecord->limit(0, 30);
             $eContentRecord->find();
             $titles = array();
             while ($eContentRecord->fetch()) {
                 $titles[] = $this->setEcontentRecordInfoForList($eContentRecord);
             }
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'freeEbooks') {
             if (!$pagination) {
                 $pagination = new Pagination();
             }
             require_once ROOT_DIR . 'sys/eContent/EContentRecord.php';
             $eContentRecord = new EContentRecord();
             $eContentRecord->orderBy('date_added DESC');
             $eContentRecord->whereAdd('accessType = \'free\'');
             $eContentRecord->limit($pagination->getOffset(), $pagination->getNumItemsPerPage());
             $eContentRecord->find();
             $titles = array();
             while ($eContentRecord->fetch()) {
                 $titles[] = $this->setEcontentRecordInfoForList($eContentRecord);
             }
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'highestRated') {
             $query = "SELECT record_id, AVG(rating) FROM `user_rating` inner join resource on resourceid = resource.id GROUP BY resourceId order by AVG(rating) DESC LIMIT 30";
             $result = mysql_query($query);
             $ids = array();
             while ($epubInfo = mysql_fetch_assoc($result)) {
                 $ids[] = $epubInfo['record_id'];
             }
             $titles = $this->loadTitleInformationForIds($ids);
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'highestRatedEContent') {
             require_once ROOT_DIR . '/sys/eContent/EContentRating.php';
             $econtentRating = new EContentRating();
             $records = $econtentRating->getRecordsListAvgRating("DESC", 30);
             $titles = array();
             if (!empty($records)) {
                 foreach ($records as $eContentRecord) {
                     $titles[] = $this->setEcontentRecordInfoForList($eContentRecord);
                 }
             }
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'recentlyReviewed') {
             $query = "SELECT record_id, MAX(created) FROM `comments` inner join resource on resource_id = resource.id group by resource_id order by max(created) DESC LIMIT 30";
             $result = mysql_query($query);
             $ids = array();
             while ($epubInfo = mysql_fetch_assoc($result)) {
                 $ids[] = $epubInfo['record_id'];
             }
             $titles = $this->loadTitleInformationForIds($ids);
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'mostPopular') {
             $query = "SELECT record_id, count(userId) from user_reading_history inner join resource on resourceId = resource.id GROUP BY resourceId order by count(userId) DESC LIMIT 30";
             $result = mysql_query($query);
             $ids = array();
             while ($epubInfo = mysql_fetch_assoc($result)) {
                 $ids[] = $epubInfo['record_id'];
             }
             $titles = $this->loadTitleInformationForIds($ids);
             return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 1);
         } elseif ($listId == 'recommendations') {
             if (!$user) {
                 return array('success' => false, 'message' => 'A valid user must be provided to load recommendations.');
             } else {
                 $userId = $user->id;
                 require_once ROOT_DIR . '/services/MyResearch/lib/Suggestions.php';
                 $suggestions = Suggestions::getSuggestions($userId);
                 $titles = array();
                 foreach ($suggestions as $id => $suggestion) {
                     $imageUrl = $configArray['Site']['coverUrl'] . "/bookcover.php?id=" . $id;
                     if (isset($suggestion['titleInfo']['issn'])) {
                         $imageUrl .= "&issn=" . $suggestion['titleInfo']['issn'];
                     }
                     if (isset($suggestion['titleInfo']['isbn10'])) {
                         $imageUrl .= "&isn=" . $suggestion['titleInfo']['isbn10'];
                     }
                     if (isset($suggestion['titleInfo']['upc'])) {
                         $imageUrl .= "&upc=" . $suggestion['titleInfo']['upc'];
                     }
                     if (isset($suggestion['titleInfo']['format_category'])) {
                         $imageUrl .= "&category=" . $suggestion['titleInfo']['format_category'];
                     }
                     $smallImageUrl = $imageUrl . "&size=small";
                     $imageUrl .= "&size=medium";
                     $titles[] = array('id' => $id, 'image' => $imageUrl, 'small_image' => $smallImageUrl, 'title' => $suggestion['titleInfo']['title'], 'author' => $suggestion['titleInfo']['author']);
                 }
                 return array('success' => true, 'listTitle' => $systemList['title'], 'listDescription' => $systemList['description'], 'titles' => $titles, 'cacheLength' => 0);
             }
         } else {
             return array('success' => false, 'message' => 'The specified list could not be found.');
         }
     }
 }
Ejemplo n.º 8
0
 function getSourceFilter()
 {
     //Populate the Source Filter
     $econtentRecord = new EContentRecord();
     $querySourceFilter = "SELECT DISTINCT source FROM econtent_record WHERE source IS NOT NULL AND source <> '' " . "ORDER BY source ASC";
     $econtentRecord->query($querySourceFilter);
     $resultsSourceFilter = array();
     $i = 0;
     while ($econtentRecord->fetch()) {
         $tmp = array('SourceValue' => $econtentRecord->source);
         $resultsSourceFilter[$i++] = $tmp;
     }
     return $resultsSourceFilter;
 }
Ejemplo n.º 9
0
 function loadCollectionDetails($source, $startDate, $endDate, $itemsPerPage, $startRecord)
 {
     $collectionDetails = array();
     $collectionDetails['records'] = array();
     $econtentRecord = new EContentRecord();
     $econtentRecord->source = $source;
     $econtentRecord->status = 'active';
     $econtentRecord->whereAdd("date_added >= {$startDate->getTimestamp()}");
     $econtentRecord->whereAdd("date_added < {$endDate->getTimestamp()}");
     $econtentRecord->orderBy('title');
     $econtentRecordCount = clone $econtentRecord;
     if ($itemsPerPage > 0) {
         $econtentRecord->limit($startRecord, $itemsPerPage);
     }
     $econtentRecord->find();
     while ($econtentRecord->fetch()) {
         $collectionDetails['records'][] = clone $econtentRecord;
     }
     //Get the total number of available results
     $econtentRecordCount->find();
     $numTotalRecords = $econtentRecordCount->N;
     $collectionDetails['resultTotal'] = $numTotalRecords;
     $collectionDetails['perPage'] = $itemsPerPage;
     return $collectionDetails;
 }
Ejemplo n.º 10
0
 function loadEContentSources()
 {
     $sources = array();
     $econtentRecord = new EContentRecord();
     $econtentRecord->query("SELECT DISTINCT source FROM econtent_record ORDER BY source");
     while ($econtentRecord->fetch()) {
         $sources[] = $econtentRecord->source;
     }
     return $sources;
 }