19declare(strict_types=1);
53 protected string $id =
'';
66 $this->
logger = $DIC->logger()->mmbr();
67 $this->
lng = $DIC->language();
68 $this->
ctrl = $DIC->ctrl();
69 $this->tpl =
$DIC->ui()->mainTemplate();
70 $this->
profile = $DIC[
'user']->getProfile();
71 $this->tree =
$DIC->repositoryTree();
72 $this->parent_gui = $a_parent_gui;
73 $this->parent_obj = $a_parent_obj;
74 $this->participants = $a_participants_object;
75 $this->waiting_list = $a_waiting_list;
78 $this->presets[
'name'] = array(
$DIC->language()->txt(
'name'),
true);
79 $this->presets[
'login'] = array(
$DIC->language()->txt(
'login'),
true);
84 $DIC->language()->loadLanguageModule(
'crs');
87 $roles = $this->participants->getRoles();
89 foreach (
$roles as $role_id) {
91 switch (substr(
$title, 0, 8)) {
95 $this->
addRole($role_id,
$DIC->language()->txt(
'event_tbl_admin'),
'admin');
99 $this->
addRole($role_id,
$DIC->language()->txt(
'event_tbl_tutor'),
'tutor');
106 $this->
addRole($role_id,
$DIC->language()->txt(
'event_tbl_member'),
'member');
111 $this->has_local_role =
true;
124 $field_info->sortExportFields();
126 foreach ($field_info->getExportableFields() as $field) {
135 $this->presets[$field] = array(
136 $GLOBALS[
'DIC'][
'lng']->txt($field),
141 $parent_obj_type = $this->tree->checkForParentType($this->parent_obj->getRefId(),
'crs') ?
'crs' :
'';
142 $parent_obj_type = $this->tree->checkForParentType($this->parent_obj->getRefId(),
'grp') ?
'grp' : $parent_obj_type;
143 $user_defined_fields = $parent_obj_type ===
''
144 ? $this->
profile->getAllUserDefinedFields()
145 : $this->
profile->getVisibleUserDefinedFields(Context::buildFromObjectType($parent_obj_type));
148 foreach ($user_defined_fields as $field) {
149 $this->presets[
'udf_' . $field->getIdentifier()] = array(
150 $field->getLabel($this->lng),
157 $this->presets[
'cdf_' . $field_obj->getId()] = array(
158 $field_obj->getName(),
168 public function addPreset(
string $a_id,
string $a_caption,
bool $a_selected =
false): void
170 $this->presets[$a_id] = array($a_caption, $a_selected);
178 $this->pre_blanks[] = $a_caption;
184 public function setTitle(
string $a_title, ?
string $a_description =
null): void
186 $this->title = $a_title;
187 $this->description = (string) $a_description;
193 protected function addRole(
int $a_id,
string $a_caption,
string $a_type): void
195 $this->role_data[$a_id] = array($a_caption, $a_type);
200 $this->roles = $a_role_ids;
206 public function addUserFilter(
string $a_id,
string $a_caption,
bool $a_checked =
false): void
208 $this->user_filters[$a_id] = array($a_caption, $a_checked);
216 $subscriber_ids = $this->participants->getSubscribers();
217 $user_ids = $subscriber_ids;
218 if ($this->waiting_list) {
219 $user_ids = array_merge($user_ids, $this->waiting_list->getUserIds());
224 foreach ($profile_data as
$user_id => $fields) {
225 foreach ((array) $fields as $field => $value) {
230 foreach ($this->
profile->getVisibleUserDefinedFields(
231 Context::buildFromObjectType($this->parent_obj->getType())
233 $profile_data = $this->
profile->getDataForMultiple($user_ids);
234 foreach ($profile_data as
$user_id => $field) {
235 $a_res[
$user_id][
'udf_' . $field->getIdentifier()] = $profile_data->getAdditionalFieldByIdentifier(
236 $field->getIdentifier()
241 if (count($user_ids)) {
244 foreach (array_unique($user_ids) as
$user_id) {
246 $a_res[
$user_id][
'login'] = $tmp_obj->getLogin();
247 $a_res[
$user_id][
'name'] = $tmp_obj->getLastname() .
', ' . $tmp_obj->getFirstname();
249 if (in_array(
$user_id, $subscriber_ids)) {
250 $a_res[
$user_id][
'status'] = $this->
lng->txt(
'crs_subscriber');
252 $a_res[
$user_id][
'status'] = $this->
lng->txt(
'crs_waiting_list');
255 foreach ((array) ($cdfs[
$user_id] ?? []) as $field_id => $value) {
256 $a_res[
$user_id][
'cdf_' . $field_id] = (string) $value;
268 if (!implode(
"", $a_values)) {
271 foreach ($a_values as $idx => $value) {
272 $a_values[$idx] = trim($value);
273 if ($a_values[$idx] ==
"") {
274 unset($a_values[$idx]);
278 $this->blank_columns = $a_values;
286 $this->callback = $a_callback;
289 public function setId(
string $a_value): void
291 $this->
id = $a_value;
299 $this->
lng->loadLanguageModule(
'crs');
302 $form->setFormAction($this->
ctrl->getFormAction($this->parent_gui, $a_cmd));
303 $form->setPreventDoubleSubmission(
false);
304 $form->setTitle($this->
lng->txt(
'sess_gen_attendance_list'));
307 $title->setValue($this->title);
311 $desc->setValue($this->description);
312 $form->addItem($desc);
314 if (count($this->presets)) {
316 $preset_value = array();
317 foreach ($this->presets as
$id => $item) {
320 $preset_value[] =
$id;
323 $preset->setValue($preset_value);
324 $form->addItem($preset);
328 $blank->setMulti(
true);
329 $form->addItem($blank);
331 if ($this->pre_blanks) {
332 $blank->setValue($this->pre_blanks);
340 foreach ($this->role_data as $role_id =>
$role_data) {
343 $role_name = $role_id;
344 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_adm') === 0) {
347 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_mem') === 0) {
350 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_tut') === 0) {
355 sprintf($this->
lng->txt(
'event_user_selection_include_role'), $role_data[0]),
358 $checked[] =
'role_' . $role_name;
359 $chk_grp->addOption($chk);
362 if ($this->waiting_list) {
363 $chk =
new ilCheckboxOption($this->
lng->txt(
'event_user_selection_include_requests'),
'subscr');
364 $chk_grp->addOption($chk);
366 $chk =
new ilCheckboxOption($this->
lng->txt(
'event_user_selection_include_waiting_list'),
'wlist');
367 $chk_grp->addOption($chk);
370 if ($this->user_filters) {
371 foreach ($this->user_filters as $sub_id => $sub_item) {
373 sprintf($this->
lng->txt(
'event_user_selection_include_filter'), $sub_item[0]),
377 $checked[] =
'members_' . $sub_id;
379 $chk_grp->addOption($chk);
382 $chk_grp->setValue($checked);
383 $form->addItem($chk_grp);
385 $form->addCommandButton($a_cmd, $this->
lng->txt(
'sess_print_attendance_list'));
387 if ($this->
id && $a_cmd) {
389 if (!$settings->hasStoredEntry()) {
393 $settings->deleteValue(
'desc');
394 $settings->exportToForm($form);
405 if ($form->checkInput()) {
406 foreach (array_keys($this->presets) as
$id) {
407 $this->presets[
$id][1] =
false;
409 foreach ((array) $form->getInput(
'preset') as $value) {
410 if (isset($this->presets[$value])) {
411 $this->presets[$value][1] =
true;
417 $this->
setTitle($form->getInput(
'title'), $form->getInput(
'desc'));
420 $selection_of_users = (array) $form->getInput(
'selection_of_users');
423 foreach (array_keys($this->role_data) as $role_id) {
425 $role_name = $role_id;
426 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_adm') === 0) {
429 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_mem') === 0) {
432 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_tut') === 0) {
436 if (in_array(
'role_' . $role_name, $selection_of_users)) {
443 if ($this->waiting_list) {
444 $this->include_subscribers = in_array(
'subscr', $selection_of_users);
445 $this->include_waiting_list = in_array(
'wlist', $selection_of_users);
448 if ($this->user_filters) {
449 foreach (array_keys($this->user_filters) as $msub_id) {
450 $this->user_filters[$msub_id][2] = in_array(
"members_" . $msub_id, $selection_of_users);
455 #$form->setValuesByPost();
457 #$settings = new ilUserFormSettings($this->id);
458 #$settings->deleteValue('desc');
459 #$settings->importFromForm($form);
471 $this->parent_obj->getType() .
's_pview_' . $this->parent_obj->getId(),
474 if (!$settings->hasStoredEntry()) {
478 $settings->deleteValue(
'desc');
482 (
string) ($settings->getValue(
'title') ?? $this->title),
483 (
string) ($settings->getValue(
'desc') ?? $this->description)
487 if ($preset_value = $settings->getValue(
'preset')) {
488 foreach (array_keys($this->presets) as
$id) {
489 $this->presets[
$id][1] =
false;
491 foreach ((array) $preset_value as $value) {
492 if (isset($this->presets[$value])) {
493 $this->presets[$value][1] =
true;
502 (array) ($settings->getValue(
'blank') ?? $this->pre_blanks)
506 $selection_of_users = $settings->getValue(
'selection_of_users');
510 foreach ($this->role_data as $role_id =>
$role_data) {
513 $role_name = $role_id;
514 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_adm') === 0) {
517 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_mem') === 0) {
520 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_tut') === 0) {
525 isset($selection_of_users) &&
526 !in_array(
'role_' . $role_name, $selection_of_users)
535 if ($this->waiting_list && isset($selection_of_users)) {
536 $this->include_subscribers = in_array(
'subscr', $selection_of_users);
537 $this->include_waiting_list = in_array(
'wlist', $selection_of_users);
541 foreach (array_keys($this->user_filters) as $msub_id) {
542 if (isset($selection_of_users)) {
543 $this->user_filters[$msub_id][2] = in_array(
"members_" . $msub_id, $selection_of_users);
546 if ($this->user_filters[$msub_id][1]) {
547 $this->user_filters[$msub_id][2] =
true;
557 $this->tpl->setContent($this->
getHTML());
558 $this->tpl->addOnLoadCode(
"il.Util.print();");
566 $tpl =
new ilTemplate(
'tpl.attendance_list_print.html',
true,
true,
'components/ILIAS/Membership');
571 if ($this->description) {
572 $tpl->
setVariable(
'TXT_DESCRIPTION', $this->description .
" (" . $time .
")");
578 foreach ($this->presets as $item) {
585 if ($this->blank_columns) {
586 foreach ($this->blank_columns as $blank) {
594 $valid_user_ids = $filters = array();
597 if ($this->has_local_role) {
599 foreach ($this->participants->getMembers() as $member_id) {
600 foreach ($this->participants->getAssignedRoles($member_id) as $role_id) {
601 $members[$role_id][] = $member_id;
605 $members = $this->participants->getMembers();
608 foreach ($this->roles as $role_id) {
609 switch ($this->role_data[$role_id][1]) {
611 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getAdmins());
615 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getTutors());
620 if (!$this->has_local_role) {
621 $valid_user_ids = array_merge($valid_user_ids, $members);
623 $valid_user_ids = array_merge($valid_user_ids, (array) ($members[$role_id] ?? []));
630 if ($this->include_subscribers) {
631 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getSubscribers());
634 if ($this->include_waiting_list) {
635 $valid_user_ids = array_merge($valid_user_ids, $this->waiting_list->getUserIds());
638 if ($this->user_filters) {
639 foreach ($this->user_filters as $sub_id => $sub_item) {
640 $filters[$sub_id] = (bool) ($sub_item[2] ??
false);
643 $valid_user_ids =
ilUtil::_sortIds(array_unique($valid_user_ids),
'usr_data',
'lastname',
'usr_id');
644 foreach ($valid_user_ids as
$user_id) {
645 if ($this->callback) {
646 $user_data = call_user_func_array($this->callback, [(
int)
$user_id, $filters]);
652 foreach ($this->presets as
$id => $item) {
656 $value = ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits((
int)
$user_id);
660 if (!($user_data[
$id] ??
null)) {
662 $value = $name[
"lastname"] .
", " . $name[
"firstname"];
667 if (!($user_data[
$id] ??
false)) {
674 $value = (string) ($user_data[
$id] ??
'');
683 if ($this->blank_columns) {
684 for ($loop = 0, $loopMax = count($this->blank_columns); $loop < $loopMax; $loop++) {
Base class for attendance lists.
setCallback(callable $a_callback)
Set participant detail callback.
getHTML()
render attendance list
addRole(int $a_id, string $a_caption, string $a_type)
Add role.
ilWaitingList $waiting_list
setTitle(string $a_title, ?string $a_description=null)
Set titles.
addUserFilter(string $a_id, string $a_caption, bool $a_checked=false)
Add user filter.
addBlank(string $a_caption)
Add blank column preset.
ilParticipants $participants
addPreset(string $a_id, string $a_caption, bool $a_selected=false)
Add user field.
initForm(string $a_cmd="")
Init form.
initFromSettings()
Directly set list attributes from default settings for print view.
getFullscreenHTML()
render list in fullscreen mode
ilGlobalTemplateInterface $tpl
getNonMemberUserData(array &$a_res)
Get user data for subscribers and waiting list.
readOrderedExportableFields()
read object export fields
bool $include_subscribers
setBlankColumns(array $a_values)
Add blank columns.
bool $include_waiting_list
setRoleSelection(array $a_role_ids)
__construct(object $a_parent_gui, ilObject $a_parent_obj, ?ilParticipants $a_participants_object=null, ?ilWaitingList $a_waiting_list=null)
initFromForm()
Set list attributes from post values.
This class represents an option in a checkbox group.
static _getFields(int $a_container_id, $a_sort=self::IL_CDF_SORT_NAME)
Get all fields of a container.
static _getValuesByObjId(int $a_obj_id)
static setUseRelativeDates(bool $a_status)
set use relative dates
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static _getInstanceByType(string $a_type)
Get Singleton Instance.
Component logger with individual log levels by component id.
static _lookupName(int $a_user_id)
static _lookupLogin(int $a_user_id)
static _readUsersProfileData(array $a_user_ids)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
Class ilObject Basic functions for all objects.
static _lookupTitle(int $obj_id)
Base class for course and group participants.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static _sortIds(array $a_ids, string $a_table, string $a_field, string $a_id_name)
Function that sorts ids by a given table field using WHERE IN E.g: __sort(array(6,...
Base class for course and group waiting lists.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
touchBlock(string $block)
overwrites ITX::touchBlock.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...