ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilCourseReferenceDeleteConfirmationTableGUI.php
Go to the documentation of this file.
1 <?php
2 
25 {
29  private $tree = null;
30 
31 
35  private $member_obj = null;
36 
40  private $participants = [];
41 
48  public function __construct($gui, $member_obj, string $cmd)
49  {
50  global $DIC;
51 
52  $this->tree = $DIC->repositoryTree();
53 
54  $this->setId('crsr_mem_confirmation');
55  parent::__construct($gui, $cmd);
56 
57  $this->member_obj = $member_obj;
58  }
59 
63  public function setParticipants(array $participants)
64  {
65  $this->participants = $participants;
66  }
67 
71  public function init()
72  {
73  $this->setRowTemplate('tpl.crsr_mem_deletion_confirmation_row.html', 'components/ILIAS/CourseReference');
74  $this->addCommandButton('deleteParticipantsWithLinkedCourses', $this->lng->txt('confirm'));
75  $this->addCommandButton('participants', $this->lng->txt('cancel'));
76  $this->setFormAction($this->ctrl->getFormAction($this->getParentObject()));
77 
78  $this->disable('sort');
79  $this->setShowRowsSelector(false);
80  $this->setSelectAllCheckbox('refs');
81 
82  $this->addColumn($this->lng->txt('type'), 'type', '50px');
83  $this->addColumn($this->lng->txt('title'), 'title');
84  }
85 
89  public function parse()
90  {
91  $rows = [];
92  foreach ($this->participants as $part_id) {
93  $row = [];
94  $row['type'] = 'usr';
95  $row['id'] = $part_id;
96 
97  $name = ilObjUser::_lookupName($part_id);
98 
99  $row['title'] = ($name['lastname'] . ', ' . $name['firstname'] . ' [' . $name['login'] . ']');
100  $rows[] = $row;
101  }
102 
103  $this->setData($rows);
104  }
105 
109  public function fillRow(array $a_set): void
110  {
111  $this->tpl->setVariable('HIDDEN_NAME', $a_set['id']);
112  $this->tpl->setVariable('TYPE_ICON', ilUtil::getImagePath('standard/icon_usr.svg'));
113  $this->tpl->setVariable('ALT_USR', $this->lng->txt('obj_usr'));
114  $this->tpl->setVariable('VAL_LOGIN', $a_set['title']);
115 
116  $linked_course_assignments = $this->readLinkedCourseAssignments($a_set['id']);
117  foreach ($linked_course_assignments as $course_ref_id) {
118  $path = new ilPathGUI();
119  $path->enableHideLeaf(false);
120  $path->enableTextOnly(false);
121  $this->tpl->setCurrentBlock('reference_path');
122  $this->tpl->setVariable('CHECK_USER_NAME', 'refs[' . $a_set['id'] . '][' . $course_ref_id . ']');
123  $this->tpl->setVariable('CHECK_USER_VAL', 1);
124  $this->tpl->setVariable('REF_PATH', $path->getPath(ROOT_FOLDER_ID, (int) $course_ref_id));
125  $this->tpl->parseCurrentBlock();
126  }
127 
128 
129  if (count($linked_course_assignments)) {
130  $this->tpl->setCurrentBlock('reference_select');
131  $this->tpl->setVariable('RUID', $a_set['id']);
132  $this->tpl->setVariable('RFORM_ID', $this->formname);
133  $this->tpl->setVariable('SEL_ALL', $this->lng->txt('select_all'));
134  $this->tpl->parseCurrentBlock();
135  }
136  }
137 
141  protected function readLinkedCourseAssignments($part_id): array
142  {
143  $childs = $this->tree->getChildsByType($this->member_obj->getRefId(), 'crsr');
144  $assigned_references = [];
145  foreach ($childs as $tree_node) {
146  $path_info = ilCourseReferencePathInfo::getInstanceByRefId($tree_node['child']);
147  if (!$path_info->hasParentCourse()) {
148  continue;
149  }
150  if (!$path_info->isMemberUpdateEnabled()) {
151  continue;
152  }
153  if (!$path_info->checkManagmentAccess()) {
154  continue;
155  }
156  $course_ref_id = $path_info->getTargetId();
157  $part = ilCourseParticipants::getInstance($course_ref_id);
158  if ($part->isMember($part_id)) {
159  $assigned_references[] = $course_ref_id;
160  }
161  }
162  return $assigned_references;
163  }
164 }
setData(array $a_data)
setFormAction(string $a_form_action, bool $a_multipart=false)
const ROOT_FOLDER_ID
Definition: constants.php:32
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
static getInstance(int $a_ref_id)
static _lookupName(int $a_user_id)
lookup user name
setId(string $a_val)
$path
Definition: ltiservices.php:29
__construct($gui, $member_obj, string $cmd)
ilCourseReferenceDeleteConfirmationTableGUI constructor.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setShowRowsSelector(bool $a_value)
Toggle rows-per-page selector.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
global $DIC
Definition: shib_login.php:26
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
__construct(Container $dic, ilPlugin $plugin)
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)
disable(string $a_module_name)
static getInstanceByRefId(int $ref_id, int $target_ref_id=0)