ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCertificateVerificationFileService Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilCertificateVerificationFileService:

Public Member Functions

 __construct (ilLanguage $language, ilDBInterface $database, ilLogger $logger, ilCertificateVerificationClassMap $classMap)
 
 createFile (ilUserCertificatePresentation $userCertificatePresentation)
 
 initStorage (int $objectId, string $subDirectory='')
 

Private Attributes

ilLanguage $language
 
ilDBInterface $database
 
ilLogger $logger
 
ilCertificateVerificationClassMap $classMap
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too. If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Niels Theen nthee.nosp@m.n@da.nosp@m.tabay.nosp@m..de

Definition at line 19 of file class.ilCertificateVerificationFileService.php.

Constructor & Destructor Documentation

◆ __construct()

Member Function Documentation

◆ createFile()

ilCertificateVerificationFileService::createFile ( ilUserCertificatePresentation  $userCertificatePresentation)
Exceptions
ilException

Definition at line 41 of file class.ilCertificateVerificationFileService.php.

References $path, ilCertificatePdfAction\createPDF(), ilUserCertificatePresentation\getObjectDescription(), ilUserCertificatePresentation\getObjectTitle(), ilUserCertificatePresentation\getUserCertificate(), IL_CAL_UNIX, initStorage(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\logger().

Referenced by ilObjExerciseVerificationGUI\save(), ilObjLTIConsumerVerificationGUI\save(), ilObjSCORMVerificationGUI\save(), ilObjCmiXapiVerificationGUI\save(), ilObjTestVerificationGUI\save(), and ilObjCourseVerificationGUI\save().

42  {
43  $userCertificate = $userCertificatePresentation->getUserCertificate();
44  $objectType = $userCertificate->getObjType();
45 
46  $this->language->loadLanguageModule('cert');
47 
48  $verificationObjectType = $this->classMap->getVerificationTypeByType($objectType);
49 
50  $verificationObject = new ilCertificateVerificationObject($verificationObjectType);
51  $verificationObject->setTitle($userCertificatePresentation->getObjectTitle());
52  $verificationObject->setDescription($userCertificatePresentation->getObjectDescription());
53 
54  $objectId = $userCertificate->getObjId();
55  $userId = $userCertificate->getUserId();
56 
57  $issueDate = new ilDate($userCertificate->getAcquiredTimestamp(), IL_CAL_UNIX);
58 
59  $verificationObject->setProperty('issued_on', $issueDate);
60 
61  $ilUserCertificateRepository = new ilUserCertificateRepository($this->database, $this->logger);
62  $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository, $this->logger);
63 
64  $pdfAction = new ilCertificatePdfAction(
65  $this->logger,
66  $pdfGenerator,
68  $this->language->txt('error_creating_certificate_pdf')
69  );
70 
71  $certificateScalar = $pdfAction->createPDF($userId, $objectId);
72 
73  if ($certificateScalar) {
74  // we need the object id for storing the certificate file
75  $verificationObject->create();
76 
77  $path = $this->initStorage($verificationObject->getId(), 'certificate');
78 
79  $fileName = $objectType . '_' . $objectId . '_' . $userId . '.pdf';
80 
81  if (file_put_contents($path . $fileName, $certificateScalar)) {
82  $verificationObject->setProperty('file', $fileName);
83  $verificationObject->update();
84 
85  return $verificationObject;
86  }
87 
88  $this->logger->info('File could not be created');
89  $verificationObject->delete();
90  }
91  return null;
92  }
Class ilPdfGeneratorConstantsTest.
const IL_CAL_UNIX
$path
Definition: ltiservices.php:32
Just a wrapper class to create Unit Test for other classes.
createPDF(int $userId, int $objectId)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initStorage()

ilCertificateVerificationFileService::initStorage ( int  $objectId,
string  $subDirectory = '' 
)

Definition at line 94 of file class.ilCertificateVerificationFileService.php.

References $path.

Referenced by createFile().

94  : string
95  {
96  $storage = new ilVerificationStorageFile($objectId);
97  $storage->create();
98 
99  $path = $storage->getAbsolutePath() . "/";
100 
101  if ($subDirectory !== '') {
102  $path .= $subDirectory . "/";
103 
104  if (!is_dir($path)) {
105  mkdir($path);
106  }
107  }
108 
109  return $path;
110  }
$path
Definition: ltiservices.php:32
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

Field Documentation

◆ $classMap

ilCertificateVerificationClassMap ilCertificateVerificationFileService::$classMap
private

Definition at line 24 of file class.ilCertificateVerificationFileService.php.

Referenced by __construct().

◆ $database

ilDBInterface ilCertificateVerificationFileService::$database
private

Definition at line 22 of file class.ilCertificateVerificationFileService.php.

Referenced by __construct().

◆ $language

ilLanguage ilCertificateVerificationFileService::$language
private

Definition at line 21 of file class.ilCertificateVerificationFileService.php.

Referenced by __construct().

◆ $logger

ilLogger ilCertificateVerificationFileService::$logger
private

Definition at line 23 of file class.ilCertificateVerificationFileService.php.

Referenced by __construct().


The documentation for this class was generated from the following file: