ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilCourseParticipantsGroupsTableDataRetrieval Class Reference
+ Inheritance diagram for ilCourseParticipantsGroupsTableDataRetrieval:
+ Collaboration diagram for ilCourseParticipantsGroupsTableDataRetrieval:

Public Member Functions

 __construct (protected ilCourseParticipantsGroupsGUI $parent_obj, protected ilTree $tree, protected ilAccess $access, protected ilUIServices $ui_services, protected int $ref_id)
 
 buildConfirmUnsubscribeActionId (int $group_ref_id)
 
 buildUnsubscribeActionId (int $group_ref_id)
 
 getAllConfirmUnsubscribeActionIds ()
 
 getAllUserIds ()
 
 getSelectableGroups ()
 
 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)
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
 init ()
 
- Public Member Functions inherited from ILIAS\UI\Component\Table\DataRetrieval
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 

Protected Attributes

const TABLE_ACTION_CONFIRM_UNSUBSCRIBE_SUFFIX = '_confirm_unsubscribe'
 
const TABLE_ACTION_UNSUBSCRIBE_SUFFIX = '_unsubscribe'
 
array $data
 
int $obj_id
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilCourseParticipantsGroupsTableDataRetrieval::__construct ( protected ilCourseParticipantsGroupsGUI  $parent_obj,
protected ilTree  $tree,
protected ilAccess  $access,
protected ilUIServices  $ui_services,
protected int  $ref_id 
)

Definition at line 31 of file class.ilCourseParticipantsGroupsTableDataRetrieval.php.

References ilObject\_lookupObjId(), ilCourseParticipantsGroupsTableGUI\TABLE_FILTER_GROUPS, and ilCourseParticipantsGroupsTableGUI\TABLE_FILTER_NAME.

37  {
38  $this->data = [];
39  $this->obj_id = ilObject::_lookupObjId($ref_id);
40  }
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:

Member Function Documentation

◆ buildConfirmUnsubscribeActionId()

ilCourseParticipantsGroupsTableDataRetrieval::buildConfirmUnsubscribeActionId ( int  $group_ref_id)

Definition at line 82 of file class.ilCourseParticipantsGroupsTableDataRetrieval.php.

Referenced by getAllConfirmUnsubscribeActionIds(), and getRows().

84  : string {
85  return $group_ref_id . self::TABLE_ACTION_CONFIRM_UNSUBSCRIBE_SUFFIX;
86  }
+ Here is the caller graph for this function:

◆ buildUnsubscribeActionId()

ilCourseParticipantsGroupsTableDataRetrieval::buildUnsubscribeActionId ( int  $group_ref_id)

Definition at line 88 of file class.ilCourseParticipantsGroupsTableDataRetrieval.php.

90  : string {
91  return $group_ref_id . self::TABLE_ACTION_UNSUBSCRIBE_SUFFIX;
92  }

◆ getAllConfirmUnsubscribeActionIds()

ilCourseParticipantsGroupsTableDataRetrieval::getAllConfirmUnsubscribeActionIds ( )

Definition at line 94 of file class.ilCourseParticipantsGroupsTableDataRetrieval.php.

References $ref_id, buildConfirmUnsubscribeActionId(), and getSelectableGroups().

Referenced by getRows().

94  : array
95  {
96  $ids = [];
97  foreach ($this->getSelectableGroups() as $ref_id => $group) {
99  }
100  return $ids;
101  }
$ref_id
Definition: ltiauth.php:65
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAllUserIds()

ilCourseParticipantsGroupsTableDataRetrieval::getAllUserIds ( )

Definition at line 103 of file class.ilCourseParticipantsGroupsTableDataRetrieval.php.

References ILIAS\Repository\int().

103  : array
104  {
105  # TODO: Filter
106  $ids = [];
107  foreach ($this->data['rows'] as $row) {
108  $ids[] = (int) $row['usr_id'];
109  }
110  return $ids;
111  }
+ Here is the call graph for this function:

◆ getRows()

ilCourseParticipantsGroupsTableDataRetrieval::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 
)

