ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilParticipantTableGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
24 /*
25  * Abstract base class for course, group participants table guis
26  * @author Stefan Meyer <smeyer.ilias@gmx.de
27  */
28 abstract 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 
40  protected array $current_filter = [];
41  protected ilObject $rep_object;
42 
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 
171  self::$accepted_ids = ilMemberAgreement::lookupAcceptedAgreements($this->getRepositoryObject()->getId());
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()
$path
Definition: ltiservices.php:29
static getTextRepresentationOfOrgUnits(bool $sort_by_title=true)
Get ref id path array.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
isColumnSelected(string $col)
addFilterItemByMetaType(string $id, int $type=self::FILTER_TEXT, bool $a_optional=false, string $caption="")
Add filter by standard type.
$GLOBALS["DIC"]
Definition: wac.php:53
global $DIC
Definition: shib_login.php:22
__construct(mixed $a_parent_obj, $a_parent_cmd="", $a_template_context="")
Base class for course and group participants.
static _getInstanceByType(string $a_type)
Get Singleton Instance.
global $ilSetting
Definition: privfeed.php:31
__construct(Container $dic, ilPlugin $plugin)
static lookupAcceptedAgreements(int $a_obj_id)
Lookup users who have accepted the agreement.
setDefaultFilterVisiblity(bool $a_status)
static _hasFields(int $a_container_id)
Check if there are any define fields.