19declare(strict_types=1);
52 protected string $id =
'';
65 $this->
logger = $DIC->logger()->mmbr();
66 $this->
lng = $DIC->language();
67 $this->
ctrl = $DIC->ctrl();
68 $this->tpl =
$DIC->ui()->mainTemplate();
69 $this->
profile = $DIC[
'user']->getProfile();
71 $this->parent_gui = $a_parent_gui;
72 $this->parent_obj = $a_parent_obj;
73 $this->participants = $a_participants_object;
74 $this->waiting_list = $a_waiting_list;
77 $this->presets[
'name'] = array(
$DIC->language()->txt(
'name'),
true);
78 $this->presets[
'login'] = array(
$DIC->language()->txt(
'login'),
true);
83 $DIC->language()->loadLanguageModule(
'crs');
86 $roles = $this->participants->getRoles();
88 foreach (
$roles as $role_id) {
90 switch (substr(
$title, 0, 8)) {
94 $this->
addRole($role_id,
$DIC->language()->txt(
'event_tbl_admin'),
'admin');
98 $this->
addRole($role_id,
$DIC->language()->txt(
'event_tbl_tutor'),
'tutor');
105 $this->
addRole($role_id,
$DIC->language()->txt(
'event_tbl_member'),
'member');
110 $this->has_local_role =
true;
123 $field_info->sortExportFields();
125 foreach ($field_info->getExportableFields() as $field) {
134 $this->presets[$field] = array(
135 $GLOBALS[
'DIC'][
'lng']->txt($field),
141 foreach ($this->
profile->getVisibleUserDefinedFields(
142 Context::buildFromObjectType($this->parent_obj->getType())
144 $this->presets[
'udf_' . $field->getIdentifier()] = array(
152 $this->presets[
'cdf_' . $field_obj->getId()] = array(
153 $field_obj->getName(),
163 public function addPreset(
string $a_id,
string $a_caption,
bool $a_selected =
false): void
165 $this->presets[$a_id] = array($a_caption, $a_selected);
173 $this->pre_blanks[] = $a_caption;
179 public function setTitle(
string $a_title, ?
string $a_description =
null): void
181 $this->title = $a_title;
182 $this->description = (string) $a_description;
188 protected function addRole(
int $a_id,
string $a_caption,
string $a_type): void
190 $this->role_data[$a_id] = array($a_caption, $a_type);
195 $this->roles = $a_role_ids;
201 public function addUserFilter(
string $a_id,
string $a_caption,
bool $a_checked =
false): void
203 $this->user_filters[$a_id] = array($a_caption, $a_checked);
211 $subscriber_ids = $this->participants->getSubscribers();
212 $user_ids = $subscriber_ids;
213 if ($this->waiting_list) {
214 $user_ids = array_merge($user_ids, $this->waiting_list->getUserIds());
219 foreach ($profile_data as
$user_id => $fields) {
220 foreach ((array) $fields as $field => $value) {
225 foreach ($this->
profile->getVisibleUserDefinedFields(
226 Context::buildFromObjectType($this->parent_obj->getType())
229 foreach ($profile_data as
$user_id => $field) {
230 $a_res[
$user_id][
'udf_' . $field->getIdentifier()] = $profile_data->getAdditionalFieldByIdentifier(
231 $field->getIdentifier()
236 if (count($user_ids)) {
239 foreach (array_unique($user_ids) as
$user_id) {
241 $a_res[
$user_id][
'login'] = $tmp_obj->getLogin();
242 $a_res[
$user_id][
'name'] = $tmp_obj->getLastname() .
', ' . $tmp_obj->getFirstname();
244 if (in_array(
$user_id, $subscriber_ids)) {
245 $a_res[
$user_id][
'status'] = $this->
lng->txt(
'crs_subscriber');
247 $a_res[
$user_id][
'status'] = $this->
lng->txt(
'crs_waiting_list');
250 foreach ((array) ($cdfs[
$user_id] ?? []) as $field_id => $value) {
251 $a_res[
$user_id][
'cdf_' . $field_id] = (string) $value;
263 if (!implode(
"", $a_values)) {
266 foreach ($a_values as $idx => $value) {
267 $a_values[$idx] = trim($value);
268 if ($a_values[$idx] ==
"") {
269 unset($a_values[$idx]);
273 $this->blank_columns = $a_values;
281 $this->callback = $a_callback;
284 public function setId(
string $a_value): void
286 $this->
id = $a_value;
294 $this->
lng->loadLanguageModule(
'crs');
297 $form->setFormAction($this->
ctrl->getFormAction($this->parent_gui, $a_cmd));
298 $form->setPreventDoubleSubmission(
false);
299 $form->setTitle($this->
lng->txt(
'sess_gen_attendance_list'));
302 $title->setValue($this->title);
306 $desc->setValue($this->description);
307 $form->addItem($desc);
309 if (count($this->presets)) {
311 $preset_value = array();
312 foreach ($this->presets as
$id => $item) {
315 $preset_value[] =
$id;
318 $preset->setValue($preset_value);
319 $form->addItem($preset);
323 $blank->setMulti(
true);
324 $form->addItem($blank);
326 if ($this->pre_blanks) {
327 $blank->setValue($this->pre_blanks);
335 foreach ($this->role_data as $role_id =>
$role_data) {
338 $role_name = $role_id;
339 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_adm') === 0) {
342 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_mem') === 0) {
345 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_tut') === 0) {
350 sprintf($this->
lng->txt(
'event_user_selection_include_role'), $role_data[0]),
353 $checked[] =
'role_' . $role_name;
354 $chk_grp->addOption($chk);
357 if ($this->waiting_list) {
358 $chk =
new ilCheckboxOption($this->
lng->txt(
'event_user_selection_include_requests'),
'subscr');
359 $chk_grp->addOption($chk);
361 $chk =
new ilCheckboxOption($this->
lng->txt(
'event_user_selection_include_waiting_list'),
'wlist');
362 $chk_grp->addOption($chk);
365 if ($this->user_filters) {
366 foreach ($this->user_filters as $sub_id => $sub_item) {
368 sprintf($this->
lng->txt(
'event_user_selection_include_filter'), $sub_item[0]),
372 $checked[] =
'members_' . $sub_id;
374 $chk_grp->addOption($chk);
377 $chk_grp->setValue($checked);
378 $form->addItem($chk_grp);
380 $form->addCommandButton($a_cmd, $this->
lng->txt(
'sess_print_attendance_list'));
382 if ($this->
id && $a_cmd) {
384 if (!$settings->hasStoredEntry()) {
388 $settings->deleteValue(
'desc');
389 $settings->exportToForm($form);
400 if ($form->checkInput()) {
401 foreach (array_keys($this->presets) as
$id) {
402 $this->presets[
$id][1] =
false;
404 foreach ((array) $form->getInput(
'preset') as $value) {
405 if (isset($this->presets[$value])) {
406 $this->presets[$value][1] =
true;
412 $this->
setTitle($form->getInput(
'title'), $form->getInput(
'desc'));
415 $selection_of_users = (array) $form->getInput(
'selection_of_users');
418 foreach (array_keys($this->role_data) as $role_id) {
420 $role_name = $role_id;
421 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_adm') === 0) {
424 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_mem') === 0) {
427 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_tut') === 0) {
431 if (in_array(
'role_' . $role_name, $selection_of_users)) {
438 if ($this->waiting_list) {
439 $this->include_subscribers = in_array(
'subscr', $selection_of_users);
440 $this->include_waiting_list = in_array(
'wlist', $selection_of_users);
443 if ($this->user_filters) {
444 foreach (array_keys($this->user_filters) as $msub_id) {
445 $this->user_filters[$msub_id][2] = in_array(
"members_" . $msub_id, $selection_of_users);
450 #$form->setValuesByPost();
452 #$settings = new ilUserFormSettings($this->id);
453 #$settings->deleteValue('desc');
454 #$settings->importFromForm($form);
466 $this->parent_obj->getType() .
's_pview_' . $this->parent_obj->getId(),
469 if (!$settings->hasStoredEntry()) {
473 $settings->deleteValue(
'desc');
477 (
string) ($settings->getValue(
'title') ?? $this->title),
478 (
string) ($settings->getValue(
'desc') ?? $this->description)
482 if ($preset_value = $settings->getValue(
'preset')) {
483 foreach (array_keys($this->presets) as
$id) {
484 $this->presets[
$id][1] =
false;
486 foreach ((array) $preset_value as $value) {
487 if (isset($this->presets[$value])) {
488 $this->presets[$value][1] =
true;
497 (array) ($settings->getValue(
'blank') ?? $this->pre_blanks)
501 $selection_of_users = $settings->getValue(
'selection_of_users');
505 foreach ($this->role_data as $role_id =>
$role_data) {
508 $role_name = $role_id;
509 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_adm') === 0) {
512 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_mem') === 0) {
515 if (strpos(
$title,
'il_' . $this->parent_obj->getType() .
'_tut') === 0) {
520 isset($selection_of_users) &&
521 !in_array(
'role_' . $role_name, $selection_of_users)
530 if ($this->waiting_list && isset($selection_of_users)) {
531 $this->include_subscribers = in_array(
'subscr', $selection_of_users);
532 $this->include_waiting_list = in_array(
'wlist', $selection_of_users);
536 foreach (array_keys($this->user_filters) as $msub_id) {
537 if (isset($selection_of_users)) {
538 $this->user_filters[$msub_id][2] = in_array(
"members_" . $msub_id, $selection_of_users);
541 if ($this->user_filters[$msub_id][1]) {
542 $this->user_filters[$msub_id][2] =
true;
552 $this->tpl->setContent($this->
getHTML());
553 $this->tpl->addOnLoadCode(
"il.Util.print();");
561 $tpl =
new ilTemplate(
'tpl.attendance_list_print.html',
true,
true,
'components/ILIAS/Membership');
566 if ($this->description) {
567 $tpl->
setVariable(
'TXT_DESCRIPTION', $this->description .
" (" . $time .
")");
573 foreach ($this->presets as $item) {
580 if ($this->blank_columns) {
581 foreach ($this->blank_columns as $blank) {
589 $valid_user_ids = $filters = array();
592 if ($this->has_local_role) {
594 foreach ($this->participants->getMembers() as $member_id) {
595 foreach ($this->participants->getAssignedRoles($member_id) as $role_id) {
596 $members[$role_id][] = $member_id;
600 $members = $this->participants->getMembers();
603 foreach ($this->roles as $role_id) {
604 switch ($this->role_data[$role_id][1]) {
606 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getAdmins());
610 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getTutors());
615 if (!$this->has_local_role) {
616 $valid_user_ids = array_merge($valid_user_ids, $members);
618 $valid_user_ids = array_merge($valid_user_ids, (array) ($members[$role_id] ?? []));
625 if ($this->include_subscribers) {
626 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getSubscribers());
629 if ($this->include_waiting_list) {
630 $valid_user_ids = array_merge($valid_user_ids, $this->waiting_list->getUserIds());
633 if ($this->user_filters) {
634 foreach ($this->user_filters as $sub_id => $sub_item) {
635 $filters[$sub_id] = (bool) ($sub_item[2] ??
false);
638 $valid_user_ids =
ilUtil::_sortIds(array_unique($valid_user_ids),
'usr_data',
'lastname',
'usr_id');
639 foreach ($valid_user_ids as
$user_id) {
640 if ($this->callback) {
641 $user_data = call_user_func_array($this->callback, [(
int)
$user_id, $filters]);
647 foreach ($this->presets as
$id => $item) {
651 $value = ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits((
int)
$user_id);
655 if (!($user_data[
$id] ??
null)) {
657 $value = $name[
"lastname"] .
", " . $name[
"firstname"];
662 if (!($user_data[
$id] ??
false)) {
669 $value = (string) ($user_data[
$id] ??
'');
678 if ($this->blank_columns) {
679 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.
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...