ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilUserFieldSettingsTableGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 include_once("./Services/Table/classes/class.ilTable2GUI.php");
5 
15 {
16  private $confirm_change = false;
17 
21  public function __construct($a_parent_obj, $a_parent_cmd)
22  {
23  global $DIC;
24 
25  $ilCtrl = $DIC['ilCtrl'];
26  $lng = $DIC['lng'];
27  $ilAccess = $DIC['ilAccess'];
28  $lng = $DIC['lng'];
29 
30  parent::__construct($a_parent_obj, $a_parent_cmd);
31  $this->setTitle($lng->txt("usr_settings_header_profile"));
32  $this->setDescription($lng->txt("usr_settings_explanation_profile"));
33  $this->setLimit(9999);
34 
35  //$this->addColumn($this->lng->txt("usrs_group"), "");
36  //$this->addColumn("", "");
37  $this->addColumn($this->lng->txt("user_field"), "");
38  $this->addColumn($this->lng->txt("access"), "");
39  $this->addColumn($this->lng->txt("export") . " / " . $this->lng->txt("search"), "");
40  $this->addColumn($this->lng->txt("default"), "");
41 
42  $this->setEnableHeader(true);
43  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
44  $this->setRowTemplate("tpl.std_fields_settings_row.html", "Services/User");
45  $this->disable("footer");
46  $this->setEnableTitle(true);
47 
48  include_once("./Services/User/classes/class.ilUserProfile.php");
49  $up = new ilUserProfile();
50  $up->skipField("username");
51  $fds = $up->getStandardFields();
52  // vd($fds);
53  foreach ($fds as $k => $f) {
54  $fds[$k]["key"] = $k;
55  }
56  $this->setData($fds);
57  $this->addCommandButton("saveGlobalUserSettings", $lng->txt("save"));
58  }
59 
63  protected function fillRow($a_set)
64  {
65  global $DIC;
66 
67  $lng = $DIC['lng'];
68  $ilSetting = $DIC['ilSetting'];
69 
70  $field = $a_set["key"];
71 
72  $props = array(
73  "visible" => "user_visible_in_profile",
74  "changeable" => "changeable",
75  "searchable" => "header_searchable",
76  "required" => "required_field",
77  "export" => "export",
78  "course_export" => "course_export",
79  'group_export' => 'group_export',
80  "visib_reg" => "header_visible_registration",
81  'visib_lua' => 'usr_settings_visib_lua',
82  'changeable_lua' => 'usr_settings_changeable_lua'
83  );
84 
85  foreach ($props as $prop => $lv) {
86  $up_prop = strtoupper($prop);
87 
88  if (($prop != "searchable" && $a_set[$prop . "_hide"] != true) ||
89  ($prop == "searchable" && ilUserSearchOptions::_isSearchable($field))) {
90  $this->tpl->setCurrentBlock($prop);
91  $this->tpl->setVariable(
92  "HEADER_" . $up_prop,
93  $lng->txt($lv)
94  );
95  $this->tpl->setVariable("PROFILE_OPTION_" . $up_prop, $prop . "_" . $field);
96 
97  // determine checked status
98  $checked = false;
99  if ($prop == "visible" && $ilSetting->get("usr_settings_hide_" . $field) != "1") {
100  $checked = true;
101  }
102  if ($prop == "changeable" && $ilSetting->get("usr_settings_disable_" . $field) != "1") {
103  $checked = true;
104  }
105  if ($prop == "searchable" && ilUserSearchOptions::_isEnabled($field)) {
106  $checked = true;
107  }
108  if ($prop == "required" && $ilSetting->get("require_" . $field) == "1") {
109  $checked = true;
110  }
111  if ($prop == "export" && $ilSetting->get("usr_settings_export_" . $field) == "1") {
112  $checked = true;
113  }
114  if ($prop == "course_export" && $ilSetting->get("usr_settings_course_export_" . $field) == "1") {
115  $checked = true;
116  }
117  if ($prop == "group_export" && $ilSetting->get("usr_settings_group_export_" . $field) == "1") {
118  $checked = true;
119  }
120  if ($prop == "visib_reg" && (int) $ilSetting->get('usr_settings_visib_reg_' . $field, '1')) {
121  $checked = true;
122  }
123  if ($prop == "visib_lua" && (int) $ilSetting->get('usr_settings_visib_lua_' . $field, '1')) {
124  $checked = true;
125  }
126 
127  if ($prop == "changeable_lua" && (int) $ilSetting->get('usr_settings_changeable_lua_' . $field, '1')) {
128  $checked = true;
129  }
130 
131 
132  if ($this->confirm_change == 1) { // confirm value
133  $checked = $_POST["chb"][$prop . "_" . $field];
134  }
135  if (isset($a_set[$prop . "_fix_value"])) { // fix values overwrite everything
136  $checked = $a_set[$prop . "_fix_value"];
137  }
138 
139  if ($checked) {
140  $this->tpl->setVariable("CHECKED_" . $up_prop, " checked=\"checked\"");
141  }
142  if (isset($a_set[$prop . "_fix_value"])) {
143  $this->tpl->setVariable("DISABLE_" . $up_prop, " disabled=\"disabled\"");
144  }
145  $this->tpl->parseCurrentBlock();
146  }
147  }
148 
149  // default
150  if ($a_set["default"] != "") {
151  switch ($a_set["input"]) {
152  case "selection":
153  case "hitsperpage":
154  $selected_option = $ilSetting->get($field);
155  if ($selected_option == "") {
156  $selected_option = $a_set["default"];
157  }
158  foreach ($a_set["options"] as $k => $v) {
159  $this->tpl->setCurrentBlock("def_sel_option");
160  $this->tpl->setVariable("OPTION_VALUE", $k);
161  $text = ($a_set["input"] == "selection")
162  ? $lng->txt($v)
163  : $v;
164  if ($a_set["input"] == "hitsperpage" && $k == 9999) {
165  $text = $lng->txt("no_limit");
166  }
167  if ($selected_option == $k) {
168  $this->tpl->setVariable(
169  "OPTION_SELECTED",
170  ' selected="selected" '
171  );
172  }
173  $this->tpl->setVariable("OPTION_TEXT", $text);
174  $this->tpl->parseCurrentBlock();
175  }
176  $this->tpl->setCurrentBlock("def_selection");
177  $this->tpl->setVariable("PROFILE_OPTION_DEFAULT_VALUE", "default_" . $field);
178  $this->tpl->parseCurrentBlock();
179  break;
180  }
181  $this->tpl->setCurrentBlock("default");
182  $this->tpl->parseCurrentBlock();
183  }
184 
185  // group name
186  $this->tpl->setVariable("TXT_GROUP", $lng->txt($a_set["group"]));
187 
188  // field name
189  $lv = ($a_set["lang_var"] == "")
190  ? $a_set["key"]
191  : $a_set["lang_var"];
192  if ($a_set["key"] == "country") {
193  $lv = "country_free_text";
194  }
195  if ($a_set["key"] == "sel_country") {
196  $lv = "country_selection";
197  }
198 
199  $this->tpl->setVariable("TXT_FIELD", $lng->txt($lv));
200  }
201 
202  public function setConfirmChange()
203  {
204  $this->confirm_change = true;
205  }
206 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
setDescription($a_val)
Set description.
global $DIC
Definition: saml.php:7
Class ilUserProfile.
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
Class ilTable2GUI.
$text
Definition: errorreport.php:18
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
disable($a_module_name)
diesables particular modules of table
global $ilSetting
Definition: privfeed.php:17
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setEnableHeader($a_enableheader)
Set Enable Header.
setEnableTitle($a_enabletitle)
Set Enable Title.
$_POST["username"]
setLimit($a_limit=0, $a_default_limit=0)