Skip to content

Commit

Permalink
MMB-282: Allow downloading the certificate uploaded file
Browse files Browse the repository at this point in the history
  • Loading branch information
olayiwola-compucorp committed Dec 6, 2023
1 parent 4fb9053 commit 086dfc6
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CRM/Certificate/Service/CertificateDownloader.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use CRM_Certificate_Enum_DownloadType as DownloadType;
use CRM_Certificate_Enum_DownloadFormat as DownloadFormat;
use CRM_Certificate_BAO_CompuCertificateImageFormat as CompuCertificateImageFormatBAO;
use CRM_Certificate_BAO_CompuCertificateTemplateImageFormat as CompuCertificateTemplateImageFormat;
Expand Down Expand Up @@ -30,6 +31,14 @@ public function __construct($certificate, $contactId, $entityId, $format) {
* Gets the template associated with a certificate configuration and renders it.
*/
public function download() {
if ($this->certificate->download_type == DownloadType::FILE_DOWNLOAD) {
$file = \CRM_Core_BAO_File::getEntityFile(CRM_Certificate_DAO_CompuCertificate::getTableName(), $this->certificate->id);
if (!empty($file)) {
CRM_Utils_System::redirect(end($file)['url']);
}
return;
}

$generatedTemplate = $this->certificateGenerator->generate($this->certificate->template_id, $this->contactId, $this->entityId);
return $this->render($generatedTemplate);
}
Expand Down

0 comments on commit 086dfc6

Please sign in to comment.