private function _getACSPdfLinks($eContentItem, $eContentCheckout)
 {
     require_once ROOT_DIR . '/sys/AdobeContentServer.php';
     global $configArray;
     $links = array();
     //Download link
     $downloadLink = AdobeContentServer::mintDownloadLink($eContentItem, $eContentCheckout);
     $links[] = array('url' => $downloadLink, 'text' => 'Download');
     return $links;
 }
Exemple #2
0
 function addFileToAcsServer()
 {
     global $configArray;
     require_once ROOT_DIR . '/sys/AdobeContentServer.php';
     if (!isset($_REQUEST['filename'])) {
         return array('error' => 'Filename parameter was not provided.  Please provide the filename in the library to add to the ACS server.');
     }
     if (!isset($_REQUEST['availableCopies'])) {
         return array('error' => 'availableCopies parameter was not provided.  Please provide the availableCopies in the library to add to the ACS server.');
     }
     $filename = $_REQUEST['filename'];
     $availableCopies = $_REQUEST['availableCopies'];
     $fullFilename = $configArray['EContent']['library'] . '/' . $filename;
     if (!file_exists($fullFilename)) {
         return array('error' => 'Filename does not exist in the library.  Unable to add to the ACS server.');
     }
     $ret = AdobeContentServer::packageFile($fullFilename, '', 1, '', $availableCopies);
     return $ret;
 }
 static function deleteResource($acsId)
 {
     global $configArray;
     $distributorId = $configArray['EContent']['distributorId'];
     AdobeContentServer::removeDistributionRights($acsId, $distributorId);
     $deleteResourceDoc = new DOMDocument('1.0', 'UTF-8');
     $deleteResourceDoc->formatOutput = true;
     //Create the message to send to the ACS server
     $deleteResourceElem = $deleteResourceDoc->appendChild($deleteResourceDoc->createElementNS("http://ns.adobe.com/adept", "request"));
     $deleteResourceElem->setAttribute("action", "delete");
     $deleteResourceElem->setAttribute("auth", "builtin");
     $resourceKeyElem = $deleteResourceElem->appendChild($deleteResourceDoc->createElement("resourceKey"));
     $resourceKeyElem->appendChild($deleteResourceDoc->createElement("resource", $acsId));
     //Add nonce, expiration, and hmac
     $deleteResourceElem->appendChild($deleteResourceDoc->createElement("expiration", date(DATE_W3C, time() + 15 * 60)));
     //Request expiration, default to 15 minutes
     $deleteResourceElem->appendChild($deleteResourceDoc->createElement('nonce', base64_encode(AdobeContentServer::makeNonce())));
     //Calculate hmac
     global $configArray;
     $serverPassword = hash("sha1", $configArray['EContent']['acsPassword'], true);
     AdobeContentServer::signNode($deleteResourceDoc, $deleteResourceElem, $serverPassword);
     $distributionURL = $configArray['EContent']['operatorURL'] . '/ManageResourceKey';
     //echo("Request:<br/>" . htmlentities($deleteResourceDoc->saveXML()) . "<br/>");
     $response = AdobeContentServer::sendRequest($deleteResourceDoc->saveXML(), $distributionURL);
     //echo("Response:<br/>" . $response . "<br/>");
     $responseData = simplexml_load_string($response);
     if (strlen($response) == 0 || isset($responseData->error) || preg_match('/<error.*/', $response)) {
         return array('result' => 'false');
     } else {
         return array('result' => 'true');
     }
 }
 function update()
 {
     if ($this->reviewStatus == 0) {
         $this->reviewStatus = 'Not Reviewed';
     }
     if ($this->getAccessType() == 'acs' && ($this->item_type == 'epub' || $this->item_type == 'pdf')) {
         require_once ROOT_DIR . '/sys/AdobeContentServer.php';
         global $configArray;
         $uploadResults = AdobeContentServer::packageFile($configArray['EContent']['library'] . '/' . $this->filename, $this->recordId, $this->id, $this->acsId, $this->getAvailableCopies());
         if ($uploadResults['success']) {
             $oldAcs = $this->acsId;
             $this->acsId = $uploadResults['acsId'];
             $fileUploaded = true;
             $deleteResults = AdobeContentServer::deleteResource($oldAcs);
         } else {
             $fileUploaded = false;
         }
     }
     $ret = parent::update();
     if ($ret > 0) {
         //Make sure to also update the record this is attached to so the full text can be generated
         if ($this->item_type == 'epub' || $this->item_type == 'pdf') {
             $record = $this->getRecord();
             $record->update();
         }
     }
     return $ret;
 }
 /**
  * @param String $itemId
  * @param String $fileName
  * @param String $acsId
  * @return array
  */
 function getActionsForItem($itemId, $fileName, $acsId)
 {
     $actions = array();
     if (!$this->isCheckedOut($itemId)) {
         //Get the number of current checkouts
         //TODO:
         if ($this->isItemAvailable($itemId, 1)) {
             $actions[] = array('url' => '', 'onclick' => "VuFind.LocalEContent.checkoutRestrictedEContent('{$this->getUniqueID()}', '{$itemId}')", 'title' => 'Check Out', 'requireLogin' => true, 'showInSummary' => true, 'showInFormats' => false);
         } else {
             $actions[] = array('url' => '', 'onclick' => "VuFind.LocalEContent.placeHoldOnRestrictedEContent('{$this->getUniqueID()}', '{$itemId}')", 'title' => 'Place Hold', 'requireLogin' => true, 'showInSummary' => true, 'showInFormats' => false);
         }
     } else {
         $actions['return'] = array('url' => '', 'onclick' => "return VuFind.LocalEContent.returnRestrictedEContent('{$this->getUniqueID()}', '{$itemId}')", 'title' => 'Return Now', 'requireLogin' => true, 'showInSummary' => true, 'showInFormats' => false);
         $fileExtension = '';
         if (strpos($fileName, '.') !== FALSE) {
             $fileExtension = substr($fileName, strrpos($fileName, '.') + 1);
         }
         global $configArray;
         //Add actions to read online, or fulfill hold in ACS server as appropriate
         if ($fileExtension == 'epub') {
             $actions[] = array('url' => $configArray['Site']['path'] . "/RestrictedEContent/{$this->getUniqueID()}/Viewer?itemId={$itemId}&file={$fileName}", 'onclick' => '', 'title' => 'Read Online', 'requireLogin' => true, 'showInSummary' => false, 'showInFormats' => true);
         }
         //Get the checkout for the current user
         $eContentCheckout = $this->getCurrentCheckout($itemId);
         require_once ROOT_DIR . '/sys/AdobeContentServer.php';
         $acsDownloadLink = AdobeContentServer::mintDownloadLink($acsId, $eContentCheckout);
         if ($acsDownloadLink) {
             $actions[] = array('url' => AdobeContentServer::mintDownloadLink($acsId, $eContentCheckout), 'onclick' => '', 'title' => 'Download', 'requireLogin' => true, 'showInSummary' => false, 'showInFormats' => true);
         }
     }
     return $actions;
 }