Пример #1
0
 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;
 }