ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $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, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

Protected Attributes

const string TABLE_ACTION_CONFIRM_UNSUBSCRIBE_SUFFIX = '_confirm_unsubscribe'
 
const string 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 32 of file class.ilCourseParticipantsGroupsTableDataRetrieval.php.

38 {
39 $this->data = [];
40 $this->obj_id = ilObject::_lookupObjId($ref_id);
41 }
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:66

References $ref_id, and ilObject\_lookupObjId().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildConfirmUnsubscribeActionId()

ilCourseParticipantsGroupsTableDataRetrieval::buildConfirmUnsubscribeActionId ( int  $group_ref_id)

◆ buildUnsubscribeActionId()

ilCourseParticipantsGroupsTableDataRetrieval::buildUnsubscribeActionId ( int  $group_ref_id)

◆ getAllConfirmUnsubscribeActionIds()

ilCourseParticipantsGroupsTableDataRetrieval::getAllConfirmUnsubscribeActionIds ( )

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

95 : array
96 {
97 $ids = [];
98 foreach ($this->getSelectableGroups() as $ref_id => $group) {
100 }
101 return $ids;
102 }

References $ref_id.

◆ getAllUserIds()

ilCourseParticipantsGroupsTableDataRetrieval::getAllUserIds ( )

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

104 : array
105 {
106 # TODO: Filter
107 $ids = [];
108 foreach ($this->data['rows'] ?? [] as $row) {
109 $ids[] = (int) $row['usr_id'];
110 }
111 return $ids;
112 }

References ILIAS\Repository\int().

+ 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,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

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

133 : Generator {
134 [$column_name, $direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
135 $rows = $this->applyFilter($filter_data);
136 $groups_rights = $this->data['groups_rights'] ?? [];
137 $comparator = function (array $f1, array $f2) { return 0; };
138 switch ($column_name) {
140 $comparator = function (array $f1, array $f2) {
141 return strcmp($f1['name'], $f2['name']);
142 };
143 break;
145 $comparator = function (array $f1, array $f2) {
146 return strcmp($f1['login'], $f2['login']);
147 };
148 break;
150 $comparator = function (array $f1, array $f2) {
151 if ($f1['groups_number'] === $f2['groups_number']) {
152 return 0;
153 }
154 return $f1['groups_number'] > $f2['groups_number'] ? 1 : -1;
155 };
156 break;
158 $comparator = function (array $f1, array $f2) {
159 return strcmp($f1['group_info']['title'], $f2['group_info']['title']);
160 };
161 break;
162 }
163 uasort($rows, $comparator);
164 if ($direction === "DESC") {
165 $rows = array_reverse($rows, true);
166 }
167 $rows = array_slice($rows, $range->getStart(), $range->getLength(), true);
168 foreach ($rows as $row) {
169 $groups_str = '';
170 $enabled_actions = [];
171 foreach ($row['groups'] as $group_info) {
172 $grp_id = $group_info['group_id'];
173 $role = $group_info['role'];
174 $title = $group_info['title'];
175 if (
176 !($role == 'admin' && $groups_rights[$grp_id]['edit_permission']) &&
177 !($role == 'member' && $groups_rights[$grp_id]['manage_members'])
178 ) {
179 continue;
180 }
181 $groups_str .= ($groups_str === '' ? $title : '<br>' . $title);
182 $enabled_actions[] = $this->buildConfirmUnsubscribeActionId($grp_id);
183 }
184 $data_row = $row_builder->buildDataRow(
185 $row['usr_id'] . '',
186 [
191 ]
192 );
193 $disabled_actions = array_diff($this->getAllConfirmUnsubscribeActionIds(), $enabled_actions);
194 foreach ($disabled_actions as $disabled_action) {
195 $data_row = $data_row->withDisabledAction($disabled_action, true);
196 }
197 yield $data_row;
198 }
199 }

◆ getSelectableGroups()

ilCourseParticipantsGroupsTableDataRetrieval::getSelectableGroups ( )

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

114 : array
115 {
116 $selectable_group_ids = [];
117 foreach ($this->data['groups'] ?? [] as $ref_id => $something) {
118 if ($this->data['groups_rights'][$ref_id]['manage_members']) {
119 $selectable_group_ids[$ref_id] = $this->data['groups'][$ref_id];
120 }
121 }
122 return $selectable_group_ids;
123 }

References $ref_id.

◆ getTotalRowCount()

ilCourseParticipantsGroupsTableDataRetrieval::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $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 201 of file class.ilCourseParticipantsGroupsTableDataRetrieval.php.

205 : ?int {
206 return count($this->applyFilter($filter_data));
207 }

◆ init()

ilCourseParticipantsGroupsTableDataRetrieval::init ( )

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

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

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

+ 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 string ilCourseParticipantsGroupsTableDataRetrieval::TABLE_ACTION_CONFIRM_UNSUBSCRIBE_SUFFIX = '_confirm_unsubscribe'
protected

◆ TABLE_ACTION_UNSUBSCRIBE_SUFFIX

const string ilCourseParticipantsGroupsTableDataRetrieval::TABLE_ACTION_UNSUBSCRIBE_SUFFIX = '_unsubscribe'
protected

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