ILIAS  release_8 Revision v8.24
class.ilLPListOfProgressGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=0);
4
28{
29 protected ?ilObjUser $tracked_user = null;
30 protected int $details_id = 0;
31 protected int $details_obj_id = 0;
32 protected string $details_type = '';
33 protected int $details_mode = 0;
34
35 public function __construct(int $a_mode, int $a_ref_id, int $a_user_id = 0)
36 {
37 parent::__construct($a_mode, $a_ref_id, $a_user_id);
38 $this->__initUser($a_user_id);
39
40 // Set item id for details
42 $this->ctrl->saveParameter($this, 'details_id');
43 }
44
45 protected function initDetailsIdFromQuery(): int
46 {
47 if ($this->http->wrapper()->query()->has('details_id')) {
48 return $this->http->wrapper()->query()->retrieve(
49 'details_id',
50 $this->refinery->kindlyTo()->int()
51 );
52 }
53 return 0;
54 }
55
59 public function executeCommand(): void
60 {
61 $this->ctrl->setReturn($this, "show");
62 $this->ctrl->setParameter($this, 'user_id', $this->getUserId());
63 switch ($this->ctrl->getNextClass()) {
64 case 'illpprogresstablegui':
65 $table_gui = new ilLPProgressTableGUI(
66 $this,
67 "",
68 $this->tracked_user
69 );
70 $this->ctrl->setReturn($this, 'show');
71 $this->ctrl->forwardCommand($table_gui);
72 break;
73
74 default:
75 $cmd = $this->__getDefaultCommand();
76 $this->$cmd();
77 }
78 }
79
80 public function show(): void
81 {
82 switch ($this->getMode()) {
83 // Show only detail of current repository item if called from repository
85 $this->__initDetails($this->getRefId());
86 $this->details();
87 return;
88
91 // if called from user folder obj_id is id of current user
92 $this->__initUser($this->getUserId());
93 break;
94 }
95 // not called from repository
96 $this->__showProgressList();
97 }
98
102 protected function saveProgress(): void
103 {
104 $info = new ilInfoScreenGUI($this);
105 $info->setContextRefId($this->ref_id);
106 $info->setContextObjId($this->details_obj_id);
107 $info->setContentObjType((string) $this->obj_type);
108 $info->saveProgress(false);
109 $this->ctrl->redirect($this);
110 }
111
112 public function details(): void
113 {
114 // Show back button to crs if called from crs. Otherwise if called from personal desktop or administration
115 // show back to list
116 $crs_id = 0;
117 if ($this->http->wrapper()->query()->has('crs_id')) {
118 $crs_id = $this->http->wrapper()->query()->retrieve(
119 'crs_id',
120 $this->refinery->kindlyTo()->int()
121 );
122 }
123 if ($crs_id) {
124 $this->ctrl->setParameter($this, 'details_id', $crs_id);
125 $this->toolbar->addButton(
126 $this->lng->txt('trac_view_crs'),
127 $this->ctrl->getLinkTarget($this, 'details')
128 );
129 } elseif ($this->getMode() == self::LP_CONTEXT_PERSONAL_DESKTOP or
130 $this->getMode() == self::LP_CONTEXT_ADMINISTRATION or
131 $this->getMode() == self::LP_CONTEXT_USER_FOLDER) {
132 $this->toolbar->addButton(
133 $this->lng->txt('trac_view_list'),
134 $this->ctrl->getLinkTarget($this, 'show')
135 );
136 }
137
138 $this->tpl->addBlockFile(
139 'ADM_CONTENT',
140 'adm_content',
141 'tpl.lp_progress_container.html',
142 'Services/Tracking'
143 );
144
145 $info = new ilInfoScreenGUI($this);
146 $info->setContextRefId($this->details_id);
147 $info->setContextObjId($this->details_obj_id);
148 $info->setContentObjType((string) $this->obj_type);
149 $info->enableLearningProgress(true);
150 $info->setFormAction($this->ctrl->getFormAction($this));
151 $this->__appendLPDetails(
152 $info,
153 $this->details_obj_id,
154 $this->tracked_user->getId()
155 );
156 $this->__showObjectDetails($info, $this->details_obj_id, false);
157
158 // Finally set template variable
159 $this->tpl->setVariable("LM_INFO", $info->getHTML());
160
161 $olp = ilObjectLP::getInstance($this->details_obj_id);
162 $collection = $olp->getCollectionInstance();
163 $obj_ids = array();
164 if ($collection) {
165 foreach ($collection->getItems() as $item_id) {
166 if ($collection instanceof ilLPCollectionOfRepositoryObjects) {
168 if ($this->access->checkAccessOfUser(
169 $this->tracked_user->getId(),
170 'visible',
171 '',
172 $item_id
173 )) {
174 $obj_ids[$obj_id] = array($item_id);
175 }
176 } else {
177 $obj_ids[] = $item_id;
178 }
179 }
180 }
181
182 // #15247
183 if (count($obj_ids) > 0) {
184 // seems obsolete
186 'read_learning_progress',
187 $this->getRefId()
188 );
189 $lp_table = new ilLPProgressTableGUI(
190 $this,
191 "details",
192 $this->tracked_user,
193 $obj_ids,
194 true,
195 $this->details_mode,
196 $personal_only,
197 $this->details_obj_id,
198 $this->details_id
199 );
200 $this->tpl->setVariable("LP_OBJECTS", $lp_table->getHTML());
201 }
202
203 $this->tpl->setVariable("LEGEND", $this->__getLegendHTML());
204 }
205
206 public function __showProgressList(): void
207 {
208 $this->tpl->addBlockFile(
209 'ADM_CONTENT',
210 'adm_content',
211 'tpl.lp_list_progress.html',
212 'Services/Tracking'
213 );
214
215 // User info
216 $info = new ilInfoScreenGUI($this);
217 $info->setFormAction($this->ctrl->getFormAction($this));
218 $lp_table = new ilLPProgressTableGUI(
219 $this,
220 "",
221 $this->tracked_user,
222 null,
223 false,
224 null,
225 false,
226 null,
227 null,
228 $this->getMode()
229 );
230 $this->tpl->setVariable("LP_OBJECTS", $lp_table->getHTML());
231
232 $this->tpl->setVariable("LEGEND", $this->__getLegendHTML());
233 }
234
238 public function __initUser(int $a_usr_id = 0): bool
239 {
240 if ($this->http->wrapper()->post()->has('user_id')) {
241 $a_usr_id = $this->http->wrapper()->post()->retrieve(
242 'user_id',
243 $this->refinery->kindlyTo()->int()
244 );
245 $this->ctrl->setParameter($this, 'user_id', $a_usr_id);
246 }
247 if ($a_usr_id) {
249 if (!$user instanceof ilObjUser) {
251 'Invalid user id given: ' . $a_usr_id
252 );
253 }
254 $this->tracked_user = $user;
255 } else {
256 $this->tracked_user = $this->user;
257 }
258
259 // #8762: see ilObjUserGUI->getTabs()
260 if ($this->mode == self::LP_CONTEXT_USER_FOLDER &&
261 $this->rbacsystem->checkAccess('read', $this->ref_id)) {
262 return false;
263 }
264
265 if ($this->mode == self::LP_CONTEXT_ORG_UNIT &&
267 $this->ref_id,
268 $a_usr_id
269 )) {
270 return false;
271 }
272
273 // Check access
274 if (!$this->rbacreview->isAssigned(
275 $this->user->getId(),
277 )) {
278 $this->tracked_user = $this->user;
279 return false;
280 }
281 return true;
282 }
283
284 public function __initDetails(int $a_details_id): void
285 {
286 if (!$a_details_id) {
287 $a_details_id = $this->getRefId();
288 }
289 if ($a_details_id) {
290 $ref_ids = ilObject::_getAllReferences($a_details_id);
291
292 $this->details_id = $a_details_id;
293 $this->details_obj_id = $this->ilObjectDataCache->lookupObjId(
294 $this->details_id
295 );
296 $this->details_type = $this->ilObjectDataCache->lookupType(
297 $this->details_obj_id
298 );
299
300 $olp = ilObjectLP::getInstance($this->details_obj_id);
301 $this->details_mode = $olp->getCurrentMode();
302 }
303 }
304}
Class ilInfoScreenGUI.
__construct(int $a_mode, int $a_ref_id, int $a_user_id=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static checkPermission(string $a_permission, int $a_ref_id, ?int $a_user_id=null)
wrapper for rbac access checks
__getLegendHTML(int $variant=ilLPStatusIcons::ICON_VARIANT_LONG)
__showObjectDetails(ilInfoScreenGUI $info, int $item_id=0, bool $add_section=true)
show details about current object.
__appendLPDetails(ilInfoScreenGUI $info, int $item_id, int $user_id)
static _checkAccessToUserLearningProgress(int $ref_id, int $usr_id)
User class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static getInstance(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupObjectId(int $ref_id)
static _getAllReferences(int $id)
get all reference ids for object ID
const SYSTEM_ROLE_ID
Definition: constants.php:29
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc