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