ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  function __construct($a_parent_obj, $a_parent_cmd)
22  {
23  global $ilCtrl, $lng, $ilAccess, $lng;
24 
25  parent::__construct($a_parent_obj, $a_parent_cmd);
26  $this->setTitle($lng->txt("usr_settings_header_profile"));
27  $this->setDescription($lng->txt("usr_settings_explanation_profile"));
28  $this->setLimit(9999);
29 
30  //$this->addColumn($this->lng->txt("usrs_group"), "");
31  $this->addColumn("", "");
32  $this->addColumn($this->lng->txt("user_field"), "");
33  $this->addColumn($this->lng->txt("access"), "");
34  $this->addColumn($this->lng->txt("export")." / ".$this->lng->txt("search"), "");
35  $this->addColumn($this->lng->txt("default"), "");
36 
37  $this->setEnableHeader(true);
38  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
39  $this->setRowTemplate("tpl.std_fields_settings_row.html", "Services/User");
40  $this->disable("footer");
41  $this->setEnableTitle(true);
42 
43  include_once("./Services/User/classes/class.ilUserProfile.php");
44  $up = new ilUserProfile();
45  $up->skipField("username");
46  $fds = $up->getStandardFields();
47  foreach ($fds as $k => $f)
48  {
49  $fds[$k]["key"] = $k;
50  }
51  $this->setData($fds);
52  $this->addCommandButton("saveGlobalUserSettings", $lng->txt("save"));
53  }
54 
58  protected function fillRow($a_set)
59  {
60  global $lng, $ilSetting;
61 
62  $field = $a_set["key"];
63 
64  $props = array(
65  "visible" => "user_visible_in_profile",
66  "changeable" => "changeable",
67  "searchable" => "header_searchable",
68  "required" => "required_field",
69  "export" => "export",
70  "course_export" => "course_export",
71  'group_export' => 'group_export',
72  "visib_reg" => "header_visible_registration",
73  'visib_lua' => 'usr_settings_visib_lua',
74  'changeable_lua' => 'usr_settings_changeable_lua'
75  );
76 
77  foreach ($props as $prop => $lv)
78  {
79  $up_prop = strtoupper($prop);
80 
81  if (($prop != "searchable" && $a_set[$prop."_hide"] != true) ||
82  ($prop == "searchable" && ilUserSearchOptions::_isSearchable($field)))
83  {
84  $this->tpl->setCurrentBlock($prop);
85  $this->tpl->setVariable("HEADER_".$up_prop,
86  $lng->txt($lv));
87  $this->tpl->setVariable("PROFILE_OPTION_".$up_prop, $prop."_".$field);
88 
89  // determine checked status
90  $checked = false;
91  if ($prop == "visible" && $ilSetting->get("usr_settings_hide_".$field) != "1")
92  {
93  $checked = true;
94  }
95  if ($prop == "changeable" && $ilSetting->get("usr_settings_disable_".$field) != "1")
96  {
97  $checked = true;
98  }
99  if ($prop == "searchable" && ilUserSearchOptions::_isEnabled($field))
100  {
101  $checked = true;
102  }
103  if ($prop == "required" && $ilSetting->get("require_".$field) == "1")
104  {
105  $checked = true;
106  }
107  if ($prop == "export" && $ilSetting->get("usr_settings_export_".$field) == "1")
108  {
109  $checked = true;
110  }
111  if ($prop == "course_export" && $ilSetting->get("usr_settings_course_export_".$field) == "1")
112  {
113  $checked = true;
114  }
115  if ($prop == "group_export" && $ilSetting->get("usr_settings_group_export_".$field) == "1")
116  {
117  $checked = true;
118  }
119  if ($prop == "visib_reg" && (int)$ilSetting->get('usr_settings_visib_reg_'.$field, '1'))
120  {
121  $checked = true;
122  }
123  if ($prop == "visib_lua" && (int)$ilSetting->get('usr_settings_visib_lua_'.$field, '1'))
124  {
125  $checked = true;
126  }
127 
128  if ($prop == "changeable_lua" && (int)$ilSetting->get('usr_settings_changeable_lua_'.$field, '1'))
129  {
130  $checked = true;
131  }
132 
133 
134  if ($this->confirm_change == 1) // confirm value
135  {
136  $checked = $_POST["chb"][$prop."_".$field];
137  }
138  if (isset($a_set[$prop."_fix_value"])) // fix values overwrite everything
139  {
140  $checked = $a_set[$prop."_fix_value"];
141  }
142 
143  if ($checked)
144  {
145  $this->tpl->setVariable("CHECKED_".$up_prop, " checked=\"checked\"");
146  }
147  if (isset($a_set[$prop."_fix_value"]))
148  {
149  $this->tpl->setVariable("DISABLE_".$up_prop, " disabled=\"disabled\"");
150  }
151  $this->tpl->parseCurrentBlock();
152  }
153  }
154 
155  // default
156  if ($a_set["default"] != "")
157  {
158  switch ($a_set["input"])
159  {
160  case "selection":
161  case "hitsperpage":
162  $selected_option = $ilSetting->get($field);
163  if ($selected_option == "")
164  {
165  $selected_option = $a_set["default"];
166  }
167  foreach ($a_set["options"] as $k => $v)
168  {
169  $this->tpl->setCurrentBlock("def_sel_option");
170  $this->tpl->setVariable("OPTION_VALUE", $k);
171  $text = ($a_set["input"] == "selection")
172  ? $lng->txt($v)
173  : $v;
174  if ($a_set["input"] == "hitsperpage" && $k == 9999)
175  {
176  $text = $lng->txt("no_limit");
177  }
178  if ($selected_option == $k)
179  {
180  $this->tpl->setVariable("OPTION_SELECTED",
181  ' selected="selected" ');
182  }
183  $this->tpl->setVariable("OPTION_TEXT", $text);
184  $this->tpl->parseCurrentBlock();
185  }
186  $this->tpl->setCurrentBlock("def_selection");
187  $this->tpl->setVariable("PROFILE_OPTION_DEFAULT_VALUE", "default_" . $field);
188  $this->tpl->parseCurrentBlock();
189  break;
190  }
191  $this->tpl->setCurrentBlock("default");
192  $this->tpl->parseCurrentBlock();
193  }
194 
195  // group name
196  $this->tpl->setVariable("TXT_GROUP", $lng->txt($a_set["group"]));
197 
198  // field name
199  $lv = ($a_set["lang_var"] == "")
200  ? $a_set["key"]
201  : $a_set["lang_var"];
202  if ($a_set["key"] == "country")
203  {
204  $lv = "country_free_text";
205  }
206  if ($a_set["key"] == "sel_country")
207  {
208  $lv = "country_selection";
209  }
210 
211  $this->tpl->setVariable("TXT_FIELD", $lng->txt($lv));
212  }
213 
214  public function setConfirmChange()
215  {
216  $this->confirm_change = true;
217  }
218 
219 }
220 ?>