ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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  function __construct($a_parent_obj, $a_parent_cmd, ilUDFPermissionHelper $a_permissions)
24  {
25  global $ilCtrl, $lng, $ilAccess, $lng;
26 
27  $this->permissions = $a_permissions;
29 
30  parent::__construct($a_parent_obj, $a_parent_cmd);
31  $this->setTitle($lng->txt("user_defined_list"));
32  $this->setLimit(9999);
33 
34  $this->addColumn("", "", 1);
35  $this->addColumn($this->lng->txt("user_field"), "");
36  $this->addColumn($this->lng->txt("access"), "");
37  $this->addColumn($this->lng->txt("export")." / ".$this->lng->txt("search").
38  " / ".$this->lng->txt("certificate"), "");
39  $this->addColumn($this->lng->txt("actions"), "");
40 
41  $this->setEnableHeader(true);
42  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
43  $this->setRowTemplate("tpl.std_fields_settings_row.html", "Services/User");
44  $this->disable("footer");
45  $this->setEnableTitle(true);
46 
47  $user_field_definitions = ilUserDefinedFields::_getInstance();
48  $fds = $user_field_definitions->getDefinitions();
49 
50  foreach ($fds as $k => $f)
51  {
52  $fds[$k]["key"] = $k;
53  }
54  $this->setData($fds);
55  $this->addCommandButton("updateFields", $lng->txt("save"));
56  $this->addMultiCommand("askDeleteField", $lng->txt("delete"));
57  }
58 
62  protected function fillRow($a_set)
63  {
64  global $lng, $ilSetting, $ilCtrl;
65 
66  $field = $a_set["field_id"];
67 
68  $props = array("visible" => "user_visible_in_profile",
69  "changeable" => "changeable",
70  "searchable" => "header_searchable",
71  "required" => "required_field",
72  "export" => "export",
73  "course_export" => "course_export",
74  'group_export' => 'group_export',
75  "visib_reg" => "header_visible_registration",
76  'visib_lua' => 'usr_settings_visib_lua',
77  'changeable_lua' => 'usr_settings_changeable_lua',
78  'certificate' => 'certificate'
79  );
80 
81  $perms = $this->permissions->hasPermissions(ilUDFPermissionHelper::CONTEXT_FIELD,
82  $field, array(
106  ));
107 
108  foreach ($props as $prop => $lv)
109  {
110  $up_prop = strtoupper($prop);
111 
112  if ($a_set["field_type"] != UDF_TYPE_WYSIWYG ||
113  ($prop != "searchable"))
114  {
115  $this->tpl->setCurrentBlock($prop);
116  $this->tpl->setVariable("HEADER_".$up_prop,
117  $lng->txt($lv));
118  $this->tpl->setVariable("PROFILE_OPTION_".$up_prop, $prop."_".$field);
119 
120  // determine checked status
121  $checked = false;
122  if ($a_set[$prop])
123  {
124  $checked = true;
125  }
126  if ($this->confirm_change == 1) // confirm value
127  {
128  $checked = $_POST["chb"][$prop."_".$field];
129  }
130 
131  if ($checked)
132  {
133  $this->tpl->setVariable("CHECKED_".$up_prop, " checked=\"checked\"");
134  }
135 
136  if (!$perms[ilUDFPermissionHelper::ACTION_FIELD_EDIT_ACCESS][$this->perm_map[$prop]])
137  {
138  $this->tpl->setVariable("DISABLE_".$up_prop, " disabled=\"disabled\"");
139  }
140 
141  $this->tpl->parseCurrentBlock();
142  }
143  }
144 
145  // actions
147  {
148  $ilCtrl->setParameter($this->parent_obj, 'field_id', $a_set["field_id"]);
149  $this->tpl->setCurrentBlock("action");
150  $this->tpl->setVariable("HREF_CMD",
151  $ilCtrl->getLinkTarget($this->parent_obj, 'edit'));
152  $this->tpl->setVariable("TXT_CMD", $lng->txt("edit"));
153  $this->tpl->parseCurrentBlock();
154  }
155 
156  // field name
157  $this->tpl->setCurrentBlock("cb");
158  $this->tpl->setVariable("FIELD_ID", $a_set["field_id"]);
159  $this->tpl->parseCurrentBlock();
160  $this->tpl->setVariable("TXT_FIELD", $a_set["field_name"]);
161  }
162 
163  public function setConfirmChange()
164  {
165  $this->confirm_change = true;
166  }
167 
168 }
169 ?>