19 declare(strict_types=1);
48 protected string $id =
'';
61 $this->
logger = $DIC->logger()->mmbr();
62 $this->
lng = $DIC->language();
63 $this->
ctrl = $DIC->ctrl();
64 $this->tpl = $DIC->ui()->mainTemplate();
66 $this->parent_gui = $a_parent_gui;
67 $this->parent_obj = $a_parent_obj;
68 $this->participants = $a_participants_object;
69 $this->waiting_list = $a_waiting_list;
72 $this->presets[
'name'] = array($DIC->language()->txt(
'name'),
true);
73 $this->presets[
'login'] = array($DIC->language()->txt(
'login'),
true);
78 $DIC->language()->loadLanguageModule(
'crs');
81 $roles = $this->participants->getRoles();
83 foreach ($roles as $role_id) {
85 switch (substr($title, 0, 8)) {
89 $this->
addRole($role_id, $DIC->language()->txt(
'event_tbl_admin'),
'admin');
93 $this->
addRole($role_id, $DIC->language()->txt(
'event_tbl_tutor'),
'tutor');
100 $this->
addRole($role_id, $DIC->language()->txt(
'event_tbl_member'),
'member');
105 $this->has_local_role =
true;
106 $this->
addRole($role_id, $title,
'local');
118 $field_info->sortExportFields();
120 foreach ($field_info->getExportableFields() as $field) {
129 $this->presets[$field] = array(
130 $GLOBALS[
'DIC'][
'lng']->txt($field),
137 foreach ($udf->getExportableFields($this->parent_obj->getId()) as $field_id => $udf_data) {
138 $this->presets[
'udf_' . $field_id] = array(
139 $udf_data[
'field_name'],
146 $this->presets[
'cdf_' . $field_obj->getId()] = array(
147 $field_obj->getName(),
157 public function addPreset(
string $a_id,
string $a_caption,
bool $a_selected =
false): void
159 $this->presets[$a_id] = array($a_caption, $a_selected);
167 $this->pre_blanks[] = $a_caption;
173 public function setTitle(
string $a_title, ?
string $a_description =
null): void
175 $this->title = $a_title;
176 $this->description = (string) $a_description;
182 protected function addRole(
int $a_id,
string $a_caption,
string $a_type): void
184 $this->role_data[$a_id] = array($a_caption, $a_type);
189 $this->roles = $a_role_ids;
195 public function addUserFilter(
string $a_id,
string $a_caption,
bool $a_checked =
false): void
197 $this->user_filters[$a_id] = array($a_caption, $a_checked);
205 $subscriber_ids = $this->participants->getSubscribers();
206 $user_ids = $subscriber_ids;
207 if ($this->waiting_list) {
208 $user_ids = array_merge($user_ids, $this->waiting_list->getUserIds());
213 foreach ($profile_data as
$user_id => $fields) {
214 foreach ((array) $fields as $field => $value) {
221 foreach ($udf->getExportableFields($this->parent_obj->getId()) as $field_id => $udf_data) {
222 foreach ($profile_data as
$user_id => $field) {
224 $a_res[
$user_id][
'udf_' . $field_id] = $udf_data->get(
'f_' . $field_id);
228 if (count($user_ids)) {
231 foreach (array_unique($user_ids) as
$user_id) {
233 $a_res[
$user_id][
'login'] = $tmp_obj->getLogin();
234 $a_res[
$user_id][
'name'] = $tmp_obj->getLastname() .
', ' . $tmp_obj->getFirstname();
236 if (in_array(
$user_id, $subscriber_ids)) {
237 $a_res[
$user_id][
'status'] = $this->
lng->txt(
'crs_subscriber');
239 $a_res[
$user_id][
'status'] = $this->
lng->txt(
'crs_waiting_list');
242 foreach ((array) ($cdfs[
$user_id] ?? []) as $field_id => $value) {
243 $a_res[
$user_id][
'cdf_' . $field_id] = (string) $value;
255 if (!implode(
"", $a_values)) {
258 foreach ($a_values as $idx => $value) {
259 $a_values[$idx] = trim($value);
260 if ($a_values[$idx] ==
"") {
261 unset($a_values[$idx]);
265 $this->blank_columns = $a_values;
273 $this->callback = $a_callback;
276 public function setId(
string $a_value): void
278 $this->
id = $a_value;
286 $this->
lng->loadLanguageModule(
'crs');
289 $form->setFormAction($this->
ctrl->getFormAction($this->parent_gui, $a_cmd));
290 $form->setPreventDoubleSubmission(
false);
291 $form->setTitle($this->
lng->txt(
'sess_gen_attendance_list'));
294 $title->setValue($this->title);
295 $form->addItem($title);
298 $desc->setValue($this->description);
299 $form->addItem($desc);
301 if (count($this->presets)) {
303 $preset_value = array();
304 foreach ($this->presets as $id => $item) {
307 $preset_value[] =
$id;
310 $preset->setValue($preset_value);
311 $form->addItem($preset);
315 $blank->setMulti(
true);
316 $form->addItem($blank);
318 if ($this->pre_blanks) {
319 $blank->setValue($this->pre_blanks);
327 foreach ($this->role_data as $role_id => $role_data) {
330 $role_name = $role_id;
331 if (strpos($title,
'il_' . $this->parent_obj->getType() .
'_adm') === 0) {
334 if (strpos($title,
'il_' . $this->parent_obj->getType() .
'_mem') === 0) {
337 if (strpos($title,
'il_' . $this->parent_obj->getType() .
'_tut') === 0) {
342 sprintf($this->
lng->txt(
'event_user_selection_include_role'), $role_data[0]),
345 $checked[] =
'role_' . $role_name;
346 $chk_grp->addOption($chk);
349 if ($this->waiting_list) {
350 $chk =
new ilCheckboxOption($this->
lng->txt(
'event_user_selection_include_requests'),
'subscr');
351 $chk_grp->addOption($chk);
353 $chk =
new ilCheckboxOption($this->
lng->txt(
'event_user_selection_include_waiting_list'),
'wlist');
354 $chk_grp->addOption($chk);
357 if ($this->user_filters) {
358 foreach ($this->user_filters as $sub_id => $sub_item) {
360 sprintf($this->
lng->txt(
'event_user_selection_include_filter'), $sub_item[0]),
364 $checked[] =
'members_' . $sub_id;
366 $chk_grp->addOption($chk);
369 $chk_grp->setValue($checked);
370 $form->addItem($chk_grp);
372 $form->addCommandButton($a_cmd, $this->
lng->txt(
'sess_print_attendance_list'));
374 if ($this->
id && $a_cmd) {
376 if (!$settings->hasStoredEntry()) {
381 $settings->exportToForm($form);
392 if ($form->checkInput()) {
393 foreach (array_keys($this->presets) as
$id) {
394 $this->presets[
$id][1] =
false;
396 foreach ((array) $form->getInput(
'preset') as $value) {
397 if (isset($this->presets[$value])) {
398 $this->presets[$value][1] =
true;
404 $this->
setTitle($form->getInput(
'title'), $form->getInput(
'desc'));
407 $selection_of_users = (array) $form->getInput(
'selection_of_users');
410 foreach (array_keys($this->role_data) as $role_id) {
412 $role_name = $role_id;
413 if (strpos($title,
'il_' . $this->parent_obj->getType() .
'_adm') === 0) {
416 if (strpos($title,
'il_' . $this->parent_obj->getType() .
'_mem') === 0) {
419 if (strpos($title,
'il_' . $this->parent_obj->getType() .
'_tut') === 0) {
423 if (in_array(
'role_' . $role_name, $selection_of_users)) {
430 if ($this->waiting_list) {
431 $this->include_subscribers = in_array(
'subscr', $selection_of_users);
432 $this->include_waiting_list = in_array(
'wlist', $selection_of_users);
435 if ($this->user_filters) {
436 foreach (array_keys($this->user_filters) as $msub_id) {
437 $this->user_filters[$msub_id][2] = in_array(
"members_" . $msub_id, $selection_of_users);
442 #$form->setValuesByPost(); 444 #$settings = new ilUserFormSettings($this->id); 445 #$settings->deleteValue('desc'); // #11340 446 #$settings->importFromForm($form); 458 $this->parent_obj->getType() .
's_pview_' . $this->parent_obj->getId(),
461 if (!$settings->hasStoredEntry()) {
469 (
string) ($settings->getValue(
'title') ??
$this->title),
474 if ($preset_value = $settings->getValue(
'preset')) {
475 foreach (array_keys($this->presets) as
$id) {
476 $this->presets[
$id][1] =
false;
478 foreach ((array) $preset_value as $value) {
479 if (isset($this->presets[$value])) {
480 $this->presets[$value][1] =
true;
493 $selection_of_users = $settings->getValue(
'selection_of_users');
497 foreach ($this->role_data as $role_id => $role_data) {
500 $role_name = $role_id;
501 if (strpos($title,
'il_' . $this->parent_obj->getType() .
'_adm') === 0) {
504 if (strpos($title,
'il_' . $this->parent_obj->getType() .
'_mem') === 0) {
507 if (strpos($title,
'il_' . $this->parent_obj->getType() .
'_tut') === 0) {
512 isset($selection_of_users) &&
513 !in_array(
'role_' . $role_name, $selection_of_users)
522 if ($this->waiting_list && isset($selection_of_users)) {
523 $this->include_subscribers = in_array(
'subscr', $selection_of_users);
524 $this->include_waiting_list = in_array(
'wlist', $selection_of_users);
528 foreach (array_keys($this->user_filters) as $msub_id) {
529 if (isset($selection_of_users)) {
530 $this->user_filters[$msub_id][2] = in_array(
"members_" . $msub_id, $selection_of_users);
533 if ($this->user_filters[$msub_id][1]) {
534 $this->user_filters[$msub_id][2] =
true;
544 $this->tpl->setContent($this->
getHTML());
545 $this->tpl->addOnLoadCode(
"il.Util.print();");
553 $tpl =
new ilTemplate(
'tpl.attendance_list_print.html',
true,
true,
'components/ILIAS/Membership');
558 if ($this->description) {
559 $tpl->
setVariable(
'TXT_DESCRIPTION', $this->description .
" (" . $time .
")");
565 foreach ($this->presets as $item) {
572 if ($this->blank_columns) {
573 foreach ($this->blank_columns as $blank) {
581 $valid_user_ids = $filters = array();
584 if ($this->has_local_role) {
586 foreach ($this->participants->getMembers() as $member_id) {
587 foreach ($this->participants->getAssignedRoles($member_id) as $role_id) {
588 $members[$role_id][] = $member_id;
592 $members = $this->participants->getMembers();
595 foreach ($this->roles as $role_id) {
596 switch ($this->role_data[$role_id][1]) {
598 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getAdmins());
602 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getTutors());
607 if (!$this->has_local_role) {
608 $valid_user_ids = array_merge($valid_user_ids, $members);
610 $valid_user_ids = array_merge($valid_user_ids, (array) ($members[$role_id] ?? []));
617 if ($this->include_subscribers) {
618 $valid_user_ids = array_merge($valid_user_ids, $this->participants->getSubscribers());
621 if ($this->include_waiting_list) {
622 $valid_user_ids = array_merge($valid_user_ids, $this->waiting_list->getUserIds());
625 if ($this->user_filters) {
626 foreach ($this->user_filters as $sub_id => $sub_item) {
627 $filters[$sub_id] = (bool) ($sub_item[2] ??
false);
630 $valid_user_ids =
ilUtil::_sortIds(array_unique($valid_user_ids),
'usr_data',
'lastname',
'usr_id');
631 foreach ($valid_user_ids as
$user_id) {
632 if ($this->callback) {
633 $user_data = call_user_func_array($this->callback, [(
int) $user_id, $filters]);
639 foreach ($this->presets as $id => $item) {
643 $value = ilOrgUnitPathStorage::getTextRepresentationOfUsersOrgUnits((
int) $user_id);
647 if (!($user_data[$id] ??
null)) {
649 $value = $name[
"lastname"] .
", " . $name[
"firstname"];
654 if (!($user_data[$id] ??
false)) {
661 $value = (string) ($user_data[$id] ??
'');
670 if ($this->blank_columns) {
671 for ($loop = 0, $loopMax = count($this->blank_columns); $loop < $loopMax; $loop++) {
static array static setUseRelativeDates(bool $a_status)
set use relative dates
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
initForm(string $a_cmd="")
Init form.
This class represents an option in a checkbox group.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Base class for course and group waiting lists.
addUserFilter(string $a_id, string $a_caption, bool $a_checked=false)
Add user filter.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
touchBlock(string $block)
overwrites ITX::touchBlock.
addPreset(string $a_id, string $a_caption, bool $a_selected=false)
Add user field.
getFullscreenHTML()
render list in fullscreen mode
static _getValuesByObjId(int $a_obj_id)
static _lookupName(int $a_user_id)
lookup user name
getNonMemberUserData(array &$a_res)
Get user data for subscribers and waiting list.
initFromSettings()
Directly set list attributes from default settings for print view.
static _getFields(int $a_container_id, $a_sort=self::IL_CDF_SORT_NAME)
Get all fields of a container.
setVariable(string $variable, $value='')
Sets the given variable to the given value.
bool $include_subscribers
Base class for attendance lists.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
setRoleSelection(array $a_role_ids)
ilGlobalTemplateInterface $tpl
addBlank(string $a_caption)
Add blank column preset.
setCallback(callable $a_callback)
Set participant detail callback.
static _lookupTitle(int $obj_id)
setBlankColumns(array $a_values)
Add blank columns.
__construct(object $a_parent_gui, ilObject $a_parent_obj, ?ilParticipants $a_participants_object=null, ?ilWaitingList $a_waiting_list=null)
readOrderedExportableFields()
read object export fields
ilParticipants $participants
bool $include_waiting_list
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
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,7),'usr_data','lastname','usr_id') => sorts by lastname.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
ilWaitingList $waiting_list
Base class for course and group participants.
static _getInstanceByType(string $a_type)
Get Singleton Instance.
static _readUsersProfileData(array $a_user_ids)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
getHTML()
render attendance list
setTitle(string $a_title, ?string $a_description=null)
Set titles.
addRole(int $a_id, string $a_caption, string $a_type)
Add role.
initFromForm()
Set list attributes from post values.
static _lookupLogin(int $a_user_id)