ILIAS  release_8 Revision v8.24
class.ilCustomUserFieldSettingsTableGUI.php
Go to the documentation of this file.
1<?php
23{
24 private bool $confirm_change = false;
29 private array $perm_map;
30 protected \ILIAS\User\StandardGUIRequest $request;
31
32 public function __construct(
33 object $a_parent_obj,
34 string $a_parent_cmd,
35 ilClaimingPermissionHelper $a_permissions
36 ) {
37 global $DIC;
38
39 $ilCtrl = $DIC['ilCtrl'];
40 $lng = $DIC['lng'];
41
42 $this->permissions = $a_permissions;
44
45 parent::__construct($a_parent_obj, $a_parent_cmd);
46 $this->setTitle($lng->txt("user_defined_list"));
47 $this->main_tpl->setOnScreenMessage('info', $lng->txt('usr_settings_explanation_profile'));
48 $this->setLimit(9999);
49
50 $this->addColumn("", "", 1);
51 $this->addColumn($this->lng->txt("user_field"), "");
52 $this->addColumn($this->lng->txt("access"), "");
53 $this->addColumn($this->lng->txt("export") . " / " . $this->lng->txt("search") .
54 " / " . $this->lng->txt("certificate"), "");
55 $this->addColumn($this->lng->txt("actions"), "");
56
57 $this->setEnableHeader(true);
58 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
59 $this->setRowTemplate("tpl.std_fields_settings_row.html", "Services/User");
60 $this->disable("footer");
61 $this->setEnableTitle(true);
62
63 $user_field_definitions = ilUserDefinedFields::_getInstance();
64 $fds = $user_field_definitions->getDefinitions();
65
66 foreach ($fds as $k => $f) {
67 $fds[$k]["key"] = $k;
68 }
69 $this->setData($fds);
70 $this->addCommandButton("updateFields", $lng->txt("save"));
71 $this->addMultiCommand("askDeleteField", $lng->txt("delete"));
72 $this->request = new \ILIAS\User\StandardGUIRequest(
73 $DIC->http(),
74 $DIC->refinery()
75 );
76 }
77
82 protected function fillRow(array $a_set): void
83 {
84 global $DIC;
85
86 $lng = $DIC['lng'];
87 $ilCtrl = $DIC['ilCtrl'];
88
89 $field = $a_set["field_id"];
90
91 $props = array("visible" => "user_visible_in_profile",
92 "changeable" => "changeable",
93 "searchable" => "header_searchable",
94 "required" => "required_field",
95 "export" => "export",
96 "course_export" => "course_export",
97 'group_export' => 'group_export',
98 "visib_reg" => "header_visible_registration",
99 'visib_lua' => 'usr_settings_visib_lua',
100 'changeable_lua' => 'usr_settings_changeable_lua',
101 'certificate' => 'certificate'
102 );
103
104 $perms = $this->permissions->hasPermissions(
106 (string) $field,
107 array(
131 )
132 );
133
134 $req_checked = $this->request->getChecked();
135
136 foreach ($props as $prop => $lv) {
137 $up_prop = strtoupper($prop);
138
139 if ($a_set["field_type"] != UDF_TYPE_WYSIWYG ||
140 ($prop != "searchable")) {
141 $this->tpl->setCurrentBlock($prop);
142 $this->tpl->setVariable(
143 "HEADER_" . $up_prop,
144 $lng->txt($lv)
145 );
146 $this->tpl->setVariable("PROFILE_OPTION_" . $up_prop, $prop . "_" . $field);
147
148 // determine checked status
149 $checked = false;
150 if ($a_set[$prop]) {
151 $checked = true;
152 }
153 if ($this->confirm_change == 1) { // confirm value
154 $checked = $req_checked[$prop . "_" . $field] ?? false;
155 }
156
157 if ($checked) {
158 $this->tpl->setVariable("CHECKED_" . $up_prop, " checked=\"checked\"");
159 }
160
161 if (!$perms[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$this->perm_map[$prop]]) {
162 $this->tpl->setVariable("DISABLE_" . $up_prop, " disabled=\"disabled\"");
163 }
164
165 $this->tpl->parseCurrentBlock();
166 }
167 }
168
169 // actions
171 $ilCtrl->setParameter($this->parent_obj, 'field_id', $a_set["field_id"]);
172 $this->tpl->setCurrentBlock("action");
173 $this->tpl->setVariable(
174 "HREF_CMD",
175 $ilCtrl->getLinkTarget($this->parent_obj, 'edit')
176 );
177 $this->tpl->setVariable("TXT_CMD", $lng->txt("edit"));
178 $this->tpl->parseCurrentBlock();
179 }
180
181 // field name
182 $this->tpl->setCurrentBlock("cb");
183 $this->tpl->setVariable("FIELD_ID", $a_set["field_id"]);
184 $this->tpl->parseCurrentBlock();
185 $this->tpl->setVariable("TXT_FIELD", $a_set["field_name"]);
186 }
187
188 public function setConfirmChange(): void
189 {
190 $this->confirm_change = true;
191 }
192}
const UDF_TYPE_WYSIWYG
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(object $a_parent_obj, string $a_parent_cmd, ilClaimingPermissionHelper $a_permissions)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setLimit(int $a_limit=0, int $a_default_limit=0)
set max.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setEnableTitle(bool $a_enabletitle)
addMultiCommand(string $a_cmd, string $a_text)
setFormAction(string $a_form_action, bool $a_multipart=false)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setEnableHeader(bool $a_enableheader)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setData(array $a_data)
Set table data.
ilLanguage $lng
disable(string $a_module_name)
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc