/** * Check if the archive has been created and is ready for download * * @param string $code * @return boolean */ public function isDownloadAvailable($code) { $check = $this->getItemStatus($code); $status = $check[0]['status']; if ($status < 2) { return false; } $message = $check[0]['errors']; $message = json_decode($message, true); if ($status > 2) { return $message; } // Create the archive session variables $_SESSION['zipcompression'] = $message['archive']; unset($message['archive']); // Check that the archive has been created $zip = new ZipFolder('', $code); if ($zip->checkArchiveExists($code)) { // Clean up the download queue and return errors $this->removeItem($code); return $message; } return false; }
function perform_action($oEntity) { // TODO find a way to do bulk email $exportCode = $_SESSION['exportcode']; $this->oZip = ZipFolder::get($exportCode); $oQueue = new DownloadQueue(); $config = KTConfig::getSingleton(); $useQueue = $config->get('export/useDownloadQueue'); if (is_a($oEntity, 'Document')) { $oDocument = $oEntity; if ($oDocument->isSymbolicLink()) { $oDocument->switchToLinkedCore(); } if ($useQueue) { DownloadQueue::addItem($this->sExportCode, $this->oFolder->getId(), $oDocument->iId, 'document'); } else { $oQueue->addDocument($this->oZip, $oDocument->iId); } } else { if (is_a($oEntity, 'Folder')) { $aDocuments = array(); $oFolder = $oEntity; if ($oFolder->isSymbolicLink()) { $oFolder = $oFolder->getLinkedFolder(); } $sFolderId = $oFolder->getId(); if ($useQueue) { DownloadQueue::addItem($this->sExportCode, $this->oFolder->getId(), $sFolderId, 'folder'); } else { $oQueue->addFolder($this->oZip, $sFolderId); } } } return "DownloadDocument"; }