Definition at line 124 of file class.ilCourseParticipantsGroupsTableDataRetrieval.php.

References buildConfirmUnsubscribeActionId(), getAllConfirmUnsubscribeActionIds(), ilCourseParticipantsGroupsTableGUI\TABLE_COL_GROUP_NUMBER, ilCourseParticipantsGroupsTableGUI\TABLE_COL_GROUPS, ilCourseParticipantsGroupsTableGUI\TABLE_COL_LOGIN, and ilCourseParticipantsGroupsTableGUI\TABLE_COL_NAME.

131  : Generator {
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']);
140  };
141  break;
143  $comparator = function (array $f1, array $f2) {
144  return strcmp($f1['login'], $f2['login']);
145  };
146  break;
148  $comparator = function (array $f1, array $f2) {
149  if ($f1['groups_number'] === $f2['groups_number']) {
150  return 0;
151  }
152  return $f1['groups_number'] > $f2['groups_number'] ? 1 : -1;
153  };
154  break;
156  $comparator = function (array $f1, array $f2) {
157  return strcmp($f1['group_info']['title'], $f2['group_info']['title']);
158  };
159  break;
160  }
161  uasort($rows, $comparator);
162  if ($direction === "DESC") {
163  $rows = array_reverse($rows, true);
164  }
165  $rows = array_slice($rows, $range->getStart(), $range->getLength(), true);
166  foreach ($rows as $row) {
167  $groups_str = '';
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'];
173  if (
174  !($role == 'admin' && $groups_rights[$grp_id]['edit_permission']) &&
175  !($role == 'member' && $groups_rights[$grp_id]['manage_members'])
176  ) {
177  continue;
178  }
179  $groups_str .= ($groups_str === '' ? $title : '<br>' . $title);
180  $enabled_actions[] = $this->buildConfirmUnsubscribeActionId($grp_id);
181  }
182  $data_row = $row_builder->buildDataRow(
183  $row['usr_id'] . '',
184  [
187  ilCourseParticipantsGroupsTableGUI::TABLE_COL_GROUP_NUMBER => (int) $row['groups_number'],
189  ]
190  );
191  $disabled_actions = array_diff($this->getAllConfirmUnsubscribeActionIds(), $enabled_actions);
192  foreach ($disabled_actions as $disabled_action) {
193  $data_row = $data_row->withDisabledAction($disabled_action, true);
194  }
195  yield $data_row;
196  }
197  }
+ Here is the call graph for this function:

◆ getSelectableGroups()

ilCourseParticipantsGroupsTableDataRetrieval::getSelectableGroups ( )

Definition at line 113 of file class.ilCourseParticipantsGroupsTableDataRetrieval.php.

References $ref_id.

Referenced by getAllConfirmUnsubscribeActionIds().

113  : array
114  {
115  $selectable_group_ids = [];
116  foreach ($this->data['groups'] as $ref_id => $something) {
117  if ($this->data['groups_rights'][$ref_id]['manage_members']) {
118  $selectable_group_ids[$ref_id] = $this->data['groups'][$ref_id];
119  }
120  }
121  return $selectable_group_ids;
122  }
$ref_id
Definition: ltiauth.php:65
+ Here is the caller graph for this function:

◆ getTotalRowCount()

ilCourseParticipantsGroupsTableDataRetrieval::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 199 of file class.ilCourseParticipantsGroupsTableDataRetrieval.php.

202  : ?int {
203  return count($this->applyFilter($filter_data));
204  }

◆ init()

ilCourseParticipantsGroupsTableDataRetrieval::init ( )

Definition at line 206 of file class.ilCourseParticipantsGroupsTableDataRetrieval.php.

References ilCourseParticipants\_getInstanceByObjId(), ilGroupParticipants\_getInstanceByObjId(), ilObjUser\_lookupName(), and ILIAS\Repository\access().

