function getEContentImportDetails() { global $interface; $id = $_REQUEST['id']; require_once ROOT_DIR . '/sys/eContent/EContentImportDetailsEntry.php'; $logEntry = new EContentImportDetailsEntry(); $logEntry->id = $id; if ($logEntry->find(true)) { $interface->assign('logEntry', $logEntry); return $interface->fetch('EContent/eContentImportDetailsEntry.tpl'); } else { return "We could not find a import log entry with that id."; } }
function getStatuses() { $importDetails = new EContentImportDetailsEntry(); $importDetails->query('SELECT DISTINCT status FROM ' . $importDetails->__table . ' ORDER BY status'); $statuses = array(); while ($importDetails->fetch()) { $statuses[] = $importDetails->status; } return $statuses; }
static function packageFileWithService($filename, $econtentRecordId, $itemId, $existingResourceId = '', $numAvailable) { global $configArray; global $logger; if (isset($configArray['EContent']['packagingURL']) && strlen($configArray['EContent']['packagingURL']) > 0) { $logger->log("Packaging file with packaging service", PEAR_LOG_INFO); //Copy the file to the ftp service $filenameNoPath = substr($filename, strrpos($filename, '/') + 1); $baseFilename = substr($filenameNoPath, 0, strrpos($filenameNoPath, '.')); $extension = substr($filenameNoPath, strrpos($filenameNoPath, '.') + 1); $newFilename = AdobeContentServer::copyFileToFtp($filename, $itemId, $extension); if (!$newFilename) { $logger->log("Could not copy file to FTP server.", PEAR_LOG_ERR); return array('success' => false); } else { //Submit to the packaging service $packagingServiceUrl = $configArray['EContent']['packagingURL']; $distributorId = $configArray['EContent']['distributorId']; $filenameEncoded = 'Received\\Data\\' . urlencode($newFilename); $distributorIdEncoded = urlencode($distributorId); $packagingServiceCall = "{$packagingServiceUrl}?method=RequestFileProtection&distributorId={$distributorIdEncoded}&filename={$filenameEncoded}&copies={$numAvailable}"; $logger->log($packagingServiceCall, PEAR_LOG_INFO); $packagingResponse = file_get_contents($packagingServiceCall); $logger->log("Response\r\n{$packagingResponse}", PEAR_LOG_INFO); $jsonResponse = json_decode($packagingResponse, true); if ($jsonResponse['success']) { //Save information to packaging log so it can be processed on the backend require_once ROOT_DIR . '/sys/eContent/EContentImportDetailsEntry.php'; $importDetails = new EContentImportDetailsEntry(); $importDetails->filename = $newFilename; $importDetails->libraryFilename = $filename; $importDetails->dateFound = time(); $importDetails->dateSentToPackaging = time(); $importDetails->econtentItemId = $itemId; $importDetails->econtentRecordId = $econtentRecordId; $importDetails->distributorId = $distributorId; $importDetails->copies = $numAvailable; $importDetails->packagingId = $jsonResponse['packagingId']; $importDetails->status = 'sentToAcs'; $importDetails->insert(); } else { $logger->log("Error submitting file to packaging service: response\r\n{$packagingResponse}", PEAR_LOG_ERR); $logger->log("Packaging call {$packagingServiceCall}", PEAR_LOG_ERR); } return $jsonResponse; } } else { $logger->log("Cannot package file because packagingURL is not set", PEAR_LOG_INFO); return array('success' => false); } }