ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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 22 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 44 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(), ILIAS\Repository\logger(), and null.

Referenced by ilObjLTIConsumerVerificationGUI\save(), and ilObjSCORMVerificationGUI\save().

45  {
46  $userCertificate = $userCertificatePresentation->getUserCertificate();
47  $objectType = $userCertificate->getObjType();
48 
49  $this->language->loadLanguageModule('cert');
50 
51  $verificationObjectType = $this->classMap->getVerificationTypeByType($objectType);
52 
53  $verificationObject = new ilCertificateVerificationObject($verificationObjectType);
54  $verificationObject->setTitle($userCertificatePresentation->getObjectTitle());
55  $verificationObject->setDescription($userCertificatePresentation->getObjectDescription());
56 
57  $objectId = $userCertificate->getObjId();
58  $userId = $userCertificate->getUserId();
59 
60  $issueDate = new ilDate($userCertificate->getAcquiredTimestamp(), IL_CAL_UNIX);
61 
62  $verificationObject->setProperty('issued_on', $issueDate);
63 
64  $ilUserCertificateRepository = new ilUserCertificateRepository($this->database, $this->logger);
65  $pdfGenerator = new ilPdfGenerator($ilUserCertificateRepository);
66 
67  $pdfAction = new ilCertificatePdfAction(
68  $pdfGenerator,
70  $this->language->txt('error_creating_certificate_pdf')
71  );
72 
73  $certificateScalar = $pdfAction->createPDF($userId, $objectId);
74 
75  if ($certificateScalar) {
76  // we need the object id for storing the certificate file
77  $verificationObject->create();
78 
79  $path = $this->initStorage($verificationObject->getId(), 'certificate');
80 
81  $fileName = $objectType . '_' . $objectId . '_' . $userId . '.pdf';
82 
83  if (file_put_contents($path . $fileName, $certificateScalar)) {
84  $verificationObject->setProperty('file', $fileName);
85  $verificationObject->update();
86 
87  return $verificationObject;
88  }
89 
90  $this->logger->info('File could not be created');
91  $verificationObject->delete();
92  }
93  return null;
94  }
const IL_CAL_UNIX
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
createPDF(int $userId, int $objectId)
language()
description: > Example for rendring a language glyph.
Definition: language.php:41
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 96 of file class.ilCertificateVerificationFileService.php.

References $path.

Referenced by createFile().

96  : string
97  {
98  $storage = new ilVerificationStorageFile($objectId);
99  $storage->create();
100 
101  $path = $storage->getAbsolutePath() . "/";
102 
103  if ($subDirectory !== '') {
104  $path .= $subDirectory . "/";
105 
106  if (!is_dir($path)) {
107  mkdir($path);
108  }
109  }
110 
111  return $path;
112  }
$path
Definition: ltiservices.php:29
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 27 of file class.ilCertificateVerificationFileService.php.

Referenced by __construct().

◆ $database

ilDBInterface ilCertificateVerificationFileService::$database
private

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

Referenced by __construct().

◆ $language

ilLanguage ilCertificateVerificationFileService::$language
private

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

Referenced by __construct().

◆ $logger

ilLogger ilCertificateVerificationFileService::$logger
private

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

Referenced by __construct().


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