ILIAS  release_8 Revision v8.24
class.ilCourseReferenceDeleteConfirmationTableGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
11{
15 private $tree = null;
16
17
21 private $member_obj = null;
22
26 private $participants = [];
27
34 public function __construct($gui, $member_obj, string $cmd)
35 {
36 global $DIC;
37
38 $this->tree = $DIC->repositoryTree();
39
40 $this->setId('crsr_mem_confirmation');
41 parent::__construct($gui, $cmd);
42
43 $this->member_obj = $member_obj;
44 }
45
49 public function setParticipants(array $participants)
50 {
51 $this->participants = $participants;
52 }
53
57 public function init()
58 {
59 $this->setRowTemplate('tpl.crsr_mem_deletion_confirmation_row.html', 'Modules/CourseReference');
60 $this->addCommandButton('deleteParticipantsWithLinkedCourses', $this->lng->txt('confirm'));
61 $this->addCommandButton('participants', $this->lng->txt('cancel'));
62 $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
63
64 $this->disable('sort');
65 $this->setShowRowsSelector(false);
66 $this->setSelectAllCheckbox('refs');
67
68 $this->addColumn($this->lng->txt('type'), 'type', '50px');
69 $this->addColumn($this->lng->txt('title'), 'title');
70 }
71
75 public function parse()
76 {
77 $rows = [];
78 foreach ($this->participants as $part_id) {
79 $row = [];
80 $row['type'] = 'usr';
81 $row['id'] = $part_id;
82
83 $name = ilObjUser::_lookupName($part_id);
84
85 $row['title'] = ($name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']');
86 $rows[] = $row;
87 }
88
89 $this->setData($rows);
90 }
91
95 public function fillRow(array $a_set): void
96 {
97 $this->tpl->setVariable('HIDDEN_NAME', $a_set['id']);
98 $this->tpl->setVariable('TYPE_ICON', ilUtil::getImagePath('icon_usr.svg'));
99 $this->tpl->setVariable('ALT_USR', $this->lng->txt('obj_usr'));
100 $this->tpl->setVariable('VAL_LOGIN', $a_set['title']);
101
102 $linked_course_assignments = $this->readLinkedCourseAssignments($a_set['id']);
103 foreach ($linked_course_assignments as $course_ref_id) {
104 $path = new ilPathGUI();
105 $path->enableHideLeaf(false);
106 $path->enableTextOnly(false);
107 $this->tpl->setCurrentBlock('reference_path');
108 $this->tpl->setVariable('CHECK_USER_NAME', 'refs[' . $a_set['id'] . '][' . $course_ref_id . ']');
109 $this->tpl->setVariable('CHECK_USER_VAL', 1);
110 $this->tpl->setVariable('REF_PATH', $path->getPath(ROOT_FOLDER_ID, (int) $course_ref_id));
111 $this->tpl->parseCurrentBlock();
112 }
113
114
115 if (count($linked_course_assignments)) {
116 $this->tpl->setCurrentBlock('reference_select');
117 $this->tpl->setVariable('RUID', $a_set['id']);
118 $this->tpl->setVariable('RFORM_ID', $this->formname);
119 $this->tpl->setVariable('SEL_ALL', $this->lng->txt('select_all'));
120 $this->tpl->parseCurrentBlock();
121 }
122 }
123
127 protected function readLinkedCourseAssignments($part_id): array
128 {
129 $childs = $this->tree->getChildsByType($this->member_obj->getRefId(), 'crsr');
130 $assigned_references = [];
131 foreach ($childs as $tree_node) {
132 $path_info = ilCourseReferencePathInfo::getInstanceByRefId($tree_node['child']);
133 if (!$path_info->hasParentCourse()) {
134 continue;
135 }
136 if (!$path_info->isMemberUpdateEnabled()) {
137 continue;
138 }
139 if (!$path_info->checkManagmentAccess()) {
140 continue;
141 }
142 $course_ref_id = $path_info->getTargetId();
143 $part = ilCourseParticipants::getInstance($course_ref_id);
144 if ($part->isMember($part_id)) {
145 $assigned_references[] = $course_ref_id;
146 }
147 }
148 return $assigned_references;
149 }
150}
fillRow(array $a_set)
Standard Version of Fill Row.Most likely to be overwritten by derived class.
__construct($gui, $member_obj, string $cmd)
ilCourseReferenceDeleteConfirmationTableGUI constructor.
static getInstanceByRefId(int $ref_id, int $target_ref_id=0)
static _lookupName(int $a_user_id)
lookup user name
static getInstance(int $a_ref_id)
Creates a path for a start and endnode.
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.
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
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)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setData(array $a_data)
Set table data.
disable(string $a_module_name)
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const ROOT_FOLDER_ID
Definition: constants.php:32
global $DIC
Definition: feed.php:28
$path
Definition: ltiservices.php:32
if($format !==null) $name
Definition: metadata.php:247
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$rows
Definition: xhr_table.php:10