349 $this->global_certificate_settings,
352 $current_template = $this->templateRepository->fetchPreviousCertificate(
$objId);
353 $currentVersion = $current_template->getVersion();
354 $nextVersion = $currentVersion + 1;
355 $current_background_rid = $this->irss->manageContainer()->find(
356 $current_template->getBackgroundImageIdentification()
358 $current_tile_image_rid = $this->irss->manageContainer()->find(
359 $current_template->getTileImageIdentification()
361 $old_background_image = $current_background_rid ===
null 362 ? $current_template->getBackgroundImagePath() :
364 $old_tile_image = $current_tile_image_rid ===
null 365 ? $current_template->getTileImagePath() :
368 $should_delete_background =
369 $this->httpWrapper->post()->retrieve(
372 $this->refinery->kindlyTo()->bool(),
376 $should_delete_tile_image =
377 $this->httpWrapper->post()->retrieve(
378 'certificate_card_tile_image_delete',
380 $this->refinery->kindlyTo()->bool(),
385 $new_background_rid = $current_background_rid && !$should_delete_background ? $current_background_rid :
386 $this->global_certificate_settings->getBackgroundImageIdentification();
388 is_string($new_background_rid) &&
389 is_string($this->global_certificate_settings->getBackgroundImageIdentification()) &&
390 $new_background_rid === $this->global_certificate_settings->getBackgroundImageIdentification()
392 if ($this->file_system->has($new_background_rid)) {
393 $new_background_rid = $this->irss->manage()->stream(
394 $this->file_system->readStream($new_background_rid),
398 $old_background_image = $new_background_rid;
399 $new_background_rid =
null;
403 $new_tile_rid = !$should_delete_tile_image ? $current_tile_image_rid :
null;
406 $this->settingsFormFactory->save($form_fields);
408 $templateValues = $this->placeholderDescriptionObject->getPlaceholderDescriptions();
410 if ($this->fileUpload->hasUploads()) {
411 if (!$this->fileUpload->hasBeenProcessed()) {
412 $this->fileUpload->process();
414 $new_background = $form->
getInput(
'background')[
'tmp_name'] ??
'';
415 $new_tile_image = $form->
getInput(
'certificate_card_tile_image')[
'tmp_name'] ??
'';
416 $results = $this->fileUpload->getResults();
418 if ($new_background !==
'') {
419 $new_background_rid = $this->irss->manage()->upload(
425 if ($new_tile_image !==
'') {
426 $new_tile_rid = $this->irss->manage()->upload(
433 $jsonEncodedTemplateValues = json_encode($templateValues, JSON_THROW_ON_ERROR);
435 if (isset($new_background_rid)) {
436 $old_background_image =
'';
438 if (isset($new_tile_rid)) {
439 $old_tile_image =
'';
442 $xslfo = $this->xlsFoParser->parse($form_fields);
443 $newHashValue =
hash(
447 isset($new_background_rid) ? $new_background_rid->serialize() :
'',
448 $jsonEncodedTemplateValues,
449 isset($new_tile_rid) ? $new_background_rid->serialize() :
'',
450 $old_background_image, $old_tile_image
454 $active = (bool) ($form_fields[
'active'] ??
false);
456 if ($newHashValue !== $current_template->getCertificateHash()) {
462 $jsonEncodedTemplateValues,
467 $old_background_image,
469 isset($new_background_rid) ? $new_background_rid->serialize() :
'',
470 isset($new_tile_rid) ? $new_tile_rid->serialize() :
'',
472 $this->templateRepository->save($certificateTemplate);
475 $certificate_handler->handleResourceChange($current_background_rid);
477 if ($current_tile_image_rid instanceof ResourceIdentification) {
478 $certificate_handler->handleResourceChange($current_tile_image_rid);
481 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'saved_successfully'),
true);
482 $this->
ctrl->redirect($this,
'certificateEditor');
486 $current_template->getId() !==
null &&
487 $current_template->isCurrentlyActive() !== $active
489 $this->templateRepository->updateActivity($current_template, $active);
490 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_change_active_status'),
true);
491 $this->
ctrl->redirect($this,
'certificateEditor');
494 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'certificate_same_not_saved'),
true);
495 $this->
ctrl->redirect($this,
'certificateEditor');
497 $this->tpl->setOnScreenMessage(
501 $this->
logger->error($e->getTraceAsString());
507 $this->tpl->setVariable(
'ADM_CONTENT', $form->
getHTML());
ilCertificateTemplateStakeholder $stakeholder
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const ILIAS_VERSION_NUMERIC
Class ResourceIdentification.
static _lookupType(int $id, bool $reference=false)