ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilPDSelectedItemsBlockMembershipsObjectDatabaseRepository.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
23 private const VALID_OBJECT_TYPES = [
24 'crs',
25 'grp',
26 ];
27
28 public function __construct(protected readonly ilDBInterface $db, protected readonly int $recovery_folder_id)
29 {
30 }
31
35 public function getValidObjectTypes(): array
36 {
38 }
39
40 public function getForUser(ilObjUser $user, array $objTypes, string $actorLanguageCode): Generator
41 {
42 $objTypes = array_intersect($objTypes, self::VALID_OBJECT_TYPES);
43 if ($objTypes === []) {
44 return;
45 }
46
47 $odObjTypes = ' AND ' . $this->db->in(
48 'od.type',
49 $objTypes,
50 false,
52 );
53
54 $res = $this->db->queryF(
55 "
56 SELECT DISTINCT
57 od.obj_id,
58 objr.ref_id,
59 (
60 CASE
61 WHEN (trans.title IS NOT NULL AND trans.title != '')
62 THEN trans.title
63 ELSE od.title
64 END
65 ) title,
66 (
67 CASE
68 WHEN (trans.description IS NOT NULL AND trans.description != '')
69 THEN trans.description
70 ELSE od.description
71 END
72 ) description,
73 od.type,
74 t.parent,
75 tp.lft parent_lft,
76 (
77 CASE
78 WHEN od.type = 'crs' THEN crs_settings.period_start
79 ELSE grp_settings.period_start
80 END
81 ) period_start,
82 (
83 CASE
84 WHEN od.type = 'crs' THEN crs_settings.period_end
85 ELSE grp_settings.period_end
86 END
87 ) period_end,
88 (
89 CASE
90 WHEN od.type = 'crs' THEN crs_settings.period_time_indication
91 ELSE grp_settings.period_time_indication
92 END
93 ) period_has_time
94 FROM rbac_ua ua
95 INNER JOIN rbac_fa fa ON fa.rol_id = ua.rol_id AND fa.assign = %s
96 INNER JOIN object_reference objr ON objr.ref_id = fa.parent
97 INNER JOIN object_data od ON od.obj_id = objr.obj_id $odObjTypes
98 INNER JOIN tree t ON t.child = objr.ref_id AND t.tree = %s AND t.parent != %s
99 INNER JOIN tree tp ON tp.child = t.parent
100 LEFT JOIN grp_settings ON grp_settings.obj_id = od.obj_id
101 LEFT JOIN crs_settings ON crs_settings.obj_id = od.obj_id
102 LEFT JOIN object_translation trans ON trans.obj_id = od.obj_id AND trans.lang_code = %s
103 WHERE ua.usr_id = %s
104 ",
106 ['y', 1, $this->recovery_folder_id, $actorLanguageCode, $user->getId()]
107 );
108
109 while ($row = $this->db->fetchAssoc($res)) {
110 $periodStart = null;
111 if (!is_null($row['period_start'])) {
112 $periodStart = new DateTimeImmutable($row['period_start'], new DateTimeZone('UTC'));
113 }
114 $periodEnd = null;
115 if (!is_null($row['period_end'])) {
116 $periodEnd = new DateTimeImmutable($row['period_end'], new DateTimeZone('UTC'));
117 }
118
120 (int) $row['ref_id'],
121 (int) $row['obj_id'],
122 (string) $row['type'],
123 (string) $row['title'],
124 (string) $row['description'],
125 (int) $row['parent'],
126 (int) $row['parent_lft'],
127 (bool) $row['period_has_time'],
128 $periodStart,
129 $periodEnd
130 );
131 }
132 }
133}
User class.
__construct(protected readonly ilDBInterface $db, protected readonly int $recovery_folder_id)
Interface ilDBInterface.
$res
Definition: ltiservices.php:69