public function getMyTransactions($user)
 {
     $return = array();
     $eContentCheckout = new EContentCheckout();
     $eContentCheckout->userId = $user->id;
     $eContentCheckout->status = 'out';
     $eContentCheckout->find();
     $return['transactions'] = array();
     $return['numTransactions'] = $eContentCheckout->find();
     while ($eContentCheckout->fetch()) {
         if ($eContentCheckout->protectionType == 'free') {
             require_once ROOT_DIR . '/RecordDrivers/PublicEContentDriver.php';
             $recordDriver = new PublicEContentDriver($eContentCheckout->recordId);
         } else {
             require_once ROOT_DIR . '/RecordDrivers/RestrictedEContentDriver.php';
             $recordDriver = new RestrictedEContentDriver($eContentCheckout->recordId);
         }
         if ($recordDriver->isValid()) {
             $daysUntilDue = ceil(($eContentCheckout->dateDue - time()) / (24 * 60 * 60));
             $overdue = $daysUntilDue < 0;
             $items = $recordDriver->getItems();
             if ($eContentCheckout->protectionType == 'free') {
                 $links['return'] = array('text' => 'Return&nbsp;Now', 'onclick' => "if (confirm('Are you sure you want to cancel this hold?')){VuFind.LocalEContent.returnPublicEContent('{$eContentCheckout->recordId}', '{$eContentCheckout->itemId}')};return false;", 'typeReturn' => 0);
             } else {
                 $links['return'] = array('text' => 'Return&nbsp;Now', 'onclick' => "if (confirm('Are you sure you want to cancel this hold?')){VuFind.LocalEContent.returnRestrictedEContent('{$eContentCheckout->recordId}', '{$eContentCheckout->itemId}')};return false;", 'typeReturn' => 0);
             }
             //Get Ratings
             $return['transactions'][] = array('id' => $eContentCheckout->recordId, 'groupedWorkId' => $recordDriver->getGroupedWorkId(), 'recordId' => $recordDriver->getUniqueID(), 'recordType' => $eContentCheckout->protectionType == 'free' ? 'PublicEContent' : 'RestrictedEContent', 'checkoutSource' => 'eContent', 'title' => $recordDriver->getTitle(), 'author' => $recordDriver->getPrimaryAuthor(), 'format' => $recordDriver->getFormatCategory(), 'duedate' => $eContentCheckout->dateDue, 'checkoutdate' => $eContentCheckout->dateCheckedOut, 'daysUntilDue' => $daysUntilDue, 'links' => $links, 'items' => $items, 'ratingData' => $recordDriver->getRatingData(), 'overdue' => $overdue, 'recordUrl' => $recordDriver->getLinkUrl(), 'bookcoverUrl' => $recordDriver->getBookcoverUrl('medium'));
         }
     }
     return $return;
 }
 /**
  * @param ReadingHistoryEntry $readingHistoryDB
  * @return mixed
  */
 public function getHistoryEntryForDatabaseEntry($readingHistoryDB)
 {
     $historyEntry = array();
     $historyEntry['itemindex'] = $readingHistoryDB->id;
     $historyEntry['deletable'] = true;
     $historyEntry['source'] = $readingHistoryDB->source;
     $historyEntry['id'] = $readingHistoryDB->sourceId;
     $historyEntry['recordId'] = $readingHistoryDB->sourceId;
     $historyEntry['shortId'] = $readingHistoryDB->sourceId;
     $historyEntry['title'] = $readingHistoryDB->title;
     $historyEntry['author'] = $readingHistoryDB->author;
     $historyEntry['format'] = array($readingHistoryDB->format);
     $historyEntry['checkout'] = $readingHistoryDB->checkOutDate;
     $historyEntry['checkin'] = $readingHistoryDB->checkInDate;
     $historyEntry['ratingData'] = null;
     $historyEntry['permanentId'] = null;
     $historyEntry['linkUrl'] = null;
     $historyEntry['coverUrl'] = null;
     $recordDriver = null;
     if ($readingHistoryDB->source == 'ILS') {
         require_once ROOT_DIR . '/RecordDrivers/MarcRecord.php';
         $recordDriver = new MarcRecord($historyEntry['id']);
     } elseif ($readingHistoryDB->source == 'OverDrive') {
         require_once ROOT_DIR . '/RecordDrivers/OverDriveRecordDriver.php';
         $recordDriver = new OverDriveRecordDriver($historyEntry['id']);
     } elseif ($readingHistoryDB->source == 'PublicEContent') {
         require_once ROOT_DIR . '/RecordDrivers/PublicEContentDriver.php';
         $recordDriver = new PublicEContentDriver($historyEntry['id']);
     } elseif ($readingHistoryDB->source == 'RestrictedEContent') {
         require_once ROOT_DIR . '/RecordDrivers/RestrictedEContentDriver.php';
         $recordDriver = new RestrictedEContentDriver($historyEntry['id']);
     }
     if ($recordDriver != null && $recordDriver->isValid()) {
         $historyEntry['ratingData'] = $recordDriver->getRatingData();
         $historyEntry['permanentId'] = $recordDriver->getPermanentId();
         $historyEntry['linkUrl'] = $recordDriver->getLinkUrl();
         $historyEntry['coverUrl'] = $recordDriver->getBookcoverUrl('medium');
         $historyEntry['format'] = $recordDriver->getFormats();
     }
     $recordDriver = null;
     return $historyEntry;
 }