ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPDSelectedItemsBlockMembershipsObjectDatabaseRepository.php
Go to the documentation of this file.
1 <?php declare(strict_types=1);
2 
21 {
22  private const VALID_OBJECT_TYPES = [
23  'crs',
24  'grp',
25  ];
26 
28  private $db;
31 
33  {
34  $this->db = $db;
35  $this->recoveryFolderId = $recoveryFolderId;
36  }
37 
41  public function getValidObjectTypes() : array
42  {
43  return self::VALID_OBJECT_TYPES;
44  }
45 
49  public function getForUser(ilObjUser $user, array $objTypes, string $actorLanguageCode) : Generator
50  {
51  $objTypes = array_intersect($objTypes, self::VALID_OBJECT_TYPES);
52  if ($objTypes === []) {
53  return;
54  }
55 
56  $odObjTypes = ' AND ' . $this->db->in(
57  'od.type',
58  $objTypes,
59  false,
60  'text'
61  );
62 
63  $res = $this->db->queryF(
64  "
65  SELECT DISTINCT
66  od.obj_id,
67  objr.ref_id,
68  (
69  CASE
70  WHEN (trans.title IS NOT NULL AND trans.title != '')
71  THEN trans.title
72  ELSE od.title
73  END
74  ) title,
75  (
76  CASE
77  WHEN (trans.description IS NOT NULL AND trans.description != '')
78  THEN trans.description
79  ELSE od.description
80  END
81  ) description,
82  od.type,
83  t.parent,
84  tp.lft parent_lft,
85  (
86  CASE
87  WHEN od.type = 'crs' THEN crs_settings.period_start
88  ELSE grp_settings.period_start
89  END
90  ) period_start,
91  (
92  CASE
93  WHEN od.type = 'crs' THEN crs_settings.period_end
94  ELSE grp_settings.period_end
95  END
96  ) period_end,
97  (
98  CASE
99  WHEN od.type = 'crs' THEN crs_settings.period_time_indication
100  ELSE grp_settings.period_time_indication
101  END
102  ) period_has_time
103  FROM rbac_ua ua
104  INNER JOIN rbac_fa fa ON fa.rol_id = ua.rol_id AND fa.assign = %s
105  INNER JOIN object_reference objr ON objr.ref_id = fa.parent
106  INNER JOIN object_data od ON od.obj_id = objr.obj_id $odObjTypes
107  INNER JOIN tree t ON t.child = objr.ref_id AND t.tree = %s AND t.parent != %s
108  INNER JOIN tree tp ON tp.child = t.parent
109  LEFT JOIN grp_settings ON grp_settings.obj_id = od.obj_id
110  LEFT JOIN crs_settings ON crs_settings.obj_id = od.obj_id
111  LEFT JOIN object_translation trans ON trans.obj_id = od.obj_id AND trans.lang_code = %s
112  WHERE ua.usr_id = %s
113  ",
114  ['text', 'integer', 'integer', 'text', 'integer'],
115  ['y', 1, $this->recoveryFolderId, $actorLanguageCode, $user->getId()]
116  );
117 
118  while ($row = $this->db->fetchAssoc($res)) {
119  $periodStart = null;
120  if (!is_null($row['period_start'])) {
121  $periodStart = new DateTimeImmutable($row['period_start'], new DateTimeZone('UTC'));
122  }
123  $periodEnd = null;
124  if (!is_null($row['period_end'])) {
125  $periodEnd = new DateTimeImmutable($row['period_end'], new DateTimeZone('UTC'));
126  }
127 
129  (int) $row['ref_id'],
130  (int) $row['obj_id'],
131  (string) $row['type'],
132  (string) $row['title'],
133  (string) $row['description'],
134  (int) $row['parent'],
135  (int) $row['parent_lft'],
136  (bool) $row['period_has_time'],
137  $periodStart,
138  $periodEnd
139  );
140  }
141  }
142 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
foreach($_POST as $key=> $value) $res
getId()
get object id public
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...