19 declare(strict_types=1);
42 protected function applyFilter(
45 if (is_null($filter_data)) {
46 return $this->data[
'rows'];
54 $group_ids = is_null($select->getValue()) ? [] : [(
int) $select->getValue()];
55 $group_ids = array_diff($group_ids, [0]);
56 $name = $text->getValue() ??
'';
58 foreach ($this->data[
'rows'] as $row) {
60 foreach ($row[
'groups'] as $group) {
61 $row_group_ids[] = $group[
'group_id'];
64 !$select->isDisabled() &&
65 count($group_ids) > 0 &&
66 count(array_diff($group_ids, $row_group_ids)) === count($group_ids)
71 !$text->isDisabled() &&
73 !str_contains($row[
'name'], $name)
85 return $group_ref_id . self::TABLE_ACTION_CONFIRM_UNSUBSCRIBE_SUFFIX;
91 return $group_ref_id . self::TABLE_ACTION_UNSUBSCRIBE_SUFFIX;
107 foreach ($this->data[
'rows'] as $row) {
108 $ids[] = (
int) $row[
'usr_id'];
115 $selectable_group_ids = [];
116 foreach ($this->data[
'groups'] as
$ref_id => $something) {
117 if ($this->data[
'groups_rights'][
$ref_id][
'manage_members']) {
121 return $selectable_group_ids;
126 array $visible_column_ids,
130 ?array $additional_parameters
132 [$column_name, $direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
133 $rows = $this->applyFilter($filter_data);
134 $groups_rights = $this->data[
'groups_rights'];
135 $comparator =
function (array $f1, array $f2) {
return 0; };
136 switch ($column_name) {
138 $comparator =
function (array $f1, array $f2) {
139 return strcmp($f1[
'name'], $f2[
'name']);
143 $comparator =
function (array $f1, array $f2) {
144 return strcmp($f1[
'login'], $f2[
'login']);
148 $comparator =
function (array $f1, array $f2) {
149 if ($f1[
'groups_number'] === $f2[
'groups_number']) {
152 return $f1[
'groups_number'] > $f2[
'groups_number'] ? 1 : -1;
156 $comparator =
function (array $f1, array $f2) {
157 return strcmp($f1[
'group_info'][
'title'], $f2[
'group_info'][
'title']);
161 uasort($rows, $comparator);
162 if ($direction ===
"DESC") {
163 $rows = array_reverse($rows,
true);
165 $rows = array_slice($rows, $range->getStart(), $range->getLength(),
true);
166 foreach ($rows as $row) {
168 $enabled_actions = [];
169 foreach ($row[
'groups'] as $group_info) {
170 $grp_id = $group_info[
'group_id'];
171 $role = $group_info[
'role'];
172 $title = $group_info[
'title'];
174 !($role ==
'admin' && $groups_rights[$grp_id][
'edit_permission']) &&
175 !($role ==
'member' && $groups_rights[$grp_id][
'manage_members'])
179 $groups_str .= ($groups_str ===
'' ? $title :
'<br>' . $title);
182 $data_row = $row_builder->buildDataRow(
192 foreach ($disabled_actions as $disabled_action) {
193 $data_row = $data_row->withDisabledAction($disabled_action,
true);
201 ?array $additional_parameters
203 return count($this->applyFilter($filter_data));
208 $parent_node = $this->tree->getNodeData($this->ref_id);
209 $groups = $this->tree->getSubTree($parent_node,
true, [
'grp']);
211 !is_array($groups) ||
216 $results_participants = [];
217 $results_groups = [];
218 $results_groups_rights = [];
219 foreach ($groups as $idx => $group_data) {
220 # check for group in group 222 $group_data[
'parent'] != $this->ref_id &&
223 $this->tree->checkForParentType(
224 $group_data[
'ref_id'],
229 unset($groups[$idx]);
232 $results_groups[$group_data[
'ref_id']] = $group_data[
'title'];
233 $results_groups_rights[$group_data[
'ref_id']][
'manage_members'] = $this->
access->checkRbacOrPositionPermissionAccess(
236 $group_data[
'ref_id']
238 $results_groups_rights[$group_data[
'ref_id']][
'edit_permission'] = $this->
access->checkAccess(
241 $group_data[
'ref_id']
244 $members = $this->
access->filterUserIdsByRbacOrPositionOfCurrentUser(
247 $group_data[
'ref_id'],
250 $admins = $this->
access->filterUserIdsByRbacOrPositionOfCurrentUser(
253 $group_data[
'ref_id'],
256 $results_participants[$group_data[
'ref_id']][
'members'] = $members;
257 $results_participants[$group_data[
'ref_id']][
'admins'] = $admins;
260 $members = $this->
access->filterUserIdsByRbacOrPositionOfCurrentUser(
266 if ($members === []) {
270 foreach ($members as $usr_id) {
272 $membership_count = 0;
275 'name' => $name[
'lastname'] .
', ' . $name[
'firstname'],
277 'login' => $name[
'login']
279 foreach (array_keys($results_participants) as $group_id) {
281 'group_id' => $group_id,
282 'title' => $results_groups[$group_id],
285 if (in_array($usr_id, $results_participants[$group_id][
'members'])) {
286 $group_info[
'role'] =
'member';
288 if (in_array($usr_id, $results_participants[$group_id][
'admins'])) {
289 $group_info[
'role'] =
'admin';
291 if ($group_info[
'role'] ===
'') {
294 $new_entry[
'groups'][] = $group_info;
297 $new_entry[
'groups_number'] = $membership_count;
298 $usr_data[] = $new_entry;
300 $this->data[
'rows'] = $usr_data;
301 $this->data[
'groups'] = $results_groups;
302 $this->data[
'groups_rights'] = $results_groups_rights;
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
Class ilCourseParticipantsGroupsGUI.
const string TABLE_COL_GROUPS
buildConfirmUnsubscribeActionId(int $group_ref_id)
Interface Observer Contains several chained tasks and infos about them.
buildUnsubscribeActionId(int $group_ref_id)
const TABLE_ACTION_CONFIRM_UNSUBSCRIBE_SUFFIX
static _lookupName(int $a_user_id)
lookup user name
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getRows(\ILIAS\UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, \ILIAS\Data\Range $range, \ILIAS\Data\Order $order, ?array $filter_data, ?array $additional_parameters)
__construct(protected ilCourseParticipantsGroupsGUI $parent_obj, protected ilTree $tree, protected ilAccess $access, protected ilUIServices $ui_services, protected int $ref_id)
static _lookupObjId(int $ref_id)
const string TABLE_COL_GROUP_NUMBER
getAllConfirmUnsubscribeActionIds()
static _getInstanceByObjId(int $a_obj_id)
const TABLE_ACTION_UNSUBSCRIBE_SUFFIX
const string TABLE_COL_NAME
const string TABLE_COL_LOGIN
const string TABLE_FILTER_NAME
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
const string TABLE_FILTER_GROUPS