ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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()

ilCertificateVerificationFileService::__construct ( ilLanguage  $language,
ilDBInterface  $database,
ilLogger  $logger,
ilCertificateVerificationClassMap  $classMap 
)

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(), ilObjCourseVerificationGUI\save(), and ilObjTestVerificationGUI\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);
63 
64  $pdfAction = new ilCertificatePdfAction(
65  $pdfGenerator,
67  $this->language->txt('error_creating_certificate_pdf')
68  );
69 
70  $certificateScalar = $pdfAction->createPDF($userId, $objectId);
71 
72  if ($certificateScalar) {
73  // we need the object id for storing the certificate file
74  $verificationObject->create();
75 
76  $path = $this->initStorage($verificationObject->getId(), 'certificate');
77 
78  $fileName = $objectType . '_' . $objectId . '_' . $userId . '.pdf';
79 
80  if (file_put_contents($path . $fileName, $certificateScalar)) {
81  $verificationObject->setProperty('file', $fileName);
82  $verificationObject->update();
83 
84  return $verificationObject;
85  }
86 
87  $this->logger->info('File could not be created');
88  $verificationObject->delete();
89  }
90  return null;
91  }
const IL_CAL_UNIX
$path
Definition: ltiservices.php:30
createPDF(int $userId, int $objectId)
language()
description: > Example for rendring a language glyph.
Definition: language.php:25
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 93 of file class.ilCertificateVerificationFileService.php.

References $path.

Referenced by createFile().

93  : string
94  {
95  $storage = new ilVerificationStorageFile($objectId);
96  $storage->create();
97 
98  $path = $storage->getAbsolutePath() . "/";
99 
100  if ($subDirectory !== '') {
101  $path .= $subDirectory . "/";
102 
103  if (!is_dir($path)) {
104  mkdir($path);
105  }
106  }
107 
108  return $path;
109  }
$path
Definition: ltiservices.php:30
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: