ILIAS  Release_4_0_x_branch Revision 61816
 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("visible" => "user_visible_in_profile",
64  "changeable" => "changeable",
65  "searchable" => "header_searchable",
66  "required" => "required_field",
67  "export" => "export",
68  "course_export" => "course_export",
69  "visib_reg" => "header_visible_registration");
70 
71  foreach ($props as $prop => $lv)
72  {
73  $up_prop = strtoupper($prop);
74 
75  if (($prop != "searchable" && $a_set[$prop."_hide"] != true) ||
76  ($prop == "searchable" && ilUserSearchOptions::_isSearchable($field)))
77  {
78  $this->tpl->setCurrentBlock($prop);
79  $this->tpl->setVariable("HEADER_".$up_prop,
80  $lng->txt($lv));
81  $this->tpl->setVariable("PROFILE_OPTION_".$up_prop, $prop."_".$field);
82 
83  // determine checked status
84  $checked = false;
85  if ($prop == "visible" && $ilSetting->get("usr_settings_hide_".$field) != "1")
86  {
87  $checked = true;
88  }
89  if ($prop == "changeable" && $ilSetting->get("usr_settings_disable_".$field) != "1")
90  {
91  $checked = true;
92  }
93  if ($prop == "searchable" && ilUserSearchOptions::_isEnabled($field))
94  {
95  $checked = true;
96  }
97  if ($prop == "required" && $ilSetting->get("require_".$field) == "1")
98  {
99  $checked = true;
100  }
101  if ($prop == "export" && $ilSetting->get("usr_settings_export_".$field) == "1")
102  {
103  $checked = true;
104  }
105  if ($prop == "course_export" && $ilSetting->get("usr_settings_course_export_".$field) == "1")
106  {
107  $checked = true;
108  }
109  if ($prop == "visib_reg" && (int)$ilSetting->get('usr_settings_visib_reg_'.$field, '1'))
110  {
111  $checked = true;
112  }
113 
114  if ($this->confirm_change == 1) // confirm value
115  {
116  $checked = $_POST["chb"][$prop."_".$field];
117  }
118  if (isset($a_set[$prop."_fix_value"])) // fix values overwrite everything
119  {
120  $checked = $a_set[$prop."_fix_value"];
121  }
122 
123  if ($checked)
124  {
125  $this->tpl->setVariable("CHECKED_".$up_prop, " checked=\"checked\"");
126  }
127  if (isset($a_set[$prop."_fix_value"]))
128  {
129  $this->tpl->setVariable("DISABLE_".$up_prop, " disabled=\"disabled\"");
130  }
131  $this->tpl->parseCurrentBlock();
132  }
133  }
134 
135  // default
136  if ($a_set["default"] != "")
137  {
138  switch ($a_set["input"])
139  {
140  case "selection":
141  case "hitsperpage":
142  $selected_option = $ilSetting->get($field);
143  if ($selected_option == "")
144  {
145  $selected_option = $a_set["default"];
146  }
147  foreach ($a_set["options"] as $k => $v)
148  {
149  $this->tpl->setCurrentBlock("def_sel_option");
150  $this->tpl->setVariable("OPTION_VALUE", $k);
151  $text = ($a_set["input"] == "selection")
152  ? $lng->txt($v)
153  : $v;
154  if ($a_set["input"] == "hitsperpage" && $k == 9999)
155  {
156  $text = $lng->txt("no_limit");
157  }
158  if ($selected_option == $k)
159  {
160  $this->tpl->setVariable("OPTION_SELECTED",
161  ' selected="selected" ');
162  }
163  $this->tpl->setVariable("OPTION_TEXT", $text);
164  $this->tpl->parseCurrentBlock();
165  }
166  $this->tpl->setCurrentBlock("def_selection");
167  $this->tpl->setVariable("PROFILE_OPTION_DEFAULT_VALUE", "default_" . $field);
168  $this->tpl->parseCurrentBlock();
169  break;
170  }
171  $this->tpl->setCurrentBlock("default");
172  $this->tpl->parseCurrentBlock();
173  }
174 
175  // group name
176  $this->tpl->setVariable("TXT_GROUP", $lng->txt($a_set["group"]));
177 
178  // field name
179  $lv = ($a_set["lang_var"] == "")
180  ? $a_set["key"]
181  : $a_set["lang_var"];
182  $this->tpl->setVariable("TXT_FIELD", $lng->txt($lv));
183  }
184 
185  public function setConfirmChange()
186  {
187  $this->confirm_change = true;
188  }
189 
190 }
191 ?>