19declare(strict_types=1);
24use Psr\Http\Message\ServerRequestInterface;
40 private readonly ServerRequestInterface
$request;
52 'title_ASC' =>
'cert_sortable_by_title_asc',
53 'title_DESC' =>
'cert_sortable_by_title_desc',
54 'date_ASC' =>
'cert_sortable_by_issue_date_asc',
55 'date_DESC' =>
'cert_sortable_by_issue_date_desc',
66 ?ServerRequestInterface
$request =
null,
75 private ?IRSS $irss =
null
79 $this->
template = $template ??
$DIC->ui()->mainTemplate();
91 $this->db =
$db ??
$DIC->database();
92 $this->irss = $irss ??
$DIC->resourceStorage();
94 $this->
language->loadLanguageModule(
'cert');
99 return 'listCertificates';
104 $cmd = $this->
ctrl->getCmd();
106 if (!$this->certificateSettings->get(
'active',
'0')) {
107 $this->
ctrl->returnToParent($this);
110 $this->
template->setTitle($this->
language->txt(
'obj_cert'));
111 if (!method_exists($this, $cmd)) {
125 $this->
help->setScreenIdComponent(
'cert');
127 if (!$this->certificateSettings->get(
'active',
'0')) {
128 $this->
ctrl->redirect($this);
131 $this->
template->setPermanentLink(
'cert',
null,
'list');
135 $this->certificateLogger,
136 $this->
language->txt(
'certificate_no_object_title')
141 $this->
user->getId(),
143 'order_field' => explode(
'_', $sorting)[0],
144 'order_direction' => explode(
'_', $sorting)[1],
145 'language' => $this->
user->getLanguage()
152 if (
$data[
'items'] !== []) {
156 foreach ($this->sortationOptions as $fieldAndDirection => $lngVariable) {
160 $sortViewControl = $this->uiFactory
163 ->withTargetURL($this->
ctrl->getLinkTarget($this,
'applySortation'),
'sort_by');
165 $uiComponents[] = $sortViewControl;
167 foreach (
$data[
'items'] as $certificateData) {
168 $tile_image_identification = $certificateData[
'tile_image_ident'] ??
'';
170 if ($tile_image_identification ===
'' || $tile_image_identification ===
'-') {
171 $tile_image_identification = $certificateData[
'tile_image_path'] ??
'';
172 if ($tile_image_identification !==
'' && $this->
filesystem->has($tile_image_identification)) {
178 $tile_image_rid = $this->irss->manage()->find($tile_image_identification);
180 $imagePath = $this->irss->consume()->src($tile_image_rid)->getSrc(
true);
184 if ($imagePath ===
'') {
188 $cardImage = $this->uiFactory->image()->standard(
190 $certificateData[
'title']
195 if ($certificateData[
'description'] !==
'') {
196 $sections[] = $this->uiFactory->listing()->descriptive([
197 $this->
language->txt(
'cert_description_label') => $certificateData[
'description']
203 $sections[] = $this->uiFactory->listing()->descriptive([
210 $objectTypeIcon = $this->uiFactory
213 ->standard($certificateData[
'obj_type'], $certificateData[
'obj_type'])
216 $objectTitle = $certificateData[
'title'];
218 foreach ($refIds as
$refId) {
219 if ($this->
access->checkAccess(
'read',
'', $refId)) {
220 $objectTitle = $this->uiRenderer->render(
221 $this->uiFactory->link()->standard($objectTitle, ilLink::_getLink(
$refId))
228 $sections[] = $this->uiFactory->listing()->descriptive([$this->
language->txt(
'cert_object_label') => implode(
231 $this->uiRenderer->render($objectTypeIcon),
237 $this->
ctrl->setParameter($this,
'certificate_id', $certificateData[
'id']);
238 $downloadHref = $this->
ctrl->getLinkTarget($this,
'download');
239 $this->
ctrl->clearParameters($this);
240 $sections[] = $this->uiFactory->button()->standard(
'Download', $downloadHref);
242 $card = $this->uiFactory
244 ->standard($certificateData[
'title'], $cardImage)
245 ->withSections($sections)
251 $deck = $this->uiFactory->deck($cards)->withSmallCardsSize();
253 $uiComponents[] = $this->uiFactory->divider()->horizontal();
255 $uiComponents[] = $deck;
257 $this->
template->setOnScreenMessage(
'info', $this->
language->txt(
'cert_currently_no_certs'));
260 $this->
template->setContent($this->uiRenderer->render($uiComponents));
266 if (!array_key_exists($sorting, $this->sortationOptions)) {
280 if (!array_key_exists($sorting, $this->sortationOptions)) {
293 $pdfGenerator =
new ilPdfGenerator($this->userCertificateRepository);
295 $userCertificateId = (
int) $this->request->getQueryParams()[
'certificate_id'];
298 $userCertificate = $this->userCertificateRepository->fetchCertificate($userCertificateId);
299 if ($userCertificate->getUserId() !== $this->
user->getId()) {
300 throw new ilException(sprintf(
'User "%s" tried to access certificate: "%s"', $this->
user->getLogin(), $userCertificateId));
303 $this->certificateLogger->warning($exception->getMessage());
304 $this->
template->setOnScreenMessage(
'failure', $this->
language->txt(
'cert_error_no_access'));
313 $this->
language->txt(
'error_creating_certificate_pdf')
316 $pdfAction->downloadPdf($userCertificate->getUserId(), $userCertificate->getObjId());
Builds a Color from either hex- or rgb values.
Class ResourceIdentification.
Just a wrapper class to create Unit Test for other classes.
static useRelativeDates()
static setUseRelativeDates(bool $a_status)
set use relative dates
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.
static getWebspaceDir(string $mode="filesystem")
get webspace directory
Component logger with individual log levels by component id.
static _getAllReferences(int $id)
get all reference ids for object ID
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
@ilCtrl_IsCalledBy ilUserCertificateGUI: ilAchievementsGUI
readonly ServerRequestInterface $request
final const SORTATION_SESSION_KEY
readonly ilAccessHandler $access
readonly Factory $uiFactory
readonly ilLanguage $language
readonly ilUserCertificateRepository $userCertificateRepository
readonly Filesystem $filesystem
readonly ilCtrlInterface $ctrl
__construct(?ilGlobalTemplateInterface $template=null, ?ilCtrlInterface $ctrl=null, ?ilLanguage $language=null, ?ilObjUser $user=null, ?ilUserCertificateRepository $userCertificateRepository=null, ?ServerRequestInterface $request=null, ?ilLogger $certificateLogger=null, private readonly ilSetting $certificateSettings=new ilSetting('certificate'), ?Factory $uiFactory=null, ?Renderer $uiRenderer=null, ?ilAccessHandler $access=null, ?Filesystem $filesystem=null, ?ilHelpGUI $help=null, ?ilDBInterface $db=null, private ?IRSS $irss=null)
readonly ilGlobalTemplateInterface $template
readonly ilDBInterface $db
readonly ilLogger $certificateLogger
readonly Renderer $uiRenderer
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static signFile(string $path_to_file)
The filesystem interface provides the public interface for the Filesystem service API consumer.
This is how the factory for UI elements looks.
An entity that renders components to a string output.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...