ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilObjCertificateSettings.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
23use ILIAS\ResourceStorage\Services as ResourceStorage;
27
35{
37 private readonly ResourceStorage $irss;
38 private readonly Filesystem $filesystem;
41
42 public function __construct(int $a_id = 0, bool $a_reference = true)
43 {
44 global $DIC;
45
46 parent::__construct($a_id, $a_reference);
47 $this->type = 'cert';
48 $this->certificate_settings = new ilSetting('certificate');
49 $this->irss = $DIC->resourceStorage();
50 $this->filesystem = $DIC->filesystem()->web();
51 $this->stakeholder = new ilCertificateTemplateStakeholder();
52 $this->resource_handler = new CertificateResourceHandler(
53 new ilUserCertificateRepository($DIC->database()),
55 $this->irss,
56 $this,
57 $this->stakeholder
58 );
59 }
60
62 {
63 $id = $this->certificate_settings->get('cert_bg_image', '');
64
65 if ($rid = $this->irss->manage()->find($id)) {
66 return $rid;
67 }
68 if ($id !== '') {
70 }
71 if ($id !== '' && $this->filesystem->has($id)) {
72 return ilWACSignedPath::signFile(ILIAS_HTTP_PATH . '/' . ILIAS_WEB_DIR . '/' . CLIENT_ID . $id);
73 }
74 return null;
75 }
76
77 public function getBackgroundImageDefaultFolder(): string
78 {
79 return '/certificates/default/';
80 }
81
88 public function uploadBackgroundImage(UploadResult $upload_result): bool
89 {
90 $identification = $this->irss->manage()->upload($upload_result, $this->stakeholder);
91 $this->certificate_settings->set('cert_bg_image', $identification->serialize());
92
93 return $identification->serialize() !== '';
94 }
95
96 public function deleteBackgroundImage(): bool
97 {
99 if ($rid instanceof ResourceIdentification) {
100 $this->certificate_settings->set('cert_bg_image', '');
101 $this->resource_handler->handleResourceChange($rid);
102
103 return true;
104 }
105
106 return false;
107 }
108
109 public function hasBackgroundImage(): bool
110 {
111 return (bool) $this->certificate_settings->get('cert_bg_image', '');
112 }
113}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class ilObjCertificateSettings.
readonly CertificateResourceHandler $resource_handler
readonly ilCertificateTemplateStakeholder $stakeholder
uploadBackgroundImage(UploadResult $upload_result)
Uploads a background image for the certificate.
__construct(int $a_id=0, bool $a_reference=true)
Class ilObject Basic functions for all objects.
ILIAS Setting Class.
static signFile(string $path_to_file)
const CLIENT_ID
Definition: constants.php:41
const ILIAS_WEB_DIR
Definition: constants.php:45
The filesystem interface provides the public interface for the Filesystem service API consumer.
Definition: Filesystem.php:37
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26