ILIAS  release_8 Revision v8.24
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
29 private int $recoveryFolderId;
30
32 {
33 $this->db = $db;
34 $this->recoveryFolderId = $recoveryFolderId;
35 }
36
40 public function getValidObjectTypes(): array
41 {
43 }
44
48 public function getForUser(ilObjUser $user, array $objTypes, string $actorLanguageCode): Generator
49 {
50 $objTypes = array_intersect($objTypes, self::VALID_OBJECT_TYPES);
51 if ($objTypes === []) {
52 return;
53 }
54
55 $odObjTypes = ' AND ' . $this->db->in(
56 'od.type',
57 $objTypes,
58 false,
59 'text'
60 );
61
62 $res = $this->db->queryF(
63 "
64 SELECT DISTINCT
65 od.obj_id,
66 objr.ref_id,
67 (
68 CASE
69 WHEN (trans.title IS NOT NULL AND trans.title != '')
70 THEN trans.title
71 ELSE od.title
72 END
73 ) title,
74 (
75 CASE
76 WHEN (trans.description IS NOT NULL AND trans.description != '')
77 THEN trans.description
78 ELSE od.description
79 END
80 ) description,
81 od.type,
82 t.parent,
83 tp.lft parent_lft,
84 (
85 CASE
86 WHEN od.type = 'crs' THEN crs_settings.period_start
87 ELSE grp_settings.period_start
88 END
89 ) period_start,
90 (
91 CASE
92 WHEN od.type = 'crs' THEN crs_settings.period_end
93 ELSE grp_settings.period_end
94 END
95 ) period_end,
96 (
97 CASE
98 WHEN od.type = 'crs' THEN crs_settings.period_time_indication
99 ELSE grp_settings.period_time_indication
100 END
101 ) period_has_time
102 FROM rbac_ua ua
103 INNER JOIN rbac_fa fa ON fa.rol_id = ua.rol_id AND fa.assign = %s
104 INNER JOIN object_reference objr ON objr.ref_id = fa.parent
105 INNER JOIN object_data od ON od.obj_id = objr.obj_id $odObjTypes
106 INNER JOIN tree t ON t.child = objr.ref_id AND t.tree = %s AND t.parent != %s
107 INNER JOIN tree tp ON tp.child = t.parent
108 LEFT JOIN grp_settings ON grp_settings.obj_id = od.obj_id
109 LEFT JOIN crs_settings ON crs_settings.obj_id = od.obj_id
110 LEFT JOIN object_translation trans ON trans.obj_id = od.obj_id AND trans.lang_code = %s
111 WHERE ua.usr_id = %s
112 ",
113 ['text', 'integer', 'integer', 'text', 'integer'],
114 ['y', 1, $this->recoveryFolderId, $actorLanguageCode, $user->getId()]
115 );
116
117 while ($row = $this->db->fetchAssoc($res)) {
118 $periodStart = null;
119 if (!is_null($row['period_start'])) {
120 $periodStart = new DateTimeImmutable($row['period_start'], new DateTimeZone('UTC'));
121 }
122 $periodEnd = null;
123 if (!is_null($row['period_end'])) {
124 $periodEnd = new DateTimeImmutable($row['period_end'], new DateTimeZone('UTC'));
125 }
126
128 (int) $row['ref_id'],
129 (int) $row['obj_id'],
130 (string) $row['type'],
131 (string) $row['title'],
132 (string) $row['description'],
133 (int) $row['parent'],
134 (int) $row['parent_lft'],
135 (bool) $row['period_has_time'],
136 $periodStart,
137 $periodEnd
138 );
139 }
140 }
141}
User class.
getForUser(ilObjUser $user, array $objTypes, string $actorLanguageCode)
@inheritDoc
Interface ilDBInterface.
$res
Definition: ltiservices.php:69