206  : void
207  {
208  $parent_node = $this->tree->getNodeData($this->ref_id);
209  $groups = $this->tree->getSubTree($parent_node, true, ['grp']);
210  if (
211  !is_array($groups) ||
212  !count($groups)
213  ) {
214  return;
215  }
216  $results_participants = [];
217  $results_groups = [];
218  $results_groups_rights = [];
219  foreach ($groups as $idx => $group_data) {
220  # check for group in group
221  if (
222  $group_data['parent'] != $this->ref_id &&
223  $this->tree->checkForParentType(
224  $group_data['ref_id'],
225  'grp',
226  true
227  )
228  ) {
229  unset($groups[$idx]);
230  continue;
231  }
232  $results_groups[$group_data['ref_id']] = $group_data['title'];
233  $results_groups_rights[$group_data['ref_id']]['manage_members'] = $this->access->checkRbacOrPositionPermissionAccess(
234  'manage_members',
235  'manage_members',
236  $group_data['ref_id']
237  );
238  $results_groups_rights[$group_data['ref_id']]['edit_permission'] = $this->access->checkAccess(
239  'edit_permission',
240  '',
241  $group_data['ref_id']
242  );
243  $gobj = ilGroupParticipants::_getInstanceByObjId($group_data['obj_id']);
244  $members = $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
245  'manage_members',
246  'manage_members',
247  $group_data['ref_id'],
248  $gobj->getMembers()
249  );
250  $admins = $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
251  'manage_members',
252  'manage_members',
253  $group_data['ref_id'],
254  $gobj->getAdmins()
255  );
256  $results_participants[$group_data['ref_id']]['members'] = $members;
257  $results_participants[$group_data['ref_id']]['admins'] = $admins;
258  }
259  $part = ilCourseParticipants::_getInstanceByObjId($this->obj_id);
260  $members = $this->access->filterUserIdsByRbacOrPositionOfCurrentUser(
261  'manage_members',
262  'manage_members',
263  $this->ref_id,
264  $part->getMembers()
265  );
266  if ($members === []) {
267  return;
268  }
269  $usr_data = [];
270  foreach ($members as $usr_id) {
271  $name = ilObjUser::_lookupName($usr_id);
272  $membership_count = 0;
273  $new_entry = [
274  'usr_id' => $usr_id,
275  'name' => $name['lastname'] . ', ' . $name['firstname'],
276  'groups' => [],
277  'login' => $name['login']
278  ];
279  foreach (array_keys($results_participants) as $group_id) {
280  $group_info = [
281  'group_id' => $group_id,
282  'title' => $results_groups[$group_id],
283  'role' => ''
284  ];
285  if (in_array($usr_id, $results_participants[$group_id]['members'])) {
286  $group_info['role'] = 'member';
287  }
288  if (in_array($usr_id, $results_participants[$group_id]['admins'])) {
289  $group_info['role'] = 'admin';
290  }
291  if ($group_info['role'] === '') {
292  continue;
293  }
294  $new_entry['groups'][] = $group_info;
295  $membership_count++;
296  }
297  $new_entry['groups_number'] = $membership_count;
298  $usr_data[] = $new_entry;
299  }
300  $this->data['rows'] = $usr_data;
301  $this->data['groups'] = $results_groups;
302  $this->data['groups_rights'] = $results_groups_rights;
303  }
static _lookupName(int $a_user_id)
lookup user name
static _getInstanceByObjId(int $a_obj_id)
static _getInstanceByObjId(int $a_obj_id)
Get singleton instance.
+ Here is the call graph for this function:

Field Documentation

◆ $data

array ilCourseParticipantsGroupsTableDataRetrieval::$data
protected

◆ $obj_id

int ilCourseParticipantsGroupsTableDataRetrieval::$obj_id
protected

◆ TABLE_ACTION_CONFIRM_UNSUBSCRIBE_SUFFIX

const ilCourseParticipantsGroupsTableDataRetrieval::TABLE_ACTION_CONFIRM_UNSUBSCRIBE_SUFFIX = '_confirm_unsubscribe'
protected

◆ TABLE_ACTION_UNSUBSCRIBE_SUFFIX

const ilCourseParticipantsGroupsTableDataRetrieval::TABLE_ACTION_UNSUBSCRIBE_SUFFIX = '_unsubscribe'
protected

The documentation for this class was generated from the following file: