ILIAS  release_7 Revision v7.30-3-g800a261c036
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($row)
96 {
97 $this->tpl->setVariable('HIDDEN_NAME', $row['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', $row['title']);
101
102 $linked_course_assignments = $this->readLinkedCourseAssignments($row['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[' . $row['id'] . '][' . $course_ref_id . ']');
109 $this->tpl->setVariable('CHECK_USER_VAL', 1);
110 $this->tpl->setVariable('REF_PATH', $path->getPath(ROOT_FOLDER_ID, $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', $row['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}
An exception for terminatinating execution or to throw for unit testing.
fillRow($row)
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($a_user_id)
lookup user name
static getInstance($a_ref_id)
Get instance by ref_id.
Creates a path for a start and endnode.
Class ilTable2GUI.
setShowRowsSelector($a_value)
Toggle rows-per-page selector.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setId($a_val)
Set id.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
const ROOT_FOLDER_ID
Definition: constants.php:30
global $DIC
Definition: goto.php:24
if($format !==null) $name
Definition: metadata.php:230
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$rows
Definition: xhr_table.php:10