ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilCustomUserFieldSettingsTableGUI.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  private $permissions; // [ilUDFPermissionHelper]
18  private $perm_map; // [array]
19 
23  public function __construct($a_parent_obj, $a_parent_cmd, ilUDFPermissionHelper $a_permissions)
24  {
25  global $DIC;
26 
27  $ilCtrl = $DIC['ilCtrl'];
28  $lng = $DIC['lng'];
29  $ilAccess = $DIC['ilAccess'];
30  $lng = $DIC['lng'];
31 
32  $this->permissions = $a_permissions;
34 
35  parent::__construct($a_parent_obj, $a_parent_cmd);
36  $this->setTitle($lng->txt("user_defined_list"));
37  $this->setLimit(9999);
38 
39  $this->addColumn("", "", 1);
40  $this->addColumn($this->lng->txt("user_field"), "");
41  $this->addColumn($this->lng->txt("access"), "");
42  $this->addColumn($this->lng->txt("export") . " / " . $this->lng->txt("search") .
43  " / " . $this->lng->txt("certificate"), "");
44  $this->addColumn($this->lng->txt("actions"), "");
45 
46  $this->setEnableHeader(true);
47  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
48  $this->setRowTemplate("tpl.std_fields_settings_row.html", "Services/User");
49  $this->disable("footer");
50  $this->setEnableTitle(true);
51 
52  $user_field_definitions = ilUserDefinedFields::_getInstance();
53  $fds = $user_field_definitions->getDefinitions();
54 
55  foreach ($fds as $k => $f) {
56  $fds[$k]["key"] = $k;
57  }
58  $this->setData($fds);
59  $this->addCommandButton("updateFields", $lng->txt("save"));
60  $this->addMultiCommand("askDeleteField", $lng->txt("delete"));
61  }
62 
66  protected function fillRow($a_set)
67  {
68  global $DIC;
69 
70  $lng = $DIC['lng'];
71  $ilSetting = $DIC['ilSetting'];
72  $ilCtrl = $DIC['ilCtrl'];
73 
74  $field = $a_set["field_id"];
75 
76  $props = array("visible" => "user_visible_in_profile",
77  "changeable" => "changeable",
78  "searchable" => "header_searchable",
79  "required" => "required_field",
80  "export" => "export",
81  "course_export" => "course_export",
82  'group_export' => 'group_export',
83  "visib_reg" => "header_visible_registration",
84  'visib_lua' => 'usr_settings_visib_lua',
85  'changeable_lua' => 'usr_settings_changeable_lua',
86  'certificate' => 'certificate'
87  );
88 
89  $perms = $this->permissions->hasPermissions(
91  $field,
92  array(
116  )
117  );
118 
119  foreach ($props as $prop => $lv) {
120  $up_prop = strtoupper($prop);
121 
122  if ($a_set["field_type"] != UDF_TYPE_WYSIWYG ||
123  ($prop != "searchable")) {
124  $this->tpl->setCurrentBlock($prop);
125  $this->tpl->setVariable(
126  "HEADER_" . $up_prop,
127  $lng->txt($lv)
128  );
129  $this->tpl->setVariable("PROFILE_OPTION_" . $up_prop, $prop . "_" . $field);
130 
131  // determine checked status
132  $checked = false;
133  if ($a_set[$prop]) {
134  $checked = true;
135  }
136  if ($this->confirm_change == 1) { // confirm value
137  $checked = $_POST["chb"][$prop . "_" . $field];
138  }
139 
140  if ($checked) {
141  $this->tpl->setVariable("CHECKED_" . $up_prop, " checked=\"checked\"");
142  }
143 
144  if (!$perms[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$this->perm_map[$prop]]) {
145  $this->tpl->setVariable("DISABLE_" . $up_prop, " disabled=\"disabled\"");
146  }
147 
148  $this->tpl->parseCurrentBlock();
149  }
150  }
151 
152  // actions
154  $ilCtrl->setParameter($this->parent_obj, 'field_id', $a_set["field_id"]);
155  $this->tpl->setCurrentBlock("action");
156  $this->tpl->setVariable(
157  "HREF_CMD",
158  $ilCtrl->getLinkTarget($this->parent_obj, 'edit')
159  );
160  $this->tpl->setVariable("TXT_CMD", $lng->txt("edit"));
161  $this->tpl->parseCurrentBlock();
162  }
163 
164  // field name
165  $this->tpl->setCurrentBlock("cb");
166  $this->tpl->setVariable("FIELD_ID", $a_set["field_id"]);
167  $this->tpl->parseCurrentBlock();
168  $this->tpl->setVariable("TXT_FIELD", $a_set["field_name"]);
169  }
170 
171  public function setConfirmChange()
172  {
173  $this->confirm_change = true;
174  }
175 }
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
static _getInstance()
Get instance.
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
__construct($a_parent_obj, $a_parent_cmd, ilUDFPermissionHelper $a_permissions)
Constructor.
Class ilTable2GUI.
TableGUI class for custom defined user fields.
addMultiCommand($a_cmd, $a_text)
Add Command button.
const UDF_TYPE_WYSIWYG
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)