19declare(strict_types=1);
23use Psr\Http\Message\ServerRequestInterface;
39 private readonly ServerRequestInterface
$request;
51 'title_ASC' =>
'cert_sortable_by_title_asc',
52 'title_DESC' =>
'cert_sortable_by_title_desc',
53 'date_ASC' =>
'cert_sortable_by_issue_date_asc',
54 'date_DESC' =>
'cert_sortable_by_issue_date_desc',
64 ?ServerRequestInterface
$request =
null,
72 private ?IRSS $irss =
null
76 $this->
template = $template ??
$DIC->ui()->mainTemplate();
81 $this->
logger = $certificateLogger ??
$DIC->logger()->cert();
82 $this->ui_factory = $uiFactory ??
$DIC->ui()->factory();
83 $this->ui_renderer = $uiRenderer ??
$DIC->ui()->renderer();
87 $this->db =
$db ??
$DIC->database();
88 $this->irss = $irss ??
$DIC->resourceStorage();
90 $this->
language->loadLanguageModule(
'cert');
95 return 'listCertificates';
100 $cmd = $this->
ctrl->getCmd();
102 if (!$this->certificateSettings->get(
'active',
'0')) {
103 $this->
ctrl->returnToParent($this);
106 $this->
template->setTitle($this->
language->txt(
'obj_cert'));
107 if (!method_exists($this, $cmd)) {
121 $this->
help->setScreenIdComponent(
'cert');
123 if (!$this->certificateSettings->get(
'active',
'0')) {
124 $this->
ctrl->redirect($this);
127 $this->
template->setPermanentLink(
'cert',
null,
'list');
132 $this->
language->txt(
'certificate_no_object_title')
137 $this->
user->getId(),
139 'order_field' => explode(
'_', $sorting)[0],
140 'order_direction' => explode(
'_', $sorting)[1],
141 'language' => $this->
user->getLanguage()
148 if (
$data[
'items'] !== []) {
149 $sortationOptions = [];
152 foreach ($this->sortation_options as $fieldAndDirection => $lngVariable) {
153 $sortationOptions[$fieldAndDirection] = $this->
language->txt($lngVariable);
156 $sortViewControl = $this->ui_factory
158 ->sortation($sortationOptions, $sorting)
159 ->withTargetURL($this->
ctrl->getLinkTarget($this,
'applySortation'),
'sort_by');
161 $uiComponents[] = $sortViewControl;
163 foreach (
$data[
'items'] as $certificateData) {
164 $tile_image_identification = $certificateData[
'tile_image_ident'] ??
'';
166 $tile_image_rid = $this->irss->manage()->find($tile_image_identification);
168 $imagePath = $this->irss->consume()->src($tile_image_rid)->getSrc(
true);
171 if ($imagePath ===
'') {
175 $cardImage = $this->ui_factory->image()->standard(
177 $certificateData[
'title']
182 if ($certificateData[
'description'] !==
'') {
183 $sections[] = $this->ui_factory->listing()->descriptive([
184 $this->
language->txt(
'cert_description_label') => $certificateData[
'description']
190 $sections[] = $this->ui_factory->listing()->descriptive([
197 $objectTypeIcon = $this->ui_factory
200 ->standard($certificateData[
'obj_type'], $certificateData[
'obj_type'])
203 $objectTitle = $certificateData[
'title'];
205 foreach ($refIds as
$refId) {
206 if ($this->
access->checkAccess(
'read',
'', $refId)) {
207 $objectTitle = $this->ui_renderer->render(
208 $this->ui_factory->link()->standard($objectTitle, ilLink::_getLink(
$refId))
215 $sections[] = $this->ui_factory->listing()->descriptive([$this->
language->txt(
'cert_object_label') => implode(
218 $this->ui_renderer->render($objectTypeIcon),
224 $this->
ctrl->setParameter($this,
'certificate_id', $certificateData[
'id']);
225 $downloadHref = $this->
ctrl->getLinkTarget($this,
'download');
226 $this->
ctrl->clearParameters($this);
227 $sections[] = $this->ui_factory->button()->standard(
'Download', $downloadHref);
229 $card = $this->ui_factory
231 ->standard($certificateData[
'title'], $cardImage)
232 ->withSections($sections)
238 $deck = $this->ui_factory->deck($cards)->withSmallCardsSize();
240 $uiComponents[] = $this->ui_factory->divider()->horizontal();
242 $uiComponents[] = $deck;
244 $this->
template->setOnScreenMessage(
'info', $this->
language->txt(
'cert_currently_no_certs'));
247 $this->
template->setContent($this->ui_renderer->render($uiComponents));
253 if (!array_key_exists($sorting, $this->sortation_options)) {
267 if (!array_key_exists($sorting, $this->sortation_options)) {
280 $certificate_id = (
int) $this->request->getQueryParams()[
'certificate_id'];
283 $certificate = $this->user_certificate_repo->fetchCertificate($certificate_id);
284 if ($certificate->getUserId() !== $this->
user->getId()) {
286 sprintf(
'User "%s" tried to access certificate: "%s"', $this->
user->getLogin(), $certificate_id)
290 $this->
logger->warning($exception->getMessage());
291 $this->
template->setOnScreenMessage(
'failure', $this->
language->txt(
'cert_error_no_access'));
300 $this->
language->txt(
'error_creating_certificate_pdf')
301 ))->withLogger($this->
logger);
302 $action->downloadPdf($certificate->getUserId(), $certificate->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.
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
readonly ilLogger $logger
readonly ilAccessHandler $access
readonly ilUserCertificateRepository $user_certificate_repo
readonly Factory $ui_factory
readonly ilLanguage $language
final const string SORTATION_SESSION_KEY
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, ?ilHelpGUI $help=null, ?ilDBInterface $db=null, private ?IRSS $irss=null)
readonly ilGlobalTemplateInterface $template
readonly Renderer $ui_renderer
readonly ilDBInterface $db
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
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...