/** * Download certificate */ public function downloadCertificate() { if ($cert_id = (int) $_GET['cert_id']) { /** @var srCertificate $cert */ $cert = srCertificate::find($cert_id); if ($cert->getUserId() == $this->user->getId() && $cert->getDefinition()->getDownloadable()) { parent::downloadCertificate(); } } }
protected function performCommand($cmd) { /** @var srCertificate $certificate */ $certificate = srCertificate::find((int) $_GET['cert_id']); switch ($cmd) { case 'callBack': $this->callBack($certificate); break; case 'undoCallBack': $this->undoCallBack($certificate); break; case 'retryGeneration': $this->retryGeneration($certificate); break; } }
/** * Download the given IDs of certificates as ZIP-File. * Note: No permission checking, this must be done by the controller calling this method * * @param array $cert_ids * @param string $filename Filename of zip, appended to the current date */ public static function downloadAsZip(array $cert_ids = array(), $filename = 'certificates') { if (count($cert_ids)) { $zip_filename = date('d-m-Y') . '-' . $filename; // Make a random temp dir in ilias data directory $tmp_dir = ilUtil::ilTempnam(); ilUtil::makeDir($tmp_dir); $zip_base_dir = $tmp_dir . DIRECTORY_SEPARATOR . $zip_filename; ilUtil::makeDir($zip_base_dir); // Copy all PDFs in folder foreach ($cert_ids as $cert_id) { /** @var srCertificate $cert */ $cert = srCertificate::find((int) $cert_id); if (!is_null($cert) && $cert->getStatus() == srCertificate::STATUS_PROCESSED) { copy($cert->getFilePath(), $zip_base_dir . DIRECTORY_SEPARATOR . $cert->getFilename(true)); } } $tmp_zip_file = $tmp_dir . DIRECTORY_SEPARATOR . $zip_filename . '.zip'; try { ilUtil::zip($zip_base_dir, $tmp_zip_file); rename($tmp_zip_file, $zip_file = ilUtil::ilTempnam()); ilUtil::delDir($tmp_dir); ilUtil::deliverFile($zip_file, $zip_filename . '.zip', '', false, true); } catch (ilFileException $e) { ilUtil::sendInfo($e->getMessage()); } } }
/** * Download multiple certificates as ZIP file * */ public function downloadCertificates() { $cert_ids = (array) $_POST['cert_id']; $ids = array(); foreach ($cert_ids as $cert_id) { /** @var srCertificate $certificate */ $certificate = srCertificate::find($cert_id); if ($certificate && $certificate->getDefinitionId() == $this->definition->getId()) { $ids[] = $cert_id; } } if (count($ids)) { srCertificate::downloadAsZip($ids, $this->ref_id . '-certificates'); } $this->showCertificates(); }
/** * Download a certificate * */ public function downloadCertificate() { if ($cert_id = (int) $_GET['cert_id']) { /** @var srCertificate $cert */ $cert = srCertificate::find($cert_id); if ($cert->getStatus() == srCertificate::STATUS_CALLED_BACK) { ilUtil::sendFailure($this->pl->txt('msg_called_back')); } elseif ($cert->getStatus() != srCertificate::STATUS_PROCESSED) { ilUtil::sendFailure($this->pl->txt('msg_not_created_yet')); } else { $cert->download(); } } $this->index(); }