19declare(strict_types=1);
62 $this->httpState =
$DIC->http();
63 $this->
upload = $DIC->upload();
64 $this->
logger = $DIC->logger()->root();
66 $this->
lng->loadLanguageModule(
'certificate');
67 $this->
lng->loadLanguageModule(
'cert');
68 $this->
lng->loadLanguageModule(
'trac');
70 $this->irss =
$DIC->resourceStorage();
83 $next_class = $this->
ctrl->getNextClass($this) ??
'';
84 $cmd = $this->
ctrl->getCmd();
88 if (!$this->rbac_system->checkAccess(
'read', $this->object->getRefId())) {
89 $this->
error->raiseError($this->
lng->txt(
'no_permission'), $this->error->WARNING);
92 switch (strtolower($next_class)) {
93 case strtolower(ilPermissionGUI::class):
94 $this->tabs_gui->setTabActive(
'perm_settings');
96 $this->
ctrl->forwardCommand($perm_gui);
100 if (!$cmd || $cmd ===
'view') {
112 if ($this->certificate_active_validator->validate() && $this->rbac_system->checkAccess(
'read', $this->object->getRefId())) {
113 $this->tabs_gui->addTab(
114 self::TAB_CERTIFICATES,
115 $this->
lng->txt(
'overview'),
116 $this->ctrl->getLinkTarget($this, self::CMD_CERTIFICATES_OVERVIEW)
120 if ($this->rbac_system->checkAccess(
'read', $this->object->getRefId())) {
121 $this->tabs_gui->addTarget(
123 $this->
ctrl->getLinkTarget($this,
'settings'),
128 if ($this->rbac_system->checkAccess(
'edit_permission', $this->object->getRefId())) {
129 $this->tabs_gui->addTarget(
131 $this->
ctrl->getLinkTargetByClass(ilPermissionGUI::class,
'perm'),
133 strtolower(ilPermissionGUI::class)
140 $this->tabs_gui->setTabActive(
'settings');
141 $form_settings =
new ilSetting(
'certificate');
144 $form->setFormAction($this->
ctrl->getFormAction($this));
145 $form->setTitle($this->
lng->txt(
'certificate_settings'));
148 $active->setChecked((
bool) $form_settings->get(
'active',
'0'));
149 $form->addItem($active);
152 $info->setValue($this->
lng->txt(
'certificate_usage'));
153 $form->addItem(
$info);
156 $bgimage->setRequired(
false);
158 if (strcmp($this->
ctrl->getCmd(),
'save') === 0) {
159 $backgroundDelete = $this->httpState->wrapper()->post()->has(
'background_delete') && $this->httpState->wrapper()->post()->retrieve(
163 if ($backgroundDelete) {
164 $this->
object->deleteBackgroundImage();
169 $this->
upload->hasUploads() &&
170 $this->httpState->request()->getMethod() ===
'POST' &&
171 $bgimage->checkInput()
173 if (!$this->
upload->hasBeenProcessed()) {
177 if (is_array($this->
upload->getResults()) && $this->upload->getResults() !== []) {
181 $result = $this->
object->uploadBackgroundImage($file);
182 if ($result ===
false) {
183 $bgimage->setAlert($this->
lng->txt(
'certificate_error_upload_bgimage'));
189 if ($this->
object->hasBackgroundImage()) {
190 $rid = $this->
object->getBackgroundImageIdentification();
192 $background_flavour = $this->irss->flavours()->get(
194 $this->card_thumbnail_definition
196 $flavour_urls = $this->irss->consume()->flavourUrls($background_flavour);
197 foreach ($flavour_urls->getURLs(
true) as
$url) {
199 $bgimage->setImage(
$url);
203 $bgimage->setInfo($this->
lng->txt(
'default_background_info'));
204 $form->addItem($bgimage);
207 'a4' => $this->
lng->txt(
'certificate_a4'),
208 'a4landscape' => $this->
lng->txt(
'certificate_a4_landscape'),
209 'a5' => $this->
lng->txt(
'certificate_a5'),
210 'a5landscape' => $this->
lng->txt(
'certificate_a5_landscape'),
211 'letter' => $this->
lng->txt(
'certificate_letter'),
212 'letterlandscape' => $this->
lng->txt(
'certificate_letter_landscape')
214 $format->setOptions($defaultformats);
215 $format->setValue($form_settings->get(
'pageformat',
''));
216 $format->setInfo($this->
lng->txt(
'certificate_page_format_info'));
217 $form->addItem($format);
219 if ($this->rbac_system->checkAccess(
'write', $this->object->getRefId())) {
220 $form->addCommandButton(
'save', $this->
lng->txt(
'save'));
232 $this->
lng->txt(
'persistent_certificate_mode'),
233 'persistent_certificate_mode'
235 $persistentCertificateMode->setRequired(
true);
238 $this->
lng->txt(
'persistent_certificate_mode_cron'),
239 'persistent_certificate_mode_cron'
241 $cronJobMode->setInfo($this->
lng->txt(
'persistent_certificate_mode_cron_info'));
244 $this->
lng->txt(
'persistent_certificate_mode_instant'),
245 'persistent_certificate_mode_instant'
247 $instantMode->setInfo($this->
lng->txt(
'persistent_certificate_mode_instant_info'));
249 $persistentCertificateMode->addOption($cronJobMode);
250 $persistentCertificateMode->addOption($instantMode);
252 $persistentCertificateMode->setValue($form_settings->get(
253 'persistent_certificate_mode',
254 'persistent_certificate_mode_cron'
257 $form->addItem($persistentCertificateMode);
259 $this->tpl->setContent($form->getHTML());
265 !$this->certificate_active_validator->validate() ||
266 !$this->rbac_system->checkAccess(
'read', $this->object->getRefId())
268 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->WARNING);
271 $this->tabs_gui->activateTab(self::TAB_CERTIFICATES);
275 $this->tpl->setContent($table->render());
280 if (!$this->certificate_active_validator->validate() ||
281 !$this->rbac_system->checkAccess(
'read', $this->object->getRefId())) {
282 $this->
error->raiseError($this->
lng->txt(
'permission_denied'), $this->error->WARNING);
285 $certificate_id = $this->httpState->wrapper()->query()->retrieve(
288 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int()),
289 $this->refinery->always([]),
293 if ($certificate_id === []) {
294 $this->
ctrl->redirect($this, self::CMD_CERTIFICATES_OVERVIEW);
298 $certificate_id = $certificate_id[array_key_first($certificate_id)];
301 $certificate = $this->user_certificate_repo->fetchCertificate($certificate_id);
302 if (!$certificate->isCurrentlyActive()) {
303 throw new Exception(
'Certificate is not active');
309 $this->
lng->txt(
'error_creating_certificate_pdf')
310 ))->withLogger($this->
logger);
311 $pdf_action->downloadPdf($certificate->getUserId(), $certificate->getObjId());
312 $this->
ctrl->redirect($this, self::CMD_CERTIFICATES_OVERVIEW);
313 }
catch (Exception $ex) {
314 $this->
logger->error(
'Fetching user certificate for download failed. Ex.: ' . $ex->getMessage());
315 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'error_creating_certificate_pdf'),
true);
316 $this->
ctrl->redirect($this, self::CMD_CERTIFICATES_OVERVIEW);
322 $form_settings =
new ilSetting(
'certificate');
324 $mode = $this->httpState->wrapper()->post()->retrieve(
325 'persistent_certificate_mode',
326 $this->
refinery->kindlyTo()->string()
328 $previousMode = $form_settings->get(
'persistent_certificate_mode',
'persistent_certificate_mode_cron');
329 if ($mode !== $previousMode && $mode ===
'persistent_certificate_mode_instant') {
337 $this->httpState->wrapper()->post()->retrieve(
'pageformat', $this->refinery->kindlyTo()->string())
341 (
string) ($this->httpState->wrapper()->post()->has(
'active') && $this->httpState->wrapper()->post()->retrieve(
343 $this->refinery->kindlyTo()->bool()
346 $form_settings->set(
'persistent_certificate_mode', $mode);
348 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'settings_saved'));
Class ResourceIdentification.
Just a wrapper class to create Unit Test for other classes.
Component logger with individual log levels by component id.
This class represents a non editable value in a property form.
const CMD_DOWNLOAD_CERTIFICATE
__construct( $data, int $id=0, bool $call_by_reference=true, bool $prepare_output=true, ?ilUserCertificateRepository $user_certificate_repo=null, ?ilCertificateActiveValidator $certificate_active_validator=null,)
readonly ilCertificateActiveValidator $certificate_active_validator
ILIAS HTTP GlobalHttpState $httpState
readonly ilUserCertificateRepository $user_certificate_repo
getAdminTabs()
administration tabs show only permissions and trash folder
readonly FitToSquare $card_thumbnail_definition
ILIAS FileUpload FileUpload $upload
const CMD_CERTIFICATES_OVERVIEW
readonly ilLogger $logger
static _enabledLearningProgress()
Class ilObjectGUI Basic methods of all Output classes.
prepareOutput(bool $show_sub_objects=true)
Class ilObject Basic functions for all objects.
This class represents an option in a radio group.
Interface GlobalHttpState.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc