19declare(strict_types=1);
34 string $a_hier_id =
'0',
39 $this->
user = $DIC->user();
45 $cmd = $this->
ctrl->getCmd();
56 $this->tpl->setContent($a_form->getHTML());
66 $this->tpl->setContent($a_form->getHTML());
77 $root = $tree->getRootId();
79 $root = $tree->getNodeData($root);
80 foreach ($tree->getSubTree($root) as $node) {
81 if (in_array($node[
'type'], self::SUPPORTED_TYPES,
true)) {
82 $nodes[$node[
'obj_id']] = $node;
99 $activeCertificates = $repository->fetchActiveCertificates($this->
user->getId());
100 foreach ($activeCertificates as $certificate) {
101 $certificates[$certificate->getObjId()] = $certificate;
104 return $certificates;
109 $this->
lng->loadLanguageModule(
'wsp');
112 $form->setFormAction($this->
ctrl->getFormAction($this));
116 $form->setTitle($this->
lng->txt(
'cont_insert_verification'));
117 $form->addCommandButton(
'create_verification', $this->
lng->txt(
'save'));
118 $form->addCommandButton(
'cancelCreate', $this->
lng->txt(
'cancel'));
120 $form->setTitle($this->
lng->txt(
'cont_update_verification'));
121 $form->addCommandButton(
'update', $this->
lng->txt(
'save'));
122 $form->addCommandButton(
'cancelUpdate', $this->
lng->txt(
'cancel'));
123 $data = $this->content_obj->getData();
126 $certificateOptions = [];
128 $userCertificate = $certificate->getUserCertificate();
130 $userCertificate->getAcquiredTimestamp(),
134 $type = $this->
lng->txt(
'wsp_type_' . $userCertificate->getObjType() .
'v');
135 if (
'sahs' === $userCertificate->getObjType()) {
136 $type = $this->
lng->txt(
'wsp_type_scov');
138 $additionalInformation =
' (' . $type .
' / ' . $dateTime .
')';
139 $certificateOptions[$userCertificate->getObjId()] = $certificate->getObjectTitle() . $additionalInformation;
142 if ($a_insert || (isset(
$data[
'type']) &&
'crta' ===
$data[
'type'])) {
144 $certificate->setRequired(
true);
145 $certificate->setOptions($certificateOptions);
146 $form->addItem($certificate);
147 if (isset(
$data[
'id'])) {
148 $certificate->setValue(
$data[
'id']);
155 $this->
lng->txt(
'certificate_selection'),
156 'certificate_selection'
160 $this->
lng->txt(
'certificate_workspace_option'),
161 'certificate_workspace_option'
164 $this->
lng->txt(
'certificate_persistent_option'),
165 'certificate_persistent_option'
168 $workspaceCertificates =
new ilSelectInputGUI($this->
lng->txt(
'cont_verification_object'),
'object');
169 $workspaceCertificates->setRequired(
true);
170 $workspaceOptions = [];
172 $workspaceOptions[$node[
'obj_id']] = $node[
'title'] .
' (' . $this->
lng->txt(
'wsp_type_' . $node[
'type']) .
')';
174 asort($workspaceOptions);
175 $workspaceCertificates->setOptions($workspaceOptions);
177 $certificate =
new ilSelectInputGUI($this->
lng->txt(
'cont_verification_object'),
'persistent_object');
178 $certificate->setRequired(
true);
179 $certificate->setOptions($certificateOptions);
180 $persistentRadioButton->addSubItem($certificate);
181 $workspaceRadioButton->addSubItem($workspaceCertificates);
183 $certificateSource->addOption($persistentRadioButton);
184 $certificateSource->addOption($workspaceRadioButton);
186 $form->addItem($certificateSource);
188 $certificateSource->setValue(
'certificate_workspace_option');
189 $workspaceCertificates->setValue(
$data[
'id']);
202 if ($form->checkInput()) {
203 $objectId = (
int) $form->getInput(
'persistent_object');
204 $userId = $this->
user->getId();
208 $certificateFileService->createCertificateFile($userId, $objectId);
209 }
catch (\
ILIAS\Filesystem\Exception\FileAlreadyExistsException
$e) {
210 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_file_not_found_error'),
true);
211 $this->log->warning(
$e->getMessage());
212 }
catch (\
ILIAS\Filesystem\Exception\IOException
$e) {
213 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_file_input_output_error'),
true);
214 $this->log->error(
$e->getMessage());
215 $this->
ctrl->redirect($this,
'initForm');
217 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_creating_certificate_pdf'),
true);
218 $this->log->error(
$e->getMessage());
219 $this->
ctrl->redirect($this,
'initForm');
223 $this->content_obj->create($this->pg_obj, $this->hier_id, $this->pc_id);
224 $this->content_obj->setData(
'crta', $objectId);
226 $this->updated = $this->pg_obj->update();
227 if ($this->updated ===
true) {
228 $this->
ctrl->returnToParent($this,
'jump' . $this->hier_id);
231 $this->log->info(
'File could not be created');
244 if ($form->checkInput()) {
245 $option =
'certificate_persistent_option';
246 if ($form->getItemByPostVar(
'certificate_selection')) {
247 $option = $form->getInput(
'certificate_selection');
250 $oldContentData = $this->content_obj->getData();
252 if (
'certificate_workspace_option' === $option) {
253 $objectId = (
int) $form->getInput(
'object');
256 if (isset($validWorkSpaceCertificates[$objectId])) {
257 $this->content_obj->setData($validWorkSpaceCertificates[$objectId][
'type'], $objectId);
259 } elseif (
'certificate_persistent_option' === $option) {
261 $objectId = (
int) $form->getInput(
'persistent_object');
264 if (isset($validCertificates[$objectId])) {
266 $certificateFileService->createCertificateFile(
267 $this->
user->getId(),
270 $this->content_obj->setData(
'crta', $objectId);
272 }
catch (\
ILIAS\Filesystem\Exception\FileNotFoundException | \
ILIAS\Filesystem\Exception\FileAlreadyExistsException
$e) {
273 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_file_not_found_error'),
true);
274 $this->log->warning(
$e->getMessage());
275 }
catch (\
ILIAS\Filesystem\Exception\IOException
$e) {
276 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_file_input_output_error'),
true);
277 $this->log->warning(
$e->getMessage());
279 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_creating_certificate_pdf'),
true);
280 $this->log->error(
$e->getMessage());
281 $this->
ctrl->redirect($this,
'initForm');
285 if (
'crta' === $oldContentData[
'type']) {
288 $certificateFileService->deleteCertificateFile(
289 $this->
user->getId(),
290 (
int) $oldContentData[
'id']
292 }
catch (\
ILIAS\Filesystem\Exception\FileNotFoundException
$e) {
293 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_file_not_found_error'));
294 $this->log->warning(
$e->getMessage());
295 }
catch (\
ILIAS\Filesystem\Exception\IOException
$e) {
296 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_file_input_output_error'));
297 $this->log->warning(
$e->getMessage());
301 $this->updated = $this->pg_obj->update();
302 if ($this->updated ===
true) {
303 $this->
ctrl->returnToParent($this,
'jump' . $this->hier_id);
307 $this->pg_obj->addHierIDs();
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
Base class for ILIAS Exception handling.
Class ilPCVerificationGUI Handles user commands on verifications.
insert(?ilPropertyFormGUI $a_form=null)
getValidCertificateByIdMap()
__construct(ilPageObject $a_pg_obj, ?ilPCVerification $a_content_obj, string $a_hier_id='0', string $a_pc_id="")
edit(?ilPropertyFormGUI $a_form=null)
getValidWorkspaceCertificateNodeByIdMap()
initForm(bool $a_insert=false)
Class ilPCVerification Verification content object (see ILIAS DTD)
User Interface for Editing of Page Content Objects (Paragraphs, Tables, ...)
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
This class represents an option in a radio group.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.