ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLPListOfProgressGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=0);
20
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_USER_FOLDER) {
131 $this->toolbar->addButton(
132 $this->lng->txt('trac_view_list'),
133 $this->ctrl->getLinkTarget($this, 'show')
134 );
135 }
136
137 $this->tpl->addBlockFile(
138 'ADM_CONTENT',
139 'adm_content',
140 'tpl.lp_progress_container.html',
141 'components/ILIAS/Tracking'
142 );
143
144 $info = new ilInfoScreenGUI($this);
145 $info->setContextRefId($this->details_id);
146 $info->setContextObjId($this->details_obj_id);
147 $info->setContentObjType((string) $this->obj_type);
148 $info->enableLearningProgress(true);
149 $info->setFormAction($this->ctrl->getFormAction($this));
150 $this->__appendLPDetails(
151 $info,
152 $this->details_obj_id,
153 $this->tracked_user->getId()
154 );
155 $this->__showObjectDetails($info, $this->details_obj_id, $this->details_type, false);
156
157 // Finally set template variable
158 $this->tpl->setVariable("LM_INFO", $info->getHTML());
159
160 $olp = ilObjectLP::getInstance($this->details_obj_id);
161 $collection = $olp->getCollectionInstance();
162 $obj_ids = array();
163 if ($collection) {
164 foreach ($collection->getItems() as $item_id) {
165 if ($collection instanceof ilLPCollectionOfRepositoryObjects) {
167 if ($this->access->checkAccessOfUser(
168 $this->tracked_user->getId(),
169 'visible',
170 '',
171 $item_id
172 )) {
173 $obj_ids[$obj_id] = array($item_id);
174 }
175 } else {
176 $obj_ids[] = $item_id;
177 }
178 }
179 }
180
181 // #15247
182 if (count($obj_ids) > 0) {
183 // seems obsolete
185 'read_learning_progress',
186 $this->getRefId()
187 );
188 $lp_table = new ilLPProgressTableGUI(
189 $this,
190 "details",
191 $this->tracked_user,
192 $obj_ids,
193 true,
194 $this->details_mode,
195 $personal_only,
196 $this->details_obj_id,
197 $this->details_id
198 );
199 $this->tpl->setVariable("LP_OBJECTS", $lp_table->getHTML());
200 }
201
202 $this->tpl->setVariable("LEGEND", $this->__getLegendHTML());
203 }
204
205 public function __showProgressList(): void
206 {
207 $this->tpl->addBlockFile(
208 'ADM_CONTENT',
209 'adm_content',
210 'tpl.lp_list_progress.html',
211 'components/ILIAS/Tracking'
212 );
213
214 // User info
215 $info = new ilInfoScreenGUI($this);
216 $info->setFormAction($this->ctrl->getFormAction($this));
217 $lp_table = new ilLPProgressTableGUI(
218 $this,
219 "",
220 $this->tracked_user,
221 null,
222 false,
223 null,
224 false,
225 null,
226 null,
227 $this->getMode()
228 );
229 $this->tpl->setVariable("LP_OBJECTS", $lp_table->getHTML());
230
231 $this->tpl->setVariable("LEGEND", $this->__getLegendHTML());
232 }
233
237 public function __initUser(int $a_usr_id = 0): bool
238 {
239 if ($this->http->wrapper()->post()->has('user_id')) {
240 $a_usr_id = $this->http->wrapper()->post()->retrieve(
241 'user_id',
242 $this->refinery->kindlyTo()->int()
243 );
244 $this->ctrl->setParameter($this, 'user_id', $a_usr_id);
245 }
246 if ($a_usr_id) {
248 if (!$user instanceof ilObjUser) {
250 'Invalid user id given: ' . $a_usr_id
251 );
252 }
253 $this->tracked_user = $user;
254 } else {
255 $this->tracked_user = $this->user;
256 }
257
258 // #8762: see ilObjUserGUI->getTabs()
259 if ($this->mode == self::LP_CONTEXT_USER_FOLDER &&
260 $this->rbacsystem->checkAccess('read', $this->ref_id)) {
261 return false;
262 }
263
264 if ($this->mode == self::LP_CONTEXT_ORG_UNIT &&
266 $this->ref_id,
267 $a_usr_id
268 )) {
269 return false;
270 }
271
272 // Check access
273 if (!$this->rbacreview->isAssigned(
274 $this->user->getId(),
276 )) {
277 $this->tracked_user = $this->user;
278 return false;
279 }
280 return true;
281 }
282
283 public function __initDetails(int $a_details_id): void
284 {
285 if (!$a_details_id) {
286 $a_details_id = $this->getRefId();
287 }
288 if ($a_details_id) {
289 $ref_ids = ilObject::_getAllReferences($a_details_id);
290
291 $this->details_id = $a_details_id;
292 $this->details_obj_id = $this->ilObjectDataCache->lookupObjId(
293 $this->details_id
294 );
295 $this->details_type = $this->ilObjectDataCache->lookupType(
296 $this->details_obj_id
297 );
298
299 $olp = ilObjectLP::getInstance($this->details_obj_id);
300 $this->details_mode = $olp->getCurrentMode();
301 }
302 }
303}
Class ilInfoScreenGUI.
__construct(int $a_mode, int $a_ref_id, int $a_user_id=0)
TableGUI class for learning progress.
static checkPermission(string $a_permission, int $a_ref_id, ?int $a_user_id=null)
wrapper for rbac access checks
__showObjectDetails(ilInfoScreenGUI $info, int $item_id=0, string $item_type='', bool $add_section=true)
show details about current object.
__getLegendHTML(int $variant=ilLPStatusIcons::ICON_VARIANT_LONG)
__appendLPDetails(ilInfoScreenGUI $info, int $item_id, int $user_id)
static _checkAccessToUserLearningProgress(int $ref_id, int $usr_id)
User class.
class ilObjectDataCache
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)
static _lookupObjectId(int $ref_id)
static _getAllReferences(int $id)
get all reference ids for object ID
const SYSTEM_ROLE_ID
Definition: constants.php:29
$info
Definition: entry_point.php:21
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc