ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilStudyProgrammeMembersTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Data;
22
24{
25 protected Data\Factory $data_factory;
26 protected int $prg_obj_id;
27 protected bool $prg_has_lp_children;
30 protected bool $may_edit_anything;
32 protected ilObjUser $user;
36
37 public function __construct(
38 int $prg_obj_id,
39 protected int $prg_ref_id,
48 string $parent_cmd = '',
49 string $template_context = ''
50 ) {
51 $this->setId("sp_member_list_" . $prg_obj_id);
52 $this->prg_obj_id = $prg_obj_id;
53 $this->prg_user_table = $prg_user_table;
54 $this->custom_filter = $custom_filter;
55
56 $this->data_factory = $data_factory;
57 $this->ui_factory = $ui_factory;
58 $this->ui_renderer = $ui_renderer;
59 $this->permissions = $permissions;
61 $this->user = $user;
62
63 $this->prg = ilObjStudyProgramme::getInstanceByRefId($prg_ref_id);
64 $this->prg_has_lp_children = $parent_obj->getStudyProgramme()->hasLPChildren();
65
66 parent::__construct($parent_obj, $parent_cmd, $template_context);
67
68 $this->setEnableTitle(true);
69 $this->setTopCommands(false);
70 $this->setEnableHeader(true);
71 $this->setExternalSorting(true);
72 $this->setExternalSegmentation(true);
73 $this->setRowTemplate("tpl.members_table_row.html", "components/ILIAS/StudyProgramme");
74 $this->setShowRowsSelector(true);
75 $this->setFormAction($this->ctrl->getFormAction($parent_obj, "view"));
76 $this->addColumn("", "", "1", true);
77 $this->setEnableAllCommand(true);
78 $this->addMultiCommands();
79 $this->setDefaultOrderField('prgrs_id');
80 $this->setDefaultOrderDirection('ASC');
81
82 if ($this->may_edit_anything) {
83 $this->setSelectAllCheckbox($parent_obj::F_SELECTED_PROGRESS_IDS . '[]');
84 }
85
86 $selected = $this->getSelectedColumns();
87 foreach ($this->prg_user_table->getColumns($prg_obj_id, false, $this->prg->isCertificateActive()) as $column) {
88 [$col, $lng_var, $optional, $lp, $no_lp] = $column;
89
90 $show_by_lp = ($this->prg_has_lp_children && $lp) || (!$this->prg_has_lp_children && $no_lp);
91 $show_optional = !$optional || ($optional && array_key_exists($col, $selected));
92
93 if ($show_by_lp && $show_optional) {
94 $this->addColumn($lng_var, $col);
95 }
96 }
97
98 $this->addColumn($this->lng->txt('action'), '');
99
100 $this->initFilter();
102 $this->determineLimit();
103
104 $valid_user_ids = $this->getValidUserIds();
105 $filter_values = $this->getFilterValues();
106
107 $order = $this->getOrdering();
108
109 $members_list = $this->prg_user_table->fetchData(
111 $valid_user_ids,
112 $order,
113 $this->custom_filter->withValues($filter_values),
114 $this->getLimit() ? (int) $this->getLimit() : null,
115 $this->getOffset()
116 );
117
118 $count = $this->prg_user_table->countFetchData(
120 $valid_user_ids,
121 $this->custom_filter->withValues($filter_values)
122 );
123 $this->setMaxCount($count);
124
125
126 $progress_ids = array_map(
127 function ($row) {
128 return (string) $row->getId();
129 },
130 $members_list
131 );
132 $this->addHiddenInput(
133 $parent_obj::F_ALL_PROGRESS_IDS,
134 implode(',', $progress_ids)
135 );
136
137 $this->setData($members_list);
138 }
139
140 protected function getOrdering(): Data\Order
141 {
142 $field = $this->getOrderField();
143 if (!$field) {
144 $field = $this->getDefaultOrderField();
145 }
146 $direction = $this->getOrderDirection();
147 if (!$direction) {
148 $direction = $this->getDefaultOrderDirection();
149 }
150
151 return $this->data_factory->order($field, strtoupper($direction));
152 }
153
154
155 protected function fillRow($row): void
156 {
157 if (!$row instanceof ilStudyProgrammeUserTableRow) {
158 throw new \Exception("use ilStudyProgrammeUserTableRow for data output", 1);
159 }
160
161 if ($this->may_edit_anything) {
162 $this->tpl->setCurrentBlock("checkb");
163 $this->tpl->setVariable("ID", (string) $row->getId());
164 $this->tpl->parseCurrentBlock();
165 }
166
167 if (!$row->isUserActiveRaw()) {
168 $this->tpl->setCurrentBlock('access_warning');
169 $this->tpl->setVariable('PARENT_ACCESS', $this->lng->txt('usr_account_inactive'));
170 $this->tpl->parseCurrentBlock();
171 }
172
173 $this->tpl->setVariable("FIRSTNAME", $row->getFirstname());
174 $this->tpl->setVariable("LASTNAME", $row->getLastname());
175 $this->tpl->setVariable("LOGIN", $row->getLogin());
176 $this->tpl->setVariable("STATUS", $row->getStatus());
177 $this->tpl->setVariable("ASSIGN_DATE", $row->getAssignmentDate());
178 $this->tpl->setVariable("POINTS_REQUIRED", $row->getPointsRequired());
179
180 if (!$this->prg_has_lp_children) {
181 $this->tpl->setCurrentBlock("points_current");
182 $this->tpl->setVariable("POINTS_CURRENT", $row->getPointsCurrent());
183 $this->tpl->parseCurrentBlock();
184 }
185
186 foreach ($this->getSelectedColumns() as $column) {
187 switch ($column) {
188 case "prg_orgus":
189 $this->tpl->setVariable("ORGUS", $row->getOrgUs());
190 break;
191 case "prg_completion_date":
192 $this->tpl->setVariable("COMPLETION_DATE", $row->getCompletionDate());
193 break;
194 case "prg_completion_by":
195 $completion_by = $row->getCompletionBy();
196 if ($completion_by_obj_ids = $row->getCompletionByObjIds()) {
197 $out = [];
198 foreach ($completion_by_obj_ids as $completion_by_obj_id) {
199 $type = ilObject::_lookupType($completion_by_obj_id);
200 if ($type === 'crs') {
201 $out[] = $this->getCompletionLink($completion_by_obj_id, $completion_by);
202 } else {
203 $target_obj_id = $completion_by_obj_id;
204 $out[] = $this->getCompletionLink(
205 $target_obj_id,
206 ilStudyProgrammeUserTable::lookupTitle($completion_by_obj_id)
207 );
208 }
209 }
210 $completion_by = implode(', ', $out);
211 }
212 $this->tpl->setVariable("COMPLETION_BY", $completion_by);
213 break;
214 case "prg_custom_plan":
215 $this->tpl->setVariable("CUSTOM_PLAN", $row->getCustomPlan());
216 break;
217 case "prg_belongs_to":
218 $this->tpl->setVariable("BELONGS_TO", $row->getBelongsTo());
219 break;
220 case "prg_expiry_date":
221 $this->tpl->setVariable("EXPIRY_DATE", $row->getExpiryDate());
222 break;
223 case "prg_assigned_by":
224 $this->tpl->setVariable("ASSIGNED_BY", $row->getAssignmentBy());
225 break;
226 case "prg_deadline":
227 $this->tpl->setVariable("DEADLINE", $row->getDeadline());
228 break;
229 case "prg_validity":
230 $this->tpl->setVariable("VALIDITY", $row->getValidity());
231 break;
232 case 'org_units':
233 $this->tpl->setCurrentBlock('udf');
234 $this->tpl->setVariable("UDF", $row->getOrgUs());
235 $this->tpl->parseCurrentBlock();
236 break;
237 case 'gender':
238 $this->tpl->setCurrentBlock('udf');
239 $this->tpl->setVariable("UDF", $row->getGender());
240 $this->tpl->parseCurrentBlock();
241 break;
242 case 'cert_relevance':
243 $cert = '';
244 if ($row->getCertificateRelevance()) {
245 $cert = $this->getCertificateLink($row->getUsrId());
246 }
247 $this->tpl->setVariable("CERT_RELEVANCE", $cert);
248 break;
249 default:
250 $value = $row->getUserInformation()->getUserData($column) ?? '';
251 $this->tpl->setCurrentBlock('udf');
252 $this->tpl->setVariable("UDF", $value);
253 $this->tpl->parseCurrentBlock();
254 }
255 }
256 $actions = $this->getPossibleActions(
257 $row->isRootProgress(),
258 $row->getStatusRaw(),
259 $row->getNodeLifecycleStatus()
260 );
261
262 $this->tpl->setVariable(
263 "ACTIONS",
264 $this->buildActionDropDown(
265 $actions,
266 (string) $row->getId(),
267 $row->getAssignmentId()
268 )
269 );
270 }
271
272 protected function buildActionDropDown(
273 array $actions,
274 string $prgrs_id,
275 int $ass_id
276 ): string {
277 $l = [];
278
279 $view_individual_plan = $this->permissions->may(ilOrgUnitOperation::OP_VIEW_INDIVIDUAL_PLAN);
280 $edit_individual_plan = $this->permissions->may(ilOrgUnitOperation::OP_EDIT_INDIVIDUAL_PLAN);
281 $addremove_users = $this->permissions->may(ilOrgUnitOperation::OP_MANAGE_MEMBERS);
282
283 foreach ($actions as $action) {
284 switch ($action) {
295
296 if (!$edit_individual_plan) {
297 continue 2;
298 }
299 break;
301 if (!$view_individual_plan) {
302 continue 2;
303 }
304 break;
305
307 if (!$addremove_users) {
308 continue 2;
309 }
310 break;
311 }
312
313 $target = $this->getLinkTargetForAction($action, $prgrs_id, $ass_id);
314 $l[] = $this->ui_factory->button()->shy($this->lng->txt("prg_$action"), $target);
315 }
316 return $this->ui_renderer->render(
317 $this->ui_factory->dropdown()->standard($l)
318 );
319 }
320
321
322 protected function getLinkTargetForAction(string $action, string $prgrs_id, int $ass_id): string
323 {
324 return $this->getParentObject()->getLinkTargetForAction($action, $prgrs_id, $ass_id);
325 }
326
327 public function getSelectableColumns(): array
328 {
329 $cols = [];
330
331 foreach ($this->prg_user_table->getColumns($this->prg_obj_id, false, $this->prg->isCertificateActive()) as $column) {
332 [$col, $lng_var, $optional, $lp, $no_lp] = $column;
333 if ($optional) {
334 $cols[$col] = ["txt" => $lng_var];
335 }
336 }
337
338 return $cols;
339 }
340
341 protected function addMultiCommands(): void
342 {
343 foreach ($this->getMultiCommands() as $cmd => $caption) {
344 $this->addMultiCommand($cmd, $caption);
345 }
346 }
347
353 protected function getMultiCommands(): array
354 {
355 $permissions_for_edit_individual_plan = [
356 'updateFromCurrentPlanMulti' => $this->lng->txt('prg_multi_update_from_current_plan'),
357 'acknowledgeCoursesMulti' => $this->lng->txt('prg_acknowledge_completed_courses'),
358 'markRelevantMulti' => $this->lng->txt('prg_multi_mark_relevant'),
359 'markNotRelevantMulti' => $this->lng->txt('prg_multi_unmark_relevant'),
360 'changeDeadlineMulti' => $this->lng->txt('prg_multi_change_deadline'),
361 'changeExpireDateMulti' => $this->lng->txt('prg_multi_change_expire_date'),
362 'markAccreditedMulti' => $this->lng->txt('prg_multi_mark_accredited'),
363 'unmarkAccreditedMulti' => $this->lng->txt('prg_multi_unmark_accredited'),
364 ];
365 if ($this->prg->isCertificateActive()) {
366 $permissions_for_edit_individual_plan['updateCertificateMulti'] = $this->lng->txt('prg_multi_update_certificate');
367 $permissions_for_edit_individual_plan['removeCertificateMulti'] = $this->lng->txt('prg_multi_remove_certificate');
368 }
369
370 $permissions_for_manage = [
371 'removeUserMulti' => $this->lng->txt('prg_multi_remove_user'),
372 'mailUserMulti' => $this->lng->txt('prg_multi_mail_user')
373 ];
374
375 $perms = [];
376
377 if ($this->permissions->may(ilOrgUnitOperation::OP_EDIT_INDIVIDUAL_PLAN)) {
378 $perms = array_merge($perms, $permissions_for_edit_individual_plan);
379 }
380
381 if ($this->permissions->may(ilOrgUnitOperation::OP_MANAGE_MEMBERS)) {
382 $perms = array_merge($perms, $permissions_for_manage);
383 }
384
385 return $perms;
386 }
387
391 public function initFilter(): void
392 {
393 foreach ($this->custom_filter->getItemConfig() as $conf) {
394 [$id, $type, $options, $caption] = $conf;
395 $item = $this->addFilterItemByMetaType($id, $type, false, $caption);
396 if ($options) {
397 $item->setOptions($options);
398 }
399 }
400 }
401
405 protected function getFilterValues(): array
406 {
407 $this->getCurrentState();
408 $f = [];
409 foreach ($this->filters as $item) {
410 $f[$item->getFieldId()] = $this->getFilterValue($item);
411 }
412 return $f;
413 }
414
420 protected function getPossibleActions(
421 bool $is_root,
422 int $status,
423 int $node_lifecyle_status
424 ): array {
425 $actions = [];
426
427 if ($is_root) {
433 }
434
435 if ($status == ilPRGProgress::STATUS_ACCREDITED) {
437 }
438 if ($status == ilPRGProgress::STATUS_IN_PROGRESS) {
441 }
442
443 if (! $is_root &&
446 ) {
448 }
450 && $node_lifecyle_status == ilStudyProgrammeAssessmentSettings::STATUS_ACTIVE
451 ) {
453 }
454 if ($status == ilPRGProgress::STATUS_COMPLETED ||
456 && $this->prg->isCertificateActive()
457 ) {
460 }
461
462
463 return $actions;
464 }
465
466 protected function getValidUserIds(): ?array
467 {
468 if ($this->permissions->may($this->permissions::ROLEPERM_MANAGE_MEMBERS)) {
469 return null;
470 }
471
472 $valid_user_ids = $this->permissions->getUserIdsSusceptibleTo(ilOrgUnitOperation::OP_VIEW_MEMBERS);
473 array_unshift($valid_user_ids, $this->user->getId());
474 return $valid_user_ids;
475 }
476
477 protected function getCompletionLink(int $target_obj_id, string $title): string
478 {
479 $link = $title;
480 $ref_ids = ilObject::_getAllReferences($target_obj_id);
481 foreach ($ref_ids as $ref_id) {
484 $link = $this->ui_renderer->render($this->ui_factory->link()->standard($title, $url));
485 }
486 }
487 return $link;
488 }
489
490 protected function getCertificateLink(int $usr_id): string
491 {
492 $this->ctrl->setParameter($this->parent_obj, 'cert_usr_id', $usr_id);
493 $cert_url = $this->ctrl->getLinkTarget($this->parent_obj, 'deliverCertificate');
494 $this->ctrl->setParameter($this->parent_obj, 'cert_usr_id', null);
495 $icon = $this->ui_renderer->render(
496 $this->ui_factory->symbol()->icon()->standard('cert', 'relevant', 'small')
497 );
498 $link = $this->ui_factory->link()->standard($icon, $cert_url);
499 return $this->ui_renderer->render($link);
500 }
501}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$out
Definition: buildRTE.php:24
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
Definition: UI.php:24
@ilCtrl_Calls ilObjStudyProgrammeMembersGUI: ilStudyProgrammeRepositorySearchGUI @ilCtrl_Calls ilObjS...
User class.
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
static _isInTrash(int $ref_id)
Both role and OrgU-based permissions are relevant in many places of the PRG.
getPossibleActions(bool $is_root, int $status, int $node_lifecyle_status)
Get a list with possible actions on a progress record.
getCompletionLink(int $target_obj_id, string $title)
__construct(int $prg_obj_id, protected int $prg_ref_id, ilObjStudyProgrammeMembersGUI $parent_obj, ilPRGPermissionsHelper $permissions, Data\Factory $data_factory, ILIAS\UI\Factory $ui_factory, ILIAS\UI\Renderer $ui_renderer, ilStudyProgrammeUserTable $prg_user_table, ilPRGAssignmentFilter $custom_filter, ilObjUser $user, string $parent_cmd='', string $template_context='')
getLinkTargetForAction(string $action, string $prgrs_id, int $ass_id)
buildActionDropDown(array $actions, string $prgrs_id, int $ass_id)
ilStudyProgrammeUserTable provides a flattened list of progresses at a programme-node.
ilStudyProgrammeUserTable provides a flattened list of progresses at a programme-node.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
setEnableAllCommand(bool $a_value)
determineOffsetAndOrder(bool $a_omit_offset=false)
setExternalSegmentation(bool $a_val)
setEnableTitle(bool $a_enabletitle)
addHiddenInput(string $a_name, string $a_value)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setDefaultOrderField(string $a_defaultorderfield)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setTopCommands(bool $a_val)
setExternalSorting(bool $a_val)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
setMaxCount(int $a_max_count)
set max.
An entity that renders components to a string output.
Definition: Renderer.php:31
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$url
Definition: shib_logout.php:68