ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
4include_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 $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 // vd($fds);
48 foreach ($fds as $k => $f) {
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 $up_prop = strtoupper($prop);
79
80 if (($prop != "searchable" && $a_set[$prop . "_hide"] != true) ||
81 ($prop == "searchable" && ilUserSearchOptions::_isSearchable($field))) {
82 $this->tpl->setCurrentBlock($prop);
83 $this->tpl->setVariable(
84 "HEADER_" . $up_prop,
85 $lng->txt($lv)
86 );
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 $checked = true;
93 }
94 if ($prop == "changeable" && $ilSetting->get("usr_settings_disable_" . $field) != "1") {
95 $checked = true;
96 }
97 if ($prop == "searchable" && ilUserSearchOptions::_isEnabled($field)) {
98 $checked = true;
99 }
100 if ($prop == "required" && $ilSetting->get("require_" . $field) == "1") {
101 $checked = true;
102 }
103 if ($prop == "export" && $ilSetting->get("usr_settings_export_" . $field) == "1") {
104 $checked = true;
105 }
106 if ($prop == "course_export" && $ilSetting->get("usr_settings_course_export_" . $field) == "1") {
107 $checked = true;
108 }
109 if ($prop == "group_export" && $ilSetting->get("usr_settings_group_export_" . $field) == "1") {
110 $checked = true;
111 }
112 if ($prop == "visib_reg" && (int) $ilSetting->get('usr_settings_visib_reg_' . $field, '1')) {
113 $checked = true;
114 }
115 if ($prop == "visib_lua" && (int) $ilSetting->get('usr_settings_visib_lua_' . $field, '1')) {
116 $checked = true;
117 }
118
119 if ($prop == "changeable_lua" && (int) $ilSetting->get('usr_settings_changeable_lua_' . $field, '1')) {
120 $checked = true;
121 }
122
123
124 if ($this->confirm_change == 1) { // confirm value
125 $checked = $_POST["chb"][$prop . "_" . $field];
126 }
127 if (isset($a_set[$prop . "_fix_value"])) { // fix values overwrite everything
128 $checked = $a_set[$prop . "_fix_value"];
129 }
130
131 if ($checked) {
132 $this->tpl->setVariable("CHECKED_" . $up_prop, " checked=\"checked\"");
133 }
134 if (isset($a_set[$prop . "_fix_value"])) {
135 $this->tpl->setVariable("DISABLE_" . $up_prop, " disabled=\"disabled\"");
136 }
137 $this->tpl->parseCurrentBlock();
138 }
139 }
140
141 // default
142 if ($a_set["default"] != "") {
143 switch ($a_set["input"]) {
144 case "selection":
145 case "hitsperpage":
146 $selected_option = $ilSetting->get($field);
147 if ($selected_option == "") {
148 $selected_option = $a_set["default"];
149 }
150 foreach ($a_set["options"] as $k => $v) {
151 $this->tpl->setCurrentBlock("def_sel_option");
152 $this->tpl->setVariable("OPTION_VALUE", $k);
153 $text = ($a_set["input"] == "selection")
154 ? $lng->txt($v)
155 : $v;
156 if ($a_set["input"] == "hitsperpage" && $k == 9999) {
157 $text = $lng->txt("no_limit");
158 }
159 if ($selected_option == $k) {
160 $this->tpl->setVariable(
161 "OPTION_SELECTED",
162 ' selected="selected" '
163 );
164 }
165 $this->tpl->setVariable("OPTION_TEXT", $text);
166 $this->tpl->parseCurrentBlock();
167 }
168 $this->tpl->setCurrentBlock("def_selection");
169 $this->tpl->setVariable("PROFILE_OPTION_DEFAULT_VALUE", "default_" . $field);
170 $this->tpl->parseCurrentBlock();
171 break;
172 }
173 $this->tpl->setCurrentBlock("default");
174 $this->tpl->parseCurrentBlock();
175 }
176
177 // group name
178 $this->tpl->setVariable("TXT_GROUP", $lng->txt($a_set["group"]));
179
180 // field name
181 $lv = ($a_set["lang_var"] == "")
182 ? $a_set["key"]
183 : $a_set["lang_var"];
184 if ($a_set["key"] == "country") {
185 $lv = "country_free_text";
186 }
187 if ($a_set["key"] == "sel_country") {
188 $lv = "country_selection";
189 }
190
191 $this->tpl->setVariable("TXT_FIELD", $lng->txt($lv));
192 }
193
194 public function setConfirmChange()
195 {
196 $this->confirm_change = true;
197 }
198}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
Class ilTable2GUI.
setEnableHeader($a_enableheader)
Set Enable Header.
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setData($a_data)
set table data @access public
setEnableTitle($a_enabletitle)
Set Enable Title.
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
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.
setDescription($a_val)
Set description.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
Class ilUserProfile.
global $ilCtrl
Definition: ilias.php:18
global $ilSetting
Definition: privfeed.php:17
$text
Definition: errorreport.php:18