ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilParticipantTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\UI\Factory as UIFactory;
22use ILIAS\UI\Renderer as UIRenderer;
23
24/*
25 * Abstract base class for course, group participants table guis
26 * @author Stefan Meyer <smeyer.ilias@gmx.de
27 */
28abstract class ilParticipantTableGUI extends ilTable2GUI
29{
30 protected static bool $export_allowed = false;
31 protected static bool $confirmation_required = true;
35 protected static ?array $accepted_ids = null;
36 protected static ?array $all_columns = null;
37 protected static bool $has_odf_definitions = false;
38
39 protected ?ilParticipants $participants = null;
40 protected array $current_filter = [];
42
43 private UIRenderer $renderer;
44 private UIFactory $uiFactory;
45
46 public function __construct(mixed $a_parent_obj, $a_parent_cmd = "", $a_template_context = "")
47 {
48 parent::__construct($a_parent_obj, $a_parent_cmd, $a_template_context);
49
50 global $DIC;
51 $this->renderer = $DIC->ui()->renderer();
52 $this->uiFactory = $DIC->ui()->factory();
53 }
54
58 public function initFilter(): void
59 {
60 $this->setDefaultFilterVisiblity(true);
61
62 $login = $this->addFilterItemByMetaType(
63 'login',
65 false,
66 $this->lng->txt('name')
67 );
68 $this->current_filter['login'] = (string) $login->getValue();
69 $this->current_filter['roles'] = 0;
70 if ($this->isColumnSelected('roles')) {
71 $role = $this->addFilterItemByMetaType(
72 'roles',
74 false,
75 $this->lng->txt('objs_role')
76 );
77
78 $options = array();
79 $options[0] = $this->lng->txt('all_roles');
80 $role->setOptions($options + $this->getParentObject()->getLocalRoles());
81 $this->current_filter['roles'] = (int) $role->getValue();
82 }
83
84 if ($this->isColumnSelected('org_units')) {
86
87 $options[0] = $this->lng->txt('select_one');
88 foreach ($paths as $org_ref_id => $path) {
89 $options[$org_ref_id] = $path;
90 }
91
92 $org = $this->addFilterItemByMetaType(
93 'org_units',
95 false,
96 $this->lng->txt('org_units')
97 );
98 $org->setOptions($options);
99 $this->current_filter['org_units'] = $org->getValue();
100 }
101 }
102
103 public function getSelectableColumns(): array
104 {
105 global $DIC;
106
107 $ilSetting = $DIC['ilSetting'];
108
109 $GLOBALS['DIC']['lng']->loadLanguageModule('ps');
110 if (self::$all_columns) {
111 # return self::$all_columns;
112 }
113
115 self::$all_columns = $ef->getSelectableFieldsInfo($this->getRepositoryObject()->getId());
116
117 if ($ilSetting->get('user_portfolios')) {
118 self::$all_columns['prtf'] = array(
119 'txt' => $this->lng->txt('obj_prtf'),
120 'default' => false
121 );
122 }
123
124 $login = array_splice(self::$all_columns, 0, 1);
125 self::$all_columns = array_merge(
126 array(
127 'roles' =>
128 array(
129 'txt' => $this->lng->txt('objs_role'),
130 'default' => true
131 )
132 ),
133 self::$all_columns
134 );
135 self::$all_columns = array_merge($login, self::$all_columns);
136 return self::$all_columns;
137 }
138
139 protected function getRepositoryObject(): ilObject
140 {
141 return $this->rep_object;
142 }
143
144 protected function getParticipants(): ?\ilParticipants
145 {
146 return $this->participants;
147 }
148
149 public function checkAcceptance(int $a_usr_id): bool
150 {
151 if (!self::$confirmation_required) {
152 return true;
153 }
154 if (!self::$export_allowed) {
155 return false;
156 }
157 return in_array($a_usr_id, self::$accepted_ids);
158 }
159
160 protected function initSettings(): void
161 {
162 if (self::$accepted_ids !== null) {
163 return;
164 }
165 self::$export_allowed = ilPrivacySettings::getInstance()->checkExportAccess($this->getRepositoryObject()->getRefId());
166
167 self::$confirmation_required = ($this->getRepositoryObject()->getType() === 'crs')
168 ? ilPrivacySettings::getInstance()->courseConfirmationRequired()
169 : ilPrivacySettings::getInstance()->groupConfirmationRequired();
170
172
173 self::$has_odf_definitions = (bool) ilCourseDefinedFieldDefinition::_hasFields($this->getRepositoryObject()->getId());
174 }
175
176 protected function showActionLinks($a_set): void
177 {
178 $loc_enabled = (
179 $this->getRepositoryObject()->getType() === 'crs' and
181 );
182
183 $this->ctrl->setParameter($this->parent_obj, 'member_id', $a_set['usr_id']);
184
185 $dropDownItems = array();
186 $dropDownItems[] = $this->uiFactory->button()->shy(
187 $this->lng->txt('edit'),
188 $this->ctrl->getLinkTarget($this->parent_obj, 'editMember')
189 );
190
191 if (self::$has_odf_definitions) {
192 $this->ctrl->setParameterByClass('ilobjectcustomuserfieldsgui', 'member_id', $a_set['usr_id']);
193 $dropDownItems[] = $this->uiFactory->button()->shy(
194 $this->lng->txt($this->getRepositoryObject()->getType() . '_cdf_edit_member'),
195 $this->ctrl->getLinkTargetByClass('ilobjectcustomuserfieldsgui', 'editMember')
196 );
197 }
198
199 if ($loc_enabled) {
200 $this->ctrl->setParameterByClass('illomembertestresultgui', 'uid', $a_set['usr_id']);
201 $dropDownItems[] = $this->uiFactory->button()->shy(
202 $this->lng->txt('crs_loc_mem_show_res'),
203 $this->ctrl->getLinkTargetByClass('illomembertestresultgui', '')
204 );
205 }
206
207 $dropDown = $this->uiFactory->dropdown()->standard($dropDownItems);
208 $this->tpl->setVariable('ACTION_USER', $this->renderer->render($dropDown));
209 }
210}
renderer()
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
static _hasFields(int $a_container_id)
Check if there are any define fields.
static _getInstanceByType(string $a_type)
Get Singleton Instance.
static lookupAcceptedAgreements(int $a_obj_id)
Lookup users who have accepted the agreement.
Class ilObject Basic functions for all objects.
static getTextRepresentationOfOrgUnits(bool $sort_by_title=true)
Get ref id path array.
__construct(mixed $a_parent_obj, $a_parent_cmd="", $a_template_context="")
getSelectableColumns()
Get selectable columns.
Base class for course and group participants.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isColumnSelected(string $col)
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
setDefaultFilterVisiblity(bool $a_status)
An entity that renders components to a string output.
Definition: Renderer.php:31
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26
$GLOBALS["DIC"]
Definition: wac.php:54