ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilUserFieldSettingsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
23 {
24  private bool $confirm_change = false;
25  protected \ILIAS\User\StandardGUIRequest $user_request;
26 
28 
29  public function __construct(
30  object $a_parent_obj,
31  string $a_parent_cmd
32  ) {
33  global $DIC;
34 
35  $ilCtrl = $DIC['ilCtrl'];
36  $lng = $DIC['lng'];
37 
38  $this->user_settings_config = new ilUserSettingsConfig();
39 
40  parent::__construct($a_parent_obj, $a_parent_cmd);
41  $this->setTitle($lng->txt("usr_settings_header_profile"));
42  $this->main_tpl->setOnScreenMessage('info', $lng->txt('usr_settings_explanation_profile'));
43  $this->setLimit(9999);
44 
45  //$this->addColumn($this->lng->txt("usrs_group"), "");
46  //$this->addColumn("", "");
47  $this->addColumn($this->lng->txt("user_field"), "");
48  $this->addColumn($this->lng->txt("access"), "");
49  $this->addColumn($this->lng->txt("export") . " / " . $this->lng->txt("search"), "");
50  $this->addColumn($this->lng->txt("default"), "");
51 
52  $this->setEnableHeader(true);
53  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
54  $this->setRowTemplate("tpl.std_fields_settings_row.html", "Services/User");
55  $this->disable("footer");
56  $this->setEnableTitle(true);
57 
58  $up = new ilUserProfile();
59  $up->skipField("username");
60  $fds = $up->getStandardFields();
61  foreach ($fds as $k => $f) {
62  $fds[$k]["key"] = $k;
63  }
64  $this->setData($fds);
65  $this->addCommandButton("saveGlobalUserSettings", $lng->txt("save"));
66 
67  $this->user_request = new \ILIAS\User\StandardGUIRequest(
68  $DIC->http(),
69  $DIC->refinery()
70  );
71  }
72 
77  protected function fillRow(array $a_set): void
78  {
79  global $DIC;
80 
81  $lng = $DIC['lng'];
82  $ilSetting = $DIC['ilSetting'];
83  $user_settings_config = $this->user_settings_config;
84  $req_checked = $this->user_request->getChecked();
85 
86  $field = $a_set["key"];
87 
88  foreach (ilObjUserFolderGUI::USER_FIELD_TRANSLATION_MAPPING as $prop => $lv) {
89  $up_prop = strtoupper($prop);
90 
91  if (($prop != "searchable" && ($a_set[$prop . "_hide"] ?? false) != true) ||
92  ($prop == "searchable" && ilUserSearchOptions::_isSearchable($field))) {
93  $this->tpl->setCurrentBlock($prop);
94  $this->tpl->setVariable(
95  "HEADER_" . $up_prop,
96  $lng->txt($lv)
97  );
98  $this->tpl->setVariable("PROFILE_OPTION_" . $up_prop, $prop . "_" . $field);
99 
100  // determine checked status
101  $checked = false;
102  if ($prop == "visible" && $user_settings_config->isVisible($field)) {
103  $checked = true;
104  }
105  if ($prop == "changeable" && $user_settings_config->isChangeable($field)) {
106  $checked = true;
107  }
108  if ($prop == "searchable" && ilUserSearchOptions::_isEnabled($field)) {
109  $checked = true;
110  }
111  if ($prop == "required" && $ilSetting->get("require_" . $field) == "1") {
112  $checked = true;
113  }
114  if ($prop == "export" && $ilSetting->get("usr_settings_export_" . $field) == "1") {
115  $checked = true;
116  }
117  if ($prop == "course_export" && $ilSetting->get("usr_settings_course_export_" . $field) == "1") {
118  $checked = true;
119  }
120  if ($prop == "group_export" && $ilSetting->get("usr_settings_group_export_" . $field) == "1") {
121  $checked = true;
122  }
123  if ($prop == "visib_reg" && (int) $ilSetting->get('usr_settings_visib_reg_' . $field, '1')) {
124  $checked = true;
125  }
126  if ($prop == "visib_lua" && (int) $ilSetting->get('usr_settings_visib_lua_' . $field, '1')) {
127  $checked = true;
128  }
129 
130  if ($prop == "changeable_lua" && (int) $ilSetting->get('usr_settings_changeable_lua_' . $field, '1')) {
131  $checked = true;
132  }
133 
134 
135  if ($this->confirm_change == 1) { // confirm value
136  $checked = $req_checked[$prop . "_" . $field] ?? false;
137  }
138  if (isset($a_set[$prop . "_fix_value"])) { // fix values overwrite everything
139  $checked = $a_set[$prop . "_fix_value"];
140  }
141 
142  if ($checked) {
143  $this->tpl->setVariable("CHECKED_" . $up_prop, " checked=\"checked\"");
144  if (!isset($a_set["{$prop}_fix_value"])) {
145  $this->tpl->setVariable("CURRENT_OPTION_VISIBLE", "1");
146  }
147  } else {
148  $this->tpl->setVariable("CURRENT_OPTION_VISIBLE", "0");
149  }
150 
151  if (isset($a_set[$prop . "_fix_value"])) {
152  $this->tpl->setVariable("DISABLE_" . $up_prop, " disabled=\"disabled\"");
153  }
154  $this->tpl->parseCurrentBlock();
155  }
156  }
157 
158  // default
159  if (($a_set["default"] ?? "") != "") {
160  switch ($a_set["input"]) {
161  case "selection":
162  case "hitsperpage":
163  $selected_option = $ilSetting->get($field);
164  if ($selected_option == "") {
165  $selected_option = $a_set["default"];
166  }
167  foreach ($a_set["options"] as $k => $v) {
168  $this->tpl->setCurrentBlock("def_sel_option");
169  $this->tpl->setVariable("OPTION_VALUE", $k);
170  $text = ($a_set["input"] == "selection")
171  ? $lng->txt($v)
172  : $v;
173  if ($a_set["input"] == "hitsperpage" && $k == 9999) {
174  $text = $lng->txt("no_limit");
175  }
176  if ($selected_option == $k) {
177  $this->tpl->setVariable(
178  "OPTION_SELECTED",
179  ' selected="selected" '
180  );
181  }
182  $this->tpl->setVariable("OPTION_TEXT", $text);
183  $this->tpl->parseCurrentBlock();
184  }
185  $this->tpl->setCurrentBlock("def_selection");
186  $this->tpl->setVariable("PROFILE_OPTION_DEFAULT_VALUE", "default_" . $field);
187  $this->tpl->parseCurrentBlock();
188  break;
189  }
190  $this->tpl->setCurrentBlock("default");
191  $this->tpl->parseCurrentBlock();
192  }
193 
194  // group name
195  $this->tpl->setVariable("TXT_GROUP", $lng->txt($a_set["group"]));
196 
197  // field name
198  $lv = (($a_set["lang_var"] ?? "") == "")
199  ? $a_set["key"]
200  : $a_set["lang_var"];
201  if ($a_set["key"] == "country") {
202  $lv = "country_free_text";
203  }
204  if ($a_set["key"] == "sel_country") {
205  $lv = "country_selection";
206  }
207 
208  $this->tpl->setVariable("TXT_FIELD", $lng->txt($lv));
209  }
210 
211  public function setConfirmChange(): void
212  {
213  $this->confirm_change = true;
214  }
215 }
setData(array $a_data)
__construct(object $a_parent_obj, string $a_parent_cmd)
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
isVisible(string $field)
Is setting visible to user?
setEnableTitle(bool $a_enabletitle)
static _isSearchable(string $a_key)
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
Class ilUserProfile.
isChangeable(string $field)
Is setting changeable by user?
ilLanguage $lng
global $DIC
Definition: feed.php:28
ILIAS User StandardGUIRequest $user_request
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $ilSetting
Definition: privfeed.php:17
__construct(Container $dic, ilPlugin $plugin)
setLimit(int $a_limit=0, int $a_default_limit=0)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
disable(string $a_module_name)
setEnableHeader(bool $a_enableheader)