ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilUserCertificateRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
24
29{
30 public const TABLE_NAME = 'il_cert_user_cert';
31
32 private readonly ilDBInterface $database;
33 private readonly ilLogger $logger;
34 private readonly string $defaultTitle;
35 private readonly ?Factory $uuid_factory;
36
37 public function __construct(
39 ?ilLogger $logger = null,
40 ?string $defaultTitle = null,
41 ?Factory $uuid_factory = null,
42 ) {
43 if (null === $database) {
44 global $DIC;
45 $database = $DIC->database();
46 }
47 $this->database = $database;
48
49 if (null === $logger) {
50 global $DIC;
51 $logger = $DIC->logger()->cert();
52 }
53 $this->logger = $logger;
54
55 if (null === $defaultTitle) {
56 global $DIC;
57 $defaultTitle = $DIC->language()->txt('certificate_no_object_title');
58 }
59
60 $this->defaultTitle = $defaultTitle;
61
62 if (!$uuid_factory) {
64 }
65 $this->uuid_factory = $uuid_factory;
66
67 }
68
72 public function save(ilUserCertificate $userCertificate): ilUserCertificate
73 {
74 $this->logger->debug('START - saving of user certificate');
75
76 $version = (int) $this->fetchLatestVersion($userCertificate->getObjId(), $userCertificate->getUserId());
77 ++$version;
78
79 $id = $this->database->nextId(self::TABLE_NAME);
80
81 $objId = $userCertificate->getObjId();
82 $userId = $userCertificate->getUserId();
83
85
86 $columns = [
87 'id' => ['integer', $id],
88 'pattern_certificate_id' => ['integer', $userCertificate->getPatternCertificateId()],
89 'obj_id' => ['integer', $objId],
90 'obj_type' => ['text', $userCertificate->getObjType()],
91 'usr_id' => ['integer', $userId],
92 'user_name' => ['text', $userCertificate->getUserName()],
93 'acquired_timestamp' => ['integer', $userCertificate->getAcquiredTimestamp()],
94 'certificate_content' => ['clob', $userCertificate->getCertificateContent()],
95 'template_values' => ['clob', $userCertificate->getTemplateValues()],
96 'valid_until' => ['integer', $userCertificate->getValidUntil()],
97 'version' => ['integer', $version],
98 'ilias_version' => ['text', $userCertificate->getIliasVersion()],
99 'currently_active' => ['integer', (int) $userCertificate->isCurrentlyActive()],
100 'background_image_ident' => ['text', $userCertificate->getBackgroundImageIdentification()],
101 'tile_image_ident' => ['text', $userCertificate->getTileImageIdentification()],
102 'certificate_id' => ['text', $userCertificate->getCertificateId()->asString()]
103 ];
104
105 $this->logger->debug(
106 sprintf(
107 'END - Save certificate with following values: %s',
108 json_encode($columns, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)
109 )
110 );
111
112 $this->database->insert(self::TABLE_NAME, $columns);
113
114 return $userCertificate->withId($id)->withVersion($version);
115 }
116
120 public function fetchActiveCertificates(int $userId): array
121 {
122 $this->logger->debug(sprintf('START - Fetching all active certificates for user: "%s"', $userId));
123
124 $sql = '
125SELECT ' . self::TABLE_NAME . '.*,
126il_cert_user_cert.certificate_id,
127 COALESCE(object_data.title, object_data_del.title, ' . $this->database->quote($this->defaultTitle, 'text') . ') AS title
128FROM ' . self::TABLE_NAME . '
129LEFT JOIN object_data ON object_data.obj_id = ' . self::TABLE_NAME . '.obj_id
130LEFT JOIN object_data_del ON object_data_del.obj_id = ' . self::TABLE_NAME . '.obj_id
131WHERE usr_id = ' . $this->database->quote($userId, 'integer') . '
132AND currently_active = 1';
133
134 $query = $this->database->query($sql);
135
136 $result = [];
137 while ($row = $this->database->fetchAssoc($query)) {
138 $userCertificate = $this->createUserCertificate($row);
139
140 $presentation = new ilUserCertificatePresentation(
141 (int) $row['obj_id'],
142 (string) $row['obj_type'],
143 $userCertificate,
144 $row['title'],
145 ''
146 );
147 $result[] = $presentation;
148 }
149
150 $this->logger->debug(sprintf('Actual results: "%s"', json_encode($result, JSON_THROW_ON_ERROR)));
151 $this->logger->debug(
152 sprintf(
153 'END - All active certificates for user: "%s" total: "%s"',
154 $userId,
155 count($result)
156 )
157 );
158
159 return $result;
160 }
161
166 int $userId,
167 int $startTimestamp,
168 int $endTimeStamp
169 ): array {
170 $this->logger->debug(sprintf('START - Fetching all active certificates for user: "%s"', $userId));
171
172 $sql = '
173SELECT ' . self::TABLE_NAME . '.*,
174il_cert_user_cert.certificate_id,
175 COALESCE(object_data.title, object_data_del.title, ' . $this->database->quote($this->defaultTitle, 'text') . ') AS title
176FROM ' . self::TABLE_NAME . '
177LEFT JOIN object_data ON object_data.obj_id = ' . self::TABLE_NAME . '.obj_id
178LEFT JOIN object_data_del ON object_data_del.obj_id = ' . self::TABLE_NAME . '.obj_id
179WHERE usr_id = ' . $this->database->quote($userId, 'integer') . '
180AND currently_active = 1
181AND acquired_timestamp >= ' . $this->database->quote($startTimestamp, 'integer') . '
182AND acquired_timestamp <= ' . $this->database->quote($endTimeStamp, 'integer');
183
184 $query = $this->database->query($sql);
185
186 $result = [];
187 while ($row = $this->database->fetchAssoc($query)) {
188 $userCertificate = $this->createUserCertificate($row);
189
190 $presentation = new ilUserCertificatePresentation(
191 (int) $row['obj_id'],
192 (string) $row['obj_type'],
193 $userCertificate,
194 $row['title'],
195 ''
196 );
197 $result[] = $presentation;
198 }
199
200 $this->logger->debug(sprintf('Actual results: "%s"', json_encode($result, JSON_THROW_ON_ERROR)));
201 $this->logger->debug(
202 sprintf(
203 'END - All active certificates for user: "%s" total: "%s"',
204 $userId,
205 count($result)
206 )
207 );
208
209 return $result;
210 }
211
215 public function fetchActiveCertificate(int $userId, int $objectId): ilUserCertificate
216 {
217 $this->logger->debug(
218 sprintf(
219 'START - Fetching all active certificates for user: "%s" and object: "%s"',
220 $userId,
221 $objectId
222 )
223 );
224
225 $sql = 'SELECT *
226 FROM ' . self::TABLE_NAME . '
227 WHERE usr_id = ' . $this->database->quote($userId, 'integer') . '
228 AND obj_id = ' . $this->database->quote($objectId, 'integer') . '
229 AND currently_active = 1';
230
231 $query = $this->database->query($sql);
232
233 while ($row = $this->database->fetchAssoc($query)) {
234 $this->logger->debug(sprintf('Active certificate values: %s', json_encode($row, JSON_THROW_ON_ERROR)));
235
236 $this->logger->debug(
237 sprintf(
238 'END -Found active user certificate for user: "%s" and object: "%s"',
239 $userId,
240 $objectId
241 )
242 );
243
244 return $this->createUserCertificate($row);
245 }
246
247 throw new ilException(
248 sprintf('There is no active entry for user id: "%s" and object id: "%s"', $userId, $objectId)
249 );
250 }
251
255 public function fetchActiveCertificateForPresentation(int $userId, int $objectId): ilUserCertificatePresentation
256 {
257 $this->logger->debug(
258 sprintf(
259 'START - Fetching all active certificates for user: "%s" and object: "%s"',
260 $userId,
261 $objectId
262 )
263 );
264
265 $sql = 'SELECT ' . self::TABLE_NAME . '.*,
266 il_cert_user_cert.certificate_id,usr_data.lastname,
267 COALESCE(object_data.title, object_data_del.title, ' . $this->database->quote($this->defaultTitle, 'text') . ') AS title
268 FROM ' . self::TABLE_NAME . '
269 LEFT JOIN object_data ON object_data.obj_id = ' . self::TABLE_NAME . '.obj_id
270 LEFT JOIN object_data_del ON object_data_del.obj_id = ' . self::TABLE_NAME . '.obj_id
271 LEFT JOIN usr_data ON usr_data.usr_id = ' . self::TABLE_NAME . '.usr_id
272 WHERE ' . self::TABLE_NAME . '.usr_id = ' . $this->database->quote($userId, 'integer') . '
273 AND ' . self::TABLE_NAME . '.obj_id = ' . $this->database->quote($objectId, 'integer') . '
274 AND ' . self::TABLE_NAME . '.currently_active = 1';
275
276 $query = $this->database->query($sql);
277
278 while ($row = $this->database->fetchAssoc($query)) {
279 $this->logger->debug(sprintf('Active certificate values: %s', json_encode($row, JSON_THROW_ON_ERROR)));
280
281 $this->logger->debug(
282 sprintf(
283 'END -Found active user certificate for user: "%s" and object: "%s"',
284 $userId,
285 $objectId
286 )
287 );
288
289 $userCertificate = $this->createUserCertificate($row);
290
292 (int) $row['obj_id'],
293 (string) $row['obj_type'],
294 $userCertificate,
295 $row['title'],
296 '',
297 $row['lastname']
298 );
299 }
300
301 throw new ilException(
302 sprintf('There is no active entry for user id: "%s" and object id: "%s"', $userId, $objectId)
303 );
304 }
305
309 public function fetchActiveCertificatesByTypeForPresentation(int $userId, string $type): array
310 {
311 $this->logger->debug(
312 sprintf(
313 'START - Fetching all active certificates for user: "%s" and type: "%s"',
314 $userId,
315 $type
316 )
317 );
318
319 $sql = 'SELECT ' . self::TABLE_NAME . '.*,
320 il_cert_user_cert.certificate_id,COALESCE(object_data.title, object_data_del.title, ' . $this->database->quote($this->defaultTitle, 'text') . ') AS title
321 FROM ' . self::TABLE_NAME . '
322 LEFT JOIN object_data ON object_data.obj_id = ' . self::TABLE_NAME . '.obj_id
323 LEFT JOIN object_data_del ON object_data_del.obj_id = ' . self::TABLE_NAME . '.obj_id
324 WHERE usr_id = ' . $this->database->quote($userId, 'integer') . '
325 AND obj_type = ' . $this->database->quote($type, 'text') . '
326 AND currently_active = 1';
327
328 $query = $this->database->query($sql);
329
330 $result = [];
331 while ($row = $this->database->fetchAssoc($query)) {
332 $userCertificate = $this->createUserCertificate($row);
333
334 $presentation = new ilUserCertificatePresentation(
335 (int) $row['obj_id'],
336 (string) $row['obj_type'],
337 $userCertificate,
338 $row['title'],
339 ''
340 );
341 $result[] = $presentation;
342 }
343
344 $this->logger->debug(
345 sprintf(
346 'END - Fetching all active certificates for user: "%s" and type: "%s"',
347 $userId,
348 $type
349 )
350 );
351
352 return $result;
353 }
354
359 {
360 $this->logger->debug(sprintf('START - Fetch certificate by id: "%s"', $id));
361
362 $sql = 'SELECT * FROM ' . self::TABLE_NAME . ' WHERE id = ' . $this->database->quote($id, 'integer');
363
364 $query = $this->database->query($sql);
365
366 while ($row = $this->database->fetchAssoc($query)) {
367 $this->logger->debug(sprintf('Fetched certificate: "%s"', json_encode($row, JSON_THROW_ON_ERROR)));
368
369 $this->logger->debug(sprintf('END - Fetch certificate by id: "%s"', $id));
370
371 return $this->createUserCertificate($row);
372 }
373
374 throw new ilException('No certificate found for user certificate id: ' . $id);
375 }
376
381 public function fetchObjectIdsWithCertificateForUser(int $userId, array $objectIds): array
382 {
383 $this->logger->debug(
384 sprintf(
385 'START - Fetch certificate for user("%s") and ids: "%s"',
386 $userId,
387 json_encode($objectIds, JSON_THROW_ON_ERROR)
388 )
389 );
390
391 if ([] === $objectIds) {
392 return [];
393 }
394
395 $inStatementObjectIds = $this->database->in(
396 'obj_id',
397 $objectIds,
398 false,
399 'integer'
400 );
401
402 $sql = 'SELECT obj_id FROM ' . self::TABLE_NAME . '
403 WHERE usr_id = ' . $this->database->quote($userId, 'integer') .
404 ' AND ' . $inStatementObjectIds .
405 ' AND currently_active = ' . $this->database->quote(1, 'integer');
406
407 $query = $this->database->query($sql);
408
409 $result = [];
410
411 while ($row = $this->database->fetchAssoc($query)) {
412 $this->logger->debug(sprintf('Fetched certificate: "%s"', json_encode($row, JSON_THROW_ON_ERROR)));
413 $result[] = (int) $row['obj_id'];
414 }
415
416 return $result;
417 }
418
422 public function fetchUserIdsWithCertificateForObject(int $objectId): array
423 {
424 $this->logger->debug(sprintf('START - Fetch certificate for object("%s")"', $objectId));
425
426 $sql = 'SELECT usr_id FROM ' . self::TABLE_NAME . '
427 WHERE obj_id = ' . $this->database->quote($objectId, 'integer') . '
428 AND currently_active = ' . $this->database->quote(1, 'integer');
429
430 $query = $this->database->query($sql);
431
432 $result = [];
433
434 while ($row = $this->database->fetchAssoc($query)) {
435 $this->logger->debug(sprintf('Fetched certificate: "%s"', json_encode($row, JSON_THROW_ON_ERROR)));
436 $result[] = (int) $row['usr_id'];
437 }
438
439 return $result;
440 }
441
442 public function deleteUserCertificates(int $userId): void
443 {
444 $this->logger->debug(sprintf('START - Delete certificate for user("%s")"', $userId));
445
446 $sql = 'DELETE FROM ' . self::TABLE_NAME . ' WHERE usr_id = ' . $this->database->quote($userId, 'integer');
447
448 $this->database->manipulate($sql);
449
450 $this->logger->debug(sprintf('END - Successfully deleted certificate for user("%s")"', $userId));
451 }
452
456 private function fetchCertificatesOfObject(int $objId, int $userId): array
457 {
458 $this->logger->debug(
459 sprintf(
460 'START - fetching all certificates of object(user id: "%s", object id: "%s")',
461 $userId,
462 $objId
463 )
464 );
465
466 $sql = 'SELECT * FROM ' . self::TABLE_NAME . '
467 WHERE usr_id = ' . $this->database->quote($userId, 'integer') . '
468 AND obj_id = ' . $this->database->quote($objId, 'integer');
469
470 $query = $this->database->query($sql);
471
472 $result = [];
473 while ($row = $this->database->fetchAssoc($query)) {
474 $this->logger->debug(
475 sprintf(
476 'Certificate found: "%s")',
477 json_encode($row, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT)
478 )
479 );
480
481 $this->logger->debug(sprintf('Certificate: "%s"', json_encode($row, JSON_THROW_ON_ERROR)));
482
483 $result[] = $this->createUserCertificate($row);
484 }
485
486 $this->logger->debug(
487 sprintf(
488 'END - fetching all certificates of object(user id: "%s", object id: "%s")',
489 $userId,
490 $objId
491 )
492 );
493
494 return $result;
495 }
496
497 private function fetchLatestVersion(int $objId, int $userId): string
498 {
499 $this->logger->debug(
500 sprintf(
501 'START - fetching of latest certificates of object(user id: "%s", object id: "%s")',
502 $userId,
503 $objId
504 )
505 );
506
507 $templates = $this->fetchCertificatesOfObject($objId, $userId);
508
509 $version = 0;
510 foreach ($templates as $template) {
511 if ($template->getVersion() > $version) {
512 $version = $template->getVersion();
513 }
514 }
515
516 $this->logger->debug(
517 sprintf(
518 'END - fetching of latest certificates of object(user id: "%s", object id: "%s") with version "%s"',
519 $userId,
520 $objId,
522 )
523 );
524
525 return (string) $version;
526 }
527
528 private function deactivatePreviousCertificates(int $objId, int $userId): void
529 {
530 $this->logger->debug(
531 sprintf(
532 'START - deactivating previous certificates for user id: "%s" and object id: "%s"',
533 $userId,
534 $objId
535 )
536 );
537
538 $sql = '
539UPDATE ' . self::TABLE_NAME . '
540SET currently_active = 0
541WHERE obj_id = ' . $this->database->quote($objId, 'integer') . '
542AND usr_id = ' . $this->database->quote($userId, 'integer');
543
544 $this->database->manipulate($sql);
545
546 $this->logger->debug(
547 sprintf(
548 'END - deactivating previous certificates for user id: "%s" and object id: "%s"',
549 $userId,
550 $objId
551 )
552 );
553 }
554
555 public function isResourceUsed(string $relative_image_identification): bool
556 {
557 $this->logger->debug(
558 sprintf(
559 'START - Checking if any certificate template uses background image identification "%s"',
560 $relative_image_identification
561 )
562 );
563
564 $result = $this->database->queryF(
565 'SELECT EXISTS(SELECT 1 FROM ' . self::TABLE_NAME . ' WHERE
566 (background_image_ident = %s OR tile_image_ident = %s)
567 AND currently_active = 1) AS does_exist',
568 ['text', 'text'],
569 [$relative_image_identification, $relative_image_identification]
570 );
571
572 $exists = (bool) ($this->database->fetchAssoc($result)['does_exist'] ?? false);
573
574 $this->logger->debug(
575 sprintf(
576 'END - Image identification "%s" is ' . $exists ? 'in use' : 'unused',
577 $relative_image_identification
578 )
579 );
580
581 return $exists;
582 }
583
587 private function createUserCertificate(array $row): ilUserCertificate
588 {
589 return new ilUserCertificate(
590 (int) $row['pattern_certificate_id'],
591 (int) $row['obj_id'],
592 $row['obj_type'],
593 (int) $row['usr_id'],
594 $row['user_name'],
595 (int) $row['acquired_timestamp'],
596 $row['certificate_content'],
597 $row['template_values'],
598 (int) $row['valid_until'],
599 (int) $row['version'],
600 $row['ilias_version'],
601 (bool) $row['currently_active'],
602 new CertificateId($row['certificate_id']),
603 (string) $row['background_image_ident'],
604 (string) $row['tile_image_ident'],
605 isset($row['id']) ? (int) $row['id'] : null
606 );
607 }
608
609 public function deleteUserCertificatesForObject(int $userId, int $obj_id): void
610 {
611 $this->logger->debug(
612 sprintf('START - Delete certificate for user("%s") in object (obj_id: %s)"', $userId, $obj_id)
613 );
614
615 $sql = 'DELETE FROM ' . self::TABLE_NAME . ' ' . PHP_EOL
616 . ' WHERE usr_id = ' . $this->database->quote($userId, 'integer') . PHP_EOL
617 . ' AND obj_id = ' . $this->database->quote($obj_id, 'integer');
618
619 $this->database->manipulate($sql);
620
621 $this->logger->debug(
622 sprintf('END - Successfully deleted certificate for user("%s") in object (obj_id: %s)"', $userId, $obj_id)
623 );
624 }
625
626 private function overviewTableColumnToDbColumn(string $table_column): string
627 {
628 $result = match ($table_column) {
629 'certificate_id' => $table_column,
630 'issue_date' => 'acquired_timestamp',
631 'object' => 'object_data.title',
632 'owner' => 'usr_data.login',
633 'obj_id' => 'cert.obj_id',
634 default => null,
635 };
636
637 if (!$result) {
638 throw new InvalidArgumentException('Invalid table column passed');
639 }
640
641 return $result;
642 }
643
649 string $user_language,
650 array $filter,
651 ?Range $range = null,
652 string $order_field = 'issue_date',
653 string $order_direction = 'ASC'
654 ): array {
655 $order_field = $this->overviewTableColumnToDbColumn($order_field);
656
657 $sql_filters = [];
658 foreach ($filter as $key => $value) {
659 if ($value === null) {
660 continue;
661 }
662
663 $column_name = $this->overviewTableColumnToDbColumn($key);
664
665 if ($key === 'issue_date') {
666 $sql_filter = $this->getIssueDateSqlFilter($column_name, is_array($value) ? $value : []);
667 if ($sql_filter) {
668 $sql_filters[] = $sql_filter;
669 }
670 } else {
671 $sql_filters[] = $this->database->like($column_name, ilDBConstants::T_TEXT, "%$value%");
672 }
673 }
674
675 if ($range) {
676 $this->database->setLimit($range->getLength(), $range->getStart());
677 }
678
679 $result = $this->database->query(
680 'SELECT cert.*, ' .
681 '(CASE
682 WHEN (trans.title IS NOT NULL AND LENGTH(trans.title) > 0) THEN trans.title
683 WHEN (object_data.title IS NOT NULL AND LENGTH(object_data.title) > 0) THEN object_data.title
684 WHEN (object_data_del.title IS NOT NULL AND LENGTH(object_data_del.title) > 0) THEN object_data_del.title
685 ELSE ' . $this->database->quote($this->defaultTitle, ilDBConstants::T_TEXT) . '
686 END
687 ) as object, '
688 . 'usr_data.login AS owner FROM il_cert_user_cert AS cert '
689 . 'LEFT JOIN object_data ON object_data.obj_id = cert.obj_id '
690 . 'INNER JOIN usr_data ON usr_data.usr_id = cert.usr_id '
691 . 'LEFT JOIN object_data_del ON object_data_del.obj_id = cert.obj_id '
692 . 'LEFT JOIN object_translation trans ON trans.obj_id = object_data.obj_id AND trans.lang_code = ' . $this->database->quote($user_language, 'text')
693 . ($sql_filters !== [] ? " WHERE " . implode(" AND ", $sql_filters) : "")
694 . ' ORDER BY ' . $order_field . ' ' . $order_direction
695 );
696
697 $certificates = [];
698 while ($row = $this->database->fetchAssoc($result)) {
699 $certificates[] = $this->createUserCertificate($row);
700 }
701 return $certificates;
702 }
703
707 private function getIssueDateSqlFilter(string $column_name, array $duration): ?string
708 {
709 if (array_keys($duration) === ["from", "to"] && $duration !== ["from" => null, "to" => null]) {
710 $from = $duration["from"];
711 $to = $duration["to"];
712
713 $sql_filter = "";
714 if ($from && $to) {
715 $sql_filter = $column_name
716 . ' BETWEEN '
717 . $this->database->quote($from->getTimestamp(), ilDBConstants::T_INTEGER)
718 . ' AND '
719 . $this->database->quote($to->getTimestamp(), ilDBConstants::T_INTEGER);
720 }
721
722 if ($from && !$to) {
723 $sql_filter = $column_name
724 . ' >= '
725 . $this->database->quote($from->getTimestamp(), ilDBConstants::T_INTEGER);
726 }
727
728 if (!$from && $to) {
729 $sql_filter = $column_name
730 . ' <= '
731 . $this->database->quote($to->getTimestamp(), ilDBConstants::T_INTEGER);
732 }
733
734 if ($sql_filter) {
735 return $sql_filter;
736 }
737 }
738 return null;
739 }
740
744 public function fetchCertificatesForOverviewCount(array $filter, ?Range $range = null): int
745 {
746 $sql_filters = [];
747 foreach ($filter as $key => $value) {
748 if ($value === null) {
749 continue;
750 }
751
752 $column_name = $key;
753 switch ($key) {
754 case 'issue_date':
755 $column_name = 'acquired_timestamp';
756 break;
757 case 'object':
758 $column_name = 'object_data.title';
759 break;
760 case 'owner':
761 $column_name = 'usr_data.login';
762 break;
763 case 'obj_id':
764 $column_name = 'cert.obj_id';
765 break;
766 }
767
768 if ($key === 'issue_date') {
769 $sql_filter = $this->getIssueDateSqlFilter($column_name, is_array($value) ? $value : []);
770 if ($sql_filter) {
771 $sql_filters[] = $sql_filter;
772 }
773 } else {
774 $sql_filters[] = $this->database->like($column_name, ilDBConstants::T_TEXT, "%$value%");
775 }
776 }
777
778 if ($range) {
779 $this->database->setLimit($range->getLength(), $range->getStart());
780 }
781
782 $result = $this->database->query(
783 'SELECT COUNT(id) as count FROM il_cert_user_cert AS cert '
784 . 'LEFT JOIN object_data ON object_data.obj_id = cert.obj_id '
785 . 'INNER JOIN usr_data ON usr_data.usr_id = cert.usr_id'
786 . ($sql_filters !== [] ? ' AND ' . implode(' AND ', $sql_filters) : '')
787 );
788
789 return (int) $this->database->fetchAssoc($result)['count'];
790 }
791
793 {
794 return new CertificateId($this->uuid_factory->uuid4AsString());
795 }
796}
$version
Definition: plugin.php:24
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$duration
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
Base class for ILIAS Exception handling.
Component logger with individual log levels by component id.
isResourceUsed(string $relative_image_identification)
deleteUserCertificatesForObject(int $userId, int $obj_id)
fetchActiveCertificatesInIntervalForPresentation(int $userId, int $startTimestamp, int $endTimeStamp)
fetchCertificatesForOverview(string $user_language, array $filter, ?Range $range=null, string $order_field='issue_date', string $order_direction='ASC')
fetchActiveCertificateForPresentation(int $userId, int $objectId)
deactivatePreviousCertificates(int $objId, int $userId)
fetchObjectIdsWithCertificateForUser(int $userId, array $objectIds)
fetchCertificatesForOverviewCount(array $filter, ?Range $range=null)
fetchActiveCertificatesByTypeForPresentation(int $userId, string $type)
getIssueDateSqlFilter(string $column_name, array $duration)
fetchActiveCertificate(int $userId, int $objectId)
__construct(?ilDBInterface $database=null, ?ilLogger $logger=null, ?string $defaultTitle=null, ?Factory $uuid_factory=null,)
save(ilUserCertificate $userCertificate)
Interface ilDBInterface.
global $DIC
Definition: shib_login.php:26
$objId
Definition: xapitoken.php